Skip to content

Commit 680973e

Browse files
Shaohua Liaegl
authored andcommitted
[IA64] utrace Convert compat ptrace to use compat_sys_ptrace
Convert IA64 32-bit ptrace to use compat_sys_ptrace. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent 9690ad0 commit 680973e

4 files changed

Lines changed: 89 additions & 87 deletions

File tree

‎arch/ia64/ia32/ia32_entry.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ ia32_syscall_table:
204204
data8 sys_setuid /* 16-bit version */
205205
data8 sys_getuid /* 16-bit version */
206206
data8 compat_sys_stime /* 25 */
207-
data8 sys32_ptrace
207+
data8 compat_sys_ptrace
208208
data8 sys32_alarm
209209
data8 sys_ni_syscall
210210
data8 sys32_pause

‎arch/ia64/ia32/sys_ia32.c‎

Lines changed: 6 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,25 +1300,6 @@ sys32_waitpid (int pid, unsigned int *stat_addr, int options)
13001300
return compat_sys_wait4(pid, stat_addr, options, NULL);
13011301
}
13021302

1303-
static unsigned int
1304-
ia32_peek (struct task_struct *child, unsigned long addr, unsigned int *val)
1305-
{
1306-
size_t copied;
1307-
unsigned int ret;
1308-
1309-
copied = access_process_vm(child, addr, val, sizeof(*val), 0);
1310-
return (copied != sizeof(ret)) ? -EIO : 0;
1311-
}
1312-
1313-
static unsigned int
1314-
ia32_poke (struct task_struct *child, unsigned long addr, unsigned int val)
1315-
{
1316-
1317-
if (access_process_vm(child, addr, &val, sizeof(val), 1) != sizeof(val))
1318-
return -EIO;
1319-
return 0;
1320-
}
1321-
13221303
/*
13231304
* The order in which registers are stored in the ptrace regs structure
13241305
*/
@@ -1616,49 +1597,15 @@ restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __u
16161597
return 0;
16171598
}
16181599

1619-
asmlinkage long
1620-
sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data)
1600+
long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
1601+
compat_ulong_t caddr, compat_ulong_t cdata)
16211602
{
1622-
struct task_struct *child;
1623-
unsigned int value, tmp;
1603+
unsigned long addr = caddr;
1604+
unsigned long data = cdata;
1605+
unsigned int tmp;
16241606
long i, ret;
16251607

1626-
lock_kernel();
1627-
if (request == PTRACE_TRACEME) {
1628-
ret = ptrace_traceme();
1629-
goto out;
1630-
}
1631-
1632-
child = ptrace_get_task_struct(pid);
1633-
if (IS_ERR(child)) {
1634-
ret = PTR_ERR(child);
1635-
goto out;
1636-
}
1637-
1638-
if (request == PTRACE_ATTACH) {
1639-
ret = sys_ptrace(request, pid, addr, data);
1640-
goto out_tsk;
1641-
}
1642-
1643-
ret = ptrace_check_attach(child, request == PTRACE_KILL);
1644-
if (ret < 0)
1645-
goto out_tsk;
1646-
16471608
switch (request) {
1648-
case PTRACE_PEEKTEXT:
1649-
case PTRACE_PEEKDATA: /* read word at location addr */
1650-
ret = ia32_peek(child, addr, &value);
1651-
if (ret == 0)
1652-
ret = put_user(value, (unsigned int __user *) compat_ptr(data));
1653-
else
1654-
ret = -EIO;
1655-
goto out_tsk;
1656-
1657-
case PTRACE_POKETEXT:
1658-
case PTRACE_POKEDATA: /* write the word at location addr */
1659-
ret = ia32_poke(child, addr, data);
1660-
goto out_tsk;
1661-
16621609
case PTRACE_PEEKUSR: /* read word at addr in USER area */
16631610
ret = -EIO;
16641611
if ((addr & 3) || addr > 17*sizeof(int))
@@ -1723,27 +1670,9 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data)
17231670
compat_ptr(data));
17241671
break;
17251672

1726-
case PTRACE_GETEVENTMSG:
1727-
ret = put_user(child->ptrace_message, (unsigned int __user *) compat_ptr(data));
1728-
break;
1729-
1730-
case PTRACE_SYSCALL: /* continue, stop after next syscall */
1731-
case PTRACE_CONT: /* restart after signal. */
1732-
case PTRACE_KILL:
1733-
case PTRACE_SINGLESTEP: /* execute chile for one instruction */
1734-
case PTRACE_DETACH: /* detach a process */
1735-
ret = sys_ptrace(request, pid, addr, data);
1736-
break;
1737-
17381673
default:
1739-
ret = ptrace_request(child, request, addr, data);
1740-
break;
1741-
1674+
return compat_ptrace_request(child, request, caddr, cdata);
17421675
}
1743-
out_tsk:
1744-
put_task_struct(child);
1745-
out:
1746-
unlock_kernel();
17471676
return ret;
17481677
}
17491678

‎arch/ia64/include/asm/ptrace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)
325325
#define arch_has_block_step() (1)
326326
extern void user_enable_block_step(struct task_struct *);
327327

328+
#define __ARCH_WANT_COMPAT_SYS_PTRACE
329+
328330
#endif /* !__KERNEL__ */
329331

330332
/* pt_all_user_regs is used for PTRACE_GETREGS PTRACE_SETREGS */

‎arch/ia64/include/asm/syscall.h‎

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,55 @@
1919
static inline long syscall_get_nr(struct task_struct *task,
2020
struct pt_regs *regs)
2121
{
22-
BUG_ON(IS_IA32_PROCESS(regs));
23-
2422
if ((long)regs->cr_ifs < 0) /* Not a syscall */
2523
return -1;
24+
25+
#ifdef CONFIG_IA32_SUPPORT
26+
if (IS_IA32_PROCESS(regs))
27+
return regs->r1;
28+
#endif
29+
2630
return regs->r15;
2731
}
2832

2933
static inline void syscall_rollback(struct task_struct *task,
3034
struct pt_regs *regs)
3135
{
32-
BUG_ON(IS_IA32_PROCESS(regs));
36+
#ifdef CONFIG_IA32_SUPPORT
37+
if (IS_IA32_PROCESS(regs))
38+
regs->r8 = regs->r1;
39+
#endif
40+
3341
/* do nothing */
3442
}
3543

3644
static inline long syscall_get_error(struct task_struct *task,
3745
struct pt_regs *regs)
3846
{
39-
BUG_ON(IS_IA32_PROCESS(regs));
47+
#ifdef CONFIG_IA32_SUPPORT
48+
if (IS_IA32_PROCESS(regs))
49+
return regs->r8;
50+
#endif
4051

4152
return regs->r10 == -1 ? regs->r8:0;
4253
}
4354

4455
static inline long syscall_get_return_value(struct task_struct *task,
4556
struct pt_regs *regs)
4657
{
47-
BUG_ON(IS_IA32_PROCESS(regs));
48-
4958
return regs->r8;
5059
}
5160

5261
static inline void syscall_set_return_value(struct task_struct *task,
5362
struct pt_regs *regs,
5463
int error, long val)
5564
{
56-
BUG_ON(IS_IA32_PROCESS(regs));
65+
#ifdef CONFIG_IA32_SUPPORT
66+
if (IS_IA32_PROCESS(regs)) {
67+
regs->r8 = (long) error ? error : val;
68+
return;
69+
}
70+
#endif
5771

5872
if (error) {
5973
/* error < 0, but ia64 uses > 0 return value */
@@ -73,9 +87,39 @@ static inline void syscall_get_arguments(struct task_struct *task,
7387
unsigned int i, unsigned int n,
7488
unsigned long *args)
7589
{
76-
BUG_ON(IS_IA32_PROCESS(regs));
7790
BUG_ON(i + n > 6);
7891

92+
#ifdef CONFIG_IA32_SUPPORT
93+
if (IS_IA32_PROCESS(regs)) {
94+
switch (i + n) {
95+
case 6:
96+
if (!n--) break;
97+
*args++ = regs->r13;
98+
case 5:
99+
if (!n--) break;
100+
*args++ = regs->r15;
101+
case 4:
102+
if (!n--) break;
103+
*args++ = regs->r14;
104+
case 3:
105+
if (!n--) break;
106+
*args++ = regs->r10;
107+
case 2:
108+
if (!n--) break;
109+
*args++ = regs->r9;
110+
case 1:
111+
if (!n--) break;
112+
*args++ = regs->r11;
113+
case 0:
114+
if (!n--) break;
115+
default:
116+
BUG();
117+
break;
118+
}
119+
120+
return;
121+
}
122+
#endif
79123
ia64_syscall_get_set_arguments(task, regs, i, n, args, 0);
80124
}
81125

@@ -84,9 +128,36 @@ static inline void syscall_set_arguments(struct task_struct *task,
84128
unsigned int i, unsigned int n,
85129
unsigned long *args)
86130
{
87-
BUG_ON(IS_IA32_PROCESS(regs));
88131
BUG_ON(i + n > 6);
89132

133+
#ifdef CONFIG_IA32_SUPPORT
134+
if (IS_IA32_PROCESS(regs)) {
135+
switch (i + n) {
136+
case 6:
137+
if (!n--) break;
138+
regs->r13 = *args++;
139+
case 5:
140+
if (!n--) break;
141+
regs->r15 = *args++;
142+
case 4:
143+
if (!n--) break;
144+
regs->r14 = *args++;
145+
case 3:
146+
if (!n--) break;
147+
regs->r10 = *args++;
148+
case 2:
149+
if (!n--) break;
150+
regs->r9 = *args++;
151+
case 1:
152+
if (!n--) break;
153+
regs->r11 = *args++;
154+
case 0:
155+
if (!n--) break;
156+
}
157+
158+
return;
159+
}
160+
#endif
90161
ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
91162
}
92163
#endif /* _ASM_SYSCALL_H */

0 commit comments

Comments
 (0)