Interrupt Window means a specific timing that a processor can inject an interrupt. On Intel VT-x, there is an option to intercept Interrupt Window by setting the bit in Primary Processor-based VM-Execution Control field in VMCS. However, there isn’t such an option on AMD-V.
If we take a look at the layout of VMCB, we may observe that AMD-V provides a virtual local APIC mechanism for you to inject virtual interrupts. The interception vector 3 also provides interception of virtual interrupt. These two combined are actually making you intercepting interrupt window. The workflow is:
- Use the virtual Local APIC to inject a virtual interrupt (Set the
V_IRQbit). If you would like to intercept interrupt window regardless of TPR, set theV_IGN_TPRbit in order to let the virtual interrupt ignore the virtual TPR. Or otherwise you can intercept an interrupt window with a specific TPR. - Intercept the virtual interrupts by setting
VINTRinterception bit. The processor cannot take the virtual interrupt until therflags.ifis set and theTPRmeets the priority requirements. Therefore, the interception is exactly the moment of interrupt window. - You may realize that this is actually even more advanced than Intel VT-x in that, on Intel VT-x, you will need to intercept accesses to the
cr8register in order to virtualizeTPR.
On Zen 4 processors, you can materialize intercepting NMI-window on AMD-V in the similar fashion. Note that you can’t simply treat iret instruction as NMI-window opportunity since on later implementations of AMD64 architecture, a new MSR called EXCP_IN_PROG is used to prevent re-entrance of exceptions. This MSR is effective against NMI by masking it when the corresponding bit is set. So even if the iret instruction is executed, it does not necessarily mean the NMI-window is incoming. Also, wrmsr instruction could also mean an NMI-window if it is trying to reset the bit in EXCP_IN_PROG MSR.