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

selftests/powerpc: Properly handle failure in switch_endian_test

On older CPUs the switch_endian() syscall doesn't work. Currently that
causes the switch_endian_test to just crash. Instead detect the
failure and properly exit with a failure message.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200819015727.1977134-9-mpe@ellerman.id.au

+19 -4
+19 -4
tools/testing/selftests/powerpc/switch_endian/switch_endian_test.S
··· 3 3 4 4 .data 5 5 .balign 8 6 - message: 6 + success_message: 7 7 .ascii "success: switch_endian_test\n\0" 8 + 9 + .balign 8 10 + failure_message: 11 + .ascii "failure: switch_endian_test\n\0" 8 12 9 13 .section ".toc" 10 14 .balign 8 ··· 68 64 li r0, __NR_switch_endian 69 65 sc 70 66 67 + tdi 0, 0, 0x48 // b +8 if the endian was switched 68 + b .Lfail // exit if endian didn't switch 69 + 71 70 #include "check-reversed.S" 72 71 73 72 /* Flip back, r0 already has the switch syscall number */ ··· 78 71 79 72 #include "check.S" 80 73 74 + ld r4, success_message@got(%r2) 75 + li r5, 28 // strlen(success_message) 76 + li r14, 0 // exit status 77 + .Lout: 81 78 li r0, __NR_write 82 79 li r3, 1 /* stdout */ 83 - ld r4, message@got(%r2) 84 - li r5, 28 /* strlen(message3) */ 85 80 sc 86 81 li r0, __NR_exit 87 - li r3, 0 82 + mr r3, r14 88 83 sc 89 84 b . 85 + 86 + .Lfail: 87 + ld r4, failure_message@got(%r2) 88 + li r5, 28 // strlen(failure_message) 89 + li r14, 1 90 + b .Lout