Commit dc55b3c3 authored by Yosry Ahmed's avatar Yosry Ahmed Committed by Paolo Bonzini
Browse files

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 1d5a1b58 ("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: 1d5a1b58 ("KVM: x86: nSVM: correctly virtualize LBR msrs when L2 is running")
Reported-by: default avatarMatteo Rizzo <matteorizzo@google.com>
Reported-by: default avatar <evn@google.com>
Co-developed-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarYosry 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: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent ca00c3af
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3004,7 +3004,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: