perf_regs.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ARCH_PERF_REGS_H
  3. #define ARCH_PERF_REGS_H
  4. #include <stdlib.h>
  5. #include <linux/types.h>
  6. #include <asm/perf_regs.h>
  7. void perf_regs_load(u64 *regs);
  8. #ifndef HAVE_ARCH_X86_64_SUPPORT
  9. #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
  10. #define PERF_REGS_MAX PERF_REG_X86_32_MAX
  11. #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
  12. #else
  13. #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \
  14. (1ULL << PERF_REG_X86_ES) | \
  15. (1ULL << PERF_REG_X86_FS) | \
  16. (1ULL << PERF_REG_X86_GS))
  17. #define PERF_REGS_MASK (((1ULL << PERF_REG_X86_64_MAX) - 1) & ~REG_NOSUPPORT)
  18. #define PERF_REGS_MAX PERF_REG_X86_64_MAX
  19. #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64
  20. #endif
  21. #define PERF_REG_IP PERF_REG_X86_IP
  22. #define PERF_REG_SP PERF_REG_X86_SP
  23. static inline const char *perf_reg_name(int id)
  24. {
  25. switch (id) {
  26. case PERF_REG_X86_AX:
  27. return "AX";
  28. case PERF_REG_X86_BX:
  29. return "BX";
  30. case PERF_REG_X86_CX:
  31. return "CX";
  32. case PERF_REG_X86_DX:
  33. return "DX";
  34. case PERF_REG_X86_SI:
  35. return "SI";
  36. case PERF_REG_X86_DI:
  37. return "DI";
  38. case PERF_REG_X86_BP:
  39. return "BP";
  40. case PERF_REG_X86_SP:
  41. return "SP";
  42. case PERF_REG_X86_IP:
  43. return "IP";
  44. case PERF_REG_X86_FLAGS:
  45. return "FLAGS";
  46. case PERF_REG_X86_CS:
  47. return "CS";
  48. case PERF_REG_X86_SS:
  49. return "SS";
  50. case PERF_REG_X86_DS:
  51. return "DS";
  52. case PERF_REG_X86_ES:
  53. return "ES";
  54. case PERF_REG_X86_FS:
  55. return "FS";
  56. case PERF_REG_X86_GS:
  57. return "GS";
  58. #ifdef HAVE_ARCH_X86_64_SUPPORT
  59. case PERF_REG_X86_R8:
  60. return "R8";
  61. case PERF_REG_X86_R9:
  62. return "R9";
  63. case PERF_REG_X86_R10:
  64. return "R10";
  65. case PERF_REG_X86_R11:
  66. return "R11";
  67. case PERF_REG_X86_R12:
  68. return "R12";
  69. case PERF_REG_X86_R13:
  70. return "R13";
  71. case PERF_REG_X86_R14:
  72. return "R14";
  73. case PERF_REG_X86_R15:
  74. return "R15";
  75. #endif /* HAVE_ARCH_X86_64_SUPPORT */
  76. default:
  77. return NULL;
  78. }
  79. return NULL;
  80. }
  81. #endif /* ARCH_PERF_REGS_H */