All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: David Dunn <daviddunn@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com,
	like.xu.linux@gmail.com, cloudliang@tencent.com
Subject: Re: [PATCH v2 6/6] selftests: kvm/x86: Add test for KVM_SET_PMU_EVENT_FILTER
Date: Fri, 14 Jan 2022 21:01:55 -0800	[thread overview]
Message-ID: <CALMp9eRWWgY1UT6KvnpHoopA86W9=kXojjYpvjLasJ9oBtNGSA@mail.gmail.com> (raw)
In-Reply-To: <CABOYuvb=LgmGSZ33Ht6eGYO8P-88Y7i=F=AEjVDxPfkQg46x0g@mail.gmail.com>

On Fri, Jan 14, 2022 at 11:15 AM David Dunn <daviddunn@google.com> wrote:
>
> Jim,
>
> The patch set looks good to me.  A couple comments and questions
> related just to this test are inline.
>
> On Thu, Jan 13, 2022 at 5:21 PM Jim Mattson <jmattson@google.com> wrote:
>
> > + * Determining AMD support for a PMU event requires consulting the AMD
> > + * PPR for the CPU or reference material derived therefrom.
> > + */
> > +static bool vcpu_supports_amd_zen_br_retired(void)
> > +{
> > +       struct kvm_cpuid_entry2 *entry;
> > +       struct kvm_cpuid2 *cpuid;
> > +
> > +       cpuid = kvm_get_supported_cpuid();
> > +       entry = kvm_get_supported_cpuid_index(1, 0);
> > +       return entry &&
> > +               ((x86_family(entry->eax) == 0x17 &&
> > +                 (x86_model(entry->eax) == 1 ||
> > +                  x86_model(entry->eax) == 0x31)) ||
> > +                (x86_family(entry->eax) == 0x19 &&
> > +                 x86_model(entry->eax) == 1));
> > +}
>
> The above function does not verify that the AMD host you are running
> on supports PMU.  In particular, you might be running the KVM test
> suite within a guest.  Is there a way to do that check here without
> direct access to MSRs?  If not, maybe we need a KVM capability to
> query this information.

On Intel, if the parent hypervisor has constructed the CPUID:0AH leaf
correctly, the test will skip because it can't find what it wants in
CPUID:0AH, and the CPU family isn't what it is looking for on the AMD
side.

On AMD, the test assumes that the PMU is there (as the specification
requires). For the Zen line, a VM with vPMU enabled should report
CPUID:80000001H:ECX.PerfCtrExtCore[bit 23] set, and a VM with vPMU
disabled should report that bit clear.

In v3, I'm adding a PMU sanity check based on Linux's check_hw_exists().

> > +       r = kvm_check_cap(KVM_CAP_PMU_EVENT_FILTER);
> > +       if (!r) {
> > +               print_skip("KVM_CAP_PMU_EVENT_FILTER not supported");
> > +               exit(KSFT_SKIP);
> > +       }
>
> This capability is still supported even when PMU has been disabled by
> Like Xu's new module parameter.  Should all the PMU related
> capabilities be gated behind that module parameter?

Perhaps. That's something for Like Xu to consider with the current
rewrite of the module parameter.

> Dave Dunn

  reply	other threads:[~2022-01-15  5:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14  1:21 [PATCH v2 0/6] KVM: x86/pmu: Use binary search to check filtered events Jim Mattson
2022-01-14  1:21 ` [PATCH v2 1/6] " Jim Mattson
2022-01-14  1:21 ` [PATCH v2 2/6] selftests: kvm/x86: Parameterize the CPUID vendor string check Jim Mattson
2022-01-14  1:21 ` [PATCH v2 3/6] selftests: kvm/x86: Introduce is_amd_cpu() Jim Mattson
2022-01-14  1:21 ` [PATCH v2 4/6] selftests: kvm/x86: Export x86_family() for use outside of processor.c Jim Mattson
2022-01-14  1:21 ` [PATCH v2 5/6] selftests: kvm/x86: Introduce x86_model() Jim Mattson
2022-01-14  1:21 ` [PATCH v2 6/6] selftests: kvm/x86: Add test for KVM_SET_PMU_EVENT_FILTER Jim Mattson
2022-01-14 19:15   ` David Dunn
2022-01-15  5:01     ` Jim Mattson [this message]
2022-01-18  9:15 ` [PATCH v2 0/6] KVM: x86/pmu: Use binary search to check filtered events Paolo Bonzini

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='CALMp9eRWWgY1UT6KvnpHoopA86W9=kXojjYpvjLasJ9oBtNGSA@mail.gmail.com' \
    --to=jmattson@google.com \
    --cc=cloudliang@tencent.com \
    --cc=daviddunn@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=like.xu.linux@gmail.com \
    --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.