kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86/pmu: Apply event filter mechanism to emulated instructions
@ 2023-02-22  8:20 Like Xu
  2023-02-22 19:28 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Like Xu @ 2023-02-22  8:20 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: Paolo Bonzini, kvm, linux-kernel, Jinrong Liang

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86/pmu: Apply event filter mechanism to emulated instructions
  2023-02-22  8:20 [PATCH] KVM: x86/pmu: Apply event filter mechanism to emulated instructions Like Xu
@ 2023-02-22 19:28 ` Sean Christopherson
  2023-02-22 20:38   ` Aaron Lewis
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2023-02-22 19:28 UTC (permalink / raw)
  To: Like Xu; +Cc: Paolo Bonzini, kvm, linux-kernel, Jinrong Liang, Aaron Lewis

On Wed, Feb 22, 2023, Like Xu wrote:
> 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>

Already posted by Aaron[*], but I don't think there's been a follow-up.  Aaron?

[*] https://lore.kernel.org/all/20221209194957.2774423-2-aaronlewis@google.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86/pmu: Apply event filter mechanism to emulated instructions
  2023-02-22 19:28 ` Sean Christopherson
@ 2023-02-22 20:38   ` Aaron Lewis
  0 siblings, 0 replies; 3+ messages in thread
From: Aaron Lewis @ 2023-02-22 20:38 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Like Xu, Paolo Bonzini, kvm, linux-kernel, Jinrong Liang

On Wed, Feb 22, 2023 at 7:28 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Wed, Feb 22, 2023, Like Xu wrote:
> > 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>
>
> Already posted by Aaron[*], but I don't think there's been a follow-up.  Aaron?
>
> [*] https://lore.kernel.org/all/20221209194957.2774423-2-aaronlewis@google.com

There hasn't been a follow-up yet.  I'll try to get one out in the
next week or so.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-22 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22  8:20 [PATCH] KVM: x86/pmu: Apply event filter mechanism to emulated instructions Like Xu
2023-02-22 19:28 ` Sean Christopherson
2023-02-22 20:38   ` Aaron Lewis

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).