aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 12:02:26 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 12:02:26 -0500
commit37969581301e50872a1ae84dc73962b5f7ee6b76 (patch)
tree35bbd6a07f903f248f4bd209b8d194a922415fe0 /arch/powerpc/kernel
parent80ff8a805113850a3ffafcc8e6eaa1fdd51b02f3 (diff)
parent24f1a849614ba1805e26a05da7cc8c6bd67490ea (diff)
Merge branch 'for-2.6.25' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
* 'for-2.6.25' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: (69 commits) [POWERPC] Add SPE registers to core dumps [POWERPC] Use regset code for compat PTRACE_*REGS* calls [POWERPC] Use generic compat_sys_ptrace [POWERPC] Use generic compat_ptrace_request [POWERPC] Use generic ptrace peekdata/pokedata [POWERPC] Use regset code for PTRACE_*REGS* requests [POWERPC] Switch to generic compat_binfmt_elf code [POWERPC] Switch to using user_regset-based core dumps [POWERPC] Add user_regset compat support [POWERPC] Add user_regset_view definitions [POWERPC] Use user_regset accessors for GPRs [POWERPC] ptrace accessors for special regs MSR and TRAP [POWERPC] Use user_regset accessors for SPE regs [POWERPC] Use user_regset accessors for altivec regs [POWERPC] Use user_regset accessors for FP regs [POWERPC] mpc52xx: fix compile error introduce when rebasing patch [POWERPC] 4xx: PCIe indirect DCR spinlock fix. [POWERPC] Add missing native dcr dcr_ind_lock spinlock [POWERPC] 4xx: Fix offset value on Warp board [POWERPC] 4xx: Add 440EPx Sequoia ehci dts entry ...
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile4
-rw-r--r--arch/powerpc/kernel/asm-offsets.c3
-rw-r--r--arch/powerpc/kernel/binfmt_elf32.c69
-rw-r--r--arch/powerpc/kernel/cputable.c10
-rw-r--r--arch/powerpc/kernel/legacy_serial.c3
-rw-r--r--arch/powerpc/kernel/pmc.c2
-rw-r--r--arch/powerpc/kernel/ptrace.c727
-rw-r--r--arch/powerpc/kernel/ptrace32.c161
-rw-r--r--arch/powerpc/kernel/traps.c2
-rw-r--r--arch/powerpc/kernel/vio.c2
10 files changed, 555 insertions, 428 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 58dbfeff9b4d..0662ae46f724 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -2,6 +2,8 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
6
5ifeq ($(CONFIG_PPC64),y) 7ifeq ($(CONFIG_PPC64),y)
6CFLAGS_prom_init.o += -mno-minimal-toc 8CFLAGS_prom_init.o += -mno-minimal-toc
7endif 9endif
@@ -15,7 +17,7 @@ obj-y := semaphore.o cputable.o ptrace.o syscalls.o \
15 init_task.o process.o systbl.o idle.o \ 17 init_task.o process.o systbl.o idle.o \
16 signal.o 18 signal.o
17obj-y += vdso32/ 19obj-y += vdso32/
18obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ 20obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \
19 signal_64.o ptrace32.o \ 21 signal_64.o ptrace32.o \
20 paca.o cpu_setup_ppc970.o \ 22 paca.o cpu_setup_ppc970.o \
21 cpu_setup_pa6t.o \ 23 cpu_setup_pa6t.o \
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index ed083feaf6f9..e6e49289f788 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -22,6 +22,7 @@
22#include <linux/mman.h> 22#include <linux/mman.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/suspend.h> 24#include <linux/suspend.h>
25#include <linux/hrtimer.h>
25#ifdef CONFIG_PPC64 26#ifdef CONFIG_PPC64
26#include <linux/time.h> 27#include <linux/time.h>
27#include <linux/hardirq.h> 28#include <linux/hardirq.h>
@@ -312,7 +313,7 @@ int main(void)
312 DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); 313 DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
313 DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); 314 DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
314 DEFINE(NSEC_PER_SEC, NSEC_PER_SEC); 315 DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
315 DEFINE(CLOCK_REALTIME_RES, TICK_NSEC); 316 DEFINE(CLOCK_REALTIME_RES, (KTIME_MONOTONIC_RES).tv64);
316 317
317#ifdef CONFIG_BUG 318#ifdef CONFIG_BUG
318 DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry)); 319 DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry));
diff --git a/arch/powerpc/kernel/binfmt_elf32.c b/arch/powerpc/kernel/binfmt_elf32.c
deleted file mode 100644
index 1d45d7782d4e..000000000000
--- a/arch/powerpc/kernel/binfmt_elf32.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * binfmt_elf32.c: Support 32-bit PPC ELF binaries on Power3 and followons.
3 * based on the SPARC64 version.
4 * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com)
5 * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
6 *
7 * Copyright (C) 2000,2001 Ken Aaker (kdaaker@rchland.vnet.ibm.com), IBM Corp
8 * Copyright (C) 2001 Anton Blanchard (anton@au.ibm.com), IBM
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <asm/processor.h>
17#include <linux/module.h>
18#include <linux/compat.h>
19#include <linux/elfcore-compat.h>
20
21#undef ELF_ARCH
22#undef ELF_CLASS
23#define ELF_CLASS ELFCLASS32
24#define ELF_ARCH EM_PPC
25
26#undef elfhdr
27#undef elf_phdr
28#undef elf_note
29#undef elf_addr_t
30#define elfhdr elf32_hdr
31#define elf_phdr elf32_phdr
32#define elf_note elf32_note
33#define elf_addr_t Elf32_Off
34
35#define elf_prstatus compat_elf_prstatus
36#define elf_prpsinfo compat_elf_prpsinfo
37
38#define elf_core_copy_regs compat_elf_core_copy_regs
39static inline void compat_elf_core_copy_regs(compat_elf_gregset_t *elf_regs,
40 struct pt_regs *regs)
41{
42 PPC_ELF_CORE_COPY_REGS((*elf_regs), regs);
43}
44
45#define elf_core_copy_task_regs compat_elf_core_copy_task_regs
46static int compat_elf_core_copy_task_regs(struct task_struct *tsk,
47 compat_elf_gregset_t *elf_regs)
48{
49 struct pt_regs *regs = tsk->thread.regs;
50 if (regs)
51 compat_elf_core_copy_regs(elf_regs, regs);
52 return 1;
53}
54
55#include <linux/time.h>
56
57#undef cputime_to_timeval
58#define cputime_to_timeval cputime_to_compat_timeval
59static __inline__ void
60cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
61{
62 unsigned long jiffies = cputime_to_jiffies(cputime);
63 value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
64 value->tv_sec = jiffies / HZ;
65}
66
67#define init_elf_binfmt init_elf32_binfmt
68
69#include "../../../fs/binfmt_elf.c"
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index a4c2771b5e62..2a8f5cc5184f 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -959,6 +959,9 @@ static struct cpu_spec __initdata cpu_specs[] = {
959 .icache_bsize = 32, 959 .icache_bsize = 32,
960 .dcache_bsize = 32, 960 .dcache_bsize = 32,
961 .cpu_setup = __setup_cpu_603, 961 .cpu_setup = __setup_cpu_603,
962 .num_pmcs = 4,
963 .oprofile_cpu_type = "ppc/e300",
964 .oprofile_type = PPC_OPROFILE_FSL_EMB,
962 .platform = "ppc603", 965 .platform = "ppc603",
963 }, 966 },
964 { /* e300c4 (e300c1, plus one IU) */ 967 { /* e300c4 (e300c1, plus one IU) */
@@ -971,6 +974,9 @@ static struct cpu_spec __initdata cpu_specs[] = {
971 .dcache_bsize = 32, 974 .dcache_bsize = 32,
972 .cpu_setup = __setup_cpu_603, 975 .cpu_setup = __setup_cpu_603,
973 .machine_check = machine_check_generic, 976 .machine_check = machine_check_generic,
977 .num_pmcs = 4,
978 .oprofile_cpu_type = "ppc/e300",
979 .oprofile_type = PPC_OPROFILE_FSL_EMB,
974 .platform = "ppc603", 980 .platform = "ppc603",
975 }, 981 },
976 { /* default match, we assume split I/D cache & TB (non-601)... */ 982 { /* default match, we assume split I/D cache & TB (non-601)... */
@@ -1435,7 +1441,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
1435 .dcache_bsize = 32, 1441 .dcache_bsize = 32,
1436 .num_pmcs = 4, 1442 .num_pmcs = 4,
1437 .oprofile_cpu_type = "ppc/e500", 1443 .oprofile_cpu_type = "ppc/e500",
1438 .oprofile_type = PPC_OPROFILE_BOOKE, 1444 .oprofile_type = PPC_OPROFILE_FSL_EMB,
1439 .machine_check = machine_check_e500, 1445 .machine_check = machine_check_e500,
1440 .platform = "ppc8540", 1446 .platform = "ppc8540",
1441 }, 1447 },
@@ -1453,7 +1459,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
1453 .dcache_bsize = 32, 1459 .dcache_bsize = 32,
1454 .num_pmcs = 4, 1460 .num_pmcs = 4,
1455 .oprofile_cpu_type = "ppc/e500", 1461 .oprofile_cpu_type = "ppc/e500",
1456 .oprofile_type = PPC_OPROFILE_BOOKE, 1462 .oprofile_type = PPC_OPROFILE_FSL_EMB,
1457 .machine_check = machine_check_e500, 1463 .machine_check = machine_check_e500,
1458 .platform = "ppc8548", 1464 .platform = "ppc8548",
1459 }, 1465 },
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 76b862bd1fe9..61dd17449ddc 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -36,7 +36,8 @@ static struct legacy_serial_info {
36static struct __initdata of_device_id parents[] = { 36static struct __initdata of_device_id parents[] = {
37 {.type = "soc",}, 37 {.type = "soc",},
38 {.type = "tsi-bridge",}, 38 {.type = "tsi-bridge",},
39 {.type = "opb", .compatible = "ibm,opb",}, 39 {.type = "opb", },
40 {.compatible = "ibm,opb",},
40 {.compatible = "simple-bus",}, 41 {.compatible = "simple-bus",},
41 {.compatible = "wrs,epld-localbus",}, 42 {.compatible = "wrs,epld-localbus",},
42}; 43};
diff --git a/arch/powerpc/kernel/pmc.c b/arch/powerpc/kernel/pmc.c
index ea04e0ab3f2f..0516e2d3e02e 100644
--- a/arch/powerpc/kernel/pmc.c
+++ b/arch/powerpc/kernel/pmc.c
@@ -26,7 +26,7 @@
26 26
27static void dummy_perf(struct pt_regs *regs) 27static void dummy_perf(struct pt_regs *regs)
28{ 28{
29#if defined(CONFIG_FSL_BOOKE) && !defined(CONFIG_E200) 29#if defined(CONFIG_FSL_EMB_PERFMON)
30 mtpmr(PMRN_PMGC0, mfpmr(PMRN_PMGC0) & ~PMGC0_PMIE); 30 mtpmr(PMRN_PMGC0, mfpmr(PMRN_PMGC0) & ~PMGC0_PMIE);
31#elif defined(CONFIG_PPC64) || defined(CONFIG_6xx) 31#elif defined(CONFIG_PPC64) || defined(CONFIG_6xx)
32 if (cur_cpu_spec->pmc_type == PPC_PMC_IBM) 32 if (cur_cpu_spec->pmc_type == PPC_PMC_IBM)
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 8b056d2295cc..7673e9865733 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -21,6 +21,8 @@
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/ptrace.h> 23#include <linux/ptrace.h>
24#include <linux/regset.h>
25#include <linux/elf.h>
24#include <linux/user.h> 26#include <linux/user.h>
25#include <linux/security.h> 27#include <linux/security.h>
26#include <linux/signal.h> 28#include <linux/signal.h>
@@ -58,20 +60,38 @@
58#define PT_MAX_PUT_REG PT_CCR 60#define PT_MAX_PUT_REG PT_CCR
59#endif 61#endif
60 62
63static unsigned long get_user_msr(struct task_struct *task)
64{
65 return task->thread.regs->msr | task->thread.fpexc_mode;
66}
67
68static int set_user_msr(struct task_struct *task, unsigned long msr)
69{
70 task->thread.regs->msr &= ~MSR_DEBUGCHANGE;
71 task->thread.regs->msr |= msr & MSR_DEBUGCHANGE;
72 return 0;
73}
74
75/*
76 * We prevent mucking around with the reserved area of trap
77 * which are used internally by the kernel.
78 */
79static int set_user_trap(struct task_struct *task, unsigned long trap)
80{
81 task->thread.regs->trap = trap & 0xfff0;
82 return 0;
83}
84
61/* 85/*
62 * Get contents of register REGNO in task TASK. 86 * Get contents of register REGNO in task TASK.
63 */ 87 */
64unsigned long ptrace_get_reg(struct task_struct *task, int regno) 88unsigned long ptrace_get_reg(struct task_struct *task, int regno)
65{ 89{
66 unsigned long tmp = 0;
67
68 if (task->thread.regs == NULL) 90 if (task->thread.regs == NULL)
69 return -EIO; 91 return -EIO;
70 92
71 if (regno == PT_MSR) { 93 if (regno == PT_MSR)
72 tmp = ((unsigned long *)task->thread.regs)[PT_MSR]; 94 return get_user_msr(task);
73 return tmp | task->thread.fpexc_mode;
74 }
75 95
76 if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) 96 if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long)))
77 return ((unsigned long *)task->thread.regs)[regno]; 97 return ((unsigned long *)task->thread.regs)[regno];
@@ -87,40 +107,134 @@ int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data)
87 if (task->thread.regs == NULL) 107 if (task->thread.regs == NULL)
88 return -EIO; 108 return -EIO;
89 109
90 if (regno <= PT_MAX_PUT_REG || regno == PT_TRAP) { 110 if (regno == PT_MSR)
91 if (regno == PT_MSR) 111 return set_user_msr(task, data);
92 data = (data & MSR_DEBUGCHANGE) 112 if (regno == PT_TRAP)
93 | (task->thread.regs->msr & ~MSR_DEBUGCHANGE); 113 return set_user_trap(task, data);
94 /* We prevent mucking around with the reserved area of trap 114
95 * which are used internally by the kernel 115 if (regno <= PT_MAX_PUT_REG) {
96 */
97 if (regno == PT_TRAP)
98 data &= 0xfff0;
99 ((unsigned long *)task->thread.regs)[regno] = data; 116 ((unsigned long *)task->thread.regs)[regno] = data;
100 return 0; 117 return 0;
101 } 118 }
102 return -EIO; 119 return -EIO;
103} 120}
104 121
122static int gpr_get(struct task_struct *target, const struct user_regset *regset,
123 unsigned int pos, unsigned int count,
124 void *kbuf, void __user *ubuf)
125{
126 int ret;
127
128 if (target->thread.regs == NULL)
129 return -EIO;
130
131 CHECK_FULL_REGS(target->thread.regs);
132
133 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
134 target->thread.regs,
135 0, offsetof(struct pt_regs, msr));
136 if (!ret) {
137 unsigned long msr = get_user_msr(target);
138 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &msr,
139 offsetof(struct pt_regs, msr),
140 offsetof(struct pt_regs, msr) +
141 sizeof(msr));
142 }
143
144 BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
145 offsetof(struct pt_regs, msr) + sizeof(long));
146
147 if (!ret)
148 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
149 &target->thread.regs->orig_gpr3,
150 offsetof(struct pt_regs, orig_gpr3),
151 sizeof(struct pt_regs));
152 if (!ret)
153 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
154 sizeof(struct pt_regs), -1);
155
156 return ret;
157}
158
159static int gpr_set(struct task_struct *target, const struct user_regset *regset,
160 unsigned int pos, unsigned int count,
161 const void *kbuf, const void __user *ubuf)
162{
163 unsigned long reg;
164 int ret;
165
166 if (target->thread.regs == NULL)
167 return -EIO;
168
169 CHECK_FULL_REGS(target->thread.regs);
170
171 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
172 target->thread.regs,
173 0, PT_MSR * sizeof(reg));
105 174
106static int get_fpregs(void __user *data, struct task_struct *task, 175 if (!ret && count > 0) {
107 int has_fpscr) 176 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &reg,
177 PT_MSR * sizeof(reg),
178 (PT_MSR + 1) * sizeof(reg));
179 if (!ret)
180 ret = set_user_msr(target, reg);
181 }
182
183 BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
184 offsetof(struct pt_regs, msr) + sizeof(long));
185
186 if (!ret)
187 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
188 &target->thread.regs->orig_gpr3,
189 PT_ORIG_R3 * sizeof(reg),
190 (PT_MAX_PUT_REG + 1) * sizeof(reg));
191
192 if (PT_MAX_PUT_REG + 1 < PT_TRAP && !ret)
193 ret = user_regset_copyin_ignore(
194 &pos, &count, &kbuf, &ubuf,
195 (PT_MAX_PUT_REG + 1) * sizeof(reg),
196 PT_TRAP * sizeof(reg));
197
198 if (!ret && count > 0) {
199 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &reg,
200 PT_TRAP * sizeof(reg),
201 (PT_TRAP + 1) * sizeof(reg));
202 if (!ret)
203 ret = set_user_trap(target, reg);
204 }
205
206 if (!ret)
207 ret = user_regset_copyin_ignore(
208 &pos, &count, &kbuf, &ubuf,
209 (PT_TRAP + 1) * sizeof(reg), -1);
210
211 return ret;
212}
213
214static int fpr_get(struct task_struct *target, const struct user_regset *regset,
215 unsigned int pos, unsigned int count,
216 void *kbuf, void __user *ubuf)
108{ 217{
109 unsigned int count = has_fpscr ? 33 : 32; 218 flush_fp_to_thread(target);
110 219
111 if (copy_to_user(data, task->thread.fpr, count * sizeof(double))) 220 BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
112 return -EFAULT; 221 offsetof(struct thread_struct, fpr[32]));
113 return 0; 222
223 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
224 &target->thread.fpr, 0, -1);
114} 225}
115 226
116static int set_fpregs(void __user *data, struct task_struct *task, 227static int fpr_set(struct task_struct *target, const struct user_regset *regset,
117 int has_fpscr) 228 unsigned int pos, unsigned int count,
229 const void *kbuf, const void __user *ubuf)
118{ 230{
119 unsigned int count = has_fpscr ? 33 : 32; 231 flush_fp_to_thread(target);
120 232
121 if (copy_from_user(task->thread.fpr, data, count * sizeof(double))) 233 BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
122 return -EFAULT; 234 offsetof(struct thread_struct, fpr[32]));
123 return 0; 235
236 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
237 &target->thread.fpr, 0, -1);
124} 238}
125 239
126 240
@@ -138,56 +252,74 @@ static int set_fpregs(void __user *data, struct task_struct *task,
138 * (combined (32- and 64-bit) gdb. 252 * (combined (32- and 64-bit) gdb.
139 */ 253 */
140 254
141/* 255static int vr_active(struct task_struct *target,
142 * Get contents of AltiVec register state in task TASK 256 const struct user_regset *regset)
143 */
144static int get_vrregs(unsigned long __user *data, struct task_struct *task)
145{ 257{
146 unsigned long regsize; 258 flush_altivec_to_thread(target);
259 return target->thread.used_vr ? regset->n : 0;
260}
147 261
148 /* copy AltiVec registers VR[0] .. VR[31] */ 262static int vr_get(struct task_struct *target, const struct user_regset *regset,
149 regsize = 32 * sizeof(vector128); 263 unsigned int pos, unsigned int count,
150 if (copy_to_user(data, task->thread.vr, regsize)) 264 void *kbuf, void __user *ubuf)
151 return -EFAULT; 265{
152 data += (regsize / sizeof(unsigned long)); 266 int ret;
153 267
154 /* copy VSCR */ 268 flush_altivec_to_thread(target);
155 regsize = 1 * sizeof(vector128);
156 if (copy_to_user(data, &task->thread.vscr, regsize))
157 return -EFAULT;
158 data += (regsize / sizeof(unsigned long));
159 269
160 /* copy VRSAVE */ 270 BUILD_BUG_ON(offsetof(struct thread_struct, vscr) !=
161 if (put_user(task->thread.vrsave, (u32 __user *)data)) 271 offsetof(struct thread_struct, vr[32]));
162 return -EFAULT;
163 272
164 return 0; 273 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
274 &target->thread.vr, 0,
275 33 * sizeof(vector128));
276 if (!ret) {
277 /*
278 * Copy out only the low-order word of vrsave.
279 */
280 union {
281 elf_vrreg_t reg;
282 u32 word;
283 } vrsave;
284 memset(&vrsave, 0, sizeof(vrsave));
285 vrsave.word = target->thread.vrsave;
286 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &vrsave,
287 33 * sizeof(vector128), -1);
288 }
289
290 return ret;
165} 291}
166 292
167/* 293static int vr_set(struct task_struct *target, const struct user_regset *regset,
168 * Write contents of AltiVec register state into task TASK. 294 unsigned int pos, unsigned int count,
169 */ 295 const void *kbuf, const void __user *ubuf)
170static int set_vrregs(struct task_struct *task, unsigned long __user *data)
171{ 296{
172 unsigned long regsize; 297 int ret;
173 298
174 /* copy AltiVec registers VR[0] .. VR[31] */ 299 flush_altivec_to_thread(target);
175 regsize = 32 * sizeof(vector128);
176 if (copy_from_user(task->thread.vr, data, regsize))
177 return -EFAULT;
178 data += (regsize / sizeof(unsigned long));
179 300
180 /* copy VSCR */ 301 BUILD_BUG_ON(offsetof(struct thread_struct, vscr) !=
181 regsize = 1 * sizeof(vector128); 302 offsetof(struct thread_struct, vr[32]));
182 if (copy_from_user(&task->thread.vscr, data, regsize))
183 return -EFAULT;
184 data += (regsize / sizeof(unsigned long));
185 303
186 /* copy VRSAVE */ 304 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
187 if (get_user(task->thread.vrsave, (u32 __user *)data)) 305 &target->thread.vr, 0, 33 * sizeof(vector128));
188 return -EFAULT; 306 if (!ret && count > 0) {
307 /*
308 * We use only the first word of vrsave.
309 */
310 union {
311 elf_vrreg_t reg;
312 u32 word;
313 } vrsave;
314 memset(&vrsave, 0, sizeof(vrsave));
315 vrsave.word = target->thread.vrsave;
316 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &vrsave,
317 33 * sizeof(vector128), -1);
318 if (!ret)
319 target->thread.vrsave = vrsave.word;
320 }
189 321
190 return 0; 322 return ret;
191} 323}
192#endif /* CONFIG_ALTIVEC */ 324#endif /* CONFIG_ALTIVEC */
193 325
@@ -203,57 +335,273 @@ static int set_vrregs(struct task_struct *task, unsigned long __user *data)
203 * } 335 * }
204 */ 336 */
205 337
206/* 338static int evr_active(struct task_struct *target,
207 * Get contents of SPE register state in task TASK. 339 const struct user_regset *regset)
208 */
209static int get_evrregs(unsigned long *data, struct task_struct *task)
210{ 340{
211 int i; 341 flush_spe_to_thread(target);
342 return target->thread.used_spe ? regset->n : 0;
343}
212 344
213 if (!access_ok(VERIFY_WRITE, data, 35 * sizeof(unsigned long))) 345static int evr_get(struct task_struct *target, const struct user_regset *regset,
214 return -EFAULT; 346 unsigned int pos, unsigned int count,
347 void *kbuf, void __user *ubuf)
348{
349 int ret;
215 350
216 /* copy SPEFSCR */ 351 flush_spe_to_thread(target);
217 if (__put_user(task->thread.spefscr, &data[34]))
218 return -EFAULT;
219 352
220 /* copy SPE registers EVR[0] .. EVR[31] */ 353 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
221 for (i = 0; i < 32; i++, data++) 354 &target->thread.evr,
222 if (__put_user(task->thread.evr[i], data)) 355 0, sizeof(target->thread.evr));
223 return -EFAULT;
224 356
225 /* copy ACC */ 357 BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
226 if (__put_user64(task->thread.acc, (unsigned long long *)data)) 358 offsetof(struct thread_struct, spefscr));
227 return -EFAULT;
228 359
229 return 0; 360 if (!ret)
361 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
362 &target->thread.acc,
363 sizeof(target->thread.evr), -1);
364
365 return ret;
366}
367
368static int evr_set(struct task_struct *target, const struct user_regset *regset,
369 unsigned int pos, unsigned int count,
370 const void *kbuf, const void __user *ubuf)
371{
372 int ret;
373
374 flush_spe_to_thread(target);
375
376 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
377 &target->thread.evr,
378 0, sizeof(target->thread.evr));
379
380 BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
381 offsetof(struct thread_struct, spefscr));
382
383 if (!ret)
384 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
385 &target->thread.acc,
386 sizeof(target->thread.evr), -1);
387
388 return ret;
230} 389}
390#endif /* CONFIG_SPE */
391
231 392
232/* 393/*
233 * Write contents of SPE register state into task TASK. 394 * These are our native regset flavors.
234 */ 395 */
235static int set_evrregs(struct task_struct *task, unsigned long *data) 396enum powerpc_regset {
397 REGSET_GPR,
398 REGSET_FPR,
399#ifdef CONFIG_ALTIVEC
400 REGSET_VMX,
401#endif
402#ifdef CONFIG_SPE
403 REGSET_SPE,
404#endif
405};
406
407static const struct user_regset native_regsets[] = {
408 [REGSET_GPR] = {
409 .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
410 .size = sizeof(long), .align = sizeof(long),
411 .get = gpr_get, .set = gpr_set
412 },
413 [REGSET_FPR] = {
414 .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
415 .size = sizeof(double), .align = sizeof(double),
416 .get = fpr_get, .set = fpr_set
417 },
418#ifdef CONFIG_ALTIVEC
419 [REGSET_VMX] = {
420 .core_note_type = NT_PPC_VMX, .n = 34,
421 .size = sizeof(vector128), .align = sizeof(vector128),
422 .active = vr_active, .get = vr_get, .set = vr_set
423 },
424#endif
425#ifdef CONFIG_SPE
426 [REGSET_SPE] = {
427 .n = 35,
428 .size = sizeof(u32), .align = sizeof(u32),
429 .active = evr_active, .get = evr_get, .set = evr_set
430 },
431#endif
432};
433
434static const struct user_regset_view user_ppc_native_view = {
435 .name = UTS_MACHINE, .e_machine = ELF_ARCH, .ei_osabi = ELF_OSABI,
436 .regsets = native_regsets, .n = ARRAY_SIZE(native_regsets)
437};
438
439#ifdef CONFIG_PPC64
440#include <linux/compat.h>
441
442static int gpr32_get(struct task_struct *target,
443 const struct user_regset *regset,
444 unsigned int pos, unsigned int count,
445 void *kbuf, void __user *ubuf)
236{ 446{
237 int i; 447 const unsigned long *regs = &target->thread.regs->gpr[0];
448 compat_ulong_t *k = kbuf;
449 compat_ulong_t __user *u = ubuf;
450 compat_ulong_t reg;
451
452 if (target->thread.regs == NULL)
453 return -EIO;
454
455 CHECK_FULL_REGS(target->thread.regs);
238 456
239 if (!access_ok(VERIFY_READ, data, 35 * sizeof(unsigned long))) 457 pos /= sizeof(reg);
240 return -EFAULT; 458 count /= sizeof(reg);
241 459
242 /* copy SPEFSCR */ 460 if (kbuf)
243 if (__get_user(task->thread.spefscr, &data[34])) 461 for (; count > 0 && pos < PT_MSR; --count)
244 return -EFAULT; 462 *k++ = regs[pos++];
463 else
464 for (; count > 0 && pos < PT_MSR; --count)
465 if (__put_user((compat_ulong_t) regs[pos++], u++))
466 return -EFAULT;
245 467
246 /* copy SPE registers EVR[0] .. EVR[31] */ 468 if (count > 0 && pos == PT_MSR) {
247 for (i = 0; i < 32; i++, data++) 469 reg = get_user_msr(target);
248 if (__get_user(task->thread.evr[i], data)) 470 if (kbuf)
471 *k++ = reg;
472 else if (__put_user(reg, u++))
249 return -EFAULT; 473 return -EFAULT;
250 /* copy ACC */ 474 ++pos;
251 if (__get_user64(task->thread.acc, (unsigned long long*)data)) 475 --count;
252 return -EFAULT; 476 }
253 477
254 return 0; 478 if (kbuf)
479 for (; count > 0 && pos < PT_REGS_COUNT; --count)
480 *k++ = regs[pos++];
481 else
482 for (; count > 0 && pos < PT_REGS_COUNT; --count)
483 if (__put_user((compat_ulong_t) regs[pos++], u++))
484 return -EFAULT;
485
486 kbuf = k;
487 ubuf = u;
488 pos *= sizeof(reg);
489 count *= sizeof(reg);
490 return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
491 PT_REGS_COUNT * sizeof(reg), -1);
492}
493
494static int gpr32_set(struct task_struct *target,
495 const struct user_regset *regset,
496 unsigned int pos, unsigned int count,
497 const void *kbuf, const void __user *ubuf)
498{
499 unsigned long *regs = &target->thread.regs->gpr[0];
500 const compat_ulong_t *k = kbuf;
501 const compat_ulong_t __user *u = ubuf;
502 compat_ulong_t reg;
503
504 if (target->thread.regs == NULL)
505 return -EIO;
506
507 CHECK_FULL_REGS(target->thread.regs);
508
509 pos /= sizeof(reg);
510 count /= sizeof(reg);
511
512 if (kbuf)
513 for (; count > 0 && pos < PT_MSR; --count)
514 regs[pos++] = *k++;
515 else
516 for (; count > 0 && pos < PT_MSR; --count) {
517 if (__get_user(reg, u++))
518 return -EFAULT;
519 regs[pos++] = reg;
520 }
521
522
523 if (count > 0 && pos == PT_MSR) {
524 if (kbuf)
525 reg = *k++;
526 else if (__get_user(reg, u++))
527 return -EFAULT;
528 set_user_msr(target, reg);
529 ++pos;
530 --count;
531 }
532
533 if (kbuf)
534 for (; count > 0 && pos <= PT_MAX_PUT_REG; --count)
535 regs[pos++] = *k++;
536 else
537 for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) {
538 if (__get_user(reg, u++))
539 return -EFAULT;
540 regs[pos++] = reg;
541 }
542
543 if (count > 0 && pos == PT_TRAP) {
544 if (kbuf)
545 reg = *k++;
546 else if (__get_user(reg, u++))
547 return -EFAULT;
548 set_user_trap(target, reg);
549 ++pos;
550 --count;
551 }
552
553 kbuf = k;
554 ubuf = u;
555 pos *= sizeof(reg);
556 count *= sizeof(reg);
557 return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
558 (PT_TRAP + 1) * sizeof(reg), -1);
559}
560
561/*
562 * These are the regset flavors matching the CONFIG_PPC32 native set.
563 */
564static const struct user_regset compat_regsets[] = {
565 [REGSET_GPR] = {
566 .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
567 .size = sizeof(compat_long_t), .align = sizeof(compat_long_t),
568 .get = gpr32_get, .set = gpr32_set
569 },
570 [REGSET_FPR] = {
571 .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
572 .size = sizeof(double), .align = sizeof(double),
573 .get = fpr_get, .set = fpr_set
574 },
575#ifdef CONFIG_ALTIVEC
576 [REGSET_VMX] = {
577 .core_note_type = NT_PPC_VMX, .n = 34,
578 .size = sizeof(vector128), .align = sizeof(vector128),
579 .active = vr_active, .get = vr_get, .set = vr_set
580 },
581#endif
582#ifdef CONFIG_SPE
583 [REGSET_SPE] = {
584 .core_note_type = NT_PPC_SPE, .n = 35,
585 .size = sizeof(u32), .align = sizeof(u32),
586 .active = evr_active, .get = evr_get, .set = evr_set
587 },
588#endif
589};
590
591static const struct user_regset_view user_ppc_compat_view = {
592 .name = "ppc", .e_machine = EM_PPC, .ei_osabi = ELF_OSABI,
593 .regsets = compat_regsets, .n = ARRAY_SIZE(compat_regsets)
594};
595#endif /* CONFIG_PPC64 */
596
597const struct user_regset_view *task_user_regset_view(struct task_struct *task)
598{
599#ifdef CONFIG_PPC64
600 if (test_tsk_thread_flag(task, TIF_32BIT))
601 return &user_ppc_compat_view;
602#endif
603 return &user_ppc_native_view;
255} 604}
256#endif /* CONFIG_SPE */
257 605
258 606
259void user_enable_single_step(struct task_struct *task) 607void user_enable_single_step(struct task_struct *task)
@@ -323,55 +671,29 @@ void ptrace_disable(struct task_struct *child)
323static long arch_ptrace_old(struct task_struct *child, long request, long addr, 671static long arch_ptrace_old(struct task_struct *child, long request, long addr,
324 long data) 672 long data)
325{ 673{
326 int ret = -EPERM; 674 switch (request) {
327 675 case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */
328 switch(request) { 676 return copy_regset_to_user(child, &user_ppc_native_view,
329 case PPC_PTRACE_GETREGS: { /* Get GPRs 0 - 31. */ 677 REGSET_GPR, 0, 32 * sizeof(long),
330 int i; 678 (void __user *) data);
331 unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; 679
332 unsigned long __user *tmp = (unsigned long __user *)addr; 680 case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */
333 681 return copy_regset_from_user(child, &user_ppc_native_view,
334 CHECK_FULL_REGS(child->thread.regs); 682 REGSET_GPR, 0, 32 * sizeof(long),
335 for (i = 0; i < 32; i++) { 683 (const void __user *) data);
336 ret = put_user(*reg, tmp); 684
337 if (ret) 685 case PPC_PTRACE_GETFPREGS: /* Get FPRs 0 - 31. */
338 break; 686 return copy_regset_to_user(child, &user_ppc_native_view,
339 reg++; 687 REGSET_FPR, 0, 32 * sizeof(double),
340 tmp++; 688 (void __user *) data);
341 } 689
342 break; 690 case PPC_PTRACE_SETFPREGS: /* Set FPRs 0 - 31. */
343 } 691 return copy_regset_from_user(child, &user_ppc_native_view,
344 692 REGSET_FPR, 0, 32 * sizeof(double),
345 case PPC_PTRACE_SETREGS: { /* Set GPRs 0 - 31. */ 693 (const void __user *) data);
346 int i;
347 unsigned long *reg = &((unsigned long *)child->thread.regs)[0];
348 unsigned long __user *tmp = (unsigned long __user *)addr;
349
350 CHECK_FULL_REGS(child->thread.regs);
351 for (i = 0; i < 32; i++) {
352 ret = get_user(*reg, tmp);
353 if (ret)
354 break;
355 reg++;
356 tmp++;
357 }
358 break;
359 }
360
361 case PPC_PTRACE_GETFPREGS: { /* Get FPRs 0 - 31. */
362 flush_fp_to_thread(child);
363 ret = get_fpregs((void __user *)addr, child, 0);
364 break;
365 }
366
367 case PPC_PTRACE_SETFPREGS: { /* Get FPRs 0 - 31. */
368 flush_fp_to_thread(child);
369 ret = set_fpregs((void __user *)addr, child, 0);
370 break;
371 } 694 }
372 695
373 } 696 return -EPERM;
374 return ret;
375} 697}
376 698
377long arch_ptrace(struct task_struct *child, long request, long addr, long data) 699long arch_ptrace(struct task_struct *child, long request, long addr, long data)
@@ -379,12 +701,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
379 int ret = -EPERM; 701 int ret = -EPERM;
380 702
381 switch (request) { 703 switch (request) {
382 /* when I and D space are separate, these will need to be fixed. */
383 case PTRACE_PEEKTEXT: /* read word at location addr. */
384 case PTRACE_PEEKDATA:
385 ret = generic_ptrace_peekdata(child, addr, data);
386 break;
387
388 /* read the word at location addr in the USER area. */ 704 /* read the word at location addr in the USER area. */
389 case PTRACE_PEEKUSR: { 705 case PTRACE_PEEKUSR: {
390 unsigned long index, tmp; 706 unsigned long index, tmp;
@@ -412,12 +728,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
412 break; 728 break;
413 } 729 }
414 730
415 /* If I and D space are separate, this will have to be fixed. */
416 case PTRACE_POKETEXT: /* write the word at location addr. */
417 case PTRACE_POKEDATA:
418 ret = generic_ptrace_pokedata(child, addr, data);
419 break;
420
421 /* write the word at location addr in the USER area */ 731 /* write the word at location addr in the USER area */
422 case PTRACE_POKEUSR: { 732 case PTRACE_POKEUSR: {
423 unsigned long index; 733 unsigned long index;
@@ -462,85 +772,60 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
462#ifdef CONFIG_PPC64 772#ifdef CONFIG_PPC64
463 case PTRACE_GETREGS64: 773 case PTRACE_GETREGS64:
464#endif 774#endif
465 case PTRACE_GETREGS: { /* Get all pt_regs from the child. */ 775 case PTRACE_GETREGS: /* Get all pt_regs from the child. */
466 int ui; 776 return copy_regset_to_user(child, &user_ppc_native_view,
467 if (!access_ok(VERIFY_WRITE, (void __user *)data, 777 REGSET_GPR,
468 sizeof(struct pt_regs))) { 778 0, sizeof(struct pt_regs),
469 ret = -EIO; 779 (void __user *) data);
470 break;
471 }
472 CHECK_FULL_REGS(child->thread.regs);
473 ret = 0;
474 for (ui = 0; ui < PT_REGS_COUNT; ui ++) {
475 ret |= __put_user(ptrace_get_reg(child, ui),
476 (unsigned long __user *) data);
477 data += sizeof(long);
478 }
479 break;
480 }
481 780
482#ifdef CONFIG_PPC64 781#ifdef CONFIG_PPC64
483 case PTRACE_SETREGS64: 782 case PTRACE_SETREGS64:
484#endif 783#endif
485 case PTRACE_SETREGS: { /* Set all gp regs in the child. */ 784 case PTRACE_SETREGS: /* Set all gp regs in the child. */
486 unsigned long tmp; 785 return copy_regset_from_user(child, &user_ppc_native_view,
487 int ui; 786 REGSET_GPR,
488 if (!access_ok(VERIFY_READ, (void __user *)data, 787 0, sizeof(struct pt_regs),
489 sizeof(struct pt_regs))) { 788 (const void __user *) data);
490 ret = -EIO; 789
491 break; 790 case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */
492 } 791 return copy_regset_to_user(child, &user_ppc_native_view,
493 CHECK_FULL_REGS(child->thread.regs); 792 REGSET_FPR,
494 ret = 0; 793 0, sizeof(elf_fpregset_t),
495 for (ui = 0; ui < PT_REGS_COUNT; ui ++) { 794 (void __user *) data);
496 ret = __get_user(tmp, (unsigned long __user *) data); 795
497 if (ret) 796 case PTRACE_SETFPREGS: /* Set the child FPU state (FPR0...31 + FPSCR) */
498 break; 797 return copy_regset_from_user(child, &user_ppc_native_view,
499 ptrace_put_reg(child, ui, tmp); 798 REGSET_FPR,
500 data += sizeof(long); 799 0, sizeof(elf_fpregset_t),
501 } 800 (const void __user *) data);
502 break;
503 }
504
505 case PTRACE_GETFPREGS: { /* Get the child FPU state (FPR0...31 + FPSCR) */
506 flush_fp_to_thread(child);
507 ret = get_fpregs((void __user *)data, child, 1);
508 break;
509 }
510
511 case PTRACE_SETFPREGS: { /* Set the child FPU state (FPR0...31 + FPSCR) */
512 flush_fp_to_thread(child);
513 ret = set_fpregs((void __user *)data, child, 1);
514 break;
515 }
516 801
517#ifdef CONFIG_ALTIVEC 802#ifdef CONFIG_ALTIVEC
518 case PTRACE_GETVRREGS: 803 case PTRACE_GETVRREGS:
519 /* Get the child altivec register state. */ 804 return copy_regset_to_user(child, &user_ppc_native_view,
520 flush_altivec_to_thread(child); 805 REGSET_VMX,
521 ret = get_vrregs((unsigned long __user *)data, child); 806 0, (33 * sizeof(vector128) +
522 break; 807 sizeof(u32)),
808 (void __user *) data);
523 809
524 case PTRACE_SETVRREGS: 810 case PTRACE_SETVRREGS:
525 /* Set the child altivec register state. */ 811 return copy_regset_from_user(child, &user_ppc_native_view,
526 flush_altivec_to_thread(child); 812 REGSET_VMX,
527 ret = set_vrregs(child, (unsigned long __user *)data); 813 0, (33 * sizeof(vector128) +
528 break; 814 sizeof(u32)),
815 (const void __user *) data);
529#endif 816#endif
530#ifdef CONFIG_SPE 817#ifdef CONFIG_SPE
531 case PTRACE_GETEVRREGS: 818 case PTRACE_GETEVRREGS:
532 /* Get the child spe register state. */ 819 /* Get the child spe register state. */
533 flush_spe_to_thread(child); 820 return copy_regset_to_user(child, &user_ppc_native_view,
534 ret = get_evrregs((unsigned long __user *)data, child); 821 REGSET_SPE, 0, 35 * sizeof(u32),
535 break; 822 (void __user *) data);
536 823
537 case PTRACE_SETEVRREGS: 824 case PTRACE_SETEVRREGS:
538 /* Set the child spe register state. */ 825 /* Set the child spe register state. */
539 /* this is to clear the MSR_SPE bit to force a reload 826 return copy_regset_from_user(child, &user_ppc_native_view,
540 * of register state from memory */ 827 REGSET_SPE, 0, 35 * sizeof(u32),
541 flush_spe_to_thread(child); 828 (const void __user *) data);
542 ret = set_evrregs(child, (unsigned long __user *)data);
543 break;
544#endif 829#endif
545 830
546 /* Old reverse args ptrace callss */ 831 /* Old reverse args ptrace callss */
diff --git a/arch/powerpc/kernel/ptrace32.c b/arch/powerpc/kernel/ptrace32.c
index fea6206ff90f..4c1de6af4c09 100644
--- a/arch/powerpc/kernel/ptrace32.c
+++ b/arch/powerpc/kernel/ptrace32.c
@@ -24,9 +24,11 @@
24#include <linux/smp_lock.h> 24#include <linux/smp_lock.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/ptrace.h> 26#include <linux/ptrace.h>
27#include <linux/regset.h>
27#include <linux/user.h> 28#include <linux/user.h>
28#include <linux/security.h> 29#include <linux/security.h>
29#include <linux/signal.h> 30#include <linux/signal.h>
31#include <linux/compat.h>
30 32
31#include <asm/uaccess.h> 33#include <asm/uaccess.h>
32#include <asm/page.h> 34#include <asm/page.h>
@@ -45,87 +47,31 @@
45static long compat_ptrace_old(struct task_struct *child, long request, 47static long compat_ptrace_old(struct task_struct *child, long request,
46 long addr, long data) 48 long addr, long data)
47{ 49{
48 int ret = -EPERM; 50 switch (request) {
49 51 case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */
50 switch(request) { 52 return copy_regset_to_user(child,
51 case PPC_PTRACE_GETREGS: { /* Get GPRs 0 - 31. */ 53 task_user_regset_view(current), 0,
52 int i; 54 0, 32 * sizeof(compat_long_t),
53 unsigned long *reg = &((unsigned long *)child->thread.regs)[0]; 55 compat_ptr(data));
54 unsigned int __user *tmp = (unsigned int __user *)addr; 56
55 57 case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */
56 CHECK_FULL_REGS(child->thread.regs); 58 return copy_regset_from_user(child,
57 for (i = 0; i < 32; i++) { 59 task_user_regset_view(current), 0,
58 ret = put_user(*reg, tmp); 60 0, 32 * sizeof(compat_long_t),
59 if (ret) 61 compat_ptr(data));
60 break;
61 reg++;
62 tmp++;
63 }
64 break;
65 }
66
67 case PPC_PTRACE_SETREGS: { /* Set GPRs 0 - 31. */
68 int i;
69 unsigned long *reg = &((unsigned long *)child->thread.regs)[0];
70 unsigned int __user *tmp = (unsigned int __user *)addr;
71
72 CHECK_FULL_REGS(child->thread.regs);
73 for (i = 0; i < 32; i++) {
74 ret = get_user(*reg, tmp);
75 if (ret)
76 break;
77 reg++;
78 tmp++;
79 }
80 break;
81 } 62 }
82 63
83 } 64 return -EPERM;
84 return ret;
85} 65}
86 66
87long compat_sys_ptrace(int request, int pid, unsigned long addr, 67long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
88 unsigned long data) 68 compat_ulong_t caddr, compat_ulong_t cdata)
89{ 69{
90 struct task_struct *child; 70 unsigned long addr = caddr;
71 unsigned long data = cdata;
91 int ret; 72 int ret;
92 73
93 lock_kernel();
94 if (request == PTRACE_TRACEME) {
95 ret = ptrace_traceme();
96 goto out;
97 }
98
99 child = ptrace_get_task_struct(pid);
100 if (IS_ERR(child)) {
101 ret = PTR_ERR(child);
102 goto out;
103 }
104
105 if (request == PTRACE_ATTACH) {
106 ret = ptrace_attach(child);
107 goto out_tsk;
108 }
109
110 ret = ptrace_check_attach(child, request == PTRACE_KILL);
111 if (ret < 0)
112 goto out_tsk;
113
114 switch (request) { 74 switch (request) {
115 /* when I and D space are separate, these will need to be fixed. */
116 case PTRACE_PEEKTEXT: /* read word at location addr. */
117 case PTRACE_PEEKDATA: {
118 unsigned int tmp;
119 int copied;
120
121 copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
122 ret = -EIO;
123 if (copied != sizeof(tmp))
124 break;
125 ret = put_user(tmp, (u32 __user *)data);
126 break;
127 }
128
129 /* 75 /*
130 * Read 4 bytes of the other process' storage 76 * Read 4 bytes of the other process' storage
131 * data is a pointer specifying where the user wants the 77 * data is a pointer specifying where the user wants the
@@ -225,19 +171,6 @@ long compat_sys_ptrace(int request, int pid, unsigned long addr,
225 break; 171 break;
226 } 172 }
227 173
228 /* If I and D space are separate, this will have to be fixed. */
229 case PTRACE_POKETEXT: /* write the word at location addr. */
230 case PTRACE_POKEDATA: {
231 unsigned int tmp;
232 tmp = data;
233 ret = 0;
234 if (access_process_vm(child, addr, &tmp, sizeof(tmp), 1)
235 == sizeof(tmp))
236 break;
237 ret = -EIO;
238 break;
239 }
240
241 /* 174 /*
242 * Write 4 bytes into the other process' storage 175 * Write 4 bytes into the other process' storage
243 * data is the 4 bytes that the user wants written 176 * data is the 4 bytes that the user wants written
@@ -337,46 +270,17 @@ long compat_sys_ptrace(int request, int pid, unsigned long addr,
337 break; 270 break;
338 } 271 }
339 272
340 case PTRACE_GETEVENTMSG: 273 case PTRACE_GETREGS: /* Get all pt_regs from the child. */
341 ret = put_user(child->ptrace_message, (unsigned int __user *) data); 274 return copy_regset_to_user(
342 break; 275 child, task_user_regset_view(current), 0,
276 0, PT_REGS_COUNT * sizeof(compat_long_t),
277 compat_ptr(data));
343 278
344 case PTRACE_GETREGS: { /* Get all pt_regs from the child. */ 279 case PTRACE_SETREGS: /* Set all gp regs in the child. */
345 int ui; 280 return copy_regset_from_user(
346 if (!access_ok(VERIFY_WRITE, (void __user *)data, 281 child, task_user_regset_view(current), 0,
347 PT_REGS_COUNT * sizeof(int))) { 282 0, PT_REGS_COUNT * sizeof(compat_long_t),
348 ret = -EIO; 283 compat_ptr(data));
349 break;
350 }
351 CHECK_FULL_REGS(child->thread.regs);
352 ret = 0;
353 for (ui = 0; ui < PT_REGS_COUNT; ui ++) {
354 ret |= __put_user(ptrace_get_reg(child, ui),
355 (unsigned int __user *) data);
356 data += sizeof(int);
357 }
358 break;
359 }
360
361 case PTRACE_SETREGS: { /* Set all gp regs in the child. */
362 unsigned long tmp;
363 int ui;
364 if (!access_ok(VERIFY_READ, (void __user *)data,
365 PT_REGS_COUNT * sizeof(int))) {
366 ret = -EIO;
367 break;
368 }
369 CHECK_FULL_REGS(child->thread.regs);
370 ret = 0;
371 for (ui = 0; ui < PT_REGS_COUNT; ui ++) {
372 ret = __get_user(tmp, (unsigned int __user *) data);
373 if (ret)
374 break;
375 ptrace_put_reg(child, ui, tmp);
376 data += sizeof(int);
377 }
378 break;
379 }
380 284
381 case PTRACE_GETFPREGS: 285 case PTRACE_GETFPREGS:
382 case PTRACE_SETFPREGS: 286 case PTRACE_SETFPREGS:
@@ -402,12 +306,9 @@ long compat_sys_ptrace(int request, int pid, unsigned long addr,
402 break; 306 break;
403 307
404 default: 308 default:
405 ret = ptrace_request(child, request, addr, data); 309 ret = compat_ptrace_request(child, request, addr, data);
406 break; 310 break;
407 } 311 }
408out_tsk: 312
409 put_task_struct(child);
410out:
411 unlock_kernel();
412 return ret; 313 return ret;
413} 314}
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 848a20475db8..4b5b7ff4f78b 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -54,7 +54,7 @@
54#endif 54#endif
55#include <asm/kexec.h> 55#include <asm/kexec.h>
56 56
57#ifdef CONFIG_DEBUGGER 57#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
58int (*__debugger)(struct pt_regs *regs); 58int (*__debugger)(struct pt_regs *regs);
59int (*__debugger_ipi)(struct pt_regs *regs); 59int (*__debugger_ipi)(struct pt_regs *regs);
60int (*__debugger_bpt)(struct pt_regs *regs); 60int (*__debugger_bpt)(struct pt_regs *regs);
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index f0bad7070fb5..f98867252ee2 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -176,7 +176,7 @@ static void __devinit vio_dev_release(struct device *dev)
176 * Returns a pointer to the created vio_dev or NULL if node has 176 * Returns a pointer to the created vio_dev or NULL if node has
177 * NULL device_type or compatible fields. 177 * NULL device_type or compatible fields.
178 */ 178 */
179struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node) 179struct vio_dev *vio_register_device_node(struct device_node *of_node)
180{ 180{
181 struct vio_dev *viodev; 181 struct vio_dev *viodev;
182 const unsigned int *unit_address; 182 const unsigned int *unit_address;