From: Wei Wang <wei.w.wang@intel.com>
To: Eric Hankland <ehankland@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH] KVM: x86: Add fixed counters to PMU filter
Date: Fri, 19 Jul 2019 16:31:54 +0800 [thread overview]
Message-ID: <5D317FFA.8000507@intel.com> (raw)
In-Reply-To: <20190718183818.190051-1-ehankland@google.com>
On 07/19/2019 02:38 AM, Eric Hankland wrote:
> From: ehankland <ehankland@google.com>
>
> Updates KVM_CAP_PMU_EVENT_FILTER so it can also whitelist or blacklist
> fixed counters.
>
> Signed-off-by: ehankland <ehankland@google.com>
> ---
> Documentation/virtual/kvm/api.txt | 13 ++++++++-----
> arch/x86/include/uapi/asm/kvm.h | 9 ++++++---
> arch/x86/kvm/pmu.c | 30 +++++++++++++++++++++++++-----
> 3 files changed, 39 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index 2cd6250b2896..96bcf1aa1931 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -4090,17 +4090,20 @@ Parameters: struct kvm_pmu_event_filter (in)
> Returns: 0 on success, -1 on error
>
> struct kvm_pmu_event_filter {
> - __u32 action;
> - __u32 nevents;
> - __u64 events[0];
> + __u32 action;
> + __u32 nevents;
> + __u32 fixed_counter_bitmap;
> + __u32 flags;
> + __u32 pad[4];
> + __u64 events[0];
> };
>
> This ioctl restricts the set of PMU events that the guest can program.
> The argument holds a list of events which will be allowed or denied.
> The eventsel+umask of each event the guest attempts to program is compared
> against the events field to determine whether the guest should have access.
> -This only affects general purpose counters; fixed purpose counters can
> -be disabled by changing the perfmon CPUID leaf.
> +The events field only controls general purpose counters; fixed purpose
> +counters are controlled by the fixed_counter_bitmap.
>
> Valid values for 'action':
> #define KVM_PMU_EVENT_ALLOW 0
> diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
> index e901b0ab116f..503d3f42da16 100644
> --- a/arch/x86/include/uapi/asm/kvm.h
> +++ b/arch/x86/include/uapi/asm/kvm.h
> @@ -435,9 +435,12 @@ struct kvm_nested_state {
>
> /* for KVM_CAP_PMU_EVENT_FILTER */
> struct kvm_pmu_event_filter {
> - __u32 action;
> - __u32 nevents;
> - __u64 events[0];
> + __u32 action;
> + __u32 nevents;
> + __u32 fixed_counter_bitmap;
> + __u32 flags;
> + __u32 pad[4];
> + __u64 events[0];
> };
>
> #define KVM_PMU_EVENT_ALLOW 0
> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> index aa5a2597305a..ae5cd1b02086 100644
> --- a/arch/x86/kvm/pmu.c
> +++ b/arch/x86/kvm/pmu.c
> @@ -19,8 +19,8 @@
> #include "lapic.h"
> #include "pmu.h"
>
> -/* This keeps the total size of the filter under 4k. */
> -#define KVM_PMU_EVENT_FILTER_MAX_EVENTS 63
> +/* This is enough to filter the vast majority of currently defined events. */
> +#define KVM_PMU_EVENT_FILTER_MAX_EVENTS 300
>
> /* NOTE:
> * - Each perf counter is defined as "struct kvm_pmc";
> @@ -206,12 +206,25 @@ void reprogram_fixed_counter(struct kvm_pmc *pmc, u8 ctrl, int idx)
> {
> unsigned en_field = ctrl & 0x3;
> bool pmi = ctrl & 0x8;
> + struct kvm_pmu_event_filter *filter;
> + struct kvm *kvm = pmc->vcpu->kvm;
> +
unnecessary white space here, other part looks good to me.
Reviewed-by: Wei Wang <wei.w.wang@intel.com>
Best,
Wei
next prev parent reply other threads:[~2019-07-19 8:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-18 18:38 [PATCH] KVM: x86: Add fixed counters to PMU filter Eric Hankland
2019-07-19 8:31 ` Wei Wang [this message]
2019-07-19 16:55 ` 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=5D317FFA.8000507@intel.com \
--to=wei.w.wang@intel.com \
--cc=ehankland@google.com \
--cc=eranian@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 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.