diff options
author | Alex Smith <alex@alex-smith.me.uk> | 2014-07-23 09:40:13 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-08-01 18:06:37 -0400 |
commit | a79ebea620109cf5e58711077177b34d60960898 (patch) | |
tree | d7745b50619c92af16f3b6657a07d5440a37d5c3 /arch/mips/kernel/ptrace.c | |
parent | 457ed7702dcc8ba13e3eea7f2d44d0e18dc76b3f (diff) |
MIPS: ptrace: Fix user pt_regs definition, use in ptrace_{get, set}regs()
In uapi/asm/ptrace.h, a user version of pt_regs is defined wrapped in
ifndef __KERNEL__. This structure definition does not match anything
used by any kernel API, in particular it does not match the format used
by PTRACE_{GET,SET}REGS.
Therefore, replace the structure definition with one matching what is
used by PTRACE_{GET,SET}REGS. The format used by these is the same for
both 32-bit and 64-bit.
Also, change the implementation of PTRACE_{GET,SET}REGS to use this new
structure definition. The structure is renamed to user_pt_regs when
__KERNEL__ is defined to avoid conflicts with the kernel's own pt_regs.
Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7457/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/ptrace.c')
-rw-r--r-- | arch/mips/kernel/ptrace.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 8bd13ed084d2..0fdb91e36137 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
@@ -63,7 +63,7 @@ void ptrace_disable(struct task_struct *child) | |||
63 | * for 32-bit kernels and for 32-bit processes on a 64-bit kernel. | 63 | * for 32-bit kernels and for 32-bit processes on a 64-bit kernel. |
64 | * Registers are sign extended to fill the available space. | 64 | * Registers are sign extended to fill the available space. |
65 | */ | 65 | */ |
66 | int ptrace_getregs(struct task_struct *child, __s64 __user *data) | 66 | int ptrace_getregs(struct task_struct *child, struct user_pt_regs __user *data) |
67 | { | 67 | { |
68 | struct pt_regs *regs; | 68 | struct pt_regs *regs; |
69 | int i; | 69 | int i; |
@@ -74,13 +74,13 @@ int ptrace_getregs(struct task_struct *child, __s64 __user *data) | |||
74 | regs = task_pt_regs(child); | 74 | regs = task_pt_regs(child); |
75 | 75 | ||
76 | for (i = 0; i < 32; i++) | 76 | for (i = 0; i < 32; i++) |
77 | __put_user((long)regs->regs[i], data + i); | 77 | __put_user((long)regs->regs[i], (__s64 __user *)&data->regs[i]); |
78 | __put_user((long)regs->lo, data + EF_LO - EF_R0); | 78 | __put_user((long)regs->lo, (__s64 __user *)&data->lo); |
79 | __put_user((long)regs->hi, data + EF_HI - EF_R0); | 79 | __put_user((long)regs->hi, (__s64 __user *)&data->hi); |
80 | __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0); | 80 | __put_user((long)regs->cp0_epc, (__s64 __user *)&data->cp0_epc); |
81 | __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0); | 81 | __put_user((long)regs->cp0_badvaddr, (__s64 __user *)&data->cp0_badvaddr); |
82 | __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0); | 82 | __put_user((long)regs->cp0_status, (__s64 __user *)&data->cp0_status); |
83 | __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0); | 83 | __put_user((long)regs->cp0_cause, (__s64 __user *)&data->cp0_cause); |
84 | 84 | ||
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
@@ -90,7 +90,7 @@ int ptrace_getregs(struct task_struct *child, __s64 __user *data) | |||
90 | * the 64-bit format. On a 32-bit kernel only the lower order half | 90 | * the 64-bit format. On a 32-bit kernel only the lower order half |
91 | * (according to endianness) will be used. | 91 | * (according to endianness) will be used. |
92 | */ | 92 | */ |
93 | int ptrace_setregs(struct task_struct *child, __s64 __user *data) | 93 | int ptrace_setregs(struct task_struct *child, struct user_pt_regs __user *data) |
94 | { | 94 | { |
95 | struct pt_regs *regs; | 95 | struct pt_regs *regs; |
96 | int i; | 96 | int i; |
@@ -101,10 +101,10 @@ int ptrace_setregs(struct task_struct *child, __s64 __user *data) | |||
101 | regs = task_pt_regs(child); | 101 | regs = task_pt_regs(child); |
102 | 102 | ||
103 | for (i = 0; i < 32; i++) | 103 | for (i = 0; i < 32; i++) |
104 | __get_user(regs->regs[i], data + i); | 104 | __get_user(regs->regs[i], (__s64 __user *)&data->regs[i]); |
105 | __get_user(regs->lo, data + EF_LO - EF_R0); | 105 | __get_user(regs->lo, (__s64 __user *)&data->lo); |
106 | __get_user(regs->hi, data + EF_HI - EF_R0); | 106 | __get_user(regs->hi, (__s64 __user *)&data->hi); |
107 | __get_user(regs->cp0_epc, data + EF_CP0_EPC - EF_R0); | 107 | __get_user(regs->cp0_epc, (__s64 __user *)&data->cp0_epc); |
108 | 108 | ||
109 | /* badvaddr, status, and cause may not be written. */ | 109 | /* badvaddr, status, and cause may not be written. */ |
110 | 110 | ||