[RFC 20/31] objtool: Add UD1 detection

Josh Poimboeuf
2024-09-03T04:00:39Z

A UD1 isn't a BUG and shouldn't be treated like one.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
tools/objtool/arch/x86/decode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 6b34b058a821..72d55dcd3d7f 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -528,11 +528,19 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
/* sysenter, sysret */
insn->type = INSN_CONTEXT_SWITCH;

- } else if (op2 == 0x0b || op2 == 0xb9) {
+ } else if (op2 == 0x0b) {

/* ud2 */
insn->type = INSN_BUG;

+ } else if (op2 == 0xb9) {
+
+ /*
+ * ud1 - only used for the static call trampoline to
+ * stop speculation. Basically used like an int3.
+ */
+ insn->type = INSN_TRAP;
+
} else if (op2 == 0x0d || op2 == 0x1f) {

/* nopl/nopw */
--
2.45.2