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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211006203135.2566248-1-songliubraving@fb.com>
Date:   Wed, 6 Oct 2021 13:31:35 -0700
From:   Song Liu <songliubraving@...com>
To:     <bpf@...r.kernel.org>, <netdev@...r.kernel.org>
CC:     <ast@...nel.org>, <daniel@...earbox.net>, <andrii@...nel.org>,
        <kernel-team@...com>, Song Liu <songliubraving@...com>
Subject: [PATCH] selftests/bpf: skip get_branch_snapshot in vm

VMs running on latest kernel support LBR. However, bpf_get_branch_snapshot
couldn't stop the LBR before too many entries are flushed. Skip the test
for VMs before we find a proper fix for VMs.

Read the "flags" line from /proc/cpuinfo, if it contains "hypervisor",
skip test get_branch_snapshot.

Fixes: 025bd7c753aa (selftests/bpf: Add test for bpf_get_branch_snapshot)
Signed-off-by: Song Liu <songliubraving@...com>
---
 .../bpf/prog_tests/get_branch_snapshot.c      | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c b/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
index 67e86f8d86775..bf9d47a859449 100644
--- a/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
+++ b/tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
@@ -6,6 +6,30 @@
 static int *pfd_array;
 static int cpu_cnt;
 
+static bool is_hypervisor(void)
+{
+	char *line = NULL;
+	bool ret = false;
+	size_t len;
+	FILE *fp;
+
+	fp = fopen("/proc/cpuinfo", "r");
+	if (!fp)
+		return false;
+
+	while (getline(&line, &len, fp) != -1) {
+		if (strstr(line, "flags") == line) {
+			if (strstr(line, "hypervisor") != NULL)
+				ret = true;
+			break;
+		}
+	}
+
+	free(line);
+	fclose(fp);
+	return ret;
+}
+
 static int create_perf_events(void)
 {
 	struct perf_event_attr attr = {0};
@@ -54,6 +78,14 @@ void test_get_branch_snapshot(void)
 	struct get_branch_snapshot *skel = NULL;
 	int err;
 
+	if (is_hypervisor()) {
+		/* As of today, LBR in hypervisor cannot be stopped before
+		 * too many entries are flushed. Skip the test for now in
+		 * hypervisor until we optimize the LBR in hypervisor.
+		 */
+		test__skip();
+		return;
+	}
 	if (create_perf_events()) {
 		test__skip();  /* system doesn't support LBR */
 		goto cleanup;
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ