[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALMp9eQBLj=Qh_70Xvbu9ZkYkWBd=yNgeG-zbvLa__F+d-+BZA@mail.gmail.com>
Date: Wed, 7 May 2025 11:09:07 -0700
From: Jim Mattson <jmattson@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>
Subject: Re: [PATCH v3 1/2] KVM: x86: Provide a capability to disable
APERF/MPERF read intercepts
On Mon, May 5, 2025 at 9:34 AM Sean Christopherson <seanjc@...gle.com> wrote:
>
> On Mon, May 05, 2025, Jim Mattson wrote:
> > On Mon, Apr 28, 2025 at 3:58 PM Sean Christopherson <seanjc@...gle.com> wrote:
> > > diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> > > index 88a9475899c8..1675017eea88 100644
> > > --- a/arch/x86/kvm/x86.h
> > > +++ b/arch/x86/kvm/x86.h
> > > @@ -481,25 +481,15 @@ static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec)
> > > __rem; \
> > > })
> > >
> > > -static inline bool kvm_mwait_in_guest(struct kvm *kvm)
> > > -{
> > > - return kvm->arch.mwait_in_guest;
> > > -}
> > > -
> > > -static inline bool kvm_hlt_in_guest(struct kvm *kvm)
> > > -{
> > > - return kvm->arch.hlt_in_guest;
> > > -}
> > > -
> > > -static inline bool kvm_pause_in_guest(struct kvm *kvm)
> > > -{
> > > - return kvm->arch.pause_in_guest;
> > > -}
> > > -
> > > -static inline bool kvm_cstate_in_guest(struct kvm *kvm)
> > > -{
> > > - return kvm->arch.cstate_in_guest;
> > > -}
> > > +#define BUILD_DISABLED_EXITS_HELPER(lname, uname) \
> > > +static inline bool kvm_##lname##_in_guest(struct kvm *kvm) \
> > > +{ \
> > > + return kvm->arch.disabled_exits & KVM_X86_DISABLE_EXITS_##uname; \
> > > +}
> > > +BUILD_DISABLED_EXITS_HELPER(hlt, HLT);
> > > +BUILD_DISABLED_EXITS_HELPER(pause, PAUSE);
> > > +BUILD_DISABLED_EXITS_HELPER(mwait, MWAIT);
> > > +BUILD_DISABLED_EXITS_HELPER(cstate, CSTATE);
> >
> > The boilerplate is bad, but that's abhorrent.
>
> Assuming it's the macros you hate, keep the "u64 disabled_exits" change but
> manually code all of the getters?
Sounds good. I'll try to get a V4 out this week.
Powered by blists - more mailing lists