本文主要记录SDM中Relative Priority of Faults and VM Exits一节的相关笔记。
The following principles describe the ordering between existing faults and VM exits:

  • Certain exceptions have priority over VM exits. These include invalid-opcode exceptions (#UD), faults based on privilege level, and general-protection exceptions that are based on checking I/O permission bits in the taskstate segment (TSS). For example, execution of RDMSR with CPL = 3 generates a general-protection exception and not a VM exit.

XSETBVinstruction为例:

In non-root mode,if the current privileage level is not 0, VM exit won’t happen. Because faults based on privilege level has priority over VM exits.

In non-root mode,if CR4.OSXSAVE[bit 18] = 0, VM exit won’t happen. Because invalid-opcode exceptions(#UD) has priority over VM exits.

详细内容可参考patch:hv: vmexit: refine xsetbv_vmexit_handler API