Skip to content

Commit 0fbd290

Browse files
sean-jcgregkh
authored andcommitted
KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQs
commit 189ecdb upstream. Snapshot the host's DEBUGCTL after disabling IRQs, as perf can toggle debugctl bits from IRQ context, e.g. when enabling/disabling events via smp_call_function_single(). Taking the snapshot (long) before IRQs are disabled could result in KVM effectively clobbering DEBUGCTL due to using a stale snapshot. Cc: stable@vger.kernel.org Reviewed-and-tested-by: Ravi Bangoria <ravi.bangoria@amd.com> Link: https://lore.kernel.org/r/20250227222411.3490595-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5e1b0b0 commit 0fbd290

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arch/x86/kvm/x86.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4976,7 +4976,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
49764976

49774977
/* Save host pkru register if supported */
49784978
vcpu->arch.host_pkru = read_pkru();
4979-
vcpu->arch.host_debugctl = get_debugctlmsr();
49804979

49814980
/* Apply any externally detected TSC adjustments (due to suspend) */
49824981
if (unlikely(vcpu->arch.tsc_offset_adjustment)) {
@@ -10961,6 +10960,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
1096110960
set_debugreg(0, 7);
1096210961
}
1096310962

10963+
vcpu->arch.host_debugctl = get_debugctlmsr();
10964+
1096410965
guest_timing_enter_irqoff();
1096510966

1096610967
for (;;) {

0 commit comments

Comments
 (0)