lkml.org 
[lkml]   [2023]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH v3 4/6] KVM: x86: Make use of kvm_read_cr*_bits() when testing bits
    From
    On 15.03.23 23:18, Sean Christopherson wrote:
    > 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@grsecurity.net>
    >> ---
    >> 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@google.com

    Unfortunately, not all users of kvm_read_cr*_bits() only want to read a
    single bit. There are a very few that read bit masks -- but you're
    probably fully aware of this.

    Thanks,
    Mathias

    \
     
     \ /
      Last update: 2023-03-27 01:10    [W:2.112 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site