[PATCH v2 2/2] selftests/arm64: Implement cmpbr_sigill() to hwcap test

Yifan Wu posted 2 patches 1 month ago
[PATCH v2 2/2] selftests/arm64: Implement cmpbr_sigill() to hwcap test
Posted by Yifan Wu 1 month ago
The function executes a CBEQ instruction which is valid if the CPU
supports the CMPBR extension. The CBEQ branches to skip the following
UDF instruction, and no SIGILL is generated. Otherwise, it will
generate a SIGILL.

Signed-off-by: Yifan Wu <wuyifan50@huawei.com>
---
 tools/testing/selftests/arm64/abi/hwcap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
index c2661a312fc9..e22703d6b97c 100644
--- a/tools/testing/selftests/arm64/abi/hwcap.c
+++ b/tools/testing/selftests/arm64/abi/hwcap.c
@@ -56,7 +56,8 @@ static void atomics_sigill(void)
 
 static void cmpbr_sigill(void)
 {
-	/* Not implemented, too complicated and unreliable anyway */
+	asm volatile(".inst 0x74C00040\n" /* CBEQ w0, w0, +8 */
+		     "udf #0" : : : "cc"); /* UDF #0 */
 }
 
 static void crc32_sigill(void)
-- 
2.33.0
Re: [PATCH v2 2/2] selftests/arm64: Implement cmpbr_sigill() to hwcap test
Posted by Mark Brown 1 month ago
On Thu, Mar 05, 2026 at 09:36:38AM +0800, Yifan Wu wrote:

> The function executes a CBEQ instruction which is valid if the CPU
> supports the CMPBR extension. The CBEQ branches to skip the following
> UDF instruction, and no SIGILL is generated. Otherwise, it will
> generate a SIGILL.

Reviewed-by: Mark Brown <broonie@kernel.org>