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-next>] [day] [month] [year] [list]
Message-Id: <20220804073819.76460-1-likexu@tencent.com>
Date:   Thu,  4 Aug 2022 15:38:19 +0800
From:   Like Xu <like.xu.linux@...il.com>
To:     Sean Christopherson <seanjc@...gle.com>,
        Paolo Bonzini <pbonzini@...hat.com>
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] selftests: kvm/x86: test if it checks all the bits in the LBR_FMT bit-field

From: Like Xu <likexu@...cent.com>

User space only enable guest LBR feature when the exactly supported
LBR format value is initialized to the MSR_IA32_PERF_CAPABILITIES.
The input is also invalid if only partially supported bits are set.

Note for PEBS feature, the PEBS_FORMAT bit field is the primary concern,
thus if the PEBS_FORMAT input is empty, the other bits check about PEBS
(like PEBS_TRAP or ARCH_REG) will be ignored.

Signed-off-by: Like Xu <likexu@...cent.com>
---
 tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
index 6ec901dab61e..98483947f921 100644
--- a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
+++ b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
@@ -13,6 +13,7 @@
 
 #define _GNU_SOURCE /* for program_invocation_short_name */
 #include <sys/ioctl.h>
+#include <linux/bitmap.h>
 
 #include "kvm_util.h"
 #include "vmx.h"
@@ -56,7 +57,7 @@ int main(int argc, char *argv[])
 	const struct kvm_cpuid_entry2 *entry_a_0;
 	struct kvm_vm *vm;
 	struct kvm_vcpu *vcpu;
-	int ret;
+	int ret, bit;
 	union cpuid10_eax eax;
 	union perf_capabilities host_cap;
 
@@ -97,6 +98,12 @@ int main(int argc, char *argv[])
 	ret = _vcpu_set_msr(vcpu, MSR_IA32_PERF_CAPABILITIES, 0x30);
 	TEST_ASSERT(ret == 0, "Bad PERF_CAPABILITIES didn't fail.");
 
+	/* testcase 4, reject LBR_FMT if only partially supported bits are set */
+	for_each_set_bit(bit, (unsigned long *)&host_cap.capabilities, 6) {
+		ret = _vcpu_set_msr(vcpu, MSR_IA32_PERF_CAPABILITIES, BIT_ULL(bit));
+		TEST_ASSERT(ret == 0, "Bad PERF_CAPABILITIES didn't fail.");
+	}
+
 	printf("Completed perf capability tests.\n");
 	kvm_vm_free(vm);
 }
-- 
2.37.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ