]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/s390/kernel/perf_regs.c
ASoC: tlv320aic31xx: Reset registers during power up
[mirror_ubuntu-focal-kernel.git] / 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>
5 #include <linux/bug.h>
6 #include <asm/ptrace.h>
7 #include <asm/fpu/api.h>
8 #include <asm/fpu/types.h>
9
10 u64 perf_reg_value(struct pt_regs *regs, int idx)
11 {
12 freg_t fp;
13
14 if (WARN_ON_ONCE((u32)idx >= PERF_REG_S390_MAX))
15 return 0;
16
17 if (idx >= PERF_REG_S390_R0 && idx <= PERF_REG_S390_R15)
18 return regs->gprs[idx];
19
20 if (idx >= PERF_REG_S390_FP0 && idx <= PERF_REG_S390_FP15) {
21 if (!user_mode(regs))
22 return 0;
23
24 idx -= PERF_REG_S390_FP0;
25 fp = MACHINE_HAS_VX ? *(freg_t *)(current->thread.fpu.vxrs + idx)
26 : current->thread.fpu.fprs[idx];
27 return fp.ui;
28 }
29
30 if (idx == PERF_REG_S390_MASK)
31 return regs->psw.mask;
32 if (idx == PERF_REG_S390_PC)
33 return regs->psw.addr;
34
35 return regs->gprs[idx];
36 }
37
38 #define REG_RESERVED (~((1UL << PERF_REG_S390_MAX) - 1))
39
40 int perf_reg_validate(u64 mask)
41 {
42 if (!mask || mask & REG_RESERVED)
43 return -EINVAL;
44
45 return 0;
46 }
47
48 u64 perf_reg_abi(struct task_struct *task)
49 {
50 if (test_tsk_thread_flag(task, TIF_31BIT))
51 return PERF_SAMPLE_REGS_ABI_32;
52
53 return PERF_SAMPLE_REGS_ABI_64;
54 }
55
56 void perf_get_regs_user(struct perf_regs *regs_user,
57 struct pt_regs *regs,
58 struct pt_regs *regs_user_copy)
59 {
60 /*
61 * Use the regs from the first interruption and let
62 * perf_sample_regs_intr() handle interrupts (regs == get_irq_regs()).
63 *
64 * Also save FPU registers for user-space tasks only.
65 */
66 regs_user->regs = task_pt_regs(current);
67 if (user_mode(regs_user->regs))
68 save_fpu_regs();
69 regs_user->abi = perf_reg_abi(current);
70 }