Commit 1197f3e0 authored by David Mosberger's avatar David Mosberger Committed by Tony Luck

[IA64] clean up pt_regs accesses

This patch replaces the idiom:

	func (args..., long stack) {
		struct pt_regs *regs = (struct pt_regs *) &stack;

with the more commonly used:

	func (args..., struct pt_regs regs) {

The latter didn't used to work with the very earliest kernels and
compilers (anybody remember egcs?) but gcc-3.3 and probably even
gcc-2.96 don't have a problem with it anymore.

The change also makes sparse happier, since it doesn't like it when
you access memory past the end of the declared size of that variable.
Signed-off-by: default avatarDavid Mosberger-Tang <davidm@hpl.hp.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent d136641e
/* /*
* IA32 Architecture-specific signal handling support. * IA32 Architecture-specific signal handling support.
* *
* Copyright (C) 1999, 2001-2002 Hewlett-Packard Co * Copyright (C) 1999, 2001-2002, 2005 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com> * David Mosberger-Tang <davidm@hpl.hp.com>
* Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com> * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
* Copyright (C) 2000 VA Linux Co * Copyright (C) 2000 VA Linux Co
...@@ -970,11 +970,10 @@ ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -970,11 +970,10 @@ ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
} }
asmlinkage long asmlinkage long
sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
unsigned long stack) int arg6, int arg7, struct pt_regs regs)
{ {
struct pt_regs *regs = (struct pt_regs *) &stack; unsigned long esp = (unsigned int) regs.r12;
unsigned long esp = (unsigned int) regs->r12;
struct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(esp - 8); struct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(esp - 8);
sigset_t set; sigset_t set;
int eax; int eax;
...@@ -993,7 +992,7 @@ sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int ...@@ -993,7 +992,7 @@ sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int
recalc_sigpending(); recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&current->sighand->siglock);
if (restore_sigcontext_ia32(regs, &frame->sc, &eax)) if (restore_sigcontext_ia32(&regs, &frame->sc, &eax))
goto badframe; goto badframe;
return eax; return eax;
...@@ -1003,11 +1002,10 @@ sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int ...@@ -1003,11 +1002,10 @@ sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int
} }
asmlinkage long asmlinkage long
sys32_rt_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, sys32_rt_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4,
unsigned long stack) int arg5, int arg6, int arg7, struct pt_regs regs)
{ {
struct pt_regs *regs = (struct pt_regs *) &stack; unsigned long esp = (unsigned int) regs.r12;
unsigned long esp = (unsigned int) regs->r12;
struct rt_sigframe_ia32 __user *frame = (struct rt_sigframe_ia32 __user *)(esp - 4); struct rt_sigframe_ia32 __user *frame = (struct rt_sigframe_ia32 __user *)(esp - 4);
sigset_t set; sigset_t set;
int eax; int eax;
...@@ -1023,7 +1021,7 @@ sys32_rt_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, ...@@ -1023,7 +1021,7 @@ sys32_rt_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
recalc_sigpending(); recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&current->sighand->siglock);
if (restore_sigcontext_ia32(regs, &frame->uc.uc_mcontext, &eax)) if (restore_sigcontext_ia32(&regs, &frame->uc.uc_mcontext, &eax))
goto badframe; goto badframe;
/* It is more difficult to avoid calling this function than to /* It is more difficult to avoid calling this function than to
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com> * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
* Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
* Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
* Copyright (C) 2000-2003 Hewlett-Packard Co * Copyright (C) 2000-2003, 2005 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com> * David Mosberger-Tang <davidm@hpl.hp.com>
* Copyright (C) 2004 Gordon Jin <gordon.jin@intel.com> * Copyright (C) 2004 Gordon Jin <gordon.jin@intel.com>
* *
...@@ -1436,7 +1436,7 @@ sys32_waitpid (int pid, unsigned int *stat_addr, int options) ...@@ -1436,7 +1436,7 @@ sys32_waitpid (int pid, unsigned int *stat_addr, int options)
} }
static unsigned int static unsigned int
ia32_peek (struct pt_regs *regs, struct task_struct *child, unsigned long addr, unsigned int *val) ia32_peek (struct task_struct *child, unsigned long addr, unsigned int *val)
{ {
size_t copied; size_t copied;
unsigned int ret; unsigned int ret;
...@@ -1446,7 +1446,7 @@ ia32_peek (struct pt_regs *regs, struct task_struct *child, unsigned long addr, ...@@ -1446,7 +1446,7 @@ ia32_peek (struct pt_regs *regs, struct task_struct *child, unsigned long addr,
} }
static unsigned int static unsigned int
ia32_poke (struct pt_regs *regs, struct task_struct *child, unsigned long addr, unsigned int val) ia32_poke (struct task_struct *child, unsigned long addr, unsigned int val)
{ {
if (access_process_vm(child, addr, &val, sizeof(val), 1) != sizeof(val)) if (access_process_vm(child, addr, &val, sizeof(val), 1) != sizeof(val))
...@@ -1751,25 +1751,16 @@ restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __u ...@@ -1751,25 +1751,16 @@ restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __u
return 0; return 0;
} }
/*
* Note that the IA32 version of `ptrace' calls the IA64 routine for
* many of the requests. This will only work for requests that do
* not need access to the calling processes `pt_regs' which is located
* at the address of `stack'. Once we call the IA64 `sys_ptrace' then
* the address of `stack' will not be the address of the `pt_regs'.
*/
asmlinkage long asmlinkage long
sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data)
long arg4, long arg5, long arg6, long arg7, long stack)
{ {
struct pt_regs *regs = (struct pt_regs *) &stack;
struct task_struct *child; struct task_struct *child;
unsigned int value, tmp; unsigned int value, tmp;
long i, ret; long i, ret;
lock_kernel(); lock_kernel();
if (request == PTRACE_TRACEME) { if (request == PTRACE_TRACEME) {
ret = sys_ptrace(request, pid, addr, data, arg4, arg5, arg6, arg7, stack); ret = sys_ptrace(request, pid, addr, data);
goto out; goto out;
} }
...@@ -1786,7 +1777,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, ...@@ -1786,7 +1777,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data,
goto out_tsk; goto out_tsk;
if (request == PTRACE_ATTACH) { if (request == PTRACE_ATTACH) {
ret = sys_ptrace(request, pid, addr, data, arg4, arg5, arg6, arg7, stack); ret = sys_ptrace(request, pid, addr, data);
goto out_tsk; goto out_tsk;
} }
...@@ -1797,7 +1788,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, ...@@ -1797,7 +1788,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data,
switch (request) { switch (request) {
case PTRACE_PEEKTEXT: case PTRACE_PEEKTEXT:
case PTRACE_PEEKDATA: /* read word at location addr */ case PTRACE_PEEKDATA: /* read word at location addr */
ret = ia32_peek(regs, child, addr, &value); ret = ia32_peek(child, addr, &value);
if (ret == 0) if (ret == 0)
ret = put_user(value, (unsigned int __user *) compat_ptr(data)); ret = put_user(value, (unsigned int __user *) compat_ptr(data));
else else
...@@ -1806,7 +1797,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, ...@@ -1806,7 +1797,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data,
case PTRACE_POKETEXT: case PTRACE_POKETEXT:
case PTRACE_POKEDATA: /* write the word at location addr */ case PTRACE_POKEDATA: /* write the word at location addr */
ret = ia32_poke(regs, child, addr, data); ret = ia32_poke(child, addr, data);
goto out_tsk; goto out_tsk;
case PTRACE_PEEKUSR: /* read word at addr in USER area */ case PTRACE_PEEKUSR: /* read word at addr in USER area */
...@@ -1882,7 +1873,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data, ...@@ -1882,7 +1873,7 @@ sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data,
case PTRACE_KILL: case PTRACE_KILL:
case PTRACE_SINGLESTEP: /* execute chile for one instruction */ case PTRACE_SINGLESTEP: /* execute chile for one instruction */
case PTRACE_DETACH: /* detach a process */ case PTRACE_DETACH: /* detach a process */
ret = sys_ptrace(request, pid, addr, data, arg4, arg5, arg6, arg7, stack); ret = sys_ptrace(request, pid, addr, data);
break; break;
default: default:
...@@ -1905,9 +1896,9 @@ typedef struct { ...@@ -1905,9 +1896,9 @@ typedef struct {
asmlinkage long asmlinkage long
sys32_sigaltstack (ia32_stack_t __user *uss32, ia32_stack_t __user *uoss32, sys32_sigaltstack (ia32_stack_t __user *uss32, ia32_stack_t __user *uoss32,
long arg2, long arg3, long arg4, long arg5, long arg6, long arg7, long stack) long arg2, long arg3, long arg4, long arg5, long arg6,
long arg7, struct pt_regs pt)
{ {
struct pt_regs *pt = (struct pt_regs *) &stack;
stack_t uss, uoss; stack_t uss, uoss;
ia32_stack_t buf32; ia32_stack_t buf32;
int ret; int ret;
...@@ -1928,7 +1919,7 @@ sys32_sigaltstack (ia32_stack_t __user *uss32, ia32_stack_t __user *uoss32, ...@@ -1928,7 +1919,7 @@ sys32_sigaltstack (ia32_stack_t __user *uss32, ia32_stack_t __user *uoss32,
} }
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
ret = do_sigaltstack(uss32 ? (stack_t __user *) &uss : NULL, ret = do_sigaltstack(uss32 ? (stack_t __user *) &uss : NULL,
(stack_t __user *) &uoss, pt->r12); (stack_t __user *) &uoss, pt.r12);
current->sas_ss_size = buf32.ss_size; current->sas_ss_size = buf32.ss_size;
set_fs(old_fs); set_fs(old_fs);
out: out:
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
* The initial version of perfmon.c was written by * The initial version of perfmon.c was written by
* Ganesh Venkitachalam, IBM Corp. * Ganesh Venkitachalam, IBM Corp.
* *
* Then it was modified for perfmon-1.x by Stephane Eranian and * Then it was modified for perfmon-1.x by Stephane Eranian and
* David Mosberger, Hewlett Packard Co. * David Mosberger, Hewlett Packard Co.
* *
* Version Perfmon-2.x is a rewrite of perfmon-1.x * Version Perfmon-2.x is a rewrite of perfmon-1.x
* by Stephane Eranian, Hewlett Packard Co. * by Stephane Eranian, Hewlett Packard Co.
* *
* Copyright (C) 1999-2003 Hewlett Packard Co * Copyright (C) 1999-2003, 2005 Hewlett Packard Co
* Stephane Eranian <eranian@hpl.hp.com> * Stephane Eranian <eranian@hpl.hp.com>
* David Mosberger-Tang <davidm@hpl.hp.com> * David Mosberger-Tang <davidm@hpl.hp.com>
* *
...@@ -4778,10 +4778,8 @@ pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags) ...@@ -4778,10 +4778,8 @@ pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags)
* system-call entry point (must return long) * system-call entry point (must return long)
*/ */
asmlinkage long asmlinkage long
sys_perfmonctl (int fd, int cmd, void __user *arg, int count, long arg5, long arg6, long arg7, sys_perfmonctl (int fd, int cmd, void __user *arg, int count)
long arg8, long stack)
{ {
struct pt_regs *regs = (struct pt_regs *)&stack;
struct file *file = NULL; struct file *file = NULL;
pfm_context_t *ctx = NULL; pfm_context_t *ctx = NULL;
unsigned long flags = 0UL; unsigned long flags = 0UL;
...@@ -4905,7 +4903,7 @@ sys_perfmonctl (int fd, int cmd, void __user *arg, int count, long arg5, long ar ...@@ -4905,7 +4903,7 @@ sys_perfmonctl (int fd, int cmd, void __user *arg, int count, long arg5, long ar
if (unlikely(ret)) goto abort_locked; if (unlikely(ret)) goto abort_locked;
skip_fd: skip_fd:
ret = (*func)(ctx, args_k, count, regs); ret = (*func)(ctx, args_k, count, ia64_task_regs(current));
call_made = 1; call_made = 1;
...@@ -6671,8 +6669,7 @@ pfm_inherit(struct task_struct *task, struct pt_regs *regs) ...@@ -6671,8 +6669,7 @@ pfm_inherit(struct task_struct *task, struct pt_regs *regs)
} }
#else /* !CONFIG_PERFMON */ #else /* !CONFIG_PERFMON */
asmlinkage long asmlinkage long
sys_perfmonctl (int fd, int cmd, void *arg, int count, long arg5, long arg6, long arg7, sys_perfmonctl (int fd, int cmd, void *arg, int count)
long arg8, long stack)
{ {
return -ENOSYS; return -ENOSYS;
} }
......
...@@ -1381,10 +1381,9 @@ ptrace_disable (struct task_struct *child) ...@@ -1381,10 +1381,9 @@ ptrace_disable (struct task_struct *child)
} }
asmlinkage long asmlinkage long
sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data, sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data)
long arg4, long arg5, long arg6, long arg7, long stack)
{ {
struct pt_regs *pt, *regs = (struct pt_regs *) &stack; struct pt_regs *pt;
unsigned long urbs_end, peek_or_poke; unsigned long urbs_end, peek_or_poke;
struct task_struct *child; struct task_struct *child;
struct switch_stack *sw; struct switch_stack *sw;
...@@ -1446,7 +1445,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data, ...@@ -1446,7 +1445,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data,
if (ret == 0) { if (ret == 0) {
ret = data; ret = data;
/* ensure "ret" is not mistaken as an error code: */ /* ensure "ret" is not mistaken as an error code: */
regs->r8 = 0; force_successful_syscall_return();
} }
goto out_tsk; goto out_tsk;
...@@ -1465,7 +1464,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data, ...@@ -1465,7 +1464,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data,
} }
ret = data; ret = data;
/* ensure "ret" is not mistaken as an error code */ /* ensure "ret" is not mistaken as an error code */
regs->r8 = 0; force_successful_syscall_return();
goto out_tsk; goto out_tsk;
case PTRACE_POKEUSR: case PTRACE_POKEUSR:
...@@ -1609,16 +1608,16 @@ syscall_trace (void) ...@@ -1609,16 +1608,16 @@ syscall_trace (void)
asmlinkage void asmlinkage void
syscall_trace_enter (long arg0, long arg1, long arg2, long arg3, syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6, long arg7, long stack) long arg4, long arg5, long arg6, long arg7,
struct pt_regs regs)
{ {
struct pt_regs *regs = (struct pt_regs *) &stack;
long syscall; long syscall;
if (unlikely(current->audit_context)) { if (unlikely(current->audit_context)) {
if (IS_IA32_PROCESS(regs)) if (IS_IA32_PROCESS(&regs))
syscall = regs->r1; syscall = regs.r1;
else else
syscall = regs->r15; syscall = regs.r15;
audit_syscall_entry(current, syscall, arg0, arg1, arg2, arg3); audit_syscall_entry(current, syscall, arg0, arg1, arg2, arg3);
} }
...@@ -1632,10 +1631,11 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3, ...@@ -1632,10 +1631,11 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
asmlinkage void asmlinkage void
syscall_trace_leave (long arg0, long arg1, long arg2, long arg3, syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6, long arg7, long stack) long arg4, long arg5, long arg6, long arg7,
struct pt_regs regs)
{ {
if (unlikely(current->audit_context)) if (unlikely(current->audit_context))
audit_syscall_exit(current, ((struct pt_regs *) &stack)->r8); audit_syscall_exit(current, regs.r8);
if (test_thread_flag(TIF_SYSCALL_TRACE) if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED)) && (current->ptrace & PT_PTRACED))
......
...@@ -84,12 +84,11 @@ ia64_rt_sigsuspend (sigset_t __user *uset, size_t sigsetsize, struct sigscratch ...@@ -84,12 +84,11 @@ ia64_rt_sigsuspend (sigset_t __user *uset, size_t sigsetsize, struct sigscratch
} }
asmlinkage long asmlinkage long
sys_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, long arg2, long arg3, long arg4, sys_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, long arg2,
long arg5, long arg6, long arg7, long stack) long arg3, long arg4, long arg5, long arg6, long arg7,
struct pt_regs regs)
{ {
struct pt_regs *pt = (struct pt_regs *) &stack; return do_sigaltstack(uss, uoss, regs.r12);
return do_sigaltstack(uss, uoss, pt->r12);
} }
static long static long
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This file contains various system calls that have different calling * This file contains various system calls that have different calling
* conventions on different platforms. * conventions on different platforms.
* *
* Copyright (C) 1999-2000, 2002-2003 Hewlett-Packard Co * Copyright (C) 1999-2000, 2002-2003, 2005 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com> * David Mosberger-Tang <davidm@hpl.hp.com>
*/ */
#include <linux/config.h> #include <linux/config.h>
...@@ -163,10 +163,9 @@ ia64_brk (unsigned long brk) ...@@ -163,10 +163,9 @@ ia64_brk (unsigned long brk)
* and r9) as this is faster than doing a copy_to_user(). * and r9) as this is faster than doing a copy_to_user().
*/ */
asmlinkage long asmlinkage long
sys_pipe (long arg0, long arg1, long arg2, long arg3, sys_pipe (void)
long arg4, long arg5, long arg6, long arg7, long stack)
{ {
struct pt_regs *regs = (struct pt_regs *) &stack; struct pt_regs *regs = ia64_task_regs(current);
int fd[2]; int fd[2];
int retval; int retval;
......
...@@ -358,11 +358,10 @@ struct illegal_op_return { ...@@ -358,11 +358,10 @@ struct illegal_op_return {
}; };
struct illegal_op_return struct illegal_op_return
ia64_illegal_op_fault (unsigned long ec, unsigned long arg1, unsigned long arg2, ia64_illegal_op_fault (unsigned long ec, long arg1, long arg2, long arg3,
unsigned long arg3, unsigned long arg4, unsigned long arg5, long arg4, long arg5, long arg6, long arg7,
unsigned long arg6, unsigned long arg7, unsigned long stack) struct pt_regs regs)
{ {
struct pt_regs *regs = (struct pt_regs *) &stack;
struct illegal_op_return rv; struct illegal_op_return rv;
struct siginfo si; struct siginfo si;
char buf[128]; char buf[128];
...@@ -371,19 +370,19 @@ ia64_illegal_op_fault (unsigned long ec, unsigned long arg1, unsigned long arg2, ...@@ -371,19 +370,19 @@ ia64_illegal_op_fault (unsigned long ec, unsigned long arg1, unsigned long arg2,
{ {
extern struct illegal_op_return ia64_emulate_brl (struct pt_regs *, unsigned long); extern struct illegal_op_return ia64_emulate_brl (struct pt_regs *, unsigned long);
rv = ia64_emulate_brl(regs, ec); rv = ia64_emulate_brl(&regs, ec);
if (rv.fkt != (unsigned long) -1) if (rv.fkt != (unsigned long) -1)
return rv; return rv;
} }
#endif #endif
sprintf(buf, "IA-64 Illegal operation fault"); sprintf(buf, "IA-64 Illegal operation fault");
die_if_kernel(buf, regs, 0); die_if_kernel(buf, &regs, 0);
memset(&si, 0, sizeof(si)); memset(&si, 0, sizeof(si));
si.si_signo = SIGILL; si.si_signo = SIGILL;
si.si_code = ILL_ILLOPC; si.si_code = ILL_ILLOPC;
si.si_addr = (void __user *) (regs->cr_iip + ia64_psr(regs)->ri); si.si_addr = (void __user *) (regs.cr_iip + ia64_psr(&regs)->ri);
force_sig_info(SIGILL, &si, current); force_sig_info(SIGILL, &si, current);
rv.fkt = 0; rv.fkt = 0;
return rv; return rv;
...@@ -391,11 +390,10 @@ ia64_illegal_op_fault (unsigned long ec, unsigned long arg1, unsigned long arg2, ...@@ -391,11 +390,10 @@ ia64_illegal_op_fault (unsigned long ec, unsigned long arg1, unsigned long arg2,
void void
ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
unsigned long iim, unsigned long itir, unsigned long arg5, unsigned long iim, unsigned long itir, long arg5, long arg6,
unsigned long arg6, unsigned long arg7, unsigned long stack) long arg7, struct pt_regs regs)
{ {
struct pt_regs *regs = (struct pt_regs *) &stack; unsigned long code, error = isr, iip;
unsigned long code, error = isr;
struct siginfo siginfo; struct siginfo siginfo;
char buf[128]; char buf[128];
int result, sig; int result, sig;
...@@ -415,10 +413,12 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -415,10 +413,12 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
* This fault was due to lfetch.fault, set "ed" bit in the psr to cancel * This fault was due to lfetch.fault, set "ed" bit in the psr to cancel
* the lfetch. * the lfetch.
*/ */
ia64_psr(regs)->ed = 1; ia64_psr(&regs)->ed = 1;
return; return;
} }
iip = regs.cr_iip + ia64_psr(&regs)->ri;
switch (vector) { switch (vector) {
case 24: /* General Exception */ case 24: /* General Exception */
code = (isr >> 4) & 0xf; code = (isr >> 4) & 0xf;
...@@ -428,8 +428,8 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -428,8 +428,8 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
if (code == 8) { if (code == 8) {
# ifdef CONFIG_IA64_PRINT_HAZARDS # ifdef CONFIG_IA64_PRINT_HAZARDS
printk("%s[%d]: possible hazard @ ip=%016lx (pr = %016lx)\n", printk("%s[%d]: possible hazard @ ip=%016lx (pr = %016lx)\n",
current->comm, current->pid, regs->cr_iip + ia64_psr(regs)->ri, current->comm, current->pid,
regs->pr); regs.cr_iip + ia64_psr(&regs)->ri, regs.pr);
# endif # endif
return; return;
} }
...@@ -437,14 +437,14 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -437,14 +437,14 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
case 25: /* Disabled FP-Register */ case 25: /* Disabled FP-Register */
if (isr & 2) { if (isr & 2) {
disabled_fph_fault(regs); disabled_fph_fault(&regs);
return; return;
} }
sprintf(buf, "Disabled FPL fault---not supposed to happen!"); sprintf(buf, "Disabled FPL fault---not supposed to happen!");
break; break;
case 26: /* NaT Consumption */ case 26: /* NaT Consumption */
if (user_mode(regs)) { if (user_mode(&regs)) {
void __user *addr; void __user *addr;
if (((isr >> 4) & 0xf) == 2) { if (((isr >> 4) & 0xf) == 2) {
...@@ -456,7 +456,8 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -456,7 +456,8 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
/* register NaT consumption */ /* register NaT consumption */
sig = SIGILL; sig = SIGILL;
code = ILL_ILLOPN; code = ILL_ILLOPN;
addr = (void __user *) (regs->cr_iip + ia64_psr(regs)->ri); addr = (void __user *) (regs.cr_iip
+ ia64_psr(&regs)->ri);
} }
siginfo.si_signo = sig; siginfo.si_signo = sig;
siginfo.si_code = code; siginfo.si_code = code;
...@@ -467,17 +468,17 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -467,17 +468,17 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
siginfo.si_isr = isr; siginfo.si_isr = isr;
force_sig_info(sig, &siginfo, current); force_sig_info(sig, &siginfo, current);
return; return;
} else if (ia64_done_with_exception(regs)) } else if (ia64_done_with_exception(&regs))
return; return;
sprintf(buf, "NaT consumption"); sprintf(buf, "NaT consumption");
break; break;
case 31: /* Unsupported Data Reference */ case 31: /* Unsupported Data Reference */
if (user_mode(regs)) { if (user_mode(&regs)) {
siginfo.si_signo = SIGILL; siginfo.si_signo = SIGILL;
siginfo.si_code = ILL_ILLOPN; siginfo.si_code = ILL_ILLOPN;
siginfo.si_errno = 0; siginfo.si_errno = 0;
siginfo.si_addr = (void __user *) (regs->cr_iip + ia64_psr(regs)->ri); siginfo.si_addr = (void __user *) iip;
siginfo.si_imm = vector; siginfo.si_imm = vector;
siginfo.si_flags = __ISR_VALID; siginfo.si_flags = __ISR_VALID;
siginfo.si_isr = isr; siginfo.si_isr = isr;
...@@ -490,7 +491,7 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -490,7 +491,7 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
case 29: /* Debug */ case 29: /* Debug */
case 35: /* Taken Branch Trap */ case 35: /* Taken Branch Trap */
case 36: /* Single Step Trap */ case 36: /* Single Step Trap */
if (fsys_mode(current, regs)) { if (fsys_mode(current, &regs)) {
extern char __kernel_syscall_via_break[]; extern char __kernel_syscall_via_break[];
/* /*
* Got a trap in fsys-mode: Taken Branch Trap and Single Step trap * Got a trap in fsys-mode: Taken Branch Trap and Single Step trap
...@@ -498,13 +499,13 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -498,13 +499,13 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
*/ */
if (unlikely(vector == 29)) { if (unlikely(vector == 29)) {
die("Got debug trap in fsys-mode---not supposed to happen!", die("Got debug trap in fsys-mode---not supposed to happen!",
regs, 0); &regs, 0);
return; return;
} }
/* re-do the system call via break 0x100000: */ /* re-do the system call via break 0x100000: */
regs->cr_iip = (unsigned long) __kernel_syscall_via_break; regs.cr_iip = (unsigned long) __kernel_syscall_via_break;
ia64_psr(regs)->ri = 0; ia64_psr(&regs)->ri = 0;
ia64_psr(regs)->cpl = 3; ia64_psr(&regs)->cpl = 3;
return; return;
} }
switch (vector) { switch (vector) {
...@@ -515,8 +516,8 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -515,8 +516,8 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
* Erratum 10 (IFA may contain incorrect address) now has * Erratum 10 (IFA may contain incorrect address) now has
* "NoFix" status. There are no plans for fixing this. * "NoFix" status. There are no plans for fixing this.
*/ */
if (ia64_psr(regs)->is == 0) if (ia64_psr(&regs)->is == 0)
ifa = regs->cr_iip; ifa = regs.cr_iip;
#endif #endif
break; break;
case 35: siginfo.si_code = TRAP_BRANCH; ifa = 0; break; case 35: siginfo.si_code = TRAP_BRANCH; ifa = 0; break;
...@@ -533,12 +534,12 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -533,12 +534,12 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
case 32: /* fp fault */ case 32: /* fp fault */
case 33: /* fp trap */ case 33: /* fp trap */
result = handle_fpu_swa((vector == 32) ? 1 : 0, regs, isr); result = handle_fpu_swa((vector == 32) ? 1 : 0, &regs, isr);
if ((result < 0) || (current->thread.flags & IA64_THREAD_FPEMU_SIGFPE)) { if ((result < 0) || (current->thread.flags & IA64_THREAD_FPEMU_SIGFPE)) {
siginfo.si_signo = SIGFPE; siginfo.si_signo = SIGFPE;
siginfo.si_errno = 0; siginfo.si_errno = 0;
siginfo.si_code = FPE_FLTINV; siginfo.si_code = FPE_FLTINV;
siginfo.si_addr = (void __user *) (regs->cr_iip + ia64_psr(regs)->ri); siginfo.si_addr = (void __user *) iip;
siginfo.si_flags = __ISR_VALID; siginfo.si_flags = __ISR_VALID;
siginfo.si_isr = isr; siginfo.si_isr = isr;
siginfo.si_imm = 0; siginfo.si_imm = 0;
...@@ -554,19 +555,18 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -554,19 +555,18 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
* interesting work (e.g., signal delivery is done in the kernel * interesting work (e.g., signal delivery is done in the kernel
* exit path). * exit path).
*/ */
ia64_psr(regs)->lp = 0; ia64_psr(&regs)->lp = 0;
return; return;
} else { } else {
/* Unimplemented Instr. Address Trap */ /* Unimplemented Instr. Address Trap */
if (user_mode(regs)) { if (user_mode(&regs)) {
siginfo.si_signo = SIGILL; siginfo.si_signo = SIGILL;
siginfo.si_code = ILL_BADIADDR; siginfo.si_code = ILL_BADIADDR;
siginfo.si_errno = 0; siginfo.si_errno = 0;
siginfo.si_flags = 0; siginfo.si_flags = 0;
siginfo.si_isr = 0; siginfo.si_isr = 0;
siginfo.si_imm = 0; siginfo.si_imm = 0;
siginfo.si_addr = (void __user *) siginfo.si_addr = (void __user *) iip;
(regs->cr_iip + ia64_psr(regs)->ri);
force_sig_info(SIGILL, &siginfo, current); force_sig_info(SIGILL, &siginfo, current);
return; return;
} }
...@@ -576,23 +576,23 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -576,23 +576,23 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
case 45: case 45:
#ifdef CONFIG_IA32_SUPPORT #ifdef CONFIG_IA32_SUPPORT
if (ia32_exception(regs, isr) == 0) if (ia32_exception(&regs, isr) == 0)
return; return;
#endif #endif
printk(KERN_ERR "Unexpected IA-32 exception (Trap 45)\n"); printk(KERN_ERR "Unexpected IA-32 exception (Trap 45)\n");
printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx\n", printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx\n",
regs->cr_iip, ifa, isr); iip, ifa, isr);
force_sig(SIGSEGV, current); force_sig(SIGSEGV, current);
break; break;
case 46: case 46:
#ifdef CONFIG_IA32_SUPPORT #ifdef CONFIG_IA32_SUPPORT
if (ia32_intercept(regs, isr) == 0) if (ia32_intercept(&regs, isr) == 0)
return; return;
#endif #endif
printk(KERN_ERR "Unexpected IA-32 intercept trap (Trap 46)\n"); printk(KERN_ERR "Unexpected IA-32 intercept trap (Trap 46)\n");
printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx, iim - 0x%lx\n", printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx, iim - 0x%lx\n",
regs->cr_iip, ifa, isr, iim); iip, ifa, isr, iim);
force_sig(SIGSEGV, current); force_sig(SIGSEGV, current);
return; return;
...@@ -604,6 +604,6 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, ...@@ -604,6 +604,6 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
sprintf(buf, "Fault %lu", vector); sprintf(buf, "Fault %lu", vector);
break; break;
} }
die_if_kernel(buf, regs, error); die_if_kernel(buf, &regs, error);
force_sig(SIGILL, current); force_sig(SIGILL, current);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/* /*
* IA-64 Linux syscall numbers and inline-functions. * IA-64 Linux syscall numbers and inline-functions.
* *
* Copyright (C) 1998-2004 Hewlett-Packard Co * Copyright (C) 1998-2005 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com> * David Mosberger-Tang <davidm@hpl.hp.com>
*/ */
...@@ -376,15 +376,13 @@ struct pt_regs; ...@@ -376,15 +376,13 @@ struct pt_regs;
struct sigaction; struct sigaction;
long sys_execve(char __user *filename, char __user * __user *argv, long sys_execve(char __user *filename, char __user * __user *argv,
char __user * __user *envp, struct pt_regs *regs); char __user * __user *envp, struct pt_regs *regs);
asmlinkage long sys_pipe(long arg0, long arg1, long arg2, long arg3, asmlinkage long sys_pipe(void);
long arg4, long arg5, long arg6, long arg7, long stack);
asmlinkage long sys_ptrace(long request, pid_t pid, asmlinkage long sys_ptrace(long request, pid_t pid,
unsigned long addr, unsigned long data, unsigned long addr, unsigned long data);
long arg4, long arg5, long arg6, long arg7, long stack);
asmlinkage long sys_rt_sigaction(int sig, asmlinkage long sys_rt_sigaction(int sig,
const struct sigaction __user *act, const struct sigaction __user *act,
struct sigaction __user *oact, struct sigaction __user *oact,
size_t sigsetsize); size_t sigsetsize);
/* /*
* "Conditional" syscalls * "Conditional" syscalls
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment