Without "enable VPID" every VM entry and VM exit of L2 flushes the TLB.
L1 is now offered the secondary processor-based controls, with this one
control in them, and INVVPID.
- L2 runs with a VPID of its own when L1 has set "enable VPID". This one VPID of vmcs02 stands for all the VPIDs that L1 uses, so its mappings are flushed when L1 enters L2 with another VPID than the last time, when L1 executes INVVPID (whatever the type and the VPID), and when L2 runs on another CPU than the last time. If there is no VPID left for vmcs02, L2 runs without one as before.
- INVVPID is emulated as the SDM says (31.3), with all four types.
- A VPID of 0 with "enable VPID" makes the VM entry fail (27.2.1.1).
- INVVPID and INVEPT of any guest were VM exits that nothing handled, and bhyve(8) ended with an error. They now go the way of the other VMX instructions: #UD, unless nested VMX is on and it is INVVPID.
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