Skip to content

Commit 7538a15

Browse files
sean-jcjfvogel
authored andcommitted
KVM: VMX: Allow guest to set DEBUGCTL.RTM_DEBUG if RTM is supported
[ Upstream commit 17ec2f9 ] Let the guest set DEBUGCTL.RTM_DEBUG if RTM is supported according to the guest CPUID model, as debug support is supposed to be available if RTM is supported, and there are no known downsides to letting the guest debug RTM aborts. Note, there are no known bug reports related to RTM_DEBUG, the primary motivation is to reduce the probability of breaking existing guests when a future change adds a missing consistency check on vmcs12.GUEST_DEBUGCTL (KVM currently lets L2 run with whatever hardware supports; whoops). Note #2, KVM already emulates DR6.RTM, and doesn't restrict access to DR7.RTM. Fixes: 83c5291 ("KVM: x86: expose Intel cpu new features (HLE, RTM) to guest") Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 56eb5c57e32ccf3072ecc619facae007f2b8aa80) Signed-off-by: Jack Vogel <[email protected]>
1 parent 3e04ca1 commit 7538a15

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

arch/x86/include/asm/msr-index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@
420420
#define DEBUGCTLMSR_FREEZE_PERFMON_ON_PMI (1UL << 12)
421421
#define DEBUGCTLMSR_FREEZE_IN_SMM_BIT 14
422422
#define DEBUGCTLMSR_FREEZE_IN_SMM (1UL << DEBUGCTLMSR_FREEZE_IN_SMM_BIT)
423+
#define DEBUGCTLMSR_RTM_DEBUG BIT(15)
423424

424425
#define MSR_PEBS_FRONTEND 0x000003f7
425426

arch/x86/kvm/vmx/vmx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,10 @@ static u64 vmx_get_supported_debugctl(struct kvm_vcpu *vcpu, bool host_initiated
21852185
(host_initiated || intel_pmu_lbr_is_enabled(vcpu)))
21862186
debugctl |= DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
21872187

2188+
if (boot_cpu_has(X86_FEATURE_RTM) &&
2189+
(host_initiated || guest_cpuid_has(vcpu, X86_FEATURE_RTM)))
2190+
debugctl |= DEBUGCTLMSR_RTM_DEBUG;
2191+
21882192
return debugctl;
21892193
}
21902194

0 commit comments

Comments
 (0)