Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest/arm64: pac: Fix skipping of tests on systems without PAC

The PAC tests check to see if the system supports the relevant PAC features
but instead of skipping the tests if they can't be executed they fail the
tests which makes things look like they're not working when they are.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210819165723.43903-1-broonie@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Mark Brown and committed by
Catalin Marinas
0c69bd2c 83e5dcbe

+6 -4
+6 -4
tools/testing/selftests/arm64/pauth/pac.c
··· 25 25 do { \ 26 26 unsigned long hwcaps = getauxval(AT_HWCAP); \ 27 27 /* data key instructions are not in NOP space. This prevents a SIGILL */ \ 28 - ASSERT_NE(0, hwcaps & HWCAP_PACA) TH_LOG("PAUTH not enabled"); \ 28 + if (!(hwcaps & HWCAP_PACA)) \ 29 + SKIP(return, "PAUTH not enabled"); \ 29 30 } while (0) 30 31 #define ASSERT_GENERIC_PAUTH_ENABLED() \ 31 32 do { \ 32 33 unsigned long hwcaps = getauxval(AT_HWCAP); \ 33 34 /* generic key instructions are not in NOP space. This prevents a SIGILL */ \ 34 - ASSERT_NE(0, hwcaps & HWCAP_PACG) TH_LOG("Generic PAUTH not enabled"); \ 35 + if (!(hwcaps & HWCAP_PACG)) \ 36 + SKIP(return, "Generic PAUTH not enabled"); \ 35 37 } while (0) 36 38 37 39 void sign_specific(struct signatures *sign, size_t val) ··· 258 256 unsigned long hwcaps = getauxval(AT_HWCAP); 259 257 260 258 /* generic and data key instructions are not in NOP space. This prevents a SIGILL */ 261 - ASSERT_NE(0, hwcaps & HWCAP_PACA) TH_LOG("PAUTH not enabled"); 259 + ASSERT_PAUTH_ENABLED(); 262 260 if (!(hwcaps & HWCAP_PACG)) { 263 261 TH_LOG("WARNING: Generic PAUTH not enabled. Skipping generic key checks"); 264 262 nkeys = NKEYS - 1; ··· 301 299 unsigned long hwcaps = getauxval(AT_HWCAP); 302 300 303 301 /* generic and data key instructions are not in NOP space. This prevents a SIGILL */ 304 - ASSERT_NE(0, hwcaps & HWCAP_PACA) TH_LOG("PAUTH not enabled"); 302 + ASSERT_PAUTH_ENABLED(); 305 303 if (!(hwcaps & HWCAP_PACG)) { 306 304 TH_LOG("WARNING: Generic PAUTH not enabled. Skipping generic key checks"); 307 305 nkeys = NKEYS - 1;