From: Sean Christopherson <seanjc@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com
Subject: Re: [PATCH v5 1/7] kvm: x86/pmu: Correct the mask used in a pmu event filter lookup
Date: Mon, 17 Oct 2022 18:20:24 +0000 [thread overview]
Message-ID: <Y02c6JdM432f8H+A@google.com> (raw)
In-Reply-To: <CAAAPnDEk_bckk0W5C2vKiL4HJVUHFGV3_NqfdbsqYFqpJvuXog@mail.gmail.com>
On Sat, Oct 15, 2022, Aaron Lewis wrote:
> > And the total patch is:
> >
> > ---
> > arch/x86/kvm/pmu.c | 2 +-
> > arch/x86/kvm/pmu.h | 2 ++
> > arch/x86/kvm/svm/pmu.c | 2 ++
> > arch/x86/kvm/vmx/pmu_intel.c | 2 ++
> > 4 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> > index d9b9a0f0db17..d0e2c7eda65b 100644
> > --- a/arch/x86/kvm/pmu.c
> > +++ b/arch/x86/kvm/pmu.c
> > @@ -273,7 +273,7 @@ static bool check_pmu_event_filter(struct kvm_pmc *pmc)
> > goto out;
> >
> > if (pmc_is_gp(pmc)) {
> > - key = pmc->eventsel & AMD64_RAW_EVENT_MASK_NB;
> > + key = pmc->eventsel & kvm_pmu_ops.EVENTSEL_MASK;
> > if (bsearch(&key, filter->events, filter->nevents,
> > sizeof(__u64), cmp_u64))
> > allow_event = filter->action == KVM_PMU_EVENT_ALLOW;
> > diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h
> > index 5cc5721f260b..45a7dd24125d 100644
> > --- a/arch/x86/kvm/pmu.h
> > +++ b/arch/x86/kvm/pmu.h
> > @@ -40,6 +40,8 @@ struct kvm_pmu_ops {
> > void (*reset)(struct kvm_vcpu *vcpu);
> > void (*deliver_pmi)(struct kvm_vcpu *vcpu);
> > void (*cleanup)(struct kvm_vcpu *vcpu);
> > +
> > + const u64 EVENTSEL_MASK;
>
> Agreed, a constant is better. Had I realized I could do that, that
> would have been my first choice.
>
> What about calling it EVENTSEL_RAW_MASK to make it more descriptive
> though? It's a little too generic given there is EVENTSEL_UMASK and
> EVENTSEL_CMASK, also there is precedent for using the term 'raw event'
> for (eventsel+umask), i.e.
> https://man7.org/linux/man-pages/man1/perf-record.1.html.
Hmm. I'd prefer to avoid "raw" because that implies there's a non-raw version
that can be translated into the "raw" version. This is kinda the opposite, where
the above field is the composite type and the invidiual fields are the "raw"
components.
Refresh me, as I've gotten twisted about: this mask needs to be EVENTSEL_EVENT_MASK
+ EVENTSEL_UMASK, correct? Or phrased differently, it'll hold more than just
EVENTSEL_EVENT_MASK?
What about something completely different, e.g. FILTER_MASK? It'll require a
comment to document, but that seems inevitable, and FILTER_MASK should be really
hard to confuse with the myriad EVENTSEL_*MASK fields.
next prev parent reply other threads:[~2022-10-17 18:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 17:45 [PATCH v5 0/7] Introduce and test masked events Aaron Lewis
2022-09-20 17:45 ` [PATCH v5 1/7] kvm: x86/pmu: Correct the mask used in a pmu event filter lookup Aaron Lewis
2022-10-07 23:25 ` Sean Christopherson
2022-10-15 15:43 ` Aaron Lewis
2022-10-17 18:20 ` Sean Christopherson [this message]
2022-10-21 1:33 ` Aaron Lewis
2022-09-20 17:45 ` [PATCH v5 2/7] kvm: x86/pmu: Remove invalid raw events from the pmu event filter Aaron Lewis
2022-10-07 23:48 ` Sean Christopherson
2022-09-20 17:45 ` [PATCH v5 3/7] kvm: x86/pmu: prepare the pmu event filter for masked events Aaron Lewis
2022-10-08 0:08 ` Sean Christopherson
2022-09-20 17:46 ` [PATCH v5 4/7] kvm: x86/pmu: Introduce masked events to the pmu event filter Aaron Lewis
2022-10-08 0:37 ` Sean Christopherson
2022-10-10 15:42 ` Sean Christopherson
2022-10-15 15:43 ` Aaron Lewis
2022-10-17 17:47 ` Sean Christopherson
2022-10-19 1:06 ` Aaron Lewis
2022-10-21 1:33 ` Aaron Lewis
2022-10-21 17:50 ` Sean Christopherson
2022-09-20 17:46 ` [PATCH v5 5/7] selftests: kvm/x86: Add flags when creating a " Aaron Lewis
2022-09-20 17:46 ` [PATCH v5 6/7] selftests: kvm/x86: Add testing for KVM_SET_PMU_EVENT_FILTER Aaron Lewis
2022-09-20 17:56 ` Jim Mattson
2022-09-20 17:46 ` [PATCH v5 7/7] selftests: kvm/x86: Test masked events Aaron Lewis
2022-09-20 17:59 ` Jim Mattson
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=Y02c6JdM432f8H+A@google.com \
--to=seanjc@google.com \
--cc=aaronlewis@google.com \
--cc=jmattson@google.com \
--cc=kvm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.