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: <174022717730.10177.4676833475098422793.tip-bot2@tip-bot2>
Date: Sat, 22 Feb 2025 12:26:17 -0000
From: "tip-bot2 for Maciej Wieczor-Retman" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Maciej Wieczor-Retman" <maciej.wieczor-retman@...el.com>,
 Ingo Molnar <mingo@...nel.org>,
 "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
 Dave Hansen <dave.hansen@...ux.intel.com>,
 Alexander Potapenko <glider@...gle.com>,
 Peter Zijlstra <peterz@...radead.org>, Shuah Khan <skhan@...uxfoundation.org>,
 x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [tip: x86/mm] selftests/lam: Skip test if LAM is disabled

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     51f909dcd178655b104d979a6870535268724498
Gitweb:        https://git.kernel.org/tip/51f909dcd178655b104d979a6870535268724498
Author:        Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
AuthorDate:    Mon, 27 Jan 2025 16:31:56 +01:00
Committer:     Ingo Molnar <mingo@...nel.org>
CommitterDate: Sat, 22 Feb 2025 13:17:07 +01:00

selftests/lam: Skip test if LAM is disabled

Until LASS is merged into the kernel:

  https://lore.kernel.org/all/20241028160917.1380714-1-alexander.shishkin@linux.intel.com/

LAM is left disabled in the config file. Running the LAM selftest with
disabled LAM only results in unhelpful output.

Use one of LAM syscalls() to determine whether the kernel was compiled
with LAM support (CONFIG_ADDRESS_MASKING) or not. Skip running the tests
in the latter case.

Merge CPUID checking function with the one mentioned above to achieve a
single function that shows LAM's availability from both CPU and the
kernel.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Alexander Potapenko <glider@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Shuah Khan <skhan@...uxfoundation.org>
Link: https://lore.kernel.org/r/251d0f45f6a768030115e8d04bc85458910cb0dc.1737990375.git.maciej.wieczor-retman@intel.com
---
 tools/testing/selftests/x86/lam.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
index 60170a3..df91a41 100644
--- a/tools/testing/selftests/x86/lam.c
+++ b/tools/testing/selftests/x86/lam.c
@@ -115,13 +115,28 @@ static void segv_handler(int sig)
 	siglongjmp(segv_env, 1);
 }
 
-static inline int cpu_has_lam(void)
+static inline int lam_is_available(void)
 {
 	unsigned int cpuinfo[4];
+	unsigned long bits = 0;
+	int ret;
 
 	__cpuid_count(0x7, 1, cpuinfo[0], cpuinfo[1], cpuinfo[2], cpuinfo[3]);
 
-	return (cpuinfo[0] & (1 << 26));
+	/* Check if cpu supports LAM */
+	if (!(cpuinfo[0] & (1 << 26))) {
+		ksft_print_msg("LAM is not supported!\n");
+		return 0;
+	}
+
+	/* Return 0 if CONFIG_ADDRESS_MASKING is not set */
+	ret = syscall(SYS_arch_prctl, ARCH_GET_MAX_TAG_BITS, &bits);
+	if (ret) {
+		ksft_print_msg("LAM is disabled in the kernel!\n");
+		return 0;
+	}
+
+	return 1;
 }
 
 static inline int la57_enabled(void)
@@ -1185,10 +1200,8 @@ int main(int argc, char **argv)
 
 	tests_cnt = 0;
 
-	if (!cpu_has_lam()) {
-		ksft_print_msg("Unsupported LAM feature!\n");
+	if (!lam_is_available())
 		return KSFT_SKIP;
-	}
 
 	while ((c = getopt(argc, argv, "ht:")) != -1) {
 		switch (c) {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ