Commit 32360cdf authored by David S. Miller's avatar David S. Miller

[SPARC]: First stage of sparc32 sparse work.

parent 5cea1125
...@@ -84,47 +84,44 @@ static int apc_release(struct inode *inode, struct file *f) ...@@ -84,47 +84,44 @@ static int apc_release(struct inode *inode, struct file *f)
} }
static int apc_ioctl(struct inode *inode, struct file *f, static int apc_ioctl(struct inode *inode, struct file *f,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long __arg)
{ {
__u8 inarg; __u8 inarg, __user *arg;
arg = (__u8 __user *) __arg;
switch (cmd) { switch (cmd) {
case APCIOCGFANCTL: case APCIOCGFANCTL:
if(put_user(apc_readb(APC_FANCTL_REG) & APC_REGMASK, (__u8*) arg)) { if (put_user(apc_readb(APC_FANCTL_REG) & APC_REGMASK, arg))
return -EFAULT; return -EFAULT;
} break;
break;
case APCIOCGCPWR: case APCIOCGCPWR:
if(put_user(apc_readb(APC_CPOWER_REG) & APC_REGMASK, (__u8*) arg)) { if (put_user(apc_readb(APC_CPOWER_REG) & APC_REGMASK, arg))
return -EFAULT; return -EFAULT;
} break;
break;
case APCIOCGBPORT: case APCIOCGBPORT:
if(put_user(apc_readb(APC_BPORT_REG) & APC_BPMASK, (__u8*) arg)) { if (put_user(apc_readb(APC_BPORT_REG) & APC_BPMASK, arg))
return -EFAULT; return -EFAULT;
} break;
break;
case APCIOCSFANCTL:
case APCIOCSFANCTL: if (get_user(inarg, arg))
if(get_user(inarg, (__u8*) arg)) { return -EFAULT;
return -EFAULT; apc_writeb(inarg & APC_REGMASK, APC_FANCTL_REG);
} break;
apc_writeb(inarg & APC_REGMASK, APC_FANCTL_REG); case APCIOCSCPWR:
break; if (get_user(inarg, arg))
case APCIOCSCPWR: return -EFAULT;
if(get_user(inarg, (__u8*) arg)) { apc_writeb(inarg & APC_REGMASK, APC_CPOWER_REG);
return -EFAULT; break;
} case APCIOCSBPORT:
apc_writeb(inarg & APC_REGMASK, APC_CPOWER_REG); if (get_user(inarg, arg))
break; return -EFAULT;
case APCIOCSBPORT: apc_writeb(inarg & APC_BPMASK, APC_BPORT_REG);
if(get_user(inarg, (__u8*) arg)) { break;
return -EFAULT; default:
} return -EINVAL;
apc_writeb(inarg & APC_BPMASK, APC_BPORT_REG);
break;
default:
return -EINVAL;
}; };
return 0; return 0;
......
...@@ -238,7 +238,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev) ...@@ -238,7 +238,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
child->bus = dev->bus; child->bus = dev->bus;
fill_ebus_child(node, &regs[0], child); fill_ebus_child(node, &regs[0], child);
while ((node = prom_getsibling(node))) { while ((node = prom_getsibling(node)) != 0) {
child->next = (struct linux_ebus_child *) child->next = (struct linux_ebus_child *)
ebus_alloc(sizeof(struct linux_ebus_child)); ebus_alloc(sizeof(struct linux_ebus_child));
...@@ -330,7 +330,7 @@ void __init ebus_init(void) ...@@ -330,7 +330,7 @@ void __init ebus_init(void)
dev->bus = ebus; dev->bus = ebus;
fill_ebus_device(nd, dev); fill_ebus_device(nd, dev);
while ((nd = prom_getsibling(nd))) { while ((nd = prom_getsibling(nd)) != 0) {
dev->next = (struct linux_ebus_device *) dev->next = (struct linux_ebus_device *)
ebus_alloc(sizeof(struct linux_ebus_device)); ebus_alloc(sizeof(struct linux_ebus_device));
......
...@@ -216,7 +216,8 @@ void free_irq(unsigned int irq, void *dev_id) ...@@ -216,7 +216,8 @@ void free_irq(unsigned int irq, void *dev_id)
if (sparc_cpu_model == sun4d) { if (sparc_cpu_model == sun4d) {
extern void sun4d_free_irq(unsigned int, void *); extern void sun4d_free_irq(unsigned int, void *);
return sun4d_free_irq(irq, dev_id); sun4d_free_irq(irq, dev_id);
return;
} }
cpu_irq = irq & (NR_IRQS - 1); cpu_irq = irq & (NR_IRQS - 1);
if (cpu_irq > 14) { /* 14 irq levels on the sparc */ if (cpu_irq > 14) { /* 14 irq levels on the sparc */
......
...@@ -54,25 +54,25 @@ static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2, ...@@ -54,25 +54,25 @@ static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
} }
} }
#define fetch_reg(reg, regs) ({ \ #define fetch_reg(reg, regs) ({ \
struct reg_window *win; \ struct reg_window __user *win; \
register unsigned long ret; \ register unsigned long ret; \
\ \
if (!(reg)) ret = 0; \ if (!(reg)) ret = 0; \
else if((reg) < 16) { \ else if ((reg) < 16) { \
ret = regs->u_regs[(reg)]; \ ret = regs->u_regs[(reg)]; \
} else { \ } else { \
/* Ho hum, the slightly complicated case. */ \ /* Ho hum, the slightly complicated case. */ \
win = (struct reg_window *)regs->u_regs[UREG_FP]; \ win = (struct reg_window __user *)regs->u_regs[UREG_FP];\
if (get_user (ret, &win->locals[(reg) - 16])) return -1; \ if (get_user (ret, &win->locals[(reg) - 16])) return -1;\
} \ } \
ret; \ ret; \
}) })
static inline int static inline int
store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs) store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs)
{ {
struct reg_window *win; struct reg_window __user *win;
if (!reg) if (!reg)
return 0; return 0;
...@@ -81,7 +81,7 @@ store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs) ...@@ -81,7 +81,7 @@ store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs)
return 0; return 0;
} else { } else {
/* need to use put_user() in this case: */ /* need to use put_user() in this case: */
win = (struct reg_window *)regs->u_regs[UREG_FP]; win = (struct reg_window __user *) regs->u_regs[UREG_FP];
return (put_user(result, &win->locals[reg - 16])); return (put_user(result, &win->locals[reg - 16]));
} }
} }
...@@ -89,23 +89,30 @@ store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs) ...@@ -89,23 +89,30 @@ store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs)
extern void handle_hw_divzero (struct pt_regs *regs, unsigned long pc, extern void handle_hw_divzero (struct pt_regs *regs, unsigned long pc,
unsigned long npc, unsigned long psr); unsigned long npc, unsigned long psr);
/* Should return 0 if mul/div emulation succeeded and SIGILL should not be issued */ /* Should return 0 if mul/div emulation succeeded and SIGILL should
* not be issued.
*/
int do_user_muldiv(struct pt_regs *regs, unsigned long pc) int do_user_muldiv(struct pt_regs *regs, unsigned long pc)
{ {
unsigned int insn; unsigned int insn;
int inst; int inst;
unsigned int rs1, rs2, rdv; unsigned int rs1, rs2, rdv;
if (!pc) return -1; /* This happens to often, I think */ if (!pc)
if (get_user (insn, (unsigned int *)pc)) return -1; return -1; /* This happens to often, I think */
if ((insn & 0xc1400000) != 0x80400000) return -1; if (get_user (insn, (unsigned int __user *)pc))
return -1;
if ((insn & 0xc1400000) != 0x80400000)
return -1;
inst = ((insn >> 19) & 0xf); inst = ((insn >> 19) & 0xf);
if ((inst & 0xe) != 10 && (inst & 0xe) != 14) return -1; if ((inst & 0xe) != 10 && (inst & 0xe) != 14)
return -1;
/* Now we know we have to do something with umul, smul, udiv or sdiv */ /* Now we know we have to do something with umul, smul, udiv or sdiv */
rs1 = (insn >> 14) & 0x1f; rs1 = (insn >> 14) & 0x1f;
rs2 = insn & 0x1f; rs2 = insn & 0x1f;
rdv = (insn >> 25) & 0x1f; rdv = (insn >> 25) & 0x1f;
if(has_imm13(insn)) { if (has_imm13(insn)) {
maybe_flush_windows(rs1, 0, rdv); maybe_flush_windows(rs1, 0, rdv);
rs2 = sign_extend_imm13(insn); rs2 = sign_extend_imm13(insn);
} else { } else {
......
...@@ -400,23 +400,30 @@ void flush_thread(void) ...@@ -400,23 +400,30 @@ void flush_thread(void)
} }
} }
static __inline__ struct sparc_stackf * static __inline__ struct sparc_stackf __user *
clone_stackframe(struct sparc_stackf *dst, struct sparc_stackf *src) clone_stackframe(struct sparc_stackf __user *dst,
struct sparc_stackf __user *src)
{ {
unsigned long size; unsigned long size, fp;
struct sparc_stackf *sp; struct sparc_stackf *tmp;
struct sparc_stackf __user *sp;
if (get_user(tmp, &src->fp))
return NULL;
size = ((unsigned long)src->fp) - ((unsigned long)src); fp = (unsigned long) tmp;
sp = (struct sparc_stackf *)(((unsigned long)dst) - size); size = (fp - ((unsigned long) src));
fp = (unsigned long) dst;
sp = (struct sparc_stackf __user *)(fp - size);
/* do_fork() grabs the parent semaphore, we must release it /* do_fork() grabs the parent semaphore, we must release it
* temporarily so we can build the child clone stack frame * temporarily so we can build the child clone stack frame
* without deadlocking. * without deadlocking.
*/ */
if (copy_to_user(sp, src, size)) if (__copy_user(sp, src, size))
sp = (struct sparc_stackf *) 0; sp = NULL;
else if (put_user(dst, &sp->fp)) else if (put_user(fp, &sp->fp))
sp = (struct sparc_stackf *) 0; sp = NULL;
return sp; return sp;
} }
...@@ -435,8 +442,8 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags, ...@@ -435,8 +442,8 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags,
return do_fork(clone_flags, stack_start, return do_fork(clone_flags, stack_start,
regs, stack_size, regs, stack_size,
(int *) parent_tid_ptr, (int __user *) parent_tid_ptr,
(int *) child_tid_ptr); (int __user *) child_tid_ptr);
} }
/* Copy a Sparc thread. The fork() return value conventions /* Copy a Sparc thread. The fork() return value conventions
...@@ -519,15 +526,17 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, ...@@ -519,15 +526,17 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
p->thread.current_ds = USER_DS; p->thread.current_ds = USER_DS;
if (sp != regs->u_regs[UREG_FP]) { if (sp != regs->u_regs[UREG_FP]) {
struct sparc_stackf *childstack; struct sparc_stackf __user *childstack;
struct sparc_stackf *parentstack; struct sparc_stackf __user *parentstack;
/* /*
* This is a clone() call with supplied user stack. * This is a clone() call with supplied user stack.
* Set some valid stack frames to give to the child. * Set some valid stack frames to give to the child.
*/ */
childstack = (struct sparc_stackf *) (sp & ~0x7UL); childstack = (struct sparc_stackf __user *)
parentstack = (struct sparc_stackf *) regs->u_regs[UREG_FP]; (sp & ~0x7UL);
parentstack = (struct sparc_stackf __user *)
regs->u_regs[UREG_FP];
#if 0 #if 0
printk("clone: parent stack:\n"); printk("clone: parent stack:\n");
...@@ -654,12 +663,14 @@ asmlinkage int sparc_execve(struct pt_regs *regs) ...@@ -654,12 +663,14 @@ asmlinkage int sparc_execve(struct pt_regs *regs)
if(regs->u_regs[UREG_G1] == 0) if(regs->u_regs[UREG_G1] == 0)
base = 1; base = 1;
filename = getname((char *)regs->u_regs[base + UREG_I0]); filename = getname((char __user *)regs->u_regs[base + UREG_I0]);
error = PTR_ERR(filename); error = PTR_ERR(filename);
if(IS_ERR(filename)) if(IS_ERR(filename))
goto out; goto out;
error = do_execve(filename, (char **) regs->u_regs[base + UREG_I1], error = do_execve(filename,
(char **) regs->u_regs[base + UREG_I2], regs); (char __user * __user *)regs->u_regs[base + UREG_I1],
(char __user * __user *)regs->u_regs[base + UREG_I2],
regs);
putname(filename); putname(filename);
if (error == 0) if (error == 0)
current->ptrace &= ~PT_DTRACE; current->ptrace &= ~PT_DTRACE;
...@@ -679,25 +690,25 @@ pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) ...@@ -679,25 +690,25 @@ pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{ {
long retval; long retval;
__asm__ __volatile("mov %4, %%g2\n\t" /* Set aside fn ptr... */ __asm__ __volatile__("mov %4, %%g2\n\t" /* Set aside fn ptr... */
"mov %5, %%g3\n\t" /* and arg. */ "mov %5, %%g3\n\t" /* and arg. */
"mov %1, %%g1\n\t" "mov %1, %%g1\n\t"
"mov %2, %%o0\n\t" /* Clone flags. */ "mov %2, %%o0\n\t" /* Clone flags. */
"mov 0, %%o1\n\t" /* usp arg == 0 */ "mov 0, %%o1\n\t" /* usp arg == 0 */
"t 0x10\n\t" /* Linux/Sparc clone(). */ "t 0x10\n\t" /* Linux/Sparc clone(). */
"cmp %%o1, 0\n\t" "cmp %%o1, 0\n\t"
"be 1f\n\t" /* The parent, just return. */ "be 1f\n\t" /* The parent, just return. */
" nop\n\t" /* Delay slot. */ " nop\n\t" /* Delay slot. */
"jmpl %%g2, %%o7\n\t" /* Call the function. */ "jmpl %%g2, %%o7\n\t" /* Call the function. */
" mov %%g3, %%o0\n\t" /* Get back the arg in delay. */ " mov %%g3, %%o0\n\t" /* Get back the arg in delay. */
"mov %3, %%g1\n\t" "mov %3, %%g1\n\t"
"t 0x10\n\t" /* Linux/Sparc exit(). */ "t 0x10\n\t" /* Linux/Sparc exit(). */
/* Notreached by child. */ /* Notreached by child. */
"1: mov %%o0, %0\n\t" : "1: mov %%o0, %0\n\t" :
"=r" (retval) : "=r" (retval) :
"i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED), "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
"i" (__NR_exit), "r" (fn), "r" (arg) : "i" (__NR_exit), "r" (fn), "r" (arg) :
"g1", "g2", "g3", "o0", "o1", "memory", "cc"); "g1", "g2", "g3", "o0", "o1", "memory", "cc");
return retval; return retval;
} }
......
...@@ -50,8 +50,10 @@ static inline void pt_succ_return(struct pt_regs *regs, unsigned long value) ...@@ -50,8 +50,10 @@ static inline void pt_succ_return(struct pt_regs *regs, unsigned long value)
static void static void
pt_succ_return_linux(struct pt_regs *regs, unsigned long value, long *addr) pt_succ_return_linux(struct pt_regs *regs, unsigned long value, long *addr)
{ {
if(put_user(value, addr)) if (put_user(value, (long __user *) addr)) {
return pt_error_return(regs, EFAULT); pt_error_return(regs, EFAULT);
return;
}
regs->u_regs[UREG_I0] = 0; regs->u_regs[UREG_I0] = 0;
regs->psr &= ~PSR_C; regs->psr &= ~PSR_C;
regs->pc = regs->npc; regs->pc = regs->npc;
...@@ -368,7 +370,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -368,7 +370,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
} }
case PTRACE_GETREGS: { case PTRACE_GETREGS: {
struct pt_regs *pregs = (struct pt_regs *) addr; struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
struct pt_regs *cregs = child->thread.kregs; struct pt_regs *cregs = child->thread.kregs;
int rval; int rval;
...@@ -391,7 +393,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -391,7 +393,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
} }
case PTRACE_SETREGS: { case PTRACE_SETREGS: {
struct pt_regs *pregs = (struct pt_regs *) addr; struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
struct pt_regs *cregs = child->thread.kregs; struct pt_regs *cregs = child->thread.kregs;
unsigned long psr, pc, npc, y; unsigned long psr, pc, npc, y;
int i; int i;
...@@ -433,7 +435,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -433,7 +435,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
unsigned long *insnaddr; unsigned long *insnaddr;
unsigned long insn; unsigned long insn;
} fpq[16]; } fpq[16];
} *fps = (struct fps *) addr; };
struct fps __user *fps = (struct fps __user *) addr;
int i; int i;
i = verify_area(VERIFY_WRITE, fps, sizeof(struct fps)); i = verify_area(VERIFY_WRITE, fps, sizeof(struct fps));
...@@ -467,7 +470,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -467,7 +470,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
unsigned long *insnaddr; unsigned long *insnaddr;
unsigned long insn; unsigned long insn;
} fpq[16]; } fpq[16];
} *fps = (struct fps *) addr; };
struct fps __user *fps = (struct fps __user *) addr;
int i; int i;
i = verify_area(VERIFY_READ, fps, sizeof(struct fps)); i = verify_area(VERIFY_READ, fps, sizeof(struct fps));
...@@ -489,7 +493,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -489,7 +493,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
case PTRACE_READTEXT: case PTRACE_READTEXT:
case PTRACE_READDATA: { case PTRACE_READDATA: {
int res = ptrace_readdata(child, addr, (void *) addr2, data); int res = ptrace_readdata(child, addr,
(void __user *) addr2, data);
if (res == data) { if (res == data) {
pt_succ_return(regs, 0); pt_succ_return(regs, 0);
...@@ -504,7 +509,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -504,7 +509,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
case PTRACE_WRITETEXT: case PTRACE_WRITETEXT:
case PTRACE_WRITEDATA: { case PTRACE_WRITEDATA: {
int res = ptrace_writedata(child, (void *) addr2, addr, data); int res = ptrace_writedata(child, (void __user *) addr2,
addr, data);
if (res == data) { if (res == data) {
pt_succ_return(regs, 0); pt_succ_return(regs, 0);
......
...@@ -234,7 +234,7 @@ static inline void do_new_sigreturn (struct pt_regs *regs) ...@@ -234,7 +234,7 @@ static inline void do_new_sigreturn (struct pt_regs *regs)
if (verify_area(VERIFY_READ, sf, sizeof(*sf))) if (verify_area(VERIFY_READ, sf, sizeof(*sf)))
goto segv_and_exit; goto segv_and_exit;
if (((uint) sf) & 3) if (((unsigned long) sf) & 3)
goto segv_and_exit; goto segv_and_exit;
err = __get_user(pc, &sf->info.si_regs.pc); err = __get_user(pc, &sf->info.si_regs.pc);
...@@ -289,8 +289,10 @@ asmlinkage void do_sigreturn(struct pt_regs *regs) ...@@ -289,8 +289,10 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)
synchronize_user_stack(); synchronize_user_stack();
if (current->thread.new_signal) if (current->thread.new_signal) {
return do_new_sigreturn(regs); do_new_sigreturn(regs);
return;
}
scptr = (struct sigcontext __user *) regs->u_regs[UREG_I0]; scptr = (struct sigcontext __user *) regs->u_regs[UREG_I0];
...@@ -347,6 +349,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs) ...@@ -347,6 +349,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
struct rt_signal_frame __user *sf; struct rt_signal_frame __user *sf;
unsigned int psr, pc, npc; unsigned int psr, pc, npc;
__siginfo_fpu_t __user *fpu_save; __siginfo_fpu_t __user *fpu_save;
mm_segment_t old_fs;
sigset_t set; sigset_t set;
stack_t st; stack_t st;
int err; int err;
...@@ -386,7 +389,10 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs) ...@@ -386,7 +389,10 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
/* It is more difficult to avoid calling this function than to /* It is more difficult to avoid calling this function than to
* call it and ignore errors. * call it and ignore errors.
*/ */
do_sigaltstack(&st, NULL, (unsigned long)sf); old_fs = get_fs();
set_fs(KERNEL_DS);
do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
set_fs(old_fs);
sigdelsetmask(&set, ~_BLOCKABLE); sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&current->sighand->siglock);
...@@ -849,7 +855,7 @@ setup_svr4_frame(struct sigaction *sa, unsigned long pc, unsigned long npc, ...@@ -849,7 +855,7 @@ setup_svr4_frame(struct sigaction *sa, unsigned long pc, unsigned long npc,
/* Arguments passed to signal handler */ /* Arguments passed to signal handler */
if (regs->u_regs[14]){ if (regs->u_regs[14]){
struct reg_window *rw = (struct reg_window __user *) struct reg_window __user *rw = (struct reg_window __user *)
regs->u_regs[14]; regs->u_regs[14];
err |= __put_user(signr, &rw->ins[0]); err |= __put_user(signr, &rw->ins[0]);
...@@ -860,8 +866,8 @@ setup_svr4_frame(struct sigaction *sa, unsigned long pc, unsigned long npc, ...@@ -860,8 +866,8 @@ setup_svr4_frame(struct sigaction *sa, unsigned long pc, unsigned long npc,
goto sigsegv; goto sigsegv;
regs->u_regs[UREG_I0] = signr; regs->u_regs[UREG_I0] = signr;
regs->u_regs[UREG_I1] = (uint) si; regs->u_regs[UREG_I1] = (unsigned long) si;
regs->u_regs[UREG_I2] = (uint) uc; regs->u_regs[UREG_I2] = (unsigned long) uc;
} }
return; return;
...@@ -932,6 +938,7 @@ asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs) ...@@ -932,6 +938,7 @@ asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs)
{ {
svr4_gregset_t __user *gr; svr4_gregset_t __user *gr;
unsigned long pc, npc, psr; unsigned long pc, npc, psr;
mm_segment_t old_fs;
sigset_t set; sigset_t set;
svr4_sigset_t setv; svr4_sigset_t setv;
int err; int err;
...@@ -945,7 +952,7 @@ asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs) ...@@ -945,7 +952,7 @@ asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs)
if (current_thread_info()->w_saved) if (current_thread_info()->w_saved)
goto sigsegv_and_return; goto sigsegv_and_return;
if (((uint) c) & 3) if (((unsigned long) c) & 3)
goto sigsegv_and_return; goto sigsegv_and_return;
if (!__access_ok((unsigned long)c, sizeof(*c))) if (!__access_ok((unsigned long)c, sizeof(*c)))
...@@ -977,7 +984,11 @@ asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs) ...@@ -977,7 +984,11 @@ asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs)
/* It is more difficult to avoid calling this function than to /* It is more difficult to avoid calling this function than to
call it and ignore errors. */ call it and ignore errors. */
do_sigaltstack(&st, NULL, regs->u_regs[UREG_I6]); old_fs = get_fs();
set_fs(KERNEL_DS);
do_sigaltstack((const stack_t __user *) &st, NULL,
regs->u_regs[UREG_I6]);
set_fs(old_fs);
set.sig[0] = setv.sigbits[0]; set.sig[0] = setv.sigbits[0];
set.sig[1] = setv.sigbits[1]; set.sig[1] = setv.sigbits[1];
......
...@@ -41,18 +41,19 @@ asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg) ...@@ -41,18 +41,19 @@ asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg)
goto out; goto out;
/* First handle an easy compat. case for tty ldisc. */ /* First handle an easy compat. case for tty ldisc. */
if(cmd == TIOCSETD) { if (cmd == TIOCSETD) {
int *p, ntty = N_TTY, tmp; int __user *p;
int ntty = N_TTY, tmp;
mm_segment_t oldfs; mm_segment_t oldfs;
p = (int *) arg; p = (int __user *) arg;
ret = -EFAULT; ret = -EFAULT;
if(get_user(tmp, p)) if (get_user(tmp, p))
goto out; goto out;
if(tmp == 2) { if (tmp == 2) {
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
ret = sys_ioctl(fd, cmd, (int) &ntty); ret = sys_ioctl(fd, cmd, (unsigned long) &ntty);
set_fs(oldfs); set_fs(oldfs);
ret = (ret == -EINVAL ? -EOPNOTSUPP : ret); ret = (ret == -EINVAL ? -EOPNOTSUPP : ret);
goto out; goto out;
...@@ -60,7 +61,7 @@ asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg) ...@@ -60,7 +61,7 @@ asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg)
} }
/* Binary compatibility is good American knowhow fuckin' up. */ /* Binary compatibility is good American knowhow fuckin' up. */
if(cmd == TIOCNOTTY) { if (cmd == TIOCNOTTY) {
ret = sys_setsid(); ret = sys_setsid();
goto out; goto out;
} }
...@@ -176,39 +177,39 @@ asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg) ...@@ -176,39 +177,39 @@ asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg)
goto out; goto out;
/* Non posix grp */ /* Non posix grp */
case _IOW('t', 118, int): { case _IOW('t', 118, int): {
int oldval, newval, *ptr; int oldval, newval, __user *ptr;
cmd = TIOCSPGRP; cmd = TIOCSPGRP;
ptr = (int *) arg; ptr = (int __user *) arg;
ret = -EFAULT; ret = -EFAULT;
if(get_user(oldval, ptr)) if (get_user(oldval, ptr))
goto out; goto out;
ret = sys_ioctl(fd, cmd, arg); ret = sys_ioctl(fd, cmd, arg);
__get_user(newval, ptr); __get_user(newval, ptr);
if(newval == -1) { if (newval == -1) {
__put_user(oldval, ptr); __put_user(oldval, ptr);
ret = -EIO; ret = -EIO;
} }
if(ret == -ENOTTY) if (ret == -ENOTTY)
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
case _IOR('t', 119, int): { case _IOR('t', 119, int): {
int oldval, newval, *ptr; int oldval, newval, __user *ptr;
cmd = TIOCGPGRP; cmd = TIOCGPGRP;
ptr = (int *) arg; ptr = (int __user *) arg;
ret = -EFAULT; ret = -EFAULT;
if(get_user(oldval, ptr)) if (get_user(oldval, ptr))
goto out; goto out;
ret = sys_ioctl(fd, cmd, arg); ret = sys_ioctl(fd, cmd, arg);
__get_user(newval, ptr); __get_user(newval, ptr);
if(newval == -1) { if (newval == -1) {
__put_user(oldval, ptr); __put_user(oldval, ptr);
ret = -EIO; ret = -EIO;
} }
if(ret == -ENOTTY) if (ret == -ENOTTY)
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
......
...@@ -136,7 +136,8 @@ asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user ...@@ -136,7 +136,8 @@ asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user
if (!ptr) if (!ptr)
goto out; goto out;
err = -EFAULT; err = -EFAULT;
if(get_user(fourth.__pad, (void __user **)ptr)) if (get_user(fourth.__pad,
(void __user * __user *)ptr))
goto out; goto out;
err = sys_semctl (first, second, third, fourth); err = sys_semctl (first, second, third, fourth);
goto out; goto out;
...@@ -165,7 +166,9 @@ asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user ...@@ -165,7 +166,9 @@ asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user
goto out; goto out;
} }
case 1: default: case 1: default:
err = sys_msgrcv (first, (struct msgbuf *) ptr, second, fifth, third); err = sys_msgrcv (first,
(struct msgbuf __user *) ptr,
second, fifth, third);
goto out; goto out;
} }
case MSGGET: case MSGGET:
...@@ -194,7 +197,8 @@ asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user ...@@ -194,7 +197,8 @@ asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user
goto out; goto out;
} }
case 1: /* iBCS2 emulator entry point */ case 1: /* iBCS2 emulator entry point */
err = do_shmat (first, (char __user *) ptr, second, (ulong __user *) third); err = do_shmat (first, (char __user *) ptr,
second, (ulong *) third);
goto out; goto out;
} }
case SHMDT: case SHMDT:
......
...@@ -71,7 +71,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len, ...@@ -71,7 +71,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len,
struct file * file = NULL; struct file * file = NULL;
unsigned long retval, ret_type; unsigned long retval, ret_type;
if(flags & MAP_NORESERVE) { if (flags & MAP_NORESERVE) {
static int cnt; static int cnt;
if (cnt++ < 10) if (cnt++ < 10)
printk("%s: unimplemented SunOS MAP_NORESERVE mmap() flag\n", printk("%s: unimplemented SunOS MAP_NORESERVE mmap() flag\n",
...@@ -79,7 +79,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len, ...@@ -79,7 +79,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len,
flags &= ~MAP_NORESERVE; flags &= ~MAP_NORESERVE;
} }
retval = -EBADF; retval = -EBADF;
if(!(flags & MAP_ANONYMOUS)) { if (!(flags & MAP_ANONYMOUS)) {
if (fd >= SUNOS_NR_OPEN) if (fd >= SUNOS_NR_OPEN)
goto out; goto out;
file = fget(fd); file = fget(fd);
...@@ -93,8 +93,8 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len, ...@@ -93,8 +93,8 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len,
* SunOS is so stupid some times... hmph! * SunOS is so stupid some times... hmph!
*/ */
if (file) { if (file) {
if(imajor(file->f_dentry->d_inode) == MEM_MAJOR && if (imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
iminor(file->f_dentry->d_inode) == 5) { iminor(file->f_dentry->d_inode) == 5) {
flags |= MAP_ANONYMOUS; flags |= MAP_ANONYMOUS;
fput(file); fput(file);
file = 0; file = 0;
...@@ -103,7 +103,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len, ...@@ -103,7 +103,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len,
ret_type = flags & _MAP_NEW; ret_type = flags & _MAP_NEW;
flags &= ~_MAP_NEW; flags &= ~_MAP_NEW;
if(!(flags & MAP_FIXED)) if (!(flags & MAP_FIXED))
addr = 0; addr = 0;
else { else {
if (ARCH_SUN4C_SUN4 && if (ARCH_SUN4C_SUN4 &&
...@@ -122,7 +122,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len, ...@@ -122,7 +122,7 @@ asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len,
down_write(&current->mm->mmap_sem); down_write(&current->mm->mmap_sem);
retval = do_mmap(file, addr, len, prot, flags, off); retval = do_mmap(file, addr, len, prot, flags, off);
up_write(&current->mm->mmap_sem); up_write(&current->mm->mmap_sem);
if(!ret_type) if (!ret_type)
retval = ((retval < PAGE_OFFSET) ? 0 : retval); retval = ((retval < PAGE_OFFSET) ? 0 : retval);
out_putf: out_putf:
...@@ -149,8 +149,8 @@ asmlinkage int sunos_brk(unsigned long brk) ...@@ -149,8 +149,8 @@ asmlinkage int sunos_brk(unsigned long brk)
unsigned long newbrk, oldbrk; unsigned long newbrk, oldbrk;
down_write(&current->mm->mmap_sem); down_write(&current->mm->mmap_sem);
if(ARCH_SUN4C_SUN4) { if (ARCH_SUN4C_SUN4) {
if(brk >= 0x20000000 && brk < 0xe0000000) { if (brk >= 0x20000000 && brk < 0xe0000000) {
goto out; goto out;
} }
} }
...@@ -223,7 +223,7 @@ asmlinkage unsigned long sunos_sbrk(int increment) ...@@ -223,7 +223,7 @@ asmlinkage unsigned long sunos_sbrk(int increment)
lock_kernel(); lock_kernel();
oldbrk = current->mm->brk; oldbrk = current->mm->brk;
error = sunos_brk(((int) current->mm->brk) + increment); error = sunos_brk(((int) current->mm->brk) + increment);
if(!error) if (!error)
error = oldbrk; error = oldbrk;
unlock_kernel(); unlock_kernel();
return error; return error;
...@@ -314,20 +314,20 @@ struct sunos_dirent { ...@@ -314,20 +314,20 @@ struct sunos_dirent {
}; };
struct sunos_dirent_callback { struct sunos_dirent_callback {
struct sunos_dirent *curr; struct sunos_dirent __user *curr;
struct sunos_dirent *previous; struct sunos_dirent __user *previous;
int count; int count;
int error; int error;
}; };
#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de))) #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1)) #define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
static int sunos_filldir(void * __buf, const char * name, int namlen, static int sunos_filldir(void * __buf, const char * name, int namlen,
loff_t offset, ino_t ino, unsigned int d_type) loff_t offset, ino_t ino, unsigned int d_type)
{ {
struct sunos_dirent * dirent; struct sunos_dirent __user *dirent;
struct sunos_dirent_callback * buf = (struct sunos_dirent_callback *) __buf; struct sunos_dirent_callback * buf = __buf;
int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1); int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
buf->error = -EINVAL; /* only used if we fail.. */ buf->error = -EINVAL; /* only used if we fail.. */
...@@ -343,16 +343,16 @@ static int sunos_filldir(void * __buf, const char * name, int namlen, ...@@ -343,16 +343,16 @@ static int sunos_filldir(void * __buf, const char * name, int namlen,
put_user(reclen, &dirent->d_reclen); put_user(reclen, &dirent->d_reclen);
copy_to_user(dirent->d_name, name, namlen); copy_to_user(dirent->d_name, name, namlen);
put_user(0, dirent->d_name + namlen); put_user(0, dirent->d_name + namlen);
dirent = (void *)dirent + reclen; dirent = (void __user *) dirent + reclen;
buf->curr = dirent; buf->curr = dirent;
buf->count -= reclen; buf->count -= reclen;
return 0; return 0;
} }
asmlinkage int sunos_getdents(unsigned int fd, void * dirent, int cnt) asmlinkage int sunos_getdents(unsigned int fd, void __user *dirent, int cnt)
{ {
struct file * file; struct file * file;
struct sunos_dirent * lastdirent; struct sunos_dirent __user *lastdirent;
struct sunos_dirent_callback buf; struct sunos_dirent_callback buf;
int error = -EBADF; int error = -EBADF;
...@@ -367,7 +367,7 @@ asmlinkage int sunos_getdents(unsigned int fd, void * dirent, int cnt) ...@@ -367,7 +367,7 @@ asmlinkage int sunos_getdents(unsigned int fd, void * dirent, int cnt)
if (cnt < (sizeof(struct sunos_dirent) + 255)) if (cnt < (sizeof(struct sunos_dirent) + 255))
goto out_putf; goto out_putf;
buf.curr = (struct sunos_dirent *) dirent; buf.curr = (struct sunos_dirent __user *) dirent;
buf.previous = NULL; buf.previous = NULL;
buf.count = cnt; buf.count = cnt;
buf.error = 0; buf.error = 0;
...@@ -398,8 +398,8 @@ struct sunos_direntry { ...@@ -398,8 +398,8 @@ struct sunos_direntry {
}; };
struct sunos_direntry_callback { struct sunos_direntry_callback {
struct sunos_direntry *curr; struct sunos_direntry __user *curr;
struct sunos_direntry *previous; struct sunos_direntry __user *previous;
int count; int count;
int error; int error;
}; };
...@@ -407,8 +407,8 @@ struct sunos_direntry_callback { ...@@ -407,8 +407,8 @@ struct sunos_direntry_callback {
static int sunos_filldirentry(void * __buf, const char * name, int namlen, static int sunos_filldirentry(void * __buf, const char * name, int namlen,
loff_t offset, ino_t ino, unsigned int d_type) loff_t offset, ino_t ino, unsigned int d_type)
{ {
struct sunos_direntry * dirent; struct sunos_direntry __user *dirent;
struct sunos_direntry_callback * buf = (struct sunos_direntry_callback *) __buf; struct sunos_direntry_callback *buf = __buf;
int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1); int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
buf->error = -EINVAL; /* only used if we fail.. */ buf->error = -EINVAL; /* only used if we fail.. */
...@@ -422,16 +422,17 @@ static int sunos_filldirentry(void * __buf, const char * name, int namlen, ...@@ -422,16 +422,17 @@ static int sunos_filldirentry(void * __buf, const char * name, int namlen,
put_user(reclen, &dirent->d_reclen); put_user(reclen, &dirent->d_reclen);
copy_to_user(dirent->d_name, name, namlen); copy_to_user(dirent->d_name, name, namlen);
put_user(0, dirent->d_name + namlen); put_user(0, dirent->d_name + namlen);
dirent = (void *)dirent + reclen; dirent = (void __user *) dirent + reclen;
buf->curr = dirent; buf->curr = dirent;
buf->count -= reclen; buf->count -= reclen;
return 0; return 0;
} }
asmlinkage int sunos_getdirentries(unsigned int fd, void * dirent, int cnt, unsigned int *basep) asmlinkage int sunos_getdirentries(unsigned int fd, void __user *dirent,
int cnt, unsigned int __user *basep)
{ {
struct file * file; struct file * file;
struct sunos_direntry * lastdirent; struct sunos_direntry __user *lastdirent;
struct sunos_direntry_callback buf; struct sunos_direntry_callback buf;
int error = -EBADF; int error = -EBADF;
...@@ -443,10 +444,10 @@ asmlinkage int sunos_getdirentries(unsigned int fd, void * dirent, int cnt, unsi ...@@ -443,10 +444,10 @@ asmlinkage int sunos_getdirentries(unsigned int fd, void * dirent, int cnt, unsi
goto out; goto out;
error = -EINVAL; error = -EINVAL;
if(cnt < (sizeof(struct sunos_direntry) + 255)) if (cnt < (sizeof(struct sunos_direntry) + 255))
goto out_putf; goto out_putf;
buf.curr = (struct sunos_direntry *) dirent; buf.curr = (struct sunos_direntry __user *) dirent;
buf.previous = NULL; buf.previous = NULL;
buf.count = cnt; buf.count = cnt;
buf.error = 0; buf.error = 0;
...@@ -477,7 +478,7 @@ struct sunos_utsname { ...@@ -477,7 +478,7 @@ struct sunos_utsname {
char mach[9]; char mach[9];
}; };
asmlinkage int sunos_uname(struct sunos_utsname *name) asmlinkage int sunos_uname(struct sunos_utsname __user *name)
{ {
int ret; int ret;
down_read(&uts_sem); down_read(&uts_sem);
...@@ -556,7 +557,7 @@ asmlinkage int sunos_fpathconf(int fd, int name) ...@@ -556,7 +557,7 @@ asmlinkage int sunos_fpathconf(int fd, int name)
return ret; return ret;
} }
asmlinkage int sunos_pathconf(char *path, int name) asmlinkage int sunos_pathconf(char __user *path, int name)
{ {
int ret; int ret;
...@@ -566,7 +567,8 @@ asmlinkage int sunos_pathconf(char *path, int name) ...@@ -566,7 +567,8 @@ asmlinkage int sunos_pathconf(char *path, int name)
/* SunOS mount system call emulation */ /* SunOS mount system call emulation */
asmlinkage int sunos_select(int width, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp) asmlinkage int sunos_select(int width, fd_set __user *inp, fd_set __user *outp,
fd_set __user *exp, struct timeval __user *tvp)
{ {
int ret; int ret;
...@@ -604,19 +606,19 @@ struct sunos_fh_t { ...@@ -604,19 +606,19 @@ struct sunos_fh_t {
}; };
struct sunos_nfs_mount_args { struct sunos_nfs_mount_args {
struct sockaddr_in *addr; /* file server address */ struct sockaddr_in __user *addr; /* file server address */
struct nfs_fh *fh; /* File handle to be mounted */ struct nfs_fh __user *fh; /* File handle to be mounted */
int flags; /* flags */ int flags; /* flags */
int wsize; /* write size in bytes */ int wsize; /* write size in bytes */
int rsize; /* read size in bytes */ int rsize; /* read size in bytes */
int timeo; /* initial timeout in .1 secs */ int timeo; /* initial timeout in .1 secs */
int retrans; /* times to retry send */ int retrans; /* times to retry send */
char *hostname; /* server's hostname */ char __user *hostname; /* server's hostname */
int acregmin; /* attr cache file min secs */ int acregmin; /* attr cache file min secs */
int acregmax; /* attr cache file max secs */ int acregmax; /* attr cache file max secs */
int acdirmin; /* attr cache dir min secs */ int acdirmin; /* attr cache dir min secs */
int acdirmax; /* attr cache dir max secs */ int acdirmax; /* attr cache dir max secs */
char *netname; /* server's netname */ char __user *netname; /* server's netname */
}; };
...@@ -680,7 +682,7 @@ static int get_default (int value, int def_value) ...@@ -680,7 +682,7 @@ static int get_default (int value, int def_value)
return def_value; return def_value;
} }
static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data) static int sunos_nfs_mount(char *dir_name, int linux_flags, void __user *data)
{ {
int server_fd, err; int server_fd, err;
char *the_name, *mount_page; char *the_name, *mount_page;
...@@ -729,7 +731,7 @@ static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data) ...@@ -729,7 +731,7 @@ static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data)
linux_nfs_mount.acdirmax = sunos_mount.acdirmax; linux_nfs_mount.acdirmax = sunos_mount.acdirmax;
the_name = getname(sunos_mount.hostname); the_name = getname(sunos_mount.hostname);
if(IS_ERR(the_name)) if (IS_ERR(the_name))
return PTR_ERR(the_name); return PTR_ERR(the_name);
strlcpy(linux_nfs_mount.hostname, the_name, strlcpy(linux_nfs_mount.hostname, the_name,
...@@ -749,7 +751,7 @@ static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data) ...@@ -749,7 +751,7 @@ static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data)
} }
asmlinkage int asmlinkage int
sunos_mount(char *type, char *dir, int flags, void *data) sunos_mount(char __user *type, char __user *dir, int flags, void __user *data)
{ {
int linux_flags = 0; int linux_flags = 0;
int ret = -EINVAL; int ret = -EINVAL;
...@@ -768,11 +770,11 @@ sunos_mount(char *type, char *dir, int flags, void *data) ...@@ -768,11 +770,11 @@ sunos_mount(char *type, char *dir, int flags, void *data)
if (flags & (SMNT_GRPID|SMNT_NOSUB|SMNT_MULTI|SMNT_SYS5)) if (flags & (SMNT_GRPID|SMNT_NOSUB|SMNT_MULTI|SMNT_SYS5))
goto out; goto out;
if(flags & SMNT_REMOUNT) if (flags & SMNT_REMOUNT)
linux_flags |= MS_REMOUNT; linux_flags |= MS_REMOUNT;
if(flags & SMNT_RDONLY) if (flags & SMNT_RDONLY)
linux_flags |= MS_RDONLY; linux_flags |= MS_RDONLY;
if(flags & SMNT_NOSUID) if (flags & SMNT_NOSUID)
linux_flags |= MS_NOSUID; linux_flags |= MS_NOSUID;
dir_page = getname(dir); dir_page = getname(dir);
...@@ -785,20 +787,20 @@ sunos_mount(char *type, char *dir, int flags, void *data) ...@@ -785,20 +787,20 @@ sunos_mount(char *type, char *dir, int flags, void *data)
if (IS_ERR(type_page)) if (IS_ERR(type_page))
goto out1; goto out1;
if(strcmp(type_page, "ext2") == 0) { if (strcmp(type_page, "ext2") == 0) {
dev_fname = getname(data); dev_fname = getname(data);
} else if(strcmp(type_page, "iso9660") == 0) { } else if (strcmp(type_page, "iso9660") == 0) {
dev_fname = getname(data); dev_fname = getname(data);
} else if(strcmp(type_page, "minix") == 0) { } else if (strcmp(type_page, "minix") == 0) {
dev_fname = getname(data); dev_fname = getname(data);
} else if(strcmp(type_page, "nfs") == 0) { } else if (strcmp(type_page, "nfs") == 0) {
ret = sunos_nfs_mount (dir_page, flags, data); ret = sunos_nfs_mount (dir_page, flags, data);
goto out2; goto out2;
} else if(strcmp(type_page, "ufs") == 0) { } else if (strcmp(type_page, "ufs") == 0) {
printk("Warning: UFS filesystem mounts unsupported.\n"); printk("Warning: UFS filesystem mounts unsupported.\n");
ret = -ENODEV; ret = -ENODEV;
goto out2; goto out2;
} else if(strcmp(type_page, "proc")) { } else if (strcmp(type_page, "proc")) {
ret = -ENODEV; ret = -ENODEV;
goto out2; goto out2;
} }
...@@ -823,8 +825,8 @@ asmlinkage int sunos_setpgrp(pid_t pid, pid_t pgid) ...@@ -823,8 +825,8 @@ asmlinkage int sunos_setpgrp(pid_t pid, pid_t pgid)
int ret; int ret;
/* So stupid... */ /* So stupid... */
if((!pid || pid == current->pid) && if ((!pid || pid == current->pid) &&
!pgid) { !pgid) {
sys_setsid(); sys_setsid();
ret = 0; ret = 0;
} else { } else {
...@@ -834,7 +836,8 @@ asmlinkage int sunos_setpgrp(pid_t pid, pid_t pgid) ...@@ -834,7 +836,8 @@ asmlinkage int sunos_setpgrp(pid_t pid, pid_t pgid)
} }
/* So stupid... */ /* So stupid... */
asmlinkage int sunos_wait4(pid_t pid, unsigned int *stat_addr, int options, struct rusage *ru) asmlinkage int sunos_wait4(pid_t pid, unsigned int __user *stat_addr,
int options, struct rusage __user*ru)
{ {
int ret; int ret;
...@@ -861,7 +864,7 @@ asmlinkage int sunos_audit(void) ...@@ -861,7 +864,7 @@ asmlinkage int sunos_audit(void)
return -1; return -1;
} }
extern asmlinkage unsigned long sunos_gethostid(void) asmlinkage unsigned long sunos_gethostid(void)
{ {
unsigned long ret; unsigned long ret;
...@@ -882,7 +885,7 @@ extern asmlinkage unsigned long sunos_gethostid(void) ...@@ -882,7 +885,7 @@ extern asmlinkage unsigned long sunos_gethostid(void)
#define _SC_SAVED_IDS 7 #define _SC_SAVED_IDS 7
#define _SC_VERSION 8 #define _SC_VERSION 8
extern asmlinkage long sunos_sysconf (int name) asmlinkage long sunos_sysconf (int name)
{ {
long ret; long ret;
...@@ -947,7 +950,8 @@ asmlinkage int sunos_semsys(int op, unsigned long arg1, unsigned long arg2, ...@@ -947,7 +950,8 @@ asmlinkage int sunos_semsys(int op, unsigned long arg1, unsigned long arg2,
arg3=SETALL; break; arg3=SETALL; break;
} }
/* sys_semctl(): */ /* sys_semctl(): */
arg4.__pad=ptr; /* value to modify semaphore to */ /* value to modify semaphore to */
arg4.__pad = (void __user *) ptr;
ret = sys_semctl((int)arg1, (int)arg2, (int)arg3, arg4 ); ret = sys_semctl((int)arg1, (int)arg2, (int)arg3, arg4 );
break; break;
case 1: case 1:
...@@ -956,7 +960,7 @@ asmlinkage int sunos_semsys(int op, unsigned long arg1, unsigned long arg2, ...@@ -956,7 +960,7 @@ asmlinkage int sunos_semsys(int op, unsigned long arg1, unsigned long arg2,
break; break;
case 2: case 2:
/* sys_semop(): */ /* sys_semop(): */
ret = sys_semop((int)arg1, (struct sembuf *)arg2, (unsigned)arg3); ret = sys_semop((int)arg1, (struct sembuf __user *)arg2, (unsigned)arg3);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
...@@ -978,18 +982,18 @@ asmlinkage int sunos_msgsys(int op, unsigned long arg1, unsigned long arg2, ...@@ -978,18 +982,18 @@ asmlinkage int sunos_msgsys(int op, unsigned long arg1, unsigned long arg2,
break; break;
case 1: case 1:
rval = sys_msgctl((int)arg1, (int)arg2, rval = sys_msgctl((int)arg1, (int)arg2,
(struct msqid_ds *)arg3); (struct msqid_ds __user *)arg3);
break; break;
case 2: case 2:
lock_kernel(); lock_kernel();
sp = (struct sparc_stackf *)current->thread.kregs->u_regs[UREG_FP]; sp = (struct sparc_stackf *)current->thread.kregs->u_regs[UREG_FP];
arg5 = sp->xxargs[0]; arg5 = sp->xxargs[0];
unlock_kernel(); unlock_kernel();
rval = sys_msgrcv((int)arg1, (struct msgbuf *)arg2, rval = sys_msgrcv((int)arg1, (struct msgbuf __user *)arg2,
(size_t)arg3, (long)arg4, (int)arg5); (size_t)arg3, (long)arg4, (int)arg5);
break; break;
case 3: case 3:
rval = sys_msgsnd((int)arg1, (struct msgbuf *)arg2, rval = sys_msgsnd((int)arg1, (struct msgbuf __user *)arg2,
(size_t)arg3, (int)arg4); (size_t)arg3, (int)arg4);
break; break;
default: default:
...@@ -1008,17 +1012,17 @@ asmlinkage int sunos_shmsys(int op, unsigned long arg1, unsigned long arg2, ...@@ -1008,17 +1012,17 @@ asmlinkage int sunos_shmsys(int op, unsigned long arg1, unsigned long arg2,
switch(op) { switch(op) {
case 0: case 0:
/* do_shmat(): attach a shared memory area */ /* do_shmat(): attach a shared memory area */
rval = do_shmat((int)arg1,(char *)arg2,(int)arg3,&raddr); rval = do_shmat((int)arg1,(char __user *)arg2,(int)arg3,&raddr);
if(!rval) if (!rval)
rval = (int) raddr; rval = (int) raddr;
break; break;
case 1: case 1:
/* sys_shmctl(): modify shared memory area attr. */ /* sys_shmctl(): modify shared memory area attr. */
rval = sys_shmctl((int)arg1,(int)arg2,(struct shmid_ds *)arg3); rval = sys_shmctl((int)arg1,(int)arg2,(struct shmid_ds __user *)arg3);
break; break;
case 2: case 2:
/* sys_shmdt(): detach a shared memory area */ /* sys_shmdt(): detach a shared memory area */
rval = sys_shmdt((char *)arg1); rval = sys_shmdt((char __user *)arg1);
break; break;
case 3: case 3:
/* sys_shmget(): get a shared memory area */ /* sys_shmget(): get a shared memory area */
...@@ -1051,7 +1055,7 @@ static inline int check_nonblock(int ret, int fd) ...@@ -1051,7 +1055,7 @@ static inline int check_nonblock(int ret, int fd)
return ret; return ret;
} }
asmlinkage int sunos_read(unsigned int fd,char *buf,int count) asmlinkage int sunos_read(unsigned int fd, char __user *buf, int count)
{ {
int ret; int ret;
...@@ -1059,7 +1063,8 @@ asmlinkage int sunos_read(unsigned int fd,char *buf,int count) ...@@ -1059,7 +1063,8 @@ asmlinkage int sunos_read(unsigned int fd,char *buf,int count)
return ret; return ret;
} }
asmlinkage int sunos_readv(unsigned long fd, const struct iovec * vector, long count) asmlinkage int sunos_readv(unsigned long fd, const struct iovec __user *vector,
long count)
{ {
int ret; int ret;
...@@ -1067,7 +1072,7 @@ asmlinkage int sunos_readv(unsigned long fd, const struct iovec * vector, long c ...@@ -1067,7 +1072,7 @@ asmlinkage int sunos_readv(unsigned long fd, const struct iovec * vector, long c
return ret; return ret;
} }
asmlinkage int sunos_write(unsigned int fd,char *buf,int count) asmlinkage int sunos_write(unsigned int fd, char __user *buf, int count)
{ {
int ret; int ret;
...@@ -1075,7 +1080,8 @@ asmlinkage int sunos_write(unsigned int fd,char *buf,int count) ...@@ -1075,7 +1080,8 @@ asmlinkage int sunos_write(unsigned int fd,char *buf,int count)
return ret; return ret;
} }
asmlinkage int sunos_writev(unsigned long fd, const struct iovec * vector, long count) asmlinkage int sunos_writev(unsigned long fd,
const struct iovec __user *vector, long count)
{ {
int ret; int ret;
...@@ -1083,7 +1089,7 @@ asmlinkage int sunos_writev(unsigned long fd, const struct iovec * vector, long ...@@ -1083,7 +1089,7 @@ asmlinkage int sunos_writev(unsigned long fd, const struct iovec * vector, long
return ret; return ret;
} }
asmlinkage int sunos_recv(int fd, void * ubuf, int size, unsigned flags) asmlinkage int sunos_recv(int fd, void __user *ubuf, int size, unsigned flags)
{ {
int ret; int ret;
...@@ -1091,7 +1097,7 @@ asmlinkage int sunos_recv(int fd, void * ubuf, int size, unsigned flags) ...@@ -1091,7 +1097,7 @@ asmlinkage int sunos_recv(int fd, void * ubuf, int size, unsigned flags)
return ret; return ret;
} }
asmlinkage int sunos_send(int fd, void * buff, int len, unsigned flags) asmlinkage int sunos_send(int fd, void __user *buff, int len, unsigned flags)
{ {
int ret; int ret;
...@@ -1099,7 +1105,8 @@ asmlinkage int sunos_send(int fd, void * buff, int len, unsigned flags) ...@@ -1099,7 +1105,8 @@ asmlinkage int sunos_send(int fd, void * buff, int len, unsigned flags)
return ret; return ret;
} }
asmlinkage int sunos_accept(int fd, struct sockaddr *sa, int *addrlen) asmlinkage int sunos_accept(int fd, struct sockaddr __user *sa,
int __user *addrlen)
{ {
int ret; int ret;
...@@ -1115,13 +1122,13 @@ asmlinkage int sunos_accept(int fd, struct sockaddr *sa, int *addrlen) ...@@ -1115,13 +1122,13 @@ asmlinkage int sunos_accept(int fd, struct sockaddr *sa, int *addrlen)
#define SUNOS_SV_INTERRUPT 2 #define SUNOS_SV_INTERRUPT 2
asmlinkage int asmlinkage int
sunos_sigaction(int sig, const struct old_sigaction *act, sunos_sigaction(int sig, const struct old_sigaction __user *act,
struct old_sigaction *oact) struct old_sigaction __user *oact)
{ {
struct k_sigaction new_ka, old_ka; struct k_sigaction new_ka, old_ka;
int ret; int ret;
if(act) { if (act) {
old_sigset_t mask; old_sigset_t mask;
if (verify_area(VERIFY_READ, act, sizeof(*act)) || if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
...@@ -1156,8 +1163,8 @@ sunos_sigaction(int sig, const struct old_sigaction *act, ...@@ -1156,8 +1163,8 @@ sunos_sigaction(int sig, const struct old_sigaction *act,
} }
asmlinkage int sunos_setsockopt(int fd, int level, int optname, char *optval, asmlinkage int sunos_setsockopt(int fd, int level, int optname,
int optlen) char __user *optval, int optlen)
{ {
int tr_opt = optname; int tr_opt = optname;
int ret; int ret;
...@@ -1171,8 +1178,8 @@ asmlinkage int sunos_setsockopt(int fd, int level, int optname, char *optval, ...@@ -1171,8 +1178,8 @@ asmlinkage int sunos_setsockopt(int fd, int level, int optname, char *optval,
return ret; return ret;
} }
asmlinkage int sunos_getsockopt(int fd, int level, int optname, char *optval, asmlinkage int sunos_getsockopt(int fd, int level, int optname,
int *optlen) char __user *optval, int __user *optlen)
{ {
int tr_opt = optname; int tr_opt = optname;
int ret; int ret;
......
...@@ -109,14 +109,14 @@ static inline unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs) ...@@ -109,14 +109,14 @@ static inline unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *regs) static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *regs)
{ {
struct reg_window *win; struct reg_window __user *win;
unsigned long ret; unsigned long ret;
if(reg < 16) if (reg < 16)
return (!reg ? 0 : regs->u_regs[reg]); return (!reg ? 0 : regs->u_regs[reg]);
/* Ho hum, the slightly complicated case. */ /* Ho hum, the slightly complicated case. */
win = (struct reg_window *) regs->u_regs[UREG_FP]; win = (struct reg_window __user *) regs->u_regs[UREG_FP];
if ((unsigned long)win & 3) if ((unsigned long)win & 3)
return -1; return -1;
...@@ -431,29 +431,32 @@ static inline int ok_for_user(struct pt_regs *regs, unsigned int insn, ...@@ -431,29 +431,32 @@ static inline int ok_for_user(struct pt_regs *regs, unsigned int insn,
int retval, check = (dir == load) ? VERIFY_READ : VERIFY_WRITE; int retval, check = (dir == load) ? VERIFY_READ : VERIFY_WRITE;
int size = ((insn >> 19) & 3) == 3 ? 8 : 4; int size = ((insn >> 19) & 3) == 3 ? 8 : 4;
if((regs->pc | regs->npc) & 3) if ((regs->pc | regs->npc) & 3)
return 0; return 0;
/* Must verify_area() in all the necessary places. */ /* Must verify_area() in all the necessary places. */
#define WINREG_ADDR(regnum) ((void *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum))) #define WINREG_ADDR(regnum) \
((void __user *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum)))
retval = 0; retval = 0;
reg = (insn >> 25) & 0x1f; reg = (insn >> 25) & 0x1f;
if(reg >= 16) { if (reg >= 16) {
retval = verify_area(check, WINREG_ADDR(reg - 16), size); retval = verify_area(check, WINREG_ADDR(reg - 16), size);
if(retval) if (retval)
return retval; return retval;
} }
reg = (insn >> 14) & 0x1f; reg = (insn >> 14) & 0x1f;
if(reg >= 16) { if (reg >= 16) {
retval = verify_area(check, WINREG_ADDR(reg - 16), size); retval = verify_area(check, WINREG_ADDR(reg - 16), size);
if(retval) if (retval)
return retval; return retval;
} }
if(!(insn & 0x2000)) { if (!(insn & 0x2000)) {
reg = (insn & 0x1f); reg = (insn & 0x1f);
if(reg >= 16) { if (reg >= 16) {
retval = verify_area(check, WINREG_ADDR(reg - 16), size); retval = verify_area(check, WINREG_ADDR(reg - 16),
if(retval) size);
if (retval)
return retval; return retval;
} }
} }
......
...@@ -69,8 +69,8 @@ void synchronize_user_stack(void) ...@@ -69,8 +69,8 @@ void synchronize_user_stack(void)
unsigned long sp = tp->rwbuf_stkptrs[window]; unsigned long sp = tp->rwbuf_stkptrs[window];
/* Ok, let it rip. */ /* Ok, let it rip. */
if(copy_to_user((char *) sp, &tp->reg_window[window], if (copy_to_user((char __user *) sp, &tp->reg_window[window],
sizeof(struct reg_window))) sizeof(struct reg_window)))
continue; continue;
shift_window_buffer(window, tp->w_saved - 1, tp); shift_window_buffer(window, tp->w_saved - 1, tp);
...@@ -117,8 +117,9 @@ void try_to_clear_window_buffer(struct pt_regs *regs, int who) ...@@ -117,8 +117,9 @@ void try_to_clear_window_buffer(struct pt_regs *regs, int who)
for(window = 0; window < tp->w_saved; window++) { for(window = 0; window < tp->w_saved; window++) {
unsigned long sp = tp->rwbuf_stkptrs[window]; unsigned long sp = tp->rwbuf_stkptrs[window];
if((sp & 7) || if ((sp & 7) ||
copy_to_user((char *) sp, &tp->reg_window[window], sizeof(struct reg_window))) copy_to_user((char __user *) sp, &tp->reg_window[window],
sizeof(struct reg_window)))
do_exit(SIGILL); do_exit(SIGILL);
} }
tp->w_saved = 0; tp->w_saved = 0;
......
...@@ -175,7 +175,7 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt) ...@@ -175,7 +175,7 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt)
#ifdef DEBUG_MATHEMU #ifdef DEBUG_MATHEMU
printk("precise trap at %08lx\n", regs->pc); printk("precise trap at %08lx\n", regs->pc);
#endif #endif
if (!get_user(insn, (u32 *)regs->pc)) { if (!get_user(insn, (u32 __user *) regs->pc)) {
retcode = do_one_mathemu(insn, &fpt->thread.fsr, fpt->thread.float_regs); retcode = do_one_mathemu(insn, &fpt->thread.fsr, fpt->thread.float_regs);
if (retcode) { if (retcode) {
/* in this case we need to fix up PC & nPC */ /* in this case we need to fix up PC & nPC */
...@@ -193,7 +193,7 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt) ...@@ -193,7 +193,7 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt)
break; break;
} }
/* Now empty the queue and clear the queue_not_empty flag */ /* Now empty the queue and clear the queue_not_empty flag */
if(retcode) if (retcode)
fpt->thread.fsr &= ~(0x3000 | FSR_CEXC_MASK); fpt->thread.fsr &= ~(0x3000 | FSR_CEXC_MASK);
else else
fpt->thread.fsr &= ~0x3000; fpt->thread.fsr &= ~0x3000;
...@@ -219,18 +219,18 @@ static inline int record_exception(unsigned long *pfsr, int eflag) ...@@ -219,18 +219,18 @@ static inline int record_exception(unsigned long *pfsr, int eflag)
would_trap = (fsr & ((long)eflag << FSR_TEM_SHIFT)) != 0UL; would_trap = (fsr & ((long)eflag << FSR_TEM_SHIFT)) != 0UL;
/* If trapping, we only want to signal one bit. */ /* If trapping, we only want to signal one bit. */
if(would_trap != 0) { if (would_trap != 0) {
eflag &= ((fsr & FSR_TEM_MASK) >> FSR_TEM_SHIFT); eflag &= ((fsr & FSR_TEM_MASK) >> FSR_TEM_SHIFT);
if((eflag & (eflag - 1)) != 0) { if ((eflag & (eflag - 1)) != 0) {
if(eflag & FP_EX_INVALID) if (eflag & FP_EX_INVALID)
eflag = FP_EX_INVALID; eflag = FP_EX_INVALID;
else if(eflag & FP_EX_OVERFLOW) else if (eflag & FP_EX_OVERFLOW)
eflag = FP_EX_OVERFLOW; eflag = FP_EX_OVERFLOW;
else if(eflag & FP_EX_UNDERFLOW) else if (eflag & FP_EX_UNDERFLOW)
eflag = FP_EX_UNDERFLOW; eflag = FP_EX_UNDERFLOW;
else if(eflag & FP_EX_DIVZERO) else if (eflag & FP_EX_DIVZERO)
eflag = FP_EX_DIVZERO; eflag = FP_EX_DIVZERO;
else if(eflag & FP_EX_INEXACT) else if (eflag & FP_EX_INEXACT)
eflag = FP_EX_INEXACT; eflag = FP_EX_INEXACT;
} }
} }
...@@ -250,11 +250,11 @@ static inline int record_exception(unsigned long *pfsr, int eflag) ...@@ -250,11 +250,11 @@ static inline int record_exception(unsigned long *pfsr, int eflag)
* CEXC just generated is OR'd into the * CEXC just generated is OR'd into the
* existing value of AEXC. * existing value of AEXC.
*/ */
if(would_trap == 0) if (would_trap == 0)
fsr |= ((long)eflag << FSR_AEXC_SHIFT); fsr |= ((long)eflag << FSR_AEXC_SHIFT);
/* If trapping, indicate fault trap type IEEE. */ /* If trapping, indicate fault trap type IEEE. */
if(would_trap != 0) if (would_trap != 0)
fsr |= (1UL << 14); fsr |= (1UL << 14);
*pfsr = fsr; *pfsr = fsr;
...@@ -515,7 +515,7 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs) ...@@ -515,7 +515,7 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
case 7: FP_PACK_QP (rd, QR); break; case 7: FP_PACK_QP (rd, QR); break;
} }
} }
if(_fex == 0) if (_fex == 0)
return 1; /* success! */ return 1; /* success! */
return record_exception(pfsr, _fex); return record_exception(pfsr, _fex);
} }
...@@ -412,10 +412,10 @@ asmlinkage void do_sun4c_fault(struct pt_regs *regs, int text_fault, int write, ...@@ -412,10 +412,10 @@ asmlinkage void do_sun4c_fault(struct pt_regs *regs, int text_fault, int write,
address = regs->pc; address = regs->pc;
} else if (!write && } else if (!write &&
!(regs->psr & PSR_PS)) { !(regs->psr & PSR_PS)) {
unsigned int insn, *ip; unsigned int insn, __user *ip;
ip = (unsigned int *)regs->pc; ip = (unsigned int __user *)regs->pc;
if (! get_user(insn, ip)) { if (!get_user(insn, ip)) {
if ((insn & 0xc1680000) == 0xc0680000) if ((insn & 0xc1680000) == 0xc0680000)
write = 1; write = 1;
} }
......
...@@ -56,15 +56,6 @@ typedef struct { ...@@ -56,15 +56,6 @@ typedef struct {
#define SOFTIRQ_OFFSET (1UL << SOFTIRQ_SHIFT) #define SOFTIRQ_OFFSET (1UL << SOFTIRQ_SHIFT)
#define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT) #define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT)
/*
* The hardirq mask has to be large enough to have
* space for potentially all IRQ sources in the system
* nesting on a single CPU:
*/
#if (1 << HARDIRQ_BITS) < NR_IRQS
# error HARDIRQ_BITS is too low!
#endif
/* /*
* Are we doing bottom half or hardware interrupt processing? * Are we doing bottom half or hardware interrupt processing?
* Are we in a softirq context? Interrupt context? * Are we in a softirq context? Interrupt context?
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* See arch/sparc/kernel/sys_sparc.c for ugly details.. * See arch/sparc/kernel/sys_sparc.c for ugly details..
*/ */
struct ipc_kludge { struct ipc_kludge {
struct msgbuf *msgp; struct msgbuf __user *msgp;
long msgtyp; long msgtyp;
}; };
......
...@@ -13,12 +13,12 @@ struct semaphore { ...@@ -13,12 +13,12 @@ struct semaphore {
atomic24_t count; atomic24_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
long __magic; long __magic;
#endif #endif
}; };
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
# define __SEM_DEBUG_INIT(name) \ # define __SEM_DEBUG_INIT(name) \
, (long)&(name).__magic , (long)&(name).__magic
#else #else
...@@ -43,7 +43,7 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -43,7 +43,7 @@ static inline void sema_init (struct semaphore *sem, int val)
atomic24_set(&sem->count, val); atomic24_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic; sem->__magic = (long)&sem->__magic;
#endif #endif
} }
...@@ -68,7 +68,7 @@ static inline void down(struct semaphore * sem) ...@@ -68,7 +68,7 @@ static inline void down(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
might_sleep(); might_sleep();
...@@ -105,7 +105,7 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -105,7 +105,7 @@ static inline int down_interruptible(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
might_sleep(); might_sleep();
...@@ -145,7 +145,7 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -145,7 +145,7 @@ static inline int down_trylock(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
...@@ -184,7 +184,7 @@ static inline void up(struct semaphore * sem) ...@@ -184,7 +184,7 @@ static inline void up(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
......
...@@ -199,7 +199,7 @@ struct __new_sigaction { ...@@ -199,7 +199,7 @@ struct __new_sigaction {
#ifdef __KERNEL__ #ifdef __KERNEL__
struct k_sigaction { struct k_sigaction {
struct __new_sigaction sa; struct __new_sigaction sa;
void *ka_restorer; void __user *ka_restorer;
}; };
#endif #endif
...@@ -211,7 +211,7 @@ struct __old_sigaction { ...@@ -211,7 +211,7 @@ struct __old_sigaction {
}; };
typedef struct sigaltstack { typedef struct sigaltstack {
void *ss_sp; void __user *ss_sp;
int ss_flags; int ss_flags;
size_t ss_size; size_t ss_size;
} stack_t; } stack_t;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <asm/btfixup.h> #include <asm/btfixup.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/page.h>
/* /*
* Low level task data. * Low level task data.
......
...@@ -83,6 +83,10 @@ extern unsigned long search_extables_range(unsigned long addr, unsigned long *g2 ...@@ -83,6 +83,10 @@ extern unsigned long search_extables_range(unsigned long addr, unsigned long *g2
extern void __ret_efault(void); extern void __ret_efault(void);
extern long not_a_user_address;
#define check_user_ptr(x) \
(void) ({ void __user * __userptr = (__typeof__(*(x)) *)&not_a_user_address; __userptr; })
/* Uh, these should become the main single-value transfer routines.. /* Uh, these should become the main single-value transfer routines..
* They automatically use the right size if we just have the right * They automatically use the right size if we just have the right
* pointer type.. * pointer type..
...@@ -94,10 +98,12 @@ extern void __ret_efault(void); ...@@ -94,10 +98,12 @@ extern void __ret_efault(void);
*/ */
#define put_user(x,ptr) ({ \ #define put_user(x,ptr) ({ \
unsigned long __pu_addr = (unsigned long)(ptr); \ unsigned long __pu_addr = (unsigned long)(ptr); \
check_user_ptr(ptr); \
__put_user_check((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); }) __put_user_check((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); })
#define get_user(x,ptr) ({ \ #define get_user(x,ptr) ({ \
unsigned long __gu_addr = (unsigned long)(ptr); \ unsigned long __gu_addr = (unsigned long)(ptr); \
check_user_ptr(ptr); \
__get_user_check((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); }) __get_user_check((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); })
/* /*
...@@ -292,32 +298,32 @@ __asm__ __volatile__( \ ...@@ -292,32 +298,32 @@ __asm__ __volatile__( \
extern int __get_user_bad(void); extern int __get_user_bad(void);
extern unsigned long __copy_user(void *to, const void *from, unsigned long size); extern unsigned long __copy_user(void __user *to, const void __user *from, unsigned long size);
static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
{ {
if (n && __access_ok((unsigned long) to, n)) if (n && __access_ok((unsigned long) to, n))
return __copy_user((void *) to, from, n); return __copy_user(to, (void __user *) from, n);
else else
return n; return n;
} }
static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n) static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
{ {
return __copy_user((void *)to, from, n); return __copy_user(to, (void __user *) from, n);
} }
static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
{ {
if (n && __access_ok((unsigned long) from, n)) if (n && __access_ok((unsigned long) from, n))
return __copy_user(to, (void *) from, n); return __copy_user((void __user *) to, from, n);
else else
return n; return n;
} }
static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n) static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
{ {
return __copy_user(to, (void *)from, n); return __copy_user((void __user *) to, from, n);
} }
static inline unsigned long __clear_user(void __user *addr, unsigned long size) static inline unsigned long __clear_user(void __user *addr, unsigned long size)
......
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