On Wed, Feb 01, 2023, Mathias Krause wrote: > Make use of the kvm_read_cr{0,4}_bits() helper functions when we only > want to know the state of certain bits instead of the whole register. > > This not only makes the intend cleaner, it also avoids a VMREAD in case > the tested bits aren't guest owned. > > Signed-off-by: Mathias Krause <minipli@xxxxxxxxxxxxxx> > --- > arch/x86/kvm/pmu.c | 4 ++-- > arch/x86/kvm/vmx/vmx.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c > index d939d3b84e6f..d9922277df67 100644 > --- a/arch/x86/kvm/pmu.c > +++ b/arch/x86/kvm/pmu.c > @@ -439,9 +439,9 @@ int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned idx, u64 *data) > if (!pmc) > return 1; > > - if (!(kvm_read_cr4(vcpu) & X86_CR4_PCE) && > + if (!(kvm_read_cr4_bits(vcpu, X86_CR4_PCE)) && Purely as an FYI, I proposed adding helpers to query single CR0/CR4 bits in a separate thread[*]. No need to do anything on your end, I'll plan on applying this patch first and will handle whatever conflicts arise. [*] https://lore.kernel.org/all/ZAuRec2NkC3+4jvD@xxxxxxxxxx