Skip to content

Commit dc55b3c

Browse files
yosrym93bonzini
authored andcommitted
KVM: SVM: Mark VMCB_LBR dirty when MSR_IA32_DEBUGCTLMSR is updated
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 1d5a1b5 ("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: 1d5a1b5 ("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>
1 parent ca00c3a commit dc55b3c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

arch/x86/kvm/svm/svm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,7 +3004,11 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
30043004
if (data & DEBUGCTL_RESERVED_BITS)
30053005
return 1;
30063006

3007+
if (svm_get_lbr_vmcb(svm)->save.dbgctl == data)
3008+
break;
3009+
30073010
svm_get_lbr_vmcb(svm)->save.dbgctl = data;
3011+
vmcb_mark_dirty(svm->vmcb, VMCB_LBR);
30083012
svm_update_lbrv(vcpu);
30093013
break;
30103014
case MSR_VM_HSAVE_PA:

0 commit comments

Comments
 (0)