]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/s390/kernel/perf_regs.c
1 #include <linux/perf_event.h>
2 #include <linux/perf_regs.h>
3 #include <linux/kernel.h>
4 #include <linux/errno.h>
6 #include <asm/ptrace.h>
7 #include <asm/fpu/api.h>
8 #include <asm/fpu/types.h>
10 u64
perf_reg_value(struct pt_regs
*regs
, int idx
)
14 if (WARN_ON_ONCE((u32
)idx
>= PERF_REG_S390_MAX
))
17 if (idx
>= PERF_REG_S390_R0
&& idx
<= PERF_REG_S390_R15
)
18 return regs
->gprs
[idx
];
20 if (idx
>= PERF_REG_S390_FP0
&& idx
<= PERF_REG_S390_FP15
) {
24 idx
-= PERF_REG_S390_FP0
;
25 fp
= MACHINE_HAS_VX
? *(freg_t
*)(current
->thread
.fpu
.vxrs
+ idx
)
26 : current
->thread
.fpu
.fprs
[idx
];
30 if (idx
== PERF_REG_S390_MASK
)
31 return regs
->psw
.mask
;
32 if (idx
== PERF_REG_S390_PC
)
33 return regs
->psw
.addr
;
35 return regs
->gprs
[idx
];
38 #define REG_RESERVED (~((1UL << PERF_REG_S390_MAX) - 1))
40 int perf_reg_validate(u64 mask
)
42 if (!mask
|| mask
& REG_RESERVED
)
48 u64
perf_reg_abi(struct task_struct
*task
)
50 if (test_tsk_thread_flag(task
, TIF_31BIT
))
51 return PERF_SAMPLE_REGS_ABI_32
;
53 return PERF_SAMPLE_REGS_ABI_64
;
56 void perf_get_regs_user(struct perf_regs
*regs_user
,
58 struct pt_regs
*regs_user_copy
)
61 * Use the regs from the first interruption and let
62 * perf_sample_regs_intr() handle interrupts (regs == get_irq_regs()).
64 * Also save FPU registers for user-space tasks only.
66 regs_user
->regs
= task_pt_regs(current
);
67 if (user_mode(regs_user
->regs
))
69 regs_user
->abi
= perf_reg_abi(current
);