Merge tag 'block-5.9-2020-08-14' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / perf / util / perf_regs.c
blob5ee47ae1509c67fcf015ae5e52637d27272af423
1 // SPDX-License-Identifier: GPL-2.0
2 #include <errno.h>
3 #include "perf_regs.h"
4 #include "event.h"
6 int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,
7 char **new_op __maybe_unused)
9 return SDT_ARG_SKIP;
12 uint64_t __weak arch__intr_reg_mask(void)
14 return PERF_REGS_MASK;
17 uint64_t __weak arch__user_reg_mask(void)
19 return PERF_REGS_MASK;
22 #ifdef HAVE_PERF_REGS_SUPPORT
23 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
25 int i, idx = 0;
26 u64 mask = regs->mask;
28 if (regs->cache_mask & (1ULL << id))
29 goto out;
31 if (!(mask & (1ULL << id)))
32 return -EINVAL;
34 for (i = 0; i < id; i++) {
35 if (mask & (1ULL << i))
36 idx++;
39 regs->cache_mask |= (1ULL << id);
40 regs->cache_regs[id] = regs->regs[idx];
42 out:
43 *valp = regs->cache_regs[id];
44 return 0;
46 #endif