From: Jim Mattson <jmattson@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, seanjc@google.com
Subject: Re: [PATCH v4 6/7] selftests: kvm/x86: Add testing for KVM_SET_PMU_EVENT_FILTER
Date: Wed, 14 Sep 2022 12:00:28 -0700 [thread overview]
Message-ID: <CALMp9eRHSD8NFkweTAT=9Tgm4UgdoKybGW4=BUwif=Hz38n1ug@mail.gmail.com> (raw)
In-Reply-To: <20220831162124.947028-7-aaronlewis@google.com>
On Wed, Aug 31, 2022 at 9:21 AM Aaron Lewis <aaronlewis@google.com> wrote:
>
> Test that masked events are not using invalid bits, and if they are,
> ensure the pmu event filter is not accepted by KVM_SET_PMU_EVENT_FILTER.
> The only valid bits that can be used for masked events are set when
> using KVM_PMU_EVENT_ENCODE_MASKED_EVENT() with one exception: If any
> of the high bits (11:8) of the event select are set when using Intel,
> the PMU event filter will fail.
>
> Also, because validation was not being done prior to the introduction
> of masked events, only expect validation to fail when masked events
> are used. E.g. in the first test a filter event with all it's bits set
Nit: its
> is accepted by KVM_SET_PMU_EVENT_FILTER when flags = 0.
>
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
> .../kvm/x86_64/pmu_event_filter_test.c | 35 +++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> index bd7054a53981..73a81262ca72 100644
> --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> @@ -442,6 +442,39 @@ static bool use_amd_pmu(void)
> is_zen3(entry->eax));
> }
>
> +static int run_filter_test(struct kvm_vcpu *vcpu, const uint64_t *events,
> + int nevents, uint32_t flags)
> +{
> + struct kvm_pmu_event_filter *f;
> + int r;
> +
> + f = create_pmu_event_filter(events, nevents, KVM_PMU_EVENT_ALLOW, flags);
> + r = __vm_ioctl(vcpu->vm, KVM_SET_PMU_EVENT_FILTER, f);
> + free(f);
> +
> + return r;
> +}
> +
> +static void test_filter_ioctl(struct kvm_vcpu *vcpu)
> +{
> + uint64_t e = ~0ul;
> + int r;
> +
> + /*
> + * Unfortunately having invalid bits set in event data is expected to
> + * pass when flags == 0 (bits other than eventsel+umask).
> + */
> + r = run_filter_test(vcpu, &e, 1, 0);
> + TEST_ASSERT(r == 0, "Valid PMU Event Filter is failing");
> +
> + r = run_filter_test(vcpu, &e, 1, KVM_PMU_EVENT_FLAG_MASKED_EVENTS);
Before using KVM_PMU_EVENT_FLAG_MASKED_EVENTS, we need to test for
KVM_CAP_PMU_EVENT_MASKED_EVENTS.
next prev parent reply other threads:[~2022-09-14 19:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-31 16:21 [PATCH v4 0/7] Introduce and test masked events Aaron Lewis
2022-08-31 16:21 ` [PATCH v4 1/7] kvm: x86/pmu: Correct the mask used in a pmu event filter lookup Aaron Lewis
2022-09-14 18:15 ` Jim Mattson
2022-08-31 16:21 ` [PATCH v4 2/7] kvm: x86/pmu: Remove invalid raw events from the pmu event filter Aaron Lewis
2022-09-14 18:17 ` Jim Mattson
2022-08-31 16:21 ` [PATCH v4 3/7] kvm: x86/pmu: prepare the pmu event filter for masked events Aaron Lewis
2022-09-14 18:25 ` Jim Mattson
2022-08-31 16:21 ` [PATCH v4 4/7] kvm: x86/pmu: Introduce masked events to the pmu event filter Aaron Lewis
2022-09-14 18:45 ` Jim Mattson
2022-08-31 16:21 ` [PATCH v4 5/7] selftests: kvm/x86: Add flags when creating a " Aaron Lewis
2022-09-14 18:47 ` Jim Mattson
2022-08-31 16:21 ` [PATCH v4 6/7] selftests: kvm/x86: Add testing for KVM_SET_PMU_EVENT_FILTER Aaron Lewis
2022-09-14 19:00 ` Jim Mattson [this message]
2022-08-31 16:21 ` [PATCH v4 7/7] selftests: kvm/x86: Test masked events Aaron Lewis
2022-09-14 20:12 ` Jim Mattson
2022-09-20 15:24 ` Aaron Lewis
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='CALMp9eRHSD8NFkweTAT=9Tgm4UgdoKybGW4=BUwif=Hz38n1ug@mail.gmail.com' \
--to=jmattson@google.com \
--cc=aaronlewis@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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).