Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how KVM handle interrupt

i have been doing the KVM stuff and have a couple of questions that can not figure out.

1> as we know, normally the external interrupt will cause VMexit and the hypervisor will inject a virtual interrupt if it is for guest. Then which irq will be injected (i mean the interrupt vector for indexing the guest IDT)? How does the KVM get to know about this (associate a host IRQ with a guest virtual IRQ)?

2> if for assigned device to the guest, the hypervisor will deliver that IRQ to the guest. by tracing the code, i found the host IRQ is different with the guest's (i mean the interrupt vector). how the KVM configure which interrupt vector the guest should use?

3> if we configure not exit on external interrupt by setting some field in VMCS, what will happen during the physical interrupts? will the CPU use the guest IDT for response interrupt? If so, can KVM redirect the CPU to use another IDT for guest (assuming modifying the IDTR)?

4> where is the guest IDT located? it this configured by the qemu while initializing the vcpu and registers (include the IDTR)?

I really hope someone can reply to my questions. I will be very appreciated.

Thanks

like image 970
user1073939 Avatar asked Jun 06 '12 22:06

user1073939


1 Answers

1- 2- The code is in irq_comm.c and very complex. For the guest vector, the hypervisor traps and monitors the PCI configuration space of the guest (this is actually done in QEMU - see for instance kvm_msi_update - however a syscall to the KVM updates it with the data).

3- Yes. For setting another IDT - you need to change the IDTR field in the VMCS.

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

Sounds like you are trying to implement ELI from ASPLOS'12. Contact me offline (the second author of the paper - NA).

like image 170
nadafu Avatar answered Sep 22 '22 12:09

nadafu