1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_PERF_REGS_H
3 #define _LINUX_PERF_REGS_H
4 
5 #include <linux/sched/task_stack.h>
6 
7 struct perf_regs {
8 	__u64		abi;
9 	struct pt_regs	*regs;
10 };
11 
12 #ifdef CONFIG_HAVE_PERF_REGS
13 #include <asm/perf_regs.h>
14 
15 #ifndef PERF_REG_EXTENDED_MASK
16 #define PERF_REG_EXTENDED_MASK	0
17 #endif
18 
19 u64 perf_reg_value(struct pt_regs *regs, int idx);
20 int perf_reg_validate(u64 mask);
21 u64 perf_reg_abi(struct task_struct *task);
22 void perf_get_regs_user(struct perf_regs *regs_user,
23 			struct pt_regs *regs);
24 #else
25 
26 #define PERF_REG_EXTENDED_MASK	0
27 
perf_reg_value(struct pt_regs * regs,int idx)28 static inline u64 perf_reg_value(struct pt_regs *regs, int idx)
29 {
30 	return 0;
31 }
32 
perf_reg_validate(u64 mask)33 static inline int perf_reg_validate(u64 mask)
34 {
35 	return mask ? -ENOSYS : 0;
36 }
37 
perf_reg_abi(struct task_struct * task)38 static inline u64 perf_reg_abi(struct task_struct *task)
39 {
40 	return PERF_SAMPLE_REGS_ABI_NONE;
41 }
42 
perf_get_regs_user(struct perf_regs * regs_user,struct pt_regs * regs)43 static inline void perf_get_regs_user(struct perf_regs *regs_user,
44 				      struct pt_regs *regs)
45 {
46 	regs_user->regs = task_pt_regs(current);
47 	regs_user->abi = perf_reg_abi(current);
48 }
49 #endif /* CONFIG_HAVE_PERF_REGS */
50 #endif /* _LINUX_PERF_REGS_H */
51