1 // SPDX-License-Identifier: GPL-2.0
5 #include "util/sample.h"
8 int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,
9 char **new_op __maybe_unused)
14 uint64_t __weak arch__intr_reg_mask(void)
19 uint64_t __weak arch__user_reg_mask(void)
24 #ifdef HAVE_PERF_REGS_SUPPORT
26 const char *perf_reg_name(int id, const char *arch)
28 const char *reg_name = NULL;
30 if (!strcmp(arch, "csky"))
31 reg_name = __perf_reg_name_csky(id);
32 else if (!strcmp(arch, "loongarch"))
33 reg_name = __perf_reg_name_loongarch(id);
34 else if (!strcmp(arch, "mips"))
35 reg_name = __perf_reg_name_mips(id);
36 else if (!strcmp(arch, "powerpc"))
37 reg_name = __perf_reg_name_powerpc(id);
38 else if (!strcmp(arch, "riscv"))
39 reg_name = __perf_reg_name_riscv(id);
40 else if (!strcmp(arch, "s390"))
41 reg_name = __perf_reg_name_s390(id);
42 else if (!strcmp(arch, "x86"))
43 reg_name = __perf_reg_name_x86(id);
44 else if (!strcmp(arch, "arm"))
45 reg_name = __perf_reg_name_arm(id);
46 else if (!strcmp(arch, "arm64"))
47 reg_name = __perf_reg_name_arm64(id);
49 return reg_name ?: "unknown";
52 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
55 u64 mask = regs->mask;
57 if ((u64)id >= PERF_SAMPLE_REGS_CACHE_SIZE)
60 if (regs->cache_mask & (1ULL << id))
63 if (!(mask & (1ULL << id)))
66 for (i = 0; i < id; i++) {
67 if (mask & (1ULL << i))
71 regs->cache_mask |= (1ULL << id);
72 regs->cache_regs[id] = regs->regs[idx];
75 *valp = regs->cache_regs[id];
79 uint64_t perf_arch_reg_ip(const char *arch)
81 if (!strcmp(arch, "arm"))
82 return __perf_reg_ip_arm();
83 else if (!strcmp(arch, "arm64"))
84 return __perf_reg_ip_arm64();
85 else if (!strcmp(arch, "csky"))
86 return __perf_reg_ip_csky();
87 else if (!strcmp(arch, "loongarch"))
88 return __perf_reg_ip_loongarch();
89 else if (!strcmp(arch, "mips"))
90 return __perf_reg_ip_mips();
91 else if (!strcmp(arch, "powerpc"))
92 return __perf_reg_ip_powerpc();
93 else if (!strcmp(arch, "riscv"))
94 return __perf_reg_ip_riscv();
95 else if (!strcmp(arch, "s390"))
96 return __perf_reg_ip_s390();
97 else if (!strcmp(arch, "x86"))
98 return __perf_reg_ip_x86();
100 pr_err("Fail to find IP register for arch %s, returns 0\n", arch);
104 uint64_t perf_arch_reg_sp(const char *arch)
106 if (!strcmp(arch, "arm"))
107 return __perf_reg_sp_arm();
108 else if (!strcmp(arch, "arm64"))
109 return __perf_reg_sp_arm64();
110 else if (!strcmp(arch, "csky"))
111 return __perf_reg_sp_csky();
112 else if (!strcmp(arch, "loongarch"))
113 return __perf_reg_sp_loongarch();
114 else if (!strcmp(arch, "mips"))
115 return __perf_reg_sp_mips();
116 else if (!strcmp(arch, "powerpc"))
117 return __perf_reg_sp_powerpc();
118 else if (!strcmp(arch, "riscv"))
119 return __perf_reg_sp_riscv();
120 else if (!strcmp(arch, "s390"))
121 return __perf_reg_sp_s390();
122 else if (!strcmp(arch, "x86"))
123 return __perf_reg_sp_x86();
125 pr_err("Fail to find SP register for arch %s, returns 0\n", arch);