- 论坛徽章:
- 0
|
今天再阅读了KVM的代码能解开上面的疑团。
KVM工作结构为Linux作HOST,GUEST任意安装操作系统。
所以HOST直接使用当前Linux环境下的GDT、IDT等环境。
那样int 2,直接调用的是Linux下面的NMI ISR。
而Intel手册中提到,启用虚拟机时,如果NMI_EXITING位设置为1时,guest遇到NMI即VMX_EXIT到host,guest中的iret将对阻塞的NMI请求没有影响。
25.4 CHANGES TO INSTRUCTION BEHAVIOR IN VMX NON-ROOT OPERATION
IRET.Behavior of IRET with regard to NMI blocking (see Table 24-3) is
determined by the settings of the “NMI exiting” and “virtualNMIs” VM-execution
controls:
— If the “NMI exiting” VM-execution control is 0, IRET operates normally and
unblocks NMIs. (If the “NMI exiting” VM-execution control is 0, the “virtual
NMIs” control must be 0; see Section 26.2.1.1.)
— If the “NMI exiting” VM-execution control is 1, IRET does not affect blocking
of NMIs. If, in addition, the “virtual NMIs” VM-execution control is 1, the
logical processor tracks virtual-NMI blocking. In this case, IRET removes any
virtual-NMI blocking.
The unblocking of NMIs or virtual NMIs specified above occurs even if IRET
causes a fault |
|