Skip to content

Commit a0ee1d5

Browse files
gaochaointelsean-jc
authored andcommitted
KVM: VMX: Flush shadow VMCS on emergency reboot
Ensure the shadow VMCS cache is evicted during an emergency reboot to prevent potential memory corruption if the cache is evicted after reboot. This issue was identified through code inspection, as __loaded_vmcs_clear() flushes both the normal VMCS and the shadow VMCS. Avoid checking the "launched" state during an emergency reboot, unlike the behavior in __loaded_vmcs_clear(). This is important because reboot NMIs can interfere with operations like copy_shadow_to_vmcs12(), where shadow VMCSes are loaded directly using VMPTRLD. In such cases, if NMIs occur right after the VMCS load, the shadow VMCSes will be active but the "launched" state may not be set. Fixes: 16f5b90 ("KVM: nVMX: Copy processor-specific shadow-vmcs to VMCS12") Cc: [email protected] Signed-off-by: Chao Gao <[email protected]> Reviewed-by: Kai Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 798b9b1 commit a0ee1d5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,11 @@ void vmx_emergency_disable_virtualization_cpu(void)
770770
return;
771771

772772
list_for_each_entry(v, &per_cpu(loaded_vmcss_on_cpu, cpu),
773-
loaded_vmcss_on_cpu_link)
773+
loaded_vmcss_on_cpu_link) {
774774
vmcs_clear(v->vmcs);
775+
if (v->shadow_vmcs)
776+
vmcs_clear(v->shadow_vmcs);
777+
}
775778

776779
kvm_cpu_vmxoff();
777780
}

0 commit comments

Comments
 (0)