]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
powerpc/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
authorDave Martin <Dave.Martin@arm.com>
Tue, 1 Jul 2025 13:56:08 +0000 (14:56 +0100)
committerKees Cook <kees@kernel.org>
Tue, 15 Jul 2025 05:27:48 +0000 (22:27 -0700)
Instead of having the core code guess the note name for each regset,
use USER_REGSET_NOTE_TYPE() to pick the correct name from elf.h.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: linuxppc-dev@lists.ozlabs.org
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/20250701135616.29630-16-Dave.Martin@arm.com
Signed-off-by: Kees Cook <kees@kernel.org>
arch/powerpc/kernel/ptrace/ptrace-view.c

index c1819e0a66842b37f2a0a60ddba9b333dbcab85f..0310f9097e3937dc03a279fec84d2a14b02435c2 100644 (file)
@@ -568,114 +568,114 @@ static int pkey_set(struct task_struct *target, const struct user_regset *regset
 
 static const struct user_regset native_regsets[] = {
        [REGSET_GPR] = {
-               .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
+               USER_REGSET_NOTE_TYPE(PRSTATUS), .n = ELF_NGREG,
                .size = sizeof(long), .align = sizeof(long),
                .regset_get = gpr_get, .set = gpr_set
        },
        [REGSET_FPR] = {
-               .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
+               USER_REGSET_NOTE_TYPE(PRFPREG), .n = ELF_NFPREG,
                .size = sizeof(double), .align = sizeof(double),
                .regset_get = fpr_get, .set = fpr_set
        },
 #ifdef CONFIG_ALTIVEC
        [REGSET_VMX] = {
-               .core_note_type = NT_PPC_VMX, .n = 34,
+               USER_REGSET_NOTE_TYPE(PPC_VMX), .n = 34,
                .size = sizeof(vector128), .align = sizeof(vector128),
                .active = vr_active, .regset_get = vr_get, .set = vr_set
        },
 #endif
 #ifdef CONFIG_VSX
        [REGSET_VSX] = {
-               .core_note_type = NT_PPC_VSX, .n = 32,
+               USER_REGSET_NOTE_TYPE(PPC_VSX), .n = 32,
                .size = sizeof(double), .align = sizeof(double),
                .active = vsr_active, .regset_get = vsr_get, .set = vsr_set
        },
 #endif
 #ifdef CONFIG_SPE
        [REGSET_SPE] = {
-               .core_note_type = NT_PPC_SPE, .n = 35,
+               USER_REGSET_NOTE_TYPE(PPC_SPE), .n = 35,
                .size = sizeof(u32), .align = sizeof(u32),
                .active = evr_active, .regset_get = evr_get, .set = evr_set
        },
 #endif
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
        [REGSET_TM_CGPR] = {
-               .core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CGPR), .n = ELF_NGREG,
                .size = sizeof(long), .align = sizeof(long),
                .active = tm_cgpr_active, .regset_get = tm_cgpr_get, .set = tm_cgpr_set
        },
        [REGSET_TM_CFPR] = {
-               .core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CFPR), .n = ELF_NFPREG,
                .size = sizeof(double), .align = sizeof(double),
                .active = tm_cfpr_active, .regset_get = tm_cfpr_get, .set = tm_cfpr_set
        },
        [REGSET_TM_CVMX] = {
-               .core_note_type = NT_PPC_TM_CVMX, .n = ELF_NVMX,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CVMX), .n = ELF_NVMX,
                .size = sizeof(vector128), .align = sizeof(vector128),
                .active = tm_cvmx_active, .regset_get = tm_cvmx_get, .set = tm_cvmx_set
        },
        [REGSET_TM_CVSX] = {
-               .core_note_type = NT_PPC_TM_CVSX, .n = ELF_NVSX,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CVSX), .n = ELF_NVSX,
                .size = sizeof(double), .align = sizeof(double),
                .active = tm_cvsx_active, .regset_get = tm_cvsx_get, .set = tm_cvsx_set
        },
        [REGSET_TM_SPR] = {
-               .core_note_type = NT_PPC_TM_SPR, .n = ELF_NTMSPRREG,
+               USER_REGSET_NOTE_TYPE(PPC_TM_SPR), .n = ELF_NTMSPRREG,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_spr_active, .regset_get = tm_spr_get, .set = tm_spr_set
        },
        [REGSET_TM_CTAR] = {
-               .core_note_type = NT_PPC_TM_CTAR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CTAR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_tar_active, .regset_get = tm_tar_get, .set = tm_tar_set
        },
        [REGSET_TM_CPPR] = {
-               .core_note_type = NT_PPC_TM_CPPR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CPPR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_ppr_active, .regset_get = tm_ppr_get, .set = tm_ppr_set
        },
        [REGSET_TM_CDSCR] = {
-               .core_note_type = NT_PPC_TM_CDSCR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CDSCR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_dscr_active, .regset_get = tm_dscr_get, .set = tm_dscr_set
        },
 #endif
 #ifdef CONFIG_PPC64
        [REGSET_PPR] = {
-               .core_note_type = NT_PPC_PPR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_PPR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .regset_get = ppr_get, .set = ppr_set
        },
        [REGSET_DSCR] = {
-               .core_note_type = NT_PPC_DSCR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_DSCR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .regset_get = dscr_get, .set = dscr_set
        },
 #endif
 #ifdef CONFIG_PPC_BOOK3S_64
        [REGSET_TAR] = {
-               .core_note_type = NT_PPC_TAR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TAR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .regset_get = tar_get, .set = tar_set
        },
        [REGSET_EBB] = {
-               .core_note_type = NT_PPC_EBB, .n = ELF_NEBB,
+               USER_REGSET_NOTE_TYPE(PPC_EBB), .n = ELF_NEBB,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = ebb_active, .regset_get = ebb_get, .set = ebb_set
        },
        [REGSET_PMR] = {
-               .core_note_type = NT_PPC_PMU, .n = ELF_NPMU,
+               USER_REGSET_NOTE_TYPE(PPC_PMU), .n = ELF_NPMU,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = pmu_active, .regset_get = pmu_get, .set = pmu_set
        },
        [REGSET_DEXCR] = {
-               .core_note_type = NT_PPC_DEXCR, .n = ELF_NDEXCR,
+               USER_REGSET_NOTE_TYPE(PPC_DEXCR), .n = ELF_NDEXCR,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = dexcr_active, .regset_get = dexcr_get
        },
 #ifdef CONFIG_CHECKPOINT_RESTORE
        [REGSET_HASHKEYR] = {
-               .core_note_type = NT_PPC_HASHKEYR, .n = ELF_NHASHKEYR,
+               USER_REGSET_NOTE_TYPE(PPC_HASHKEYR), .n = ELF_NHASHKEYR,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = hashkeyr_active, .regset_get = hashkeyr_get, .set = hashkeyr_set
        },
@@ -683,7 +683,7 @@ static const struct user_regset native_regsets[] = {
 #endif
 #ifdef CONFIG_PPC_MEM_KEYS
        [REGSET_PKEY] = {
-               .core_note_type = NT_PPC_PKEY, .n = ELF_NPKEY,
+               USER_REGSET_NOTE_TYPE(PPC_PKEY), .n = ELF_NPKEY,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = pkey_active, .regset_get = pkey_get, .set = pkey_set
        },
@@ -843,92 +843,92 @@ static int gpr32_set(struct task_struct *target,
  */
 static const struct user_regset compat_regsets[] = {
        [REGSET_GPR] = {
-               .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
+               USER_REGSET_NOTE_TYPE(PRSTATUS), .n = ELF_NGREG,
                .size = sizeof(compat_long_t), .align = sizeof(compat_long_t),
                .regset_get = gpr32_get, .set = gpr32_set
        },
        [REGSET_FPR] = {
-               .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
+               USER_REGSET_NOTE_TYPE(PRFPREG), .n = ELF_NFPREG,
                .size = sizeof(double), .align = sizeof(double),
                .regset_get = fpr_get, .set = fpr_set
        },
 #ifdef CONFIG_ALTIVEC
        [REGSET_VMX] = {
-               .core_note_type = NT_PPC_VMX, .n = 34,
+               USER_REGSET_NOTE_TYPE(PPC_VMX), .n = 34,
                .size = sizeof(vector128), .align = sizeof(vector128),
                .active = vr_active, .regset_get = vr_get, .set = vr_set
        },
 #endif
 #ifdef CONFIG_SPE
        [REGSET_SPE] = {
-               .core_note_type = NT_PPC_SPE, .n = 35,
+               USER_REGSET_NOTE_TYPE(PPC_SPE), .n = 35,
                .size = sizeof(u32), .align = sizeof(u32),
                .active = evr_active, .regset_get = evr_get, .set = evr_set
        },
 #endif
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
        [REGSET_TM_CGPR] = {
-               .core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CGPR), .n = ELF_NGREG,
                .size = sizeof(long), .align = sizeof(long),
                .active = tm_cgpr_active,
                .regset_get = tm_cgpr32_get, .set = tm_cgpr32_set
        },
        [REGSET_TM_CFPR] = {
-               .core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CFPR), .n = ELF_NFPREG,
                .size = sizeof(double), .align = sizeof(double),
                .active = tm_cfpr_active, .regset_get = tm_cfpr_get, .set = tm_cfpr_set
        },
        [REGSET_TM_CVMX] = {
-               .core_note_type = NT_PPC_TM_CVMX, .n = ELF_NVMX,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CVMX), .n = ELF_NVMX,
                .size = sizeof(vector128), .align = sizeof(vector128),
                .active = tm_cvmx_active, .regset_get = tm_cvmx_get, .set = tm_cvmx_set
        },
        [REGSET_TM_CVSX] = {
-               .core_note_type = NT_PPC_TM_CVSX, .n = ELF_NVSX,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CVSX), .n = ELF_NVSX,
                .size = sizeof(double), .align = sizeof(double),
                .active = tm_cvsx_active, .regset_get = tm_cvsx_get, .set = tm_cvsx_set
        },
        [REGSET_TM_SPR] = {
-               .core_note_type = NT_PPC_TM_SPR, .n = ELF_NTMSPRREG,
+               USER_REGSET_NOTE_TYPE(PPC_TM_SPR), .n = ELF_NTMSPRREG,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_spr_active, .regset_get = tm_spr_get, .set = tm_spr_set
        },
        [REGSET_TM_CTAR] = {
-               .core_note_type = NT_PPC_TM_CTAR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CTAR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_tar_active, .regset_get = tm_tar_get, .set = tm_tar_set
        },
        [REGSET_TM_CPPR] = {
-               .core_note_type = NT_PPC_TM_CPPR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CPPR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_ppr_active, .regset_get = tm_ppr_get, .set = tm_ppr_set
        },
        [REGSET_TM_CDSCR] = {
-               .core_note_type = NT_PPC_TM_CDSCR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TM_CDSCR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = tm_dscr_active, .regset_get = tm_dscr_get, .set = tm_dscr_set
        },
 #endif
 #ifdef CONFIG_PPC64
        [REGSET_PPR] = {
-               .core_note_type = NT_PPC_PPR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_PPR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .regset_get = ppr_get, .set = ppr_set
        },
        [REGSET_DSCR] = {
-               .core_note_type = NT_PPC_DSCR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_DSCR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .regset_get = dscr_get, .set = dscr_set
        },
 #endif
 #ifdef CONFIG_PPC_BOOK3S_64
        [REGSET_TAR] = {
-               .core_note_type = NT_PPC_TAR, .n = 1,
+               USER_REGSET_NOTE_TYPE(PPC_TAR), .n = 1,
                .size = sizeof(u64), .align = sizeof(u64),
                .regset_get = tar_get, .set = tar_set
        },
        [REGSET_EBB] = {
-               .core_note_type = NT_PPC_EBB, .n = ELF_NEBB,
+               USER_REGSET_NOTE_TYPE(PPC_EBB), .n = ELF_NEBB,
                .size = sizeof(u64), .align = sizeof(u64),
                .active = ebb_active, .regset_get = ebb_get, .set = ebb_set
        },