linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Yi Lai <yi1.lai@intel.com>,
	dongsheng <dongsheng.x.zhang@intel.com>
Subject: Re: [PATCH v3 5/5] KVM: selftests: Handle Intel Atom errata that leads to PMU event overcount
Date: Fri, 19 Sep 2025 07:55:09 -0700	[thread overview]
Message-ID: <aM1uzfweXxoaaLpt@google.com> (raw)
In-Reply-To: <dd2d2e23-083e-46cf-b0bd-7dfb3198d403@linux.intel.com>

On Fri, Sep 19, 2025, Dapeng Mi wrote:
> 
> On 9/19/2025 8:45 AM, Sean Christopherson wrote:
> > diff --git a/tools/testing/selftests/kvm/x86/pmu_counters_test.c b/tools/testing/selftests/kvm/x86/pmu_counters_test.c
> > index baa7b8a2d459..acb5a5c37296 100644
> > --- a/tools/testing/selftests/kvm/x86/pmu_counters_test.c
> > +++ b/tools/testing/selftests/kvm/x86/pmu_counters_test.c
> > @@ -163,10 +163,18 @@ static void guest_assert_event_count(uint8_t idx, uint32_t pmc, uint32_t pmc_msr
> >  
> >  	switch (idx) {
> >  	case INTEL_ARCH_INSTRUCTIONS_RETIRED_INDEX:
> > -		GUEST_ASSERT_EQ(count, NUM_INSNS_RETIRED);
> > +		/* Relax precise count check due to VM-EXIT/VM-ENTRY overcount issue */
> > +		if (this_pmu_has_errata(INSTRUCTIONS_RETIRED_OVERCOUNT))
> 
> The pmu_errata_mask is a bitmap, so the argument should be
> BIT_ULL(INSTRUCTIONS_RETIRED_OVERCOUNT) instead of
> INSTRUCTIONS_RETIRED_OVERCOUNT?

Gah, I just forgot to use BIT_ULL() in this_pmu_has_errata().

diff --git a/tools/testing/selftests/kvm/include/x86/pmu.h b/tools/testing/selftests/kvm/include/x86/pmu.h
index 25d2b476daf4..308c9f6f0d57 100644
--- a/tools/testing/selftests/kvm/include/x86/pmu.h
+++ b/tools/testing/selftests/kvm/include/x86/pmu.h
@@ -115,7 +115,7 @@ void kvm_init_pmu_errata(void);
 
 static inline bool this_pmu_has_errata(enum pmu_errata errata)
 {
-       return pmu_errata_mask & errata;
+       return pmu_errata_mask & BIT_ULL(errata);
 }
 
 #endif /* SELFTEST_KVM_PMU_H */


> 
> Or better, directly define INSTRUCTIONS_RETIRED_OVERCOUNT as a bitmap, like
> this.
> 
> diff --git a/tools/testing/selftests/kvm/include/x86/pmu.h
> b/tools/testing/selftests/kvm/include/x86/pmu.h
> index 25d2b476daf4..9af448129597 100644
> --- a/tools/testing/selftests/kvm/include/x86/pmu.h
> +++ b/tools/testing/selftests/kvm/include/x86/pmu.h
> @@ -106,8 +106,8 @@ extern const uint64_t intel_pmu_arch_events[];
>  extern const uint64_t amd_pmu_zen_events[];
> 
>  enum pmu_errata {
> -       INSTRUCTIONS_RETIRED_OVERCOUNT,
> -       BRANCHES_RETIRED_OVERCOUNT,
> +       INSTRUCTIONS_RETIRED_OVERCOUNT = (1 << 0),
> +       BRANCHES_RETIRED_OVERCOUNT     = (1 << 1),

I want to utilize the auto-incrementing behavior of enums, without having to
resort to double-defines or anything. 

  reply	other threads:[~2025-09-19 14:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19  0:45 [PATCH v3 0/5] KVM: selftests: PMU fixes for GNR/SRF/CWF Sean Christopherson
2025-09-19  0:45 ` [PATCH v3 1/5] KVM: selftests: Add timing_info bit support in vmx_pmu_caps_test Sean Christopherson
2025-09-19  0:45 ` [PATCH v3 2/5] KVM: selftests: Track unavailable_mask for PMU events as 32-bit value Sean Christopherson
2025-09-19  5:43   ` Mi, Dapeng
2025-09-19 14:52     ` Sean Christopherson
2025-09-19  0:45 ` [PATCH v3 3/5] KVM: selftests: Reduce number of "unavailable PMU events" combos tested Sean Christopherson
2025-09-19  5:44   ` Mi, Dapeng
2025-09-19  0:45 ` [PATCH v3 4/5] KVM: selftests: Validate more arch-events in pmu_counters_test Sean Christopherson
2025-09-19  0:45 ` [PATCH v3 5/5] KVM: selftests: Handle Intel Atom errata that leads to PMU event overcount Sean Christopherson
2025-09-19  5:49   ` Mi, Dapeng
2025-09-19 14:55     ` Sean Christopherson [this message]
2025-09-19 16:42       ` 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=aM1uzfweXxoaaLpt@google.com \
    --to=seanjc@google.com \
    --cc=dapeng1.mi@linux.intel.com \
    --cc=dongsheng.x.zhang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yi1.lai@intel.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;
as well as URLs for NNTP newsgroup(s).