lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230420104622.12504-7-ljrcore@126.com>
Date:   Thu, 20 Apr 2023 18:46:21 +0800
From:   Jinrong Liang <ljr.kernel@...il.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Like Xu <like.xu.linux@...il.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Jonathan Corbet <corbet@....net>,
        Shuah Khan <shuah@...nel.org>,
        Aaron Lewis <aaronlewis@...gle.com>,
        David Matlack <dmatlack@...gle.com>,
        Vishal Annapurve <vannapurve@...gle.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Bagas Sanjaya <bagasdotme@...il.com>,
        Jinrong Liang <cloudliang@...cent.com>,
        linux-kselftest@...r.kernel.org, linux-doc@...r.kernel.org,
        kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2 6/7] KVM: selftests: Check gp event filters without affecting fixed event filters

From: Jinrong Liang <cloudliang@...cent.com>

From: Jinrong Liang <cloudliang@...cent.com>

Add a test to ensure that setting both generic and fixed performance
event filters does not affect the consistency of the fixed performance
filter behavior in KVM. This test helps to ensure that the fixed
performance filter works as expected even when generic performance
event filters are also set.

Signed-off-by: Jinrong Liang <cloudliang@...cent.com>
---
 .../selftests/kvm/x86_64/pmu_event_filter_test.c   | 14 ++++++++++++++
 1 file changed, 14 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 0f54c53d7fff..9be4c6f8fb7e 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
@@ -889,6 +889,7 @@ static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu,
 	uint32_t bitmap;
 	uint64_t count;
 	bool expected;
+	struct kvm_pmu_event_filter *f;
 
 	/*
 	 * Check the fixed performance counter can count normally works when
@@ -902,6 +903,19 @@ static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu,
 			expected = fixed_ctr_is_allowed(fixed_ctr_idx, actions[i], bitmap);
 			count = test_fixed_ctr_with_filter(vcpu, actions[i], bitmap);
 
+			TEST_ASSERT(expected == !!count,
+				    "Fixed event filter does not work as expected.");
+
+			/*
+			 * Check that setting both events[] and fixed_counter_bitmap
+			 * does not affect the consistency of the fixed ctrs' behaviour.
+			 *
+			 * Note, the fixed_counter_bitmap rule has high priority.
+			 */
+			f = event_filter(actions[i]);
+			f->fixed_counter_bitmap = bitmap;
+			count = test_with_filter(vcpu, f);
+
 			TEST_ASSERT(expected == !!count,
 				    "Fixed event filter does not work as expected.");
 		}
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ