From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Sean Christopherson <seanjc@google.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.12.y 1/6] KVM: SVM: Mark VMCB dirty before processing incoming snp_vmsa_gpa
Date: Mon, 31 Aug 2026 14:31:52 -0400 [thread overview]
Message-ID: <20260831183157.1673215-1-sashal@kernel.org> (raw)
In-Reply-To: <2026083106-utensil-mangy-28f5@gregkh>
From: Sean Christopherson <seanjc@google.com>
[ Upstream commit e268beee4a25ce58807a96253e95e96c2e3a5c1a ]
Mark the VMCB dirty, i.e. zero control.clean, prior to handling the new
VMSA. Nothing in the VALID_PAGE() case touches control.clean, and
isolating the VALID_PAGE() code will allow simplifying the overall logic.
Note, the VMCB probably doesn't need to be marked dirty when the VMSA is
invalid, as KVM will disallow running the vCPU in such a state. But it
also doesn't hurt anything.
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20250227012541.3234589-9-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Stable-dep-of: 42a39ad5d592 ("KVM: SEV: Track the GPA of the guest-controlled VMSA used for SNP guests")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/kvm/svm/sev.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index a6971cd236bed..058d34622be35 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3921,6 +3921,12 @@ static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
/* Clear use of the VMSA */
svm->vmcb->control.vmsa_pa = INVALID_PAGE;
+ /*
+ * When replacing the VMSA during SEV-SNP AP creation,
+ * mark the VMCB dirty so that full state is always reloaded.
+ */
+ vmcb_mark_all_dirty(svm->vmcb);
+
if (VALID_PAGE(svm->sev_es.snp_vmsa_gpa)) {
gfn_t gfn = gpa_to_gfn(svm->sev_es.snp_vmsa_gpa);
struct kvm_memory_slot *slot;
@@ -3966,12 +3972,6 @@ static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
kvm_release_pfn_clean(pfn);
}
- /*
- * When replacing the VMSA during SEV-SNP AP creation,
- * mark the VMCB dirty so that full state is always reloaded.
- */
- vmcb_mark_all_dirty(svm->vmcb);
-
return 0;
}
--
2.53.0
next prev parent reply other threads:[~2026-08-31 18:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 12:25 FAILED: patch "[PATCH] KVM: SEV: Track the GPA of the guest-controlled VMSA used for" failed to apply to 6.12-stable tree gregkh
2026-08-31 18:31 ` Sasha Levin [this message]
2026-08-31 18:31 ` [PATCH 6.12.y 2/6] KVM: SVM: Use guard(mutex) to simplify SNP vCPU state updates Sasha Levin
2026-09-01 19:03 ` Sean Christopherson
2026-08-31 18:31 ` [PATCH 6.12.y 3/6] KVM: SVM: Invalidate "next" SNP VMSA GPA even on failure Sasha Levin
2026-08-31 18:31 ` [PATCH 6.12.y 4/6] KVM: SEV: Disable SEV-SNP support on initialization failure Sasha Levin
2026-08-31 18:31 ` [PATCH 6.12.y 5/6] KVM: SVM: Move SEV-ES VMSA allocation to a dedicated sev_vcpu_create() helper Sasha Levin
2026-08-31 18:31 ` [PATCH 6.12.y 6/6] KVM: SEV: Track the GPA of the guest-controlled VMSA used for SNP guests Sasha Levin
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=20260831183157.1673215-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=thomas.lendacky@amd.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox