aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/kvm/pmu.c
diff options
context:
space:
mode:
authorGravatar Binbin Wu <binbin.wu@linux.intel.com> 2023-03-22 12:58:21 +0800
committerGravatar Sean Christopherson <seanjc@google.com> 2023-03-22 10:10:53 -0700
commit607475cfa0f753862c0030de836875fe4ac5cf8a (patch)
treed1606c5c811da33380874a051ca026d34706ab04 /arch/x86/kvm/pmu.c
parentKVM: SVM: Fix benign "bool vs. int" comparison in svm_set_cr0() (diff)
downloadlinux-607475cfa0f753862c0030de836875fe4ac5cf8a.tar.gz
linux-607475cfa0f753862c0030de836875fe4ac5cf8a.tar.bz2
linux-607475cfa0f753862c0030de836875fe4ac5cf8a.zip
KVM: x86: Add helpers to query individual CR0/CR4 bits
Add helpers to check if a specific CR0/CR4 bit is set to avoid a plethora of implicit casts from the "unsigned long" return of kvm_read_cr*_bits(), and to make each caller's intent more obvious. Defer converting helpers that do truly ugly casts from "unsigned long" to "int", e.g. is_pse(), to a future commit so that their conversion is more isolated. Opportunistically drop the superfluous pcid_enabled from kvm_set_cr3(); the local variable is used only once, immediately after its declaration. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Link: https://lore.kernel.org/r/20230322045824.22970-2-binbin.wu@linux.intel.com [sean: move "obvious" conversions to this commit, massage changelog] Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'arch/x86/kvm/pmu.c')
-rw-r--r--arch/x86/kvm/pmu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index f4aa170b5b97..bb1733bb5bf9 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -540,9 +540,9 @@ int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned idx, u64 *data)
if (!pmc)
return 1;
- if (!(kvm_read_cr4_bits(vcpu, X86_CR4_PCE)) &&
+ if (!kvm_is_cr4_bit_set(vcpu, X86_CR4_PCE) &&
(static_call(kvm_x86_get_cpl)(vcpu) != 0) &&
- (kvm_read_cr0_bits(vcpu, X86_CR0_PE)))
+ kvm_is_cr0_bit_set(vcpu, X86_CR0_PE))
return 1;
*data = pmc_read_counter(pmc) & mask;