[PATCH v4 11/11] perf syscalltbl: Mask off ABI type for MIPS system calls

From: Ian Rogers
Date: Tue Mar 04 2025 - 00:06:44 EST


Arnd Bergmann described that MIPS system calls don't necessarily start
from 0 as an ABI prefix is applied:
https://lore.kernel.org/lkml/8ed7dfb2-1e4d-4aa4-a04b-0397a89365d1@xxxxxxxxxxxxxxxx/
When decoding the "id" (aka system call number) for MIPS ignore values
greater-than 1000.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/syscalltbl.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index db0d2b81aed1..ace66e69c1bc 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -46,6 +46,14 @@ const char *syscalltbl__name(int e_machine, int id)
{
const struct syscalltbl *table = find_table(e_machine);

+ if (e_machine == EM_MIPS && id > 1000) {
+ /*
+ * MIPS may encode the N32/64/O32 type in the high part of
+ * syscall number. Mask this off if present. See the values of
+ * __NR_N32_Linux, __NR_64_Linux, __NR_O32_Linux and __NR_Linux.
+ */
+ id = id % 1000;
+ }
if (table && id >= 0 && id < table->num_to_name_len)
return table->num_to_name[id];
return NULL;
--
2.48.1.711.g2feabab25a-goog