Search code examples
intelinterruptvirtualizationhypervisorapic

VMX virtual apic interrupt


How to send external interrupts to guest when following enabled:
Use TPR shadow
Virtualize APIC access
APIC register virtualization
Virtual-interrupt delivery
Acknowledge external interrupts
External interrupts exit
Process posted-interrupt

I've tried vmcs guest interrupt status 0x810, but couldn't make it work correctly. My goal is to redirect external interrupts to guest.


Solution

  • To inject an interrupt into the guest when virtual interrupt delivery is enabled, follow steps similar to those that the CPU performs when it processes a posted interrupt, as described in SDM volume 3, section 30.6, "Posted Interrupt Processing", steps 4, 5, and 6.

    The steps are:

    1. If the interrupt being injected into the guest is due to receipt of a physical interrupt, send EOI to the physical APIC.
    2. Set the bit in VIRR corresponding to the interrupt vector being injected.
    3. Set RVI to the vector number, if it is greater than the prior value of RVI.

    Evaluation of pending virtual interrupts will be performed by the CPU upon VM entry.

    See also SDM volume 3, section 30.2, "Evaluation and Delivery of Virtual Interrupts".