From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v3 1/2] KVM: x86: Provide a capability to disable APERF/MPERF read intercepts
Date: Mon, 5 May 2025 09:34:49 -0700 [thread overview]
Message-ID: <aBjoqW6qzoc2RGrZ@google.com> (raw)
In-Reply-To: <CALMp9eS7XHpFWMAtnJPQijYO1TVW25-UGmFqc33eAeb1AE_9YA@mail.gmail.com>
On Mon, May 05, 2025, Jim Mattson wrote:
> On Mon, Apr 28, 2025 at 3:58 PM Sean Christopherson <seanjc@google.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?
next prev parent reply other threads:[~2025-05-05 16:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 22:14 [PATCH v3 0/2] KVM: x86: Provide a capability to disable APERF/MPERF read intercepts Jim Mattson
2025-03-21 22:14 ` [PATCH v3 1/2] " Jim Mattson
2025-04-28 22:58 ` Sean Christopherson
2025-05-05 15:51 ` Jim Mattson
2025-05-05 16:34 ` Sean Christopherson [this message]
2025-05-07 18:09 ` Jim Mattson
2025-03-21 22:14 ` [PATCH v3 2/2] KVM: selftests: Test behavior of KVM_X86_DISABLE_EXITS_APERFMPERF Jim Mattson
2025-04-29 1:26 ` Sean Christopherson
2025-05-07 18:19 ` Jim Mattson
2025-05-07 19:54 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aBjoqW6qzoc2RGrZ@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox