Skip to content

Commit f3e909c

Browse files
mikeypaulusmack
authored andcommitted
powerpc: Update for VSX core file and ptrace
This correctly hooks the VSX dump into Roland McGrath core file infrastructure. It adds the VSX dump information as an additional elf note in the core file (after talking more to the tool chain/gdb guys). This also ensures the formats are consistent between signals, ptrace and core files. Signed-off-by: Michael Neuling <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 436db69 commit f3e909c

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

arch/powerpc/kernel/process.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void flush_altivec_to_thread(struct task_struct *tsk)
162162
}
163163
}
164164

165-
int dump_task_altivec(struct task_struct *tsk, elf_vrreg_t *vrregs)
165+
int dump_task_altivec(struct task_struct *tsk, elf_vrregset_t *vrregs)
166166
{
167167
/* ELF_NVRREG includes the VSCR and VRSAVE which we need to save
168168
* separately, see below */
@@ -249,23 +249,6 @@ int dump_task_vsx(struct task_struct *tsk, elf_vrreg_t *vrregs)
249249
}
250250
#endif /* CONFIG_VSX */
251251

252-
int dump_task_vector(struct task_struct *tsk, elf_vrregset_t *vrregs)
253-
{
254-
int rc = 0;
255-
elf_vrreg_t *regs = (elf_vrreg_t *)vrregs;
256-
#ifdef CONFIG_ALTIVEC
257-
rc = dump_task_altivec(tsk, regs);
258-
if (rc)
259-
return rc;
260-
regs += ELF_NVRREG;
261-
#endif
262-
263-
#ifdef CONFIG_VSX
264-
rc = dump_task_vsx(tsk, regs);
265-
#endif
266-
return rc;
267-
}
268-
269252
#ifdef CONFIG_SPE
270253

271254
void enable_kernel_spe(void)

arch/powerpc/kernel/ptrace.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,15 @@ static int vsr_get(struct task_struct *target, const struct user_regset *regset,
368368
unsigned int pos, unsigned int count,
369369
void *kbuf, void __user *ubuf)
370370
{
371-
int ret;
371+
double buf[32];
372+
int ret, i;
372373

373374
flush_vsx_to_thread(target);
374375

376+
for (i = 0; i < 32 ; i++)
377+
buf[i] = current->thread.fpr[i][TS_VSRLOWOFFSET];
375378
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
376-
target->thread.fpr, 0,
377-
32 * sizeof(vector128));
379+
buf, 0, 32 * sizeof(double));
378380

379381
return ret;
380382
}
@@ -383,13 +385,16 @@ static int vsr_set(struct task_struct *target, const struct user_regset *regset,
383385
unsigned int pos, unsigned int count,
384386
const void *kbuf, const void __user *ubuf)
385387
{
386-
int ret;
388+
double buf[32];
389+
int ret,i;
387390

388391
flush_vsx_to_thread(target);
389392

390393
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
391-
target->thread.fpr, 0,
392-
32 * sizeof(vector128));
394+
buf, 0, 32 * sizeof(double));
395+
for (i = 0; i < 32 ; i++)
396+
current->thread.fpr[i][TS_VSRLOWOFFSET] = buf[i];
397+
393398

394399
return ret;
395400
}
@@ -499,8 +504,8 @@ static const struct user_regset native_regsets[] = {
499504
#endif
500505
#ifdef CONFIG_VSX
501506
[REGSET_VSX] = {
502-
.n = 32,
503-
.size = sizeof(vector128), .align = sizeof(vector128),
507+
.core_note_type = NT_PPC_VSX, .n = 32,
508+
.size = sizeof(double), .align = sizeof(double),
504509
.active = vsr_active, .get = vsr_get, .set = vsr_set
505510
},
506511
#endif

include/asm-powerpc/elf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
221221
typedef elf_vrregset_t elf_fpxregset_t;
222222

223223
#ifdef CONFIG_ALTIVEC
224-
extern int dump_task_vector(struct task_struct *, elf_vrregset_t *vrregs);
225-
#define ELF_CORE_COPY_XFPREGS(tsk, regs) dump_task_vector(tsk, regs)
224+
extern int dump_task_altivec(struct task_struct *, elf_vrregset_t *vrregs);
225+
#define ELF_CORE_COPY_XFPREGS(tsk, regs) dump_task_altivec(tsk, regs)
226226
#define ELF_CORE_XFPREG_TYPE NT_PPC_VMX
227227
#endif
228228

include/linux/elf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ typedef struct elf64_shdr {
358358
#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
359359
#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
360360
#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
361+
#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
361362
#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
362363

363364

0 commit comments

Comments
 (0)