From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Chao Gao <chao.gao@intel.com>, Kai Huang <kai.huang@intel.com>,
Sean Christopherson <seanjc@google.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1.y 3/3] KVM: VMX: Flush shadow VMCS on emergency reboot
Date: Thu, 24 Jul 2025 13:07:25 -0400 [thread overview]
Message-ID: <20250724170725.1404455-3-sashal@kernel.org> (raw)
In-Reply-To: <20250724170725.1404455-1-sashal@kernel.org>
From: Chao Gao <chao.gao@intel.com>
[ Upstream commit a0ee1d5faff135e28810f29e0f06328c66f89852 ]
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: 16f5b9034b69 ("KVM: nVMX: Copy processor-specific shadow-vmcs to VMCS12")
Cc: stable@vger.kernel.org
Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Link: https://lore.kernel.org/r/20250324140849.2099723-1-chao.gao@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/kvm/vmx/vmx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index ef9cb8445dc48..12f9b220b6bd1 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -711,8 +711,11 @@ static void vmx_emergency_disable(void)
struct loaded_vmcs *v;
list_for_each_entry(v, &per_cpu(loaded_vmcss_on_cpu, cpu),
- loaded_vmcss_on_cpu_link)
+ loaded_vmcss_on_cpu_link) {
vmcs_clear(v->vmcs);
+ if (v->shadow_vmcs)
+ vmcs_clear(v->shadow_vmcs);
+ }
__cpu_emergency_vmxoff();
}
--
2.39.5
next prev parent reply other threads:[~2025-07-24 17:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 9:06 FAILED: patch "[PATCH] KVM: VMX: Flush shadow VMCS on emergency reboot" failed to apply to 6.1-stable tree gregkh
2025-07-24 17:07 ` [PATCH 6.1.y 1/3] x86/reboot: Harden virtualization hooks for emergency reboot Sasha Levin
2025-07-24 17:07 ` [PATCH 6.1.y 2/3] x86/reboot: KVM: Handle VMXOFF in KVM's reboot callback Sasha Levin
2025-08-14 20:25 ` Sean Christopherson
2025-07-24 17:07 ` Sasha Levin [this message]
2025-08-14 20:25 ` [PATCH 6.1.y 3/3] KVM: VMX: Flush shadow VMCS on emergency reboot Sean Christopherson
2025-08-14 20:25 ` [PATCH 6.1.y 1/3] x86/reboot: Harden virtualization hooks for " Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250724170725.1404455-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=chao.gao@intel.com \
--cc=kai.huang@intel.com \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.