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
7struct perf_regs {
8 __u64 abi;
9 struct pt_regs *regs;
10};
11
12#ifdef CONFIG_HAVE_PERF_REGS
13#include <asm/perf_regs.h>
14u64 perf_reg_value(struct pt_regs *regs, int idx);
15int perf_reg_validate(u64 mask);
16u64 perf_reg_abi(struct task_struct *task);
17void perf_get_regs_user(struct perf_regs *regs_user,
18 struct pt_regs *regs,
19 struct pt_regs *regs_user_copy);
20#else
21static inline u64 perf_reg_value(struct pt_regs *regs, int idx)
22{
23 return 0;
24}
25
26static inline int perf_reg_validate(u64 mask)
27{
28 return mask ? -ENOSYS : 0;
29}
30
31static inline u64 perf_reg_abi(struct task_struct *task)
32{
33 return PERF_SAMPLE_REGS_ABI_NONE;
34}
35
36static inline void perf_get_regs_user(struct perf_regs *regs_user,
37 struct pt_regs *regs,
38 struct pt_regs *regs_user_copy)
39{
40 regs_user->regs = task_pt_regs(current);
41 regs_user->abi = perf_reg_abi(current);
42}
43#endif /* CONFIG_HAVE_PERF_REGS */
44#endif /* _LINUX_PERF_REGS_H */
45