aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Desnoyers <[email protected]>2019-04-29 11:27:57 -0400
committerShuah Khan <[email protected]>2019-05-07 15:32:05 -0600
commit24fa5d1efe98bc09a96ba41fdba96ef715aede77 (patch)
tree99f5bf1cdb52d77a8c46114ab438711c4bcaf4ff
parent97b8be816840da81296f3a90352a7fce4e66c156 (diff)
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 <[email protected]> Suggested-by: Peter Zijlstra <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
-rw-r--r--tools/testing/selftests/rseq/rseq-x86.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/testing/selftests/rseq/rseq-x86.h b/tools/testing/selftests/rseq/rseq-x86.h
index 03095236f6fa..b2da6004fe30 100644
--- a/tools/testing/selftests/rseq/rseq-x86.h
+++ b/tools/testing/selftests/rseq/rseq-x86.h
@@ -7,6 +7,13 @@
#include <stdint.h>
+/*
+ * RSEQ_SIG is used with the following reserved undefined instructions, which
+ * trap in user-space:
+ *
+ * x86-32: 0f b9 3d 53 30 05 53 ud1 0x53053053,%edi
+ * x86-64: 0f b9 3d 53 30 05 53 ud1 0x53053053(%rip),%edi
+ */
#define RSEQ_SIG 0x53053053
/*
@@ -88,8 +95,8 @@ do { \
#define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label) \
".pushsection __rseq_failure, \"ax\"\n\t" \
- /* Disassembler-friendly signature: nopl <sig>(%rip). */\
- ".byte 0x0f, 0x1f, 0x05\n\t" \
+ /* Disassembler-friendly signature: ud1 <sig>(%rip),%edi. */ \
+ ".byte 0x0f, 0xb9, 0x3d\n\t" \
".long " __rseq_str(RSEQ_SIG) "\n\t" \
__rseq_str(label) ":\n\t" \
teardown \
@@ -609,8 +616,8 @@ do { \
#define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label) \
".pushsection __rseq_failure, \"ax\"\n\t" \
- /* Disassembler-friendly signature: nopl <sig>. */ \
- ".byte 0x0f, 0x1f, 0x05\n\t" \
+ /* Disassembler-friendly signature: ud1 <sig>,%edi. */ \
+ ".byte 0x0f, 0xb9, 0x3d\n\t" \
".long " __rseq_str(RSEQ_SIG) "\n\t" \
__rseq_str(label) ":\n\t" \
teardown \