When L1 enters L2, most of the checks on L2's state are left to the CPU,
which makes them when it enters vmcs02. Three of them it cannot make:
- The host sets and clears the bits of CR0 and CR4 that are fixed in VMX operation before it writes them to vmcs02. A value of L1 with one of these bits wrong (CR0.NE or CR4.VMXE clear, a reserved bit set) was corrected without a word. The VM entry now fails with exit reason 33.
- vmcs02 has no VMCS link pointer, so the one in L1's VMCS was not looked at. It must be all ones or point to a VMCS with the right revision that is not a shadow VMCS (L1 has no VMCS shadowing). If not, the VM entry now fails with exit qualification 4.
- The fields for the event to inject are checked by the CPU too, but only when it enters vmcs02, which is after the two checks above. The order has to be the other way round: wrong controls make VMLAUNCH and VMRESUME fail, before the state of the guest is looked at. So these fields are now checked in nested_check_ctls() as the SDM says (27.2.1.3).
AI assistance: as D61708, this change was developed with an AI assistant (Anthropic's Claude) under my direction. The assistant wrote the code and this description. The tests in the test plan were run on real hardware.
Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
Sponsored by: keelos.dev