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

rseq/selftests: mips: use break instruction for RSEQ_SIG

Use break as guard instruction for the restartable sequence abort
handler.

Previously, the chosen signature was simply data, based on the
assumption that it could always sit in a literal pool. However,
some compilation environments favor disabling literal pool. Therefore,
ensure the signature is a valid uncommon trap instruction.

Suggested-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Paul Burton <paul.burton@mips.com>
CC: James Hogan <jhogan@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Mathieu Desnoyers and committed by
Shuah Khan
16b96b6e 496fd0fc

+33 -1
+33 -1
tools/testing/selftests/rseq/rseq-mips.h
··· 7 7 * (C) Copyright 2016-2018 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> 8 8 */ 9 9 10 - #define RSEQ_SIG 0x53053053 10 + /* 11 + * RSEQ_SIG uses the break instruction. The instruction pattern is: 12 + * 13 + * On MIPS: 14 + * 0350000d break 0x350 15 + * 16 + * On nanoMIPS: 17 + * 00100350 break 0x350 18 + * 19 + * On microMIPS: 20 + * 0000d407 break 0x350 21 + * 22 + * For nanoMIPS32 and microMIPS, the instruction stream is encoded as 16-bit 23 + * halfwords, so the signature halfwords need to be swapped accordingly for 24 + * little-endian. 25 + */ 26 + #if defined(__nanomips__) 27 + # ifdef __MIPSEL__ 28 + # define RSEQ_SIG 0x03500010 29 + # else 30 + # define RSEQ_SIG 0x00100350 31 + # endif 32 + #elif defined(__mips_micromips) 33 + # ifdef __MIPSEL__ 34 + # define RSEQ_SIG 0xd4070000 35 + # else 36 + # define RSEQ_SIG 0x0000d407 37 + # endif 38 + #elif defined(__mips__) 39 + # define RSEQ_SIG 0x0350000d 40 + #else 41 + /* Unknown MIPS architecture. */ 42 + #endif 11 43 12 44 #define rseq_smp_mb() __asm__ __volatile__ ("sync" ::: "memory") 13 45 #define rseq_smp_rmb() rseq_smp_mb()