简体   繁体   中英

How and when host CPU state is saved in the VMCS host-state area?

I'm trying to understand the basics of how Intel VMX/VT-x works. In the Intel Software Developer Manual it says this about VMCS:

The VMCS data are organized into six logical groups:
Guest-state area . Processor state is saved into the guest-state area on VM exits and loaded from there on VM entries.
Host-state area . Processor state is loaded from the host-state area on VM exits.
...

It makes sense to me that the CPU state is save into the guest-area on VM exits and loaded on VM entries. It also makes sense that the CPU state is loaded from the host-state area on VM exits... but when is the CPU state saved in the host-state area? Intuitively I would say that it is saved on VM entries, but the manual doesn't say so... can somebody help me clarify this?

Thanks

The CPU never saves the host state.
The VMM (aka: the hypervisor) controls when to execute vmlaunch/vmresume and can thus set the host state area accordingly before their execution.

When a VM-entry fails due to an invalid VMCS, the execution falls through to the next instruction after vmlaunch/vmresume .
When the VM-entry fails due to an invalid guest state, the execution resumes from the RIP set in the host state area (just like a VM-exit occurred).
If the CPU were to set the host state area, the two cases will be identical.

This is also why the CPU checks the host state area before entering VMX non-root mode (ie launching a VM).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM