[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250712172522.187414-4-dapeng1.mi@linux.intel.com>
Date: Sat, 12 Jul 2025 17:25:21 +0000
From: Dapeng Mi <dapeng1.mi@...ux.intel.com>
To: Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>
Cc: kvm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Jim Mattson <jmattson@...gle.com>,
Mingwei Zhang <mizhang@...gle.com>,
Zide Chen <zide.chen@...el.com>,
Das Sandipan <Sandipan.Das@....com>,
Shukla Manali <Manali.Shukla@....com>,
Yi Lai <yi1.lai@...el.com>,
Dapeng Mi <dapeng1.mi@...el.com>,
Dapeng Mi <dapeng1.mi@...ux.intel.com>
Subject: [PATCH 3/3] KVM: selftests: Relax branches event count check for event_filter test
As the branches event overcount issue on Atom platforms, once there are
VM-Exits triggered (external interrupts) in the guest loop, the measured
branch event count could be larger than NUM_BRANCHES, this would lead to
the pmu_event_filter_test print warning to info the measured branches
event count is mismatched with expected number (NUM_BRANCHES).
To eliminate this warning, relax the branches event count check on the
Atom platform which have the branches event overcount issue.
Signed-off-by: Dapeng Mi <dapeng1.mi@...ux.intel.com>
Tested-by: Yi Lai <yi1.lai@...el.com>
---
tools/testing/selftests/kvm/x86/pmu_event_filter_test.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/x86/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86/pmu_event_filter_test.c
index c15513cd74d1..9c1a92f05786 100644
--- a/tools/testing/selftests/kvm/x86/pmu_event_filter_test.c
+++ b/tools/testing/selftests/kvm/x86/pmu_event_filter_test.c
@@ -60,6 +60,8 @@ struct {
uint64_t instructions_retired;
} pmc_results;
+static uint8_t inst_overcount_flags;
+
/*
* If we encounter a #GP during the guest PMU sanity check, then the guest
* PMU is not functional. Inform the hypervisor via GUEST_SYNC(0).
@@ -214,8 +216,10 @@ static void remove_event(struct __kvm_pmu_event_filter *f, uint64_t event)
do { \
uint64_t br = pmc_results.branches_retired; \
uint64_t ir = pmc_results.instructions_retired; \
+ bool br_matched = inst_overcount_flags & BR_RETIRED_OVERCOUNT ? \
+ br >= NUM_BRANCHES : br == NUM_BRANCHES; \
\
- if (br && br != NUM_BRANCHES) \
+ if (br && !br_matched) \
pr_info("%s: Branch instructions retired = %lu (expected %u)\n", \
__func__, br, NUM_BRANCHES); \
TEST_ASSERT(br, "%s: Branch instructions retired = %lu (expected > 0)", \
@@ -850,6 +854,9 @@ int main(int argc, char *argv[])
if (use_amd_pmu())
test_amd_deny_list(vcpu);
+ if (use_intel_pmu())
+ inst_overcount_flags = detect_inst_overcount_flags();
+
test_without_filter(vcpu);
test_member_deny_list(vcpu);
test_member_allow_list(vcpu);
--
2.43.0
Powered by blists - more mailing lists