^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include "perf_regs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include "event.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) char **new_op __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) return SDT_ARG_SKIP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) uint64_t __weak arch__intr_reg_mask(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) return PERF_REGS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) uint64_t __weak arch__user_reg_mask(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) return PERF_REGS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #ifdef HAVE_PERF_REGS_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int i, idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) u64 mask = regs->mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) if (regs->cache_mask & (1ULL << id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) if (!(mask & (1ULL << id)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) for (i = 0; i < id; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (mask & (1ULL << i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) regs->cache_mask |= (1ULL << id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) regs->cache_regs[id] = regs->regs[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *valp = regs->cache_regs[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif