Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM: x86/PVM: Switch to PVM mode as soon as possible
Per to the PVM specification, the 'event_flags' in PVCS is specific to PVM mode and unrelated to the x86 specification. Therefore, it will not be changed in non-PVM mode. During VM store, the VMM may inject an event to invoke the vCPU, and the event is delivered directly before the vcpu_run() callback. However, the PVM mode switching occurs after vcpu_run(), so the vCPU delivers the event in non-PVM mode. Consequently, in pvm_set_rflags(), 'event_flags' is not updated, and the guest will observe that the X86_EFLAGS_IF is set during event handling, leading to a BUG_ON() in the guest. Additionally, when the guest exits, the 'X86_EFLAGS_IF' bit will be updated to the value maintained in the hypervisor. Therefore, the hypervisor may inject an event during the event handling of the guest before interrupt is enabled. To address this issue, switch to PVM mode during the CR0 setting and CS segment setting, and add a WARN_ON_ONCE() to detect event injection in non-PVM mode. Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
- Loading branch information
s/swith/switch/, try to use checkpatch.pl :D