From: Yosry Ahmed <yosry.ahmed@linux.dev>
To: stable@vger.kernel.org
Cc: Yosry Ahmed <yosry.ahmed@linux.dev>,
Matteo Rizzo <matteorizzo@google.com>,
evn@google.com, Jim Mattson <jmattson@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 6.12.y 2/5] KVM: SVM: Mark VMCB_LBR dirty when MSR_IA32_DEBUGCTLMSR is updated
Date: Thu, 20 Nov 2025 23:39:33 +0000 [thread overview]
Message-ID: <20251120233936.2407119-3-yosry.ahmed@linux.dev> (raw)
In-Reply-To: <20251120233936.2407119-1-yosry.ahmed@linux.dev>
The APM lists the DbgCtlMsr field as being tracked by the VMCB_LBR clean
bit. Always clear the bit when MSR_IA32_DEBUGCTLMSR is updated.
The history is complicated, it was correctly cleared for L1 before
commit 1d5a1b5860ed ("KVM: x86: nSVM: correctly virtualize LBR msrs when
L2 is running"). At that point svm_set_msr() started to rely on
svm_update_lbrv() to clear the bit, but when nested virtualization
is enabled the latter does not always clear it even if MSR_IA32_DEBUGCTLMSR
changed. Go back to clearing it directly in svm_set_msr().
Fixes: 1d5a1b5860ed ("KVM: x86: nSVM: correctly virtualize LBR msrs when L2 is running")
Reported-by: Matteo Rizzo <matteorizzo@google.com>
Reported-by: evn@google.com
Co-developed-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20251108004524.1600006-2-yosry.ahmed@linux.dev
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit dc55b3c3f61246e483e50c85d8d5366f9567e188)
---
arch/x86/kvm/svm/svm.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 6deccc1b1669..1e1210e5ef45 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3267,7 +3267,11 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
if (data & DEBUGCTL_RESERVED_BITS)
return 1;
+ if (svm_get_lbr_vmcb(svm)->save.dbgctl == data)
+ break;
+
svm_get_lbr_vmcb(svm)->save.dbgctl = data;
+ vmcb_mark_dirty(svm->vmcb, VMCB_LBR);
svm_update_lbrv(vcpu);
break;
case MSR_VM_HSAVE_PA:
--
2.52.0.rc2.455.g230fcf2819-goog
next prev parent reply other threads:[~2025-11-20 23:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 15:50 FAILED: patch "[PATCH] KVM: nSVM: Always recalculate LBR MSR intercepts in" failed to apply to 6.12-stable tree gregkh
2025-11-20 23:39 ` [PATCH 6.12.y 0/5] LBR virtualization fixes Yosry Ahmed
2025-11-20 23:39 ` [PATCH 6.12.y 1/5] KVM: SVM: Introduce svm_recalc_lbr_msr_intercepts() Yosry Ahmed
2025-11-20 23:39 ` Yosry Ahmed [this message]
2025-11-20 23:39 ` [PATCH 6.12.y 3/5] KVM: nSVM: Always recalculate LBR MSR intercepts in svm_update_lbrv() Yosry Ahmed
2025-11-20 23:39 ` [PATCH 6.12.y 4/5] KVM: nSVM: Fix and simplify LBR virtualization handling with nested Yosry Ahmed
2025-11-20 23:39 ` [PATCH 6.12.y 5/5] KVM: SVM: Fix redundant updates of LBR MSR intercepts Yosry Ahmed
2025-11-21 9:55 ` [PATCH 6.12.y 0/5] LBR virtualization fixes Greg KH
2025-11-21 15:17 ` Yosry Ahmed
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=20251120233936.2407119-3-yosry.ahmed@linux.dev \
--to=yosry.ahmed@linux.dev \
--cc=evn@google.com \
--cc=jmattson@google.com \
--cc=matteorizzo@google.com \
--cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox