1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/regset.h>
5 #include <linux/nospec.h>
6 #include <linux/pkeys.h>
8 #include "ptrace-decl.h"
10 struct pt_regs_offset {
15 #define STR(s) #s /* convert to string */
16 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
17 #define GPR_OFFSET_NAME(num) \
18 {.name = STR(r##num), .offset = offsetof(struct pt_regs, gpr[num])}, \
19 {.name = STR(gpr##num), .offset = offsetof(struct pt_regs, gpr[num])}
20 #define REG_OFFSET_END {.name = NULL, .offset = 0}
22 static const struct pt_regs_offset regoffset_table[] = {
58 REG_OFFSET_NAME(link),
62 REG_OFFSET_NAME(softe),
66 REG_OFFSET_NAME(trap),
68 REG_OFFSET_NAME(dsisr),
73 * regs_query_register_offset() - query register offset from its name
74 * @name: the name of a register
76 * regs_query_register_offset() returns the offset of a register in struct
77 * pt_regs from its name. If the name is invalid, this returns -EINVAL;
79 int regs_query_register_offset(const char *name)
81 const struct pt_regs_offset *roff;
82 for (roff = regoffset_table; roff->name != NULL; roff++)
83 if (!strcmp(roff->name, name))
89 * regs_query_register_name() - query register name from its offset
90 * @offset: the offset of a register in struct pt_regs.
92 * regs_query_register_name() returns the name of a register from its
93 * offset in struct pt_regs. If the @offset is invalid, this returns NULL;
95 const char *regs_query_register_name(unsigned int offset)
97 const struct pt_regs_offset *roff;
98 for (roff = regoffset_table; roff->name != NULL; roff++)
99 if (roff->offset == offset)
105 * does not yet catch signals sent when the child dies.
106 * in exit.c or in signal.c.
109 static unsigned long get_user_msr(struct task_struct *task)
111 return task->thread.regs->msr | task->thread.fpexc_mode;
114 static int set_user_msr(struct task_struct *task, unsigned long msr)
116 task->thread.regs->msr &= ~MSR_DEBUGCHANGE;
117 task->thread.regs->msr |= msr & MSR_DEBUGCHANGE;
122 static int get_user_dscr(struct task_struct *task, unsigned long *data)
124 *data = task->thread.dscr;
128 static int set_user_dscr(struct task_struct *task, unsigned long dscr)
130 task->thread.dscr = dscr;
131 task->thread.dscr_inherit = 1;
135 static int get_user_dscr(struct task_struct *task, unsigned long *data)
140 static int set_user_dscr(struct task_struct *task, unsigned long dscr)
147 * We prevent mucking around with the reserved area of trap
148 * which are used internally by the kernel.
150 static int set_user_trap(struct task_struct *task, unsigned long trap)
152 set_trap(task->thread.regs, trap);
157 * Get contents of register REGNO in task TASK.
159 int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data)
161 unsigned int regs_max;
163 if (task->thread.regs == NULL || !data)
166 if (regno == PT_MSR) {
167 *data = get_user_msr(task);
171 if (regno == PT_DSCR)
172 return get_user_dscr(task, data);
175 * softe copies paca->irq_soft_mask variable state. Since irq_soft_mask is
176 * no more used as a flag, lets force usr to alway see the softe value as 1
177 * which means interrupts are not soft disabled.
179 if (IS_ENABLED(CONFIG_PPC64) && regno == PT_SOFTE) {
184 regs_max = sizeof(struct user_pt_regs) / sizeof(unsigned long);
185 if (regno < regs_max) {
186 regno = array_index_nospec(regno, regs_max);
187 *data = ((unsigned long *)task->thread.regs)[regno];
195 * Write contents of register REGNO in task TASK.
197 int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data)
199 if (task->thread.regs == NULL)
203 return set_user_msr(task, data);
204 if (regno == PT_TRAP)
205 return set_user_trap(task, data);
206 if (regno == PT_DSCR)
207 return set_user_dscr(task, data);
209 if (regno <= PT_MAX_PUT_REG) {
210 regno = array_index_nospec(regno, PT_MAX_PUT_REG + 1);
211 ((unsigned long *)task->thread.regs)[regno] = data;
217 static int gpr_get(struct task_struct *target, const struct user_regset *regset,
218 unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
222 if (target->thread.regs == NULL)
225 if (!FULL_REGS(target->thread.regs)) {
226 /* We have a partial register set. Fill 14-31 with bogus values */
227 for (i = 14; i < 32; i++)
228 target->thread.regs->gpr[i] = NV_REG_POISON;
231 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
233 0, offsetof(struct pt_regs, msr));
235 unsigned long msr = get_user_msr(target);
236 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &msr,
237 offsetof(struct pt_regs, msr),
238 offsetof(struct pt_regs, msr) +
242 BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
243 offsetof(struct pt_regs, msr) + sizeof(long));
246 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
247 &target->thread.regs->orig_gpr3,
248 offsetof(struct pt_regs, orig_gpr3),
249 sizeof(struct user_pt_regs));
251 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
252 sizeof(struct user_pt_regs), -1);
257 static int gpr_set(struct task_struct *target, const struct user_regset *regset,
258 unsigned int pos, unsigned int count, const void *kbuf,
259 const void __user *ubuf)
264 if (target->thread.regs == NULL)
267 CHECK_FULL_REGS(target->thread.regs);
269 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
271 0, PT_MSR * sizeof(reg));
273 if (!ret && count > 0) {
274 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, ®,
275 PT_MSR * sizeof(reg),
276 (PT_MSR + 1) * sizeof(reg));
278 ret = set_user_msr(target, reg);
281 BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
282 offsetof(struct pt_regs, msr) + sizeof(long));
285 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
286 &target->thread.regs->orig_gpr3,
287 PT_ORIG_R3 * sizeof(reg),
288 (PT_MAX_PUT_REG + 1) * sizeof(reg));
290 if (PT_MAX_PUT_REG + 1 < PT_TRAP && !ret)
291 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
292 (PT_MAX_PUT_REG + 1) * sizeof(reg),
293 PT_TRAP * sizeof(reg));
295 if (!ret && count > 0) {
296 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, ®,
297 PT_TRAP * sizeof(reg),
298 (PT_TRAP + 1) * sizeof(reg));
300 ret = set_user_trap(target, reg);
304 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
305 (PT_TRAP + 1) * sizeof(reg), -1);
311 static int ppr_get(struct task_struct *target, const struct user_regset *regset,
312 unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
314 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
315 &target->thread.regs->ppr, 0, sizeof(u64));
318 static int ppr_set(struct task_struct *target, const struct user_regset *regset,
319 unsigned int pos, unsigned int count, const void *kbuf,
320 const void __user *ubuf)
322 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
323 &target->thread.regs->ppr, 0, sizeof(u64));
326 static int dscr_get(struct task_struct *target, const struct user_regset *regset,
327 unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
329 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
330 &target->thread.dscr, 0, sizeof(u64));
332 static int dscr_set(struct task_struct *target, const struct user_regset *regset,
333 unsigned int pos, unsigned int count, const void *kbuf,
334 const void __user *ubuf)
336 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
337 &target->thread.dscr, 0, sizeof(u64));
340 #ifdef CONFIG_PPC_BOOK3S_64
341 static int tar_get(struct task_struct *target, const struct user_regset *regset,
342 unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
344 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
345 &target->thread.tar, 0, sizeof(u64));
347 static int tar_set(struct task_struct *target, const struct user_regset *regset,
348 unsigned int pos, unsigned int count, const void *kbuf,
349 const void __user *ubuf)
351 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
352 &target->thread.tar, 0, sizeof(u64));
355 static int ebb_active(struct task_struct *target, const struct user_regset *regset)
357 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
360 if (target->thread.used_ebb)
366 static int ebb_get(struct task_struct *target, const struct user_regset *regset,
367 unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
370 BUILD_BUG_ON(TSO(ebbrr) + sizeof(unsigned long) != TSO(ebbhr));
371 BUILD_BUG_ON(TSO(ebbhr) + sizeof(unsigned long) != TSO(bescr));
373 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
376 if (!target->thread.used_ebb)
379 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.ebbrr,
380 0, 3 * sizeof(unsigned long));
383 static int ebb_set(struct task_struct *target, const struct user_regset *regset,
384 unsigned int pos, unsigned int count, const void *kbuf,
385 const void __user *ubuf)
390 BUILD_BUG_ON(TSO(ebbrr) + sizeof(unsigned long) != TSO(ebbhr));
391 BUILD_BUG_ON(TSO(ebbhr) + sizeof(unsigned long) != TSO(bescr));
393 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
396 if (target->thread.used_ebb)
399 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &target->thread.ebbrr,
400 0, sizeof(unsigned long));
403 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
404 &target->thread.ebbhr, sizeof(unsigned long),
405 2 * sizeof(unsigned long));
408 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
409 &target->thread.bescr, 2 * sizeof(unsigned long),
410 3 * sizeof(unsigned long));
414 static int pmu_active(struct task_struct *target, const struct user_regset *regset)
416 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
422 static int pmu_get(struct task_struct *target, const struct user_regset *regset,
423 unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
426 BUILD_BUG_ON(TSO(siar) + sizeof(unsigned long) != TSO(sdar));
427 BUILD_BUG_ON(TSO(sdar) + sizeof(unsigned long) != TSO(sier));
428 BUILD_BUG_ON(TSO(sier) + sizeof(unsigned long) != TSO(mmcr2));
429 BUILD_BUG_ON(TSO(mmcr2) + sizeof(unsigned long) != TSO(mmcr0));
431 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
434 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.siar,
435 0, 5 * sizeof(unsigned long));
438 static int pmu_set(struct task_struct *target, const struct user_regset *regset,
439 unsigned int pos, unsigned int count, const void *kbuf,
440 const void __user *ubuf)
445 BUILD_BUG_ON(TSO(siar) + sizeof(unsigned long) != TSO(sdar));
446 BUILD_BUG_ON(TSO(sdar) + sizeof(unsigned long) != TSO(sier));
447 BUILD_BUG_ON(TSO(sier) + sizeof(unsigned long) != TSO(mmcr2));
448 BUILD_BUG_ON(TSO(mmcr2) + sizeof(unsigned long) != TSO(mmcr0));
450 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
453 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &target->thread.siar,
454 0, sizeof(unsigned long));
457 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
458 &target->thread.sdar, sizeof(unsigned long),
459 2 * sizeof(unsigned long));
462 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
463 &target->thread.sier, 2 * sizeof(unsigned long),
464 3 * sizeof(unsigned long));
467 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
468 &target->thread.mmcr2, 3 * sizeof(unsigned long),
469 4 * sizeof(unsigned long));
472 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
473 &target->thread.mmcr0, 4 * sizeof(unsigned long),
474 5 * sizeof(unsigned long));
479 #ifdef CONFIG_PPC_MEM_KEYS
480 static int pkey_active(struct task_struct *target, const struct user_regset *regset)
482 if (!arch_pkeys_enabled())
488 static int pkey_get(struct task_struct *target, const struct user_regset *regset,
489 unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
491 BUILD_BUG_ON(TSO(amr) + sizeof(unsigned long) != TSO(iamr));
492 BUILD_BUG_ON(TSO(iamr) + sizeof(unsigned long) != TSO(uamor));
494 if (!arch_pkeys_enabled())
497 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.amr,
498 0, ELF_NPKEY * sizeof(unsigned long));
501 static int pkey_set(struct task_struct *target, const struct user_regset *regset,
502 unsigned int pos, unsigned int count, const void *kbuf,
503 const void __user *ubuf)
508 if (!arch_pkeys_enabled())
511 /* Only the AMR can be set from userspace */
512 if (pos != 0 || count != sizeof(new_amr))
515 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
516 &new_amr, 0, sizeof(new_amr));
520 /* UAMOR determines which bits of the AMR can be set from userspace. */
521 target->thread.amr = (new_amr & target->thread.uamor) |
522 (target->thread.amr & ~target->thread.uamor);
526 #endif /* CONFIG_PPC_MEM_KEYS */
528 static const struct user_regset native_regsets[] = {
530 .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
531 .size = sizeof(long), .align = sizeof(long),
532 .get = gpr_get, .set = gpr_set
535 .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
536 .size = sizeof(double), .align = sizeof(double),
537 .get = fpr_get, .set = fpr_set
539 #ifdef CONFIG_ALTIVEC
541 .core_note_type = NT_PPC_VMX, .n = 34,
542 .size = sizeof(vector128), .align = sizeof(vector128),
543 .active = vr_active, .get = vr_get, .set = vr_set
548 .core_note_type = NT_PPC_VSX, .n = 32,
549 .size = sizeof(double), .align = sizeof(double),
550 .active = vsr_active, .get = vsr_get, .set = vsr_set
555 .core_note_type = NT_PPC_SPE, .n = 35,
556 .size = sizeof(u32), .align = sizeof(u32),
557 .active = evr_active, .get = evr_get, .set = evr_set
560 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
562 .core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG,
563 .size = sizeof(long), .align = sizeof(long),
564 .active = tm_cgpr_active, .get = tm_cgpr_get, .set = tm_cgpr_set
567 .core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG,
568 .size = sizeof(double), .align = sizeof(double),
569 .active = tm_cfpr_active, .get = tm_cfpr_get, .set = tm_cfpr_set
572 .core_note_type = NT_PPC_TM_CVMX, .n = ELF_NVMX,
573 .size = sizeof(vector128), .align = sizeof(vector128),
574 .active = tm_cvmx_active, .get = tm_cvmx_get, .set = tm_cvmx_set
577 .core_note_type = NT_PPC_TM_CVSX, .n = ELF_NVSX,
578 .size = sizeof(double), .align = sizeof(double),
579 .active = tm_cvsx_active, .get = tm_cvsx_get, .set = tm_cvsx_set
582 .core_note_type = NT_PPC_TM_SPR, .n = ELF_NTMSPRREG,
583 .size = sizeof(u64), .align = sizeof(u64),
584 .active = tm_spr_active, .get = tm_spr_get, .set = tm_spr_set
587 .core_note_type = NT_PPC_TM_CTAR, .n = 1,
588 .size = sizeof(u64), .align = sizeof(u64),
589 .active = tm_tar_active, .get = tm_tar_get, .set = tm_tar_set
592 .core_note_type = NT_PPC_TM_CPPR, .n = 1,
593 .size = sizeof(u64), .align = sizeof(u64),
594 .active = tm_ppr_active, .get = tm_ppr_get, .set = tm_ppr_set
596 [REGSET_TM_CDSCR] = {
597 .core_note_type = NT_PPC_TM_CDSCR, .n = 1,
598 .size = sizeof(u64), .align = sizeof(u64),
599 .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set
604 .core_note_type = NT_PPC_PPR, .n = 1,
605 .size = sizeof(u64), .align = sizeof(u64),
606 .get = ppr_get, .set = ppr_set
609 .core_note_type = NT_PPC_DSCR, .n = 1,
610 .size = sizeof(u64), .align = sizeof(u64),
611 .get = dscr_get, .set = dscr_set
614 #ifdef CONFIG_PPC_BOOK3S_64
616 .core_note_type = NT_PPC_TAR, .n = 1,
617 .size = sizeof(u64), .align = sizeof(u64),
618 .get = tar_get, .set = tar_set
621 .core_note_type = NT_PPC_EBB, .n = ELF_NEBB,
622 .size = sizeof(u64), .align = sizeof(u64),
623 .active = ebb_active, .get = ebb_get, .set = ebb_set
626 .core_note_type = NT_PPC_PMU, .n = ELF_NPMU,
627 .size = sizeof(u64), .align = sizeof(u64),
628 .active = pmu_active, .get = pmu_get, .set = pmu_set
631 #ifdef CONFIG_PPC_MEM_KEYS
633 .core_note_type = NT_PPC_PKEY, .n = ELF_NPKEY,
634 .size = sizeof(u64), .align = sizeof(u64),
635 .active = pkey_active, .get = pkey_get, .set = pkey_set
640 const struct user_regset_view user_ppc_native_view = {
641 .name = UTS_MACHINE, .e_machine = ELF_ARCH, .ei_osabi = ELF_OSABI,
642 .regsets = native_regsets, .n = ARRAY_SIZE(native_regsets)
645 #include <linux/compat.h>
647 int gpr32_get_common(struct task_struct *target,
648 const struct user_regset *regset,
649 unsigned int pos, unsigned int count,
650 void *kbuf, void __user *ubuf,
653 compat_ulong_t *k = kbuf;
654 compat_ulong_t __user *u = ubuf;
658 count /= sizeof(reg);
661 for (; count > 0 && pos < PT_MSR; --count)
664 for (; count > 0 && pos < PT_MSR; --count)
665 if (__put_user((compat_ulong_t)regs[pos++], u++))
668 if (count > 0 && pos == PT_MSR) {
669 reg = get_user_msr(target);
672 else if (__put_user(reg, u++))
679 for (; count > 0 && pos < PT_REGS_COUNT; --count)
682 for (; count > 0 && pos < PT_REGS_COUNT; --count)
683 if (__put_user((compat_ulong_t)regs[pos++], u++))
689 count *= sizeof(reg);
690 return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
691 PT_REGS_COUNT * sizeof(reg), -1);
694 int gpr32_set_common(struct task_struct *target,
695 const struct user_regset *regset,
696 unsigned int pos, unsigned int count,
697 const void *kbuf, const void __user *ubuf,
700 const compat_ulong_t *k = kbuf;
701 const compat_ulong_t __user *u = ubuf;
705 count /= sizeof(reg);
708 for (; count > 0 && pos < PT_MSR; --count)
711 for (; count > 0 && pos < PT_MSR; --count) {
712 if (__get_user(reg, u++))
718 if (count > 0 && pos == PT_MSR) {
721 else if (__get_user(reg, u++))
723 set_user_msr(target, reg);
729 for (; count > 0 && pos <= PT_MAX_PUT_REG; --count)
731 for (; count > 0 && pos < PT_TRAP; --count, ++pos)
734 for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) {
735 if (__get_user(reg, u++))
739 for (; count > 0 && pos < PT_TRAP; --count, ++pos)
740 if (__get_user(reg, u++))
744 if (count > 0 && pos == PT_TRAP) {
747 else if (__get_user(reg, u++))
749 set_user_trap(target, reg);
757 count *= sizeof(reg);
758 return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
759 (PT_TRAP + 1) * sizeof(reg), -1);
762 static int gpr32_get(struct task_struct *target,
763 const struct user_regset *regset,
764 unsigned int pos, unsigned int count,
765 void *kbuf, void __user *ubuf)
769 if (target->thread.regs == NULL)
772 if (!FULL_REGS(target->thread.regs)) {
774 * We have a partial register set.
775 * Fill 14-31 with bogus values.
777 for (i = 14; i < 32; i++)
778 target->thread.regs->gpr[i] = NV_REG_POISON;
780 return gpr32_get_common(target, regset, pos, count, kbuf, ubuf,
781 &target->thread.regs->gpr[0]);
784 static int gpr32_set(struct task_struct *target,
785 const struct user_regset *regset,
786 unsigned int pos, unsigned int count,
787 const void *kbuf, const void __user *ubuf)
789 if (target->thread.regs == NULL)
792 CHECK_FULL_REGS(target->thread.regs);
793 return gpr32_set_common(target, regset, pos, count, kbuf, ubuf,
794 &target->thread.regs->gpr[0]);
798 * These are the regset flavors matching the CONFIG_PPC32 native set.
800 static const struct user_regset compat_regsets[] = {
802 .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
803 .size = sizeof(compat_long_t), .align = sizeof(compat_long_t),
804 .get = gpr32_get, .set = gpr32_set
807 .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
808 .size = sizeof(double), .align = sizeof(double),
809 .get = fpr_get, .set = fpr_set
811 #ifdef CONFIG_ALTIVEC
813 .core_note_type = NT_PPC_VMX, .n = 34,
814 .size = sizeof(vector128), .align = sizeof(vector128),
815 .active = vr_active, .get = vr_get, .set = vr_set
820 .core_note_type = NT_PPC_SPE, .n = 35,
821 .size = sizeof(u32), .align = sizeof(u32),
822 .active = evr_active, .get = evr_get, .set = evr_set
825 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
827 .core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG,
828 .size = sizeof(long), .align = sizeof(long),
829 .active = tm_cgpr_active,
830 .get = tm_cgpr32_get, .set = tm_cgpr32_set
833 .core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG,
834 .size = sizeof(double), .align = sizeof(double),
835 .active = tm_cfpr_active, .get = tm_cfpr_get, .set = tm_cfpr_set
838 .core_note_type = NT_PPC_TM_CVMX, .n = ELF_NVMX,
839 .size = sizeof(vector128), .align = sizeof(vector128),
840 .active = tm_cvmx_active, .get = tm_cvmx_get, .set = tm_cvmx_set
843 .core_note_type = NT_PPC_TM_CVSX, .n = ELF_NVSX,
844 .size = sizeof(double), .align = sizeof(double),
845 .active = tm_cvsx_active, .get = tm_cvsx_get, .set = tm_cvsx_set
848 .core_note_type = NT_PPC_TM_SPR, .n = ELF_NTMSPRREG,
849 .size = sizeof(u64), .align = sizeof(u64),
850 .active = tm_spr_active, .get = tm_spr_get, .set = tm_spr_set
853 .core_note_type = NT_PPC_TM_CTAR, .n = 1,
854 .size = sizeof(u64), .align = sizeof(u64),
855 .active = tm_tar_active, .get = tm_tar_get, .set = tm_tar_set
858 .core_note_type = NT_PPC_TM_CPPR, .n = 1,
859 .size = sizeof(u64), .align = sizeof(u64),
860 .active = tm_ppr_active, .get = tm_ppr_get, .set = tm_ppr_set
862 [REGSET_TM_CDSCR] = {
863 .core_note_type = NT_PPC_TM_CDSCR, .n = 1,
864 .size = sizeof(u64), .align = sizeof(u64),
865 .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set
870 .core_note_type = NT_PPC_PPR, .n = 1,
871 .size = sizeof(u64), .align = sizeof(u64),
872 .get = ppr_get, .set = ppr_set
875 .core_note_type = NT_PPC_DSCR, .n = 1,
876 .size = sizeof(u64), .align = sizeof(u64),
877 .get = dscr_get, .set = dscr_set
880 #ifdef CONFIG_PPC_BOOK3S_64
882 .core_note_type = NT_PPC_TAR, .n = 1,
883 .size = sizeof(u64), .align = sizeof(u64),
884 .get = tar_get, .set = tar_set
887 .core_note_type = NT_PPC_EBB, .n = ELF_NEBB,
888 .size = sizeof(u64), .align = sizeof(u64),
889 .active = ebb_active, .get = ebb_get, .set = ebb_set
894 static const struct user_regset_view user_ppc_compat_view = {
895 .name = "ppc", .e_machine = EM_PPC, .ei_osabi = ELF_OSABI,
896 .regsets = compat_regsets, .n = ARRAY_SIZE(compat_regsets)
899 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
901 if (IS_ENABLED(CONFIG_PPC64) && test_tsk_thread_flag(task, TIF_32BIT))
902 return &user_ppc_compat_view;
903 return &user_ppc_native_view;