Skip to content

Commit 16b96b6

Browse files
compudjshuahkh
authored andcommitted
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>
1 parent 496fd0f commit 16b96b6

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

‎tools/testing/selftests/rseq/rseq-mips.h‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,39 @@
77
* (C) Copyright 2016-2018 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
88
*/
99

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
1143

1244
#define rseq_smp_mb() __asm__ __volatile__ ("sync" ::: "memory")
1345
#define rseq_smp_rmb() rseq_smp_mb()

0 commit comments

Comments
 (0)