Skip to content

Commit 24fa5d1

Browse files
compudjshuahkh
authored andcommitted
rseq/selftests: x86: use ud1 instruction as RSEQ_SIG opcode
Use ud1 as the guard instruction for the restartable sequence abort handler. Its benefit compared to nopl is to trap execution if the program ends up trying to execute it by mistake, which makes debugging easier. The 4-byte signature per se is unchanged (it is the instruction operand). Only the opcode is changed from nopl to ud1. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Suggested-by: Peter Zijlstra <peterz@infradead.org> CC: Peter Zijlstra <peterz@infradead.org> CC: Thomas Gleixner <tglx@linutronix.de> CC: Joel Fernandes <joelaf@google.com> CC: Catalin Marinas <catalin.marinas@arm.com> CC: Dave Watson <davejwatson@fb.com> CC: Will Deacon <will.deacon@arm.com> CC: Shuah Khan <shuah@kernel.org> CC: Andi Kleen <andi@firstfloor.org> CC: linux-kselftest@vger.kernel.org CC: "H . Peter Anvin" <hpa@zytor.com> CC: Chris Lameter <cl@linux.com> CC: Russell King <linux@arm.linux.org.uk> CC: Michael Kerrisk <mtk.manpages@gmail.com> CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com> CC: Paul Turner <pjt@google.com> CC: Boqun Feng <boqun.feng@gmail.com> CC: Josh Triplett <josh@joshtriplett.org> CC: Steven Rostedt <rostedt@goodmis.org> CC: Ben Maurer <bmaurer@fb.com> CC: linux-api@vger.kernel.org CC: Andy Lutomirski <luto@amacapital.net> CC: Andrew Morton <akpm@linux-foundation.org> CC: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 97b8be8 commit 24fa5d1

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
#include <stdint.h>
99

10+
/*
11+
* RSEQ_SIG is used with the following reserved undefined instructions, which
12+
* trap in user-space:
13+
*
14+
* x86-32: 0f b9 3d 53 30 05 53 ud1 0x53053053,%edi
15+
* x86-64: 0f b9 3d 53 30 05 53 ud1 0x53053053(%rip),%edi
16+
*/
1017
#define RSEQ_SIG 0x53053053
1118

1219
/*
@@ -88,8 +95,8 @@ do { \
8895

8996
#define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label) \
9097
".pushsection __rseq_failure, \"ax\"\n\t" \
91-
/* Disassembler-friendly signature: nopl <sig>(%rip). */\
92-
".byte 0x0f, 0x1f, 0x05\n\t" \
98+
/* Disassembler-friendly signature: ud1 <sig>(%rip),%edi. */ \
99+
".byte 0x0f, 0xb9, 0x3d\n\t" \
93100
".long " __rseq_str(RSEQ_SIG) "\n\t" \
94101
__rseq_str(label) ":\n\t" \
95102
teardown \
@@ -609,8 +616,8 @@ do { \
609616

610617
#define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label) \
611618
".pushsection __rseq_failure, \"ax\"\n\t" \
612-
/* Disassembler-friendly signature: nopl <sig>. */ \
613-
".byte 0x0f, 0x1f, 0x05\n\t" \
619+
/* Disassembler-friendly signature: ud1 <sig>,%edi. */ \
620+
".byte 0x0f, 0xb9, 0x3d\n\t" \
614621
".long " __rseq_str(RSEQ_SIG) "\n\t" \
615622
__rseq_str(label) ":\n\t" \
616623
teardown \

0 commit comments

Comments
 (0)