diff options
| author | Sean Christopherson <seanjc@google.com> | 2025-02-27 14:24:10 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-03-13 13:08:04 +0100 |
| commit | 0fbd290bd6f2256686b34fcb4100f10f07bdcdba (patch) | |
| tree | 1004079c373f53c43b32cae09b1aa08a1f94a773 | |
| parent | 5e1b0b03a6525415d4d48a33a4414b900f8cfc57 (diff) | |
| download | linux-0fbd290bd6f2256686b34fcb4100f10f07bdcdba.tar.gz linux-0fbd290bd6f2256686b34fcb4100f10f07bdcdba.tar.bz2 linux-0fbd290bd6f2256686b34fcb4100f10f07bdcdba.zip | |
KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQs
commit 189ecdb3e112da703ac0699f4ec76aa78122f911 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>
| -rw-r--r-- | arch/x86/kvm/x86.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b43cfc8b8134..742d9f4bca22 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4976,7 +4976,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) /* Save host pkru register if supported */ vcpu->arch.host_pkru = read_pkru(); - vcpu->arch.host_debugctl = get_debugctlmsr(); /* Apply any externally detected TSC adjustments (due to suspend) */ if (unlikely(vcpu->arch.tsc_offset_adjustment)) { @@ -10961,6 +10960,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) set_debugreg(0, 7); } + vcpu->arch.host_debugctl = get_debugctlmsr(); + guest_timing_enter_irqoff(); for (;;) { |
