Skip to contentSkip to conversation

selftests/vm: Only run the 128TB boundary test if 5-level paging is enabled

PATCH In review Adam Sindelar 1 participant 2 messages Jun 20, 2022 – Jun 21, 2022 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/vm: Only run the 128TB boundary test if 5-level paging is enabled

The test va_128TBswitch.c expects to be able to pass mmap an address hint and length that cross the address 1<<47. This is not possible without 5-level page tables, so the test fails.

The test is already only run on 64-bit powerpc and x86 archs, but this patch adds an additional check that skips the test if PG_TABLE_LEVELS < 5. There is precedent for checking /proc/config.gz in selftests, e.g. in selftests/firmware.

---
 tools/testing/selftests/vm/Makefile          |  1 +
 tools/testing/selftests/vm/run_vmtests.sh    | 13 +++++++---
 tools/testing/selftests/vm/va_128TBswitch.sh | 26 ++++++++++++++++++++
 3 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100755 tools/testing/selftests/vm/va_128TBswitch.sh
tools/testing/selftests/vm/Makefile +1 -0
index 68cacffc93ec..bc64ca1e0de3 100644
@@ -80,6 +80,7 @@ endif
 TEST_PROGS := run_vmtests.sh
 
 TEST_FILES := test_vmalloc.sh
+TEST_FILEs += va_128TBswitch.sh
 
 KSFT_KHDR_INSTALL := 1
 include ../lib.mk
tools/testing/selftests/vm/run_vmtests.sh +9 -4
index e953f3cd9664..10cccbedaaa1 100755
@@ -290,12 +290,17 @@ fi
 echo "-----------------------------"
 echo "running virtual address 128TB switch test"
 echo "-----------------------------"
-./va_128TBswitch
-if [ $? -ne 0 ]; then
+./va_128TBswitch.sh
+ret_val=$?
+
+if [ $ret_val -eq 0 ]; then
+    echo "[PASS]"
+elif [ $ret_val -eq $ksft_skip ]; then
+	 echo "[SKIP]"
+	 exitcode=$ksft_skip
+else
     echo "[FAIL]"
     exitcode=1
-else
-    echo "[PASS]"
 fi
 fi # VADDR64
 
tools/testing/selftests/vm/va_128TBswitch.sh new file +26 -0
new file mode 100755
index 000000000000..f7b9db0bfd33
@@ -0,0 +1,26 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2022 Adam Sindelar (Meta) <[email protected]>
+#
+# This is a test for mmap behavior with 5-level paging. This script wraps the
+# real test to check that the kernel is configured to support at least 5
+# pagetable levels.
+
+# 1 means the test failed
+exitcode=1
+
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
+check_test_requirements()
+{
+    pg_table_levels=$(gzip -dcfq /proc/config.gz | grep PGTABLE_LEVELS | cut -d'=' -f 2)
+    if [ $pg_table_levels -lt 5 ]; then
+    echo "$0: PG_TABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test"
+        exit $ksft_skip
+    fi
+}
+
+check_test_requirements
+./va_128TBswitch
Signature · 1 line
2.30.2
#1 lore raw
Quoted 90 lines · Adam Sindelar

The test va_128TBswitch.c expects to be able to pass mmap an address hint and length that cross the address 1<<47. This is not possible without 5-level page tables, so the test fails.

The test is already only run on 64-bit powerpc and x86 archs, but this patch adds an additional check that skips the test if PG_TABLE_LEVELS < 5. There is precedent for checking /proc/config.gz in selftests, e.g. in selftests/firmware.

---
 tools/testing/selftests/vm/Makefile          |  1 +
 tools/testing/selftests/vm/run_vmtests.sh    | 13 +++++++---
 tools/testing/selftests/vm/va_128TBswitch.sh | 26 ++++++++++++++++++++
 3 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100755 tools/testing/selftests/vm/va_128TBswitch.sh
tools/testing/selftests/vm/Makefile +1 -0
index 68cacffc93ec..bc64ca1e0de3 100644
@@ -80,6 +80,7 @@ endif
 TEST_PROGS := run_vmtests.sh
 
 TEST_FILES := test_vmalloc.sh
+TEST_FILEs += va_128TBswitch.sh
 
 KSFT_KHDR_INSTALL := 1
 include ../lib.mk
tools/testing/selftests/vm/run_vmtests.sh +9 -4
index e953f3cd9664..10cccbedaaa1 100755
@@ -290,12 +290,17 @@ fi
 echo "-----------------------------"
 echo "running virtual address 128TB switch test"
 echo "-----------------------------"
-./va_128TBswitch
-if [ $? -ne 0 ]; then
+./va_128TBswitch.sh
+ret_val=$?
+
+if [ $ret_val -eq 0 ]; then
+    echo "[PASS]"
+elif [ $ret_val -eq $ksft_skip ]; then
+	 echo "[SKIP]"
+	 exitcode=$ksft_skip
+else
     echo "[FAIL]"
     exitcode=1
-else
-    echo "[PASS]"
 fi
 fi # VADDR64
 
tools/testing/selftests/vm/va_128TBswitch.sh new file +26 -0
new file mode 100755
index 000000000000..f7b9db0bfd33
@@ -0,0 +1,26 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2022 Adam Sindelar (Meta) <[email protected]>
+#
+# This is a test for mmap behavior with 5-level paging. This script wraps the
+# real test to check that the kernel is configured to support at least 5
+# pagetable levels.
+
+# 1 means the test failed
+exitcode=1
+
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
+check_test_requirements()
+{
+    pg_table_levels=$(gzip -dcfq /proc/config.gz | grep PGTABLE_LEVELS | cut -d'=' -f 2)
+    if [ $pg_table_levels -lt 5 ]; then
+    echo "$0: PG_TABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test"
+        exit $ksft_skip
+    fi
+}
+
+check_test_requirements
+./va_128TBswitch
Signature · 1 line
2.30.2

Actually, I think I sent this to the wrong list. My bad, please disregard - I'll send it to mm, where I think it belongs.