perf_regs.c 730 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <errno.h>
  3. #include "perf_regs.h"
  4. #include "event.h"
  5. const struct sample_reg __weak sample_reg_masks[] = {
  6. SMPL_REG_END
  7. };
  8. int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,
  9. char **new_op __maybe_unused)
  10. {
  11. return SDT_ARG_SKIP;
  12. }
  13. #ifdef HAVE_PERF_REGS_SUPPORT
  14. int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
  15. {
  16. int i, idx = 0;
  17. u64 mask = regs->mask;
  18. if (regs->cache_mask & (1ULL << id))
  19. goto out;
  20. if (!(mask & (1ULL << id)))
  21. return -EINVAL;
  22. for (i = 0; i < id; i++) {
  23. if (mask & (1ULL << i))
  24. idx++;
  25. }
  26. regs->cache_mask |= (1ULL << id);
  27. regs->cache_regs[id] = regs->regs[idx];
  28. out:
  29. *valp = regs->cache_regs[id];
  30. return 0;
  31. }
  32. #endif