]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: VMX: Fold vmx_supported_debugctl() into vcpu_supported_debugctl()
authorSean Christopherson <seanjc@google.com>
Thu, 6 Oct 2022 00:03:09 +0000 (00:03 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Nov 2022 17:18:18 +0000 (13:18 -0400)
Fold vmx_supported_debugctl() into vcpu_supported_debugctl(), its only
caller.  Setting bits only to clear them a few instructions later is
rather silly, and splitting the logic makes things seem more complicated
than they actually are.

Opportunistically drop DEBUGCTLMSR_LBR_MASK now that there's a single
reference to the pair of bits.  The extra layer of indirection provides
no meaningful value and makes it unnecessarily tedious to understand
what KVM is doing.

No functional change.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221006000314.73240-4-seanjc@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/capabilities.h
arch/x86/kvm/vmx/vmx.c

index 3bd7a897061874d7862010e9788b25482ffeab41..07254314f3dd5b4412b97c0d0b42aa4de52ac835 100644 (file)
@@ -24,8 +24,6 @@ extern int __read_mostly pt_mode;
 #define PMU_CAP_FW_WRITES      (1ULL << 13)
 #define PMU_CAP_LBR_FMT                0x3f
 
-#define DEBUGCTLMSR_LBR_MASK           (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI)
-
 struct nested_vmx_msrs {
        /*
         * We only store the "true" versions of the VMX capability MSRs. We
@@ -421,19 +419,6 @@ static inline u64 vmx_get_perf_capabilities(void)
        return perf_cap;
 }
 
-static inline u64 vmx_supported_debugctl(void)
-{
-       u64 debugctl = 0;
-
-       if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
-               debugctl |= DEBUGCTLMSR_BUS_LOCK_DETECT;
-
-       if (vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT)
-               debugctl |= DEBUGCTLMSR_LBR_MASK;
-
-       return debugctl;
-}
-
 static inline bool cpu_has_notify_vmexit(void)
 {
        return vmcs_config.cpu_based_2nd_exec_ctrl &
index 65f092e4a81b35092ba253567139d29f6d27dd53..981b38355066ad6ca969d73c382da26445f28478 100644 (file)
@@ -2023,13 +2023,15 @@ static u64 nested_vmx_truncate_sysenter_addr(struct kvm_vcpu *vcpu,
 
 static u64 vcpu_supported_debugctl(struct kvm_vcpu *vcpu)
 {
-       u64 debugctl = vmx_supported_debugctl();
+       u64 debugctl = 0;
 
-       if (!intel_pmu_lbr_is_enabled(vcpu))
-               debugctl &= ~DEBUGCTLMSR_LBR_MASK;
+       if (boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) &&
+           guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
+               debugctl |= DEBUGCTLMSR_BUS_LOCK_DETECT;
 
-       if (!guest_cpuid_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
-               debugctl &= ~DEBUGCTLMSR_BUS_LOCK_DETECT;
+       if ((vmx_get_perf_capabilities() & PMU_CAP_LBR_FMT) &&
+           intel_pmu_lbr_is_enabled(vcpu))
+               debugctl |= DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
 
        return debugctl;
 }