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