]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
objtool: Improve register reporting during function validation
authorAlexandre Chartre <alexandre.chartre@oracle.com>
Fri, 21 Nov 2025 09:53:22 +0000 (10:53 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 21 Nov 2025 14:30:10 +0000 (15:30 +0100)
When tracing function validation, instruction state changes can
report changes involving registers. These registers are reported
with the name "r<num>" (e.g. "r3"). Print the CPU specific register
name instead of a generic name (e.g. print "rbx" instead of "r3"
on x86).

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://patch.msgid.link/20251121095340.464045-13-alexandre.chartre@oracle.com
tools/objtool/arch/loongarch/decode.c
tools/objtool/arch/powerpc/decode.c
tools/objtool/arch/x86/decode.c
tools/objtool/include/objtool/arch.h
tools/objtool/trace.c

index 1de86ebb637d5992fef0a915528190675bddf478..6cd288150f495246b2dd14bca322732f0de5df12 100644 (file)
@@ -8,6 +8,17 @@
 #include <linux/objtool_types.h>
 #include <arch/elf.h>
 
+const char *arch_reg_name[CFI_NUM_REGS] = {
+       "zero", "ra", "tp", "sp",
+       "a0", "a1", "a2", "a3",
+       "a4", "a5", "a6", "a7",
+       "t0", "t1", "t2", "t3",
+       "t4", "t5", "t6", "t7",
+       "t8", "u0", "fp", "s0",
+       "s1", "s2", "s3", "s4",
+       "s5", "s6", "s7", "s8"
+};
+
 int arch_ftrace_match(const char *name)
 {
        return !strcmp(name, "_mcount");
index 4f68b402e7855940b1617e24ce3051a5b2f468f5..e534ac1123b33ed70c51d08a96a9402ed6012e09 100644 (file)
@@ -9,6 +9,18 @@
 #include <objtool/warn.h>
 #include <objtool/builtin.h>
 
+const char *arch_reg_name[CFI_NUM_REGS] = {
+       "r0",  "sp",  "r2",  "r3",
+       "r4",  "r5",  "r6",  "r7",
+       "r8",  "r9",  "r10", "r11",
+       "r12", "r13", "r14", "r15",
+       "r16", "r17", "r18", "r19",
+       "r20", "r21", "r22", "r23",
+       "r24", "r25", "r26", "r27",
+       "r28", "r29", "r30", "r31",
+       "ra"
+};
+
 int arch_ftrace_match(const char *name)
 {
        return !strcmp(name, "_mcount");
index 83e9c604ce1058d3df6548a869a34ee5bf2866a3..f4af825082284fa114fef66805fa9e88c5f4daaa 100644 (file)
 #include <objtool/builtin.h>
 #include <arch/elf.h>
 
+const char *arch_reg_name[CFI_NUM_REGS] = {
+       "rax", "rcx", "rdx", "rbx",
+       "rsp", "rbp", "rsi", "rdi",
+       "r8",  "r9",  "r10", "r11",
+       "r12", "r13", "r14", "r15",
+       "ra"
+};
+
 int arch_ftrace_match(const char *name)
 {
        return !strcmp(name, "__fentry__");
index 18c0e69ee61701bba82c28f61dc09c484a25fa69..8866158975fcbf9ec896d54e03a5894991279725 100644 (file)
@@ -103,6 +103,8 @@ bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc);
 unsigned int arch_reloc_size(struct reloc *reloc);
 unsigned long arch_jump_table_sym_offset(struct reloc *reloc, struct reloc *table);
 
+extern const char *arch_reg_name[CFI_NUM_REGS];
+
 #ifdef DISAS
 
 #include <bfd.h>
index 12bbad09d9c02b342d1dc1c43005e578af5a7698..d70d47081e82d673500ae2237dd747a07903bc21 100644 (file)
@@ -34,6 +34,7 @@ int trace_depth;
 static const char *cfi_reg_name(unsigned int reg)
 {
        static char rname_buffer[CFI_REG_NAME_MAXLEN];
+       const char *rname;
 
        switch (reg) {
        case CFI_UNDEFINED:
@@ -46,6 +47,12 @@ static const char *cfi_reg_name(unsigned int reg)
                return "(bp)";
        }
 
+       if (reg < CFI_NUM_REGS) {
+               rname = arch_reg_name[reg];
+               if (rname)
+                       return rname;
+       }
+
        if (snprintf(rname_buffer, CFI_REG_NAME_MAXLEN, "r%d", reg) == -1)
                return "<error>";