]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf dwarf-regs: Add MIPS perf to DWARF register number mapping functions
authorIan Rogers <irogers@google.com>
Sat, 17 Jan 2026 05:28:46 +0000 (21:28 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Jan 2026 18:43:56 +0000 (15:43 -0300)
Despite an unused function declaration, there was no unwind-libdw for
MIPS but there is a perf_regs.h and a libdw implementation.

Fill in the pieces so hopefully MIPS unwinding with libdw works.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Haibo Xu <haibo1.xu@intel.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Krzysztof Ɓopatowski <krzysztof.m.lopatowski@gmail.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Wielaard <mark@klomp.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergei Trofimovich <slyich@gmail.com>
Cc: Shimin Guo <shimin.guo@skydio.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/dwarf-regs-arch/Build
tools/perf/util/dwarf-regs-arch/dwarf-regs-mips.c [new file with mode: 0644]
tools/perf/util/dwarf-regs.c
tools/perf/util/include/dwarf-regs.h
tools/perf/util/unwind-libdw.h

index 10c2af3d933abb97c8d2eb14450c171d692a1ea2..ceb68ae86fd876cf1f346c5a9af37865ccf792e8 100644 (file)
@@ -2,6 +2,7 @@ perf-util-$(CONFIG_LIBDW) += dwarf-regs-arm64.o
 perf-util-$(CONFIG_LIBDW) += dwarf-regs-arm.o
 perf-util-$(CONFIG_LIBDW) += dwarf-regs-csky.o
 perf-util-$(CONFIG_LIBDW) += dwarf-regs-loongarch.o
+perf-util-$(CONFIG_LIBDW) += dwarf-regs-mips.o
 perf-util-$(CONFIG_LIBDW) += dwarf-regs-powerpc.o
 perf-util-$(CONFIG_LIBDW) += dwarf-regs-riscv.o
 perf-util-$(CONFIG_LIBDW) += dwarf-regs-s390.o
diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-mips.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-mips.c
new file mode 100644 (file)
index 0000000..3bb916b
--- /dev/null
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <errno.h>
+#include <dwarf-regs.h>
+#include "../../../arch/mips/include/uapi/asm/perf_regs.h"
+
+int __get_dwarf_regnum_for_perf_regnum_mips(int perf_regnum)
+{
+       if (perf_regnum == PERF_REG_MIPS_PC)
+               return 37;
+       if (perf_regnum < 0 || perf_regnum >= PERF_REG_MIPS_MAX)
+               return -ENOENT;
+
+       return perf_regnum;
+}
index f86f76547592d66fe7e2734e628db92e7f6689e4..797f455eba0da02e02abc843ed5adf6c95d650e2 100644 (file)
@@ -179,6 +179,8 @@ static int get_libdw_frame_nregs(unsigned int machine, unsigned int flags __mayb
                return 103;
        case EM_LOONGARCH:
                return 74;
+       case EM_MIPS:
+               return 71;
        default:
                return 0;
        }
@@ -218,6 +220,9 @@ int get_dwarf_regnum_for_perf_regnum(int perf_regnum, unsigned int machine,
        case EM_LOONGARCH:
                reg = __get_dwarf_regnum_for_perf_regnum_loongarch(perf_regnum);
                break;
+       case EM_MIPS:
+               reg = __get_dwarf_regnum_for_perf_regnum_mips(perf_regnum);
+               break;
        default:
                pr_err("ELF MACHINE %x is not supported.\n", machine);
                return -ENOENT;
index b95cf2d7b5b3683abbf993d306cd60cef5e407bb..46a764cf322fef0009c9ceaa418407f2070a37ee 100644 (file)
@@ -113,6 +113,7 @@ int __get_dwarf_regnum_for_perf_regnum_loongarch(int perf_regnum);
 int __get_dwarf_regnum_for_perf_regnum_powerpc(int perf_regnum);
 int __get_dwarf_regnum_for_perf_regnum_riscv(int perf_regnum);
 int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum);
+int __get_dwarf_regnum_for_perf_regnum_mips(int perf_regnum);
 
 /*
  * get_dwarf_regnum - Returns DWARF regnum from register name
index 20d63d881dff93eb56ef6e8a0721f65fdc3a5151..9c5b5fcaaae8741204b565f6832d6c00dbaa928f 100644 (file)
@@ -9,8 +9,6 @@ struct machine;
 struct perf_sample;
 struct thread;
 
-bool libdw_set_initial_registers_mips(Dwfl_Thread *thread, void *arg);
-
 struct unwind_info {
        Dwfl                    *dwfl;
        struct perf_sample      *sample;