From: Like Xu <like.xu.linux@gmail.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jinrong Liang <cloudliang@tencent.com>
Subject: [PATCH] KVM: x86/pmu: Apply event filter mechanism to emulated instructions
Date: Wed, 22 Feb 2023 16:20:02 +0800 [thread overview]
Message-ID: <20230222082002.97570-1-likexu@tencent.com> (raw)
From: Like Xu <likexu@tencent.com>
The check_pmu_event_filter() prevents the perf_event from being created
and stops the associated counters from increasing, the same check should
also be applied to counter increases caused by emulated instructions.
Otherwise this filter mechanism cannot be considered to be in effect.
Reported-by: Jinrong Liang <cloudliang@tencent.com>
Signed-off-by: Like Xu <likexu@tencent.com>
---
arch/x86/kvm/pmu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 7b6c3ba2c8e1..1fd1c2f0d4da 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -684,7 +684,8 @@ void kvm_pmu_trigger_event(struct kvm_vcpu *vcpu, u64 perf_hw_id)
for_each_set_bit(i, pmu->all_valid_pmc_idx, X86_PMC_IDX_MAX) {
pmc = static_call(kvm_x86_pmu_pmc_idx_to_pmc)(pmu, i);
- if (!pmc || !pmc_is_enabled(pmc) || !pmc_speculative_in_use(pmc))
+ if (!pmc || !pmc_is_enabled(pmc) || !pmc_speculative_in_use(pmc) ||
+ !check_pmu_event_filter(pmc))
continue;
/* Ignore checks for edge detect, pin control, invert and CMASK bits */
base-commit: 13738a3647368f7f600b30d241779bcd2a3ebbfd
--
2.39.2
next reply other threads:[~2023-02-22 8:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 8:20 Like Xu [this message]
2023-02-22 19:28 ` [PATCH] KVM: x86/pmu: Apply event filter mechanism to emulated instructions Sean Christopherson
2023-02-22 20:38 ` 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=20230222082002.97570-1-likexu@tencent.com \
--to=like.xu.linux@gmail.com \
--cc=cloudliang@tencent.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@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