How to interrupt KVM processing

I am doing KVM stuff and have a couple of questions that they cannot understand.

1> as you know, usually an external interrupt will cause VMexit, and the hypervisor will introduce a virtual interrupt if it is for a guest. Then what irq will be introduced (i means interrupt vector for indexing guest IDT)? How does KVM know about this (associate host IRQ with guest virtual IRQ)?

2> if for the designated device for the guest the hypervisor delivers this IRQ to the guest. while tracking the code, I found that the IRQ of the host is different from the guest (I mean the interrupt vector). How does KVM configure which interrupt vector a guest should use?

3> If we do not configure the output to an external interrupt by setting some field in VMCS, what will happen during physical interrupts? Will the processor use the guest IDT to interrupt the response? If so, can KVM redirect the processor to use a different IDT for the guest (provided the IDTR changes)?

4> where is the guest IDT located? Is this configured by qemu when initializing vcpu and registers (including IDTR)?

I really hope someone can answer my questions. I'll be very grateful.

thanks

+6
source share
1 answer

1- 2- The code is in irq_comm.c and is very complex. For the guest vector, the trap hypervisor also controls the guest PCI configuration space (this is actually done in QEMU - see, for example, kvm_msi_update - however syscall for KVM updates it with data).

3- Yes. To install another IDT, you need to change the IDTR field in VMCS.

4- Guest IDT configured by guest code. QEMU / KVM is not directly involved in this. You need to configure the execution controls for the LIDT trap in order to track changes for the guest IDTR.

It looks like you are trying to implement ELI from ASPLOS'12. Contact me offline (the second author of the article is NA).

+2
source

Source: https://habr.com/ru/post/917490/


All Articles