Skip to content

Commit cfb361f

Browse files
Shaohua Liaegl
authored andcommitted
[IA64] utrace syscall.h support for ia64
Add asm/syscall.h for IA64. Utrace requires this. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent fec6ed1 commit cfb361f

3 files changed

Lines changed: 163 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ struct switch_stack {
240240
*/
241241
# define instruction_pointer(regs) ((regs)->cr_iip + ia64_psr(regs)->ri)
242242

243+
static inline unsigned long user_stack_pointer(struct pt_regs *regs)
244+
{
245+
/* FIXME: should this be bspstore + nr_dirty regs? */
246+
return regs->ar_bspstore;
247+
}
248+
243249
#define regs_return_value(regs) ((regs)->r8)
244250

245251
/* Conserve space in histogram by encoding slot bits in address

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

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Access to user system call parameters and results
3+
*
4+
* Copyright (C) 2008 Intel Corp. Shaohua Li <shaohua.li@intel.com>
5+
*
6+
* This copyrighted material is made available to anyone wishing to use,
7+
* modify, copy, or redistribute it subject to the terms and conditions
8+
* of the GNU General Public License v.2.
9+
*
10+
* See asm-generic/syscall.h for descriptions of what we must do here.
11+
*/
12+
13+
#ifndef _ASM_SYSCALL_H
14+
#define _ASM_SYSCALL_H 1
15+
16+
#include <linux/sched.h>
17+
#include <linux/err.h>
18+
19+
static inline long syscall_get_nr(struct task_struct *task,
20+
struct pt_regs *regs)
21+
{
22+
BUG_ON(IS_IA32_PROCESS(regs));
23+
24+
if ((long)regs->cr_ifs < 0) /* Not a syscall */
25+
return -1;
26+
return regs->r15;
27+
}
28+
29+
static inline void syscall_rollback(struct task_struct *task,
30+
struct pt_regs *regs)
31+
{
32+
BUG_ON(IS_IA32_PROCESS(regs));
33+
/* do nothing */
34+
}
35+
36+
static inline long syscall_get_error(struct task_struct *task,
37+
struct pt_regs *regs)
38+
{
39+
BUG_ON(IS_IA32_PROCESS(regs));
40+
41+
return regs->r10 == -1 ? regs->r8:0;
42+
}
43+
44+
static inline long syscall_get_return_value(struct task_struct *task,
45+
struct pt_regs *regs)
46+
{
47+
BUG_ON(IS_IA32_PROCESS(regs));
48+
49+
return regs->r8;
50+
}
51+
52+
static inline void syscall_set_return_value(struct task_struct *task,
53+
struct pt_regs *regs,
54+
int error, long val)
55+
{
56+
BUG_ON(IS_IA32_PROCESS(regs));
57+
58+
if (error) {
59+
/* error < 0, but ia64 uses > 0 return value */
60+
regs->r8 = -error;
61+
regs->r10 = -1;
62+
} else {
63+
regs->r8 = val;
64+
regs->r10 = 0;
65+
}
66+
}
67+
68+
extern void ia64_syscall_get_set_arguments(struct task_struct *task,
69+
struct pt_regs *regs, unsigned int i, unsigned int n,
70+
unsigned long *args, int rw);
71+
static inline void syscall_get_arguments(struct task_struct *task,
72+
struct pt_regs *regs,
73+
unsigned int i, unsigned int n,
74+
unsigned long *args)
75+
{
76+
BUG_ON(IS_IA32_PROCESS(regs));
77+
BUG_ON(i + n > 6);
78+
79+
ia64_syscall_get_set_arguments(task, regs, i, n, args, 0);
80+
}
81+
82+
static inline void syscall_set_arguments(struct task_struct *task,
83+
struct pt_regs *regs,
84+
unsigned int i, unsigned int n,
85+
unsigned long *args)
86+
{
87+
BUG_ON(IS_IA32_PROCESS(regs));
88+
BUG_ON(i + n > 6);
89+
90+
ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
91+
}
92+
#endif /* _ASM_SYSCALL_H */

‎arch/ia64/kernel/ptrace.c‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,3 +2199,68 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *tsk)
21992199
#endif
22002200
return &user_ia64_view;
22012201
}
2202+
2203+
struct syscall_get_set_args {
2204+
unsigned int i;
2205+
unsigned int n;
2206+
unsigned long *args;
2207+
struct pt_regs *regs;
2208+
int rw;
2209+
};
2210+
2211+
static void syscall_get_set_args_cb(struct unw_frame_info *info, void *data)
2212+
{
2213+
struct syscall_get_set_args *args = data;
2214+
struct pt_regs *pt = args->regs;
2215+
unsigned long *krbs, cfm, ndirty;
2216+
int i, count;
2217+
2218+
if (unw_unwind_to_user(info) < 0)
2219+
return;
2220+
2221+
cfm = pt->cr_ifs;
2222+
krbs = (unsigned long *)info->task + IA64_RBS_OFFSET/8;
2223+
ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19));
2224+
2225+
count = 0;
2226+
if (in_syscall(pt))
2227+
count = min_t(int, args->n, cfm & 0x7f);
2228+
2229+
for (i = 0; i < count; i++) {
2230+
if (args->rw)
2231+
*ia64_rse_skip_regs(krbs, ndirty + i + args->i) =
2232+
args->args[i];
2233+
else
2234+
args->args[i] = *ia64_rse_skip_regs(krbs,
2235+
ndirty + i + args->i);
2236+
}
2237+
2238+
if (!args->rw) {
2239+
while (i < args->n) {
2240+
args->args[i] = 0;
2241+
i++;
2242+
}
2243+
}
2244+
}
2245+
2246+
void ia64_syscall_get_set_arguments(struct task_struct *task,
2247+
struct pt_regs *regs, unsigned int i, unsigned int n,
2248+
unsigned long *args, int rw)
2249+
{
2250+
struct syscall_get_set_args data = {
2251+
.i = i,
2252+
.n = n,
2253+
.args = args,
2254+
.regs = regs,
2255+
.rw = rw,
2256+
};
2257+
2258+
if (task == current)
2259+
unw_init_running(syscall_get_set_args_cb, &data);
2260+
else {
2261+
struct unw_frame_info ufi;
2262+
memset(&ufi, 0, sizeof(ufi));
2263+
unw_init_from_blocked_task(&ufi, task);
2264+
syscall_get_set_args_cb(&ufi, &data);
2265+
}
2266+
}

0 commit comments

Comments
 (0)