[PATCH] selftests: riscv: Check that hwprobe clears the value of unknown keys
Christian Sagstetter
christian.sagstetter at gmail.com
Mon Nov 30 14:51:51 PST 2026
The hwprobe ABI specifies that an unknown key returns a key of -1 and a
value of 0. The existing selftest checks the returned key and whether a
subsequent known key is processed. It would also pass if the kernel left
a nonzero value in the unknown entry.
Set the unknown entry's value to 1 before calling hwprobe and check that
the kernel returns (-1, 0). Report the result for the following key
separately so a failure identifies which behavior changed.
All seven checks passed on a riscv64 QEMU guest running Debian Linux
6.12.117. With a userspace wrapper that sets the returned value to 1,
the original test passed and the new assertion failed.
Codex identified the coverage gap, drafted the test and commit message,
and ran the QEMU checks.
Signed-off-by: Christian Sagstetter <christian.sagstetter at gmail.com>
---
tools/testing/selftests/riscv/hwprobe/hwprobe.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/riscv/hwprobe/hwprobe.c b/tools/testing/selftests/riscv/hwprobe/hwprobe.c
index eca4441ee..fc5a3fe0b 100644
--- a/tools/testing/selftests/riscv/hwprobe/hwprobe.c
+++ b/tools/testing/selftests/riscv/hwprobe/hwprobe.c
@@ -9,7 +9,7 @@ int main(int argc, char **argv)
long out;
ksft_print_header();
- ksft_set_plan(6);
+ ksft_set_plan(7);
/* Fake the CPU_SET ops. */
cpus = -1;
@@ -55,12 +55,14 @@ int main(int argc, char **argv)
"Existing key is maintained\n");
pairs[0].key = 0x5555;
+ pairs[0].value = 1;
pairs[1].key = 1;
pairs[1].value = 0xAAAA;
out = riscv_hwprobe(pairs, 2, 0, 0, 0);
- ksft_test_result(out == 0 && pairs[0].key == -1 &&
- pairs[1].key == 1 && pairs[1].value != 0xAAAA,
- "Unknown key overwritten with -1 and doesn't block other elements\n");
+ ksft_test_result(out == 0 && pairs[0].key == -1 && pairs[0].value == 0,
+ "Unknown key returns (-1, 0)\n");
+ ksft_test_result(out == 0 && pairs[1].key == 1 && pairs[1].value != 0xAAAA,
+ "Unknown key does not block the next key\n");
pairs[0].key = RISCV_HWPROBE_KEY_IMA_EXT_0;
out = riscv_hwprobe(pairs, 1, 0, 0, 0);
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.53.0
More information about the linux-riscv
mailing list