Commit d50e8cc1 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] annotations for arch/ppc and include/asm-ppc

Usual set - explicit -D<arch>=1 for sparse, __sighandler_t / __sigrestore_t
annotated, annotations in arch/ppc/kernel/*, etc. - same as for other platforms
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8450b99a
...@@ -27,6 +27,8 @@ cflags-y += -Iarch/$(ARCH) -msoft-float -pipe \ ...@@ -27,6 +27,8 @@ cflags-y += -Iarch/$(ARCH) -msoft-float -pipe \
-ffixed-r2 -Wno-uninitialized -mmultiple -ffixed-r2 -Wno-uninitialized -mmultiple
CPP = $(CC) -E $(CFLAGS) CPP = $(CC) -E $(CFLAGS)
CHECK := $(CHECK) -D__powerpc__=1
ifndef CONFIG_E500 ifndef CONFIG_E500
cflags-y += -mstring cflags-y += -mstring
endif endif
......
...@@ -448,15 +448,15 @@ int proc_dol2crvec(ctl_table *table, int write, struct file *filp, ...@@ -448,15 +448,15 @@ int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
} }
if (!write && !first && left) { if (!write && !first && left) {
if(put_user('\n', (char *) buffer)) if(put_user('\n', (char __user *) buffer))
return -EFAULT; return -EFAULT;
left--, buffer++; left--, buffer++;
} }
if (write) { if (write) {
p = (char *) buffer; char __user *s = (char __user *) buffer;
while (left) { while (left) {
char c; char c;
if(get_user(c, p++)) if(get_user(c, s++))
return -EFAULT; return -EFAULT;
if (!isspace(c)) if (!isspace(c))
break; break;
......
...@@ -544,7 +544,7 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned long adr) ...@@ -544,7 +544,7 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned long adr)
#endif #endif
else else
val = __unpack_fe01(tsk->thread.fpexc_mode); val = __unpack_fe01(tsk->thread.fpexc_mode);
return put_user(val, (unsigned int *) adr); return put_user(val, (unsigned int __user *) adr);
} }
int sys_clone(unsigned long clone_flags, unsigned long usp, int sys_clone(unsigned long clone_flags, unsigned long usp,
......
...@@ -77,7 +77,7 @@ static inline int put_reg(struct task_struct *task, int regno, ...@@ -77,7 +77,7 @@ static inline int put_reg(struct task_struct *task, int regno,
/* /*
* Get contents of AltiVec register state in task TASK * Get contents of AltiVec register state in task TASK
*/ */
static inline int get_vrregs(unsigned long *data, struct task_struct *task) static inline int get_vrregs(unsigned long __user *data, struct task_struct *task)
{ {
int i, j; int i, j;
...@@ -105,7 +105,7 @@ static inline int get_vrregs(unsigned long *data, struct task_struct *task) ...@@ -105,7 +105,7 @@ static inline int get_vrregs(unsigned long *data, struct task_struct *task)
/* /*
* Write contents of AltiVec register state into task TASK. * Write contents of AltiVec register state into task TASK.
*/ */
static inline int set_vrregs(struct task_struct *task, unsigned long *data) static inline int set_vrregs(struct task_struct *task, unsigned long __user *data)
{ {
int i, j; int i, j;
...@@ -286,7 +286,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -286,7 +286,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
ret = -EIO; ret = -EIO;
if (copied != sizeof(tmp)) if (copied != sizeof(tmp))
break; break;
ret = put_user(tmp,(unsigned long *) data); ret = put_user(tmp,(unsigned long __user *) data);
break; break;
} }
...@@ -312,7 +312,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -312,7 +312,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
preempt_enable(); preempt_enable();
tmp = ((unsigned long *)child->thread.fpr)[index - PT_FPR0]; tmp = ((unsigned long *)child->thread.fpr)[index - PT_FPR0];
} }
ret = put_user(tmp,(unsigned long *) data); ret = put_user(tmp,(unsigned long __user *) data);
break; break;
} }
...@@ -410,7 +410,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -410,7 +410,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
if (child->thread.regs->msr & MSR_VEC) if (child->thread.regs->msr & MSR_VEC)
giveup_altivec(child); giveup_altivec(child);
preempt_enable(); preempt_enable();
ret = get_vrregs((unsigned long *)data, child); ret = get_vrregs((unsigned long __user *)data, child);
break; break;
case PTRACE_SETVRREGS: case PTRACE_SETVRREGS:
...@@ -421,7 +421,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -421,7 +421,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
if (child->thread.regs->msr & MSR_VEC) if (child->thread.regs->msr & MSR_VEC)
giveup_altivec(child); giveup_altivec(child);
preempt_enable(); preempt_enable();
ret = set_vrregs(child, (unsigned long *)data); ret = set_vrregs(child, (unsigned long __user *)data);
break; break;
#endif #endif
#ifdef CONFIG_SPE #ifdef CONFIG_SPE
...@@ -429,7 +429,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -429,7 +429,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
/* Get the child spe register state. */ /* Get the child spe register state. */
if (child->thread.regs->msr & MSR_SPE) if (child->thread.regs->msr & MSR_SPE)
giveup_spe(child); giveup_spe(child);
ret = get_evrregs((unsigned long *)data, child); ret = get_evrregs((unsigned long __user *)data, child);
break; break;
case PTRACE_SETEVRREGS: case PTRACE_SETEVRREGS:
...@@ -438,7 +438,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -438,7 +438,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
* of register state from memory */ * of register state from memory */
if (child->thread.regs->msr & MSR_SPE) if (child->thread.regs->msr & MSR_SPE)
giveup_spe(child); giveup_spe(child);
ret = set_evrregs(child, (unsigned long *)data); ret = set_evrregs(child, (unsigned long __user *)data);
break; break;
#endif #endif
......
...@@ -187,7 +187,7 @@ struct rt_sigframe ...@@ -187,7 +187,7 @@ struct rt_sigframe
* altivec/spe instructions at some point. * altivec/spe instructions at some point.
*/ */
static int static int
save_user_regs(struct pt_regs *regs, struct mcontext *frame, int sigret) save_user_regs(struct pt_regs *regs, struct mcontext __user *frame, int sigret)
{ {
/* save general and floating-point registers */ /* save general and floating-point registers */
CHECK_FULL_REGS(regs); CHECK_FULL_REGS(regs);
...@@ -229,7 +229,7 @@ save_user_regs(struct pt_regs *regs, struct mcontext *frame, int sigret) ...@@ -229,7 +229,7 @@ save_user_regs(struct pt_regs *regs, struct mcontext *frame, int sigret)
* significant bits of a vector, we "cheat" and stuff VRSAVE in the * significant bits of a vector, we "cheat" and stuff VRSAVE in the
* most significant bits of that same vector. --BenH * most significant bits of that same vector. --BenH
*/ */
if (__put_user(current->thread.vrsave, (u32 *)&frame->mc_vregs[32])) if (__put_user(current->thread.vrsave, (u32 __user *)&frame->mc_vregs[32]))
return 1; return 1;
#endif /* CONFIG_ALTIVEC */ #endif /* CONFIG_ALTIVEC */
...@@ -308,7 +308,7 @@ restore_user_regs(struct pt_regs *regs, struct mcontext __user *sr, int sig) ...@@ -308,7 +308,7 @@ restore_user_regs(struct pt_regs *regs, struct mcontext __user *sr, int sig)
memset(&current->thread.vr, 0, ELF_NVRREG * sizeof(vector128)); memset(&current->thread.vr, 0, ELF_NVRREG * sizeof(vector128));
/* Always get VRSAVE back */ /* Always get VRSAVE back */
if (__get_user(current->thread.vrsave, (u32 *)&sr->mc_vregs[32])) if (__get_user(current->thread.vrsave, (u32 __user *)&sr->mc_vregs[32]))
return 1; return 1;
#endif /* CONFIG_ALTIVEC */ #endif /* CONFIG_ALTIVEC */
...@@ -412,7 +412,7 @@ handle_rt_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -412,7 +412,7 @@ handle_rt_signal(unsigned long sig, struct k_sigaction *ka,
static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int sig) static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int sig)
{ {
sigset_t set; sigset_t set;
struct mcontext *mcp; struct mcontext __user *mcp;
if (__copy_from_user(&set, &ucp->uc_sigmask, sizeof(set)) if (__copy_from_user(&set, &ucp->uc_sigmask, sizeof(set))
|| __get_user(mcp, &ucp->uc_regs)) || __get_user(mcp, &ucp->uc_regs))
...@@ -447,8 +447,8 @@ int sys_swapcontext(struct ucontext __user *old_ctx, ...@@ -447,8 +447,8 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
if (new_ctx == NULL) if (new_ctx == NULL)
return 0; return 0;
if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx)) if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx))
|| __get_user(tmp, (u8 *) new_ctx) || __get_user(tmp, (u8 __user *) new_ctx)
|| __get_user(tmp, (u8 *) (new_ctx + 1) - 1)) || __get_user(tmp, (u8 __user *) (new_ctx + 1) - 1))
return -EFAULT; return -EFAULT;
/* /*
...@@ -524,7 +524,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -524,7 +524,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
/* create a stack frame for the caller of the handler */ /* create a stack frame for the caller of the handler */
newsp -= __SIGNAL_FRAMESIZE; newsp -= __SIGNAL_FRAMESIZE;
if (verify_area(VERIFY_WRITE, (void *) newsp, origsp - newsp)) if (verify_area(VERIFY_WRITE, (void __user *) newsp, origsp - newsp))
goto badframe; goto badframe;
#if _NSIG != 64 #if _NSIG != 64
...@@ -583,7 +583,7 @@ int sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, ...@@ -583,7 +583,7 @@ int sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
set.sig[1] = sigctx._unused[3]; set.sig[1] = sigctx._unused[3];
restore_sigmask(&set); restore_sigmask(&set);
sr = (struct mcontext *) sigctx.regs; sr = (struct mcontext __user *) sigctx.regs;
if (verify_area(VERIFY_READ, sr, sizeof(*sr)) if (verify_area(VERIFY_READ, sr, sizeof(*sr))
|| restore_user_regs(regs, sr, 1)) || restore_user_regs(regs, sr, 1))
goto badframe; goto badframe;
......
...@@ -67,7 +67,7 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif ...@@ -67,7 +67,7 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif
break; break;
case SEMTIMEDOP: case SEMTIMEDOP:
ret = sys_semtimedop (first, (struct sembuf __user *)ptr, ret = sys_semtimedop (first, (struct sembuf __user *)ptr,
second, (const struct timespec *) fifth); second, (const struct timespec __user *) fifth);
break; break;
case SEMGET: case SEMGET:
ret = sys_semget (first, second, third); ret = sys_semget (first, second, third);
...@@ -208,17 +208,17 @@ unsigned long sys_mmap(unsigned long addr, size_t len, ...@@ -208,17 +208,17 @@ unsigned long sys_mmap(unsigned long addr, size_t len,
* sys_select() with the appropriate args. -- Cort * sys_select() with the appropriate args. -- Cort
*/ */
int int
ppc_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp) ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timeval __user *tvp)
{ {
if ( (unsigned long)n >= 4096 ) if ( (unsigned long)n >= 4096 )
{ {
unsigned long __user *buffer = (unsigned long __user *)n; unsigned long __user *buffer = (unsigned long __user *)n;
if (verify_area(VERIFY_READ, buffer, 5*sizeof(unsigned long)) if (verify_area(VERIFY_READ, buffer, 5*sizeof(unsigned long))
|| __get_user(n, buffer) || __get_user(n, buffer)
|| __get_user(inp, ((fd_set **)(buffer+1))) || __get_user(inp, ((fd_set __user * __user *)(buffer+1)))
|| __get_user(outp, ((fd_set **)(buffer+2))) || __get_user(outp, ((fd_set __user * __user *)(buffer+2)))
|| __get_user(exp, ((fd_set **)(buffer+3))) || __get_user(exp, ((fd_set __user * __user *)(buffer+3)))
|| __get_user(tvp, ((struct timeval **)(buffer+4)))) || __get_user(tvp, ((struct timeval __user * __user *)(buffer+4))))
return -EFAULT; return -EFAULT;
} }
return sys_select(n, inp, outp, exp, tvp); return sys_select(n, inp, outp, exp, tvp);
......
...@@ -114,7 +114,7 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr) ...@@ -114,7 +114,7 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
info.si_signo = signr; info.si_signo = signr;
info.si_errno = 0; info.si_errno = 0;
info.si_code = code; info.si_code = code;
info.si_addr = (void *) addr; info.si_addr = (void __user *) addr;
force_sig_info(signr, &info, current); force_sig_info(signr, &info, current);
} }
......
...@@ -262,7 +262,7 @@ int emulate_altivec(struct pt_regs *regs) ...@@ -262,7 +262,7 @@ int emulate_altivec(struct pt_regs *regs)
unsigned int va, vb, vc, vd; unsigned int va, vb, vc, vd;
vector128 *vrs; vector128 *vrs;
if (get_user(instr, (unsigned int *) regs->nip)) if (get_user(instr, (unsigned int __user *) regs->nip))
return -EFAULT; return -EFAULT;
if ((instr >> 26) != 4) if ((instr >> 26) != 4)
return -EINVAL; /* not an altivec instruction */ return -EINVAL; /* not an altivec instruction */
......
...@@ -59,7 +59,7 @@ static int store_updates_sp(struct pt_regs *regs) ...@@ -59,7 +59,7 @@ static int store_updates_sp(struct pt_regs *regs)
{ {
unsigned int inst; unsigned int inst;
if (get_user(inst, (unsigned int *)regs->nip)) if (get_user(inst, (unsigned int __user *)regs->nip))
return 0; return 0;
/* check for 1 in the rA field */ /* check for 1 in the rA field */
if (((inst >> 16) & 0x1f) != 1) if (((inst >> 16) & 0x1f) != 1)
...@@ -281,7 +281,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -281,7 +281,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
info.si_signo = SIGSEGV; info.si_signo = SIGSEGV;
info.si_errno = 0; info.si_errno = 0;
info.si_code = code; info.si_code = code;
info.si_addr = (void *) address; info.si_addr = (void __user *) address;
force_sig_info(SIGSEGV, &info, current); force_sig_info(SIGSEGV, &info, current);
return 0; return 0;
} }
...@@ -309,7 +309,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -309,7 +309,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
info.si_signo = SIGBUS; info.si_signo = SIGBUS;
info.si_errno = 0; info.si_errno = 0;
info.si_code = BUS_ADRERR; info.si_code = BUS_ADRERR;
info.si_addr = (void *)address; info.si_addr = (void __user *)address;
force_sig_info (SIGBUS, &info, current); force_sig_info (SIGBUS, &info, current);
if (!user_mode(regs)) if (!user_mode(regs))
return SIGBUS; return SIGBUS;
......
...@@ -118,7 +118,11 @@ typedef struct { ...@@ -118,7 +118,11 @@ typedef struct {
#define SIG_SETMASK 2 /* for setting the signal mask */ #define SIG_SETMASK 2 /* for setting the signal mask */
/* Type of a signal handler. */ /* Type of a signal handler. */
typedef void (*__sighandler_t)(int); typedef void __signalfn_t(int);
typedef __signalfn_t __user *__sighandler_t;
typedef void __restorefn_t(void);
typedef __restorefn_t __user *__sigrestore_t;
#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ #define SIG_DFL ((__sighandler_t)0) /* default signal handling */
#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ #define SIG_IGN ((__sighandler_t)1) /* ignore signal */
...@@ -128,13 +132,13 @@ struct old_sigaction { ...@@ -128,13 +132,13 @@ struct old_sigaction {
__sighandler_t sa_handler; __sighandler_t sa_handler;
old_sigset_t sa_mask; old_sigset_t sa_mask;
unsigned long sa_flags; unsigned long sa_flags;
void (*sa_restorer)(void); __sigrestore_t sa_restorer;
}; };
struct sigaction { struct sigaction {
__sighandler_t sa_handler; __sighandler_t sa_handler;
unsigned long sa_flags; unsigned long sa_flags;
void (*sa_restorer)(void); __sigrestore_t sa_restorer;
sigset_t sa_mask; /* mask last for extensibility */ sigset_t sa_mask; /* mask last for extensibility */
}; };
...@@ -143,7 +147,7 @@ struct k_sigaction { ...@@ -143,7 +147,7 @@ struct k_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;
......
...@@ -13,10 +13,10 @@ struct mcontext { ...@@ -13,10 +13,10 @@ struct mcontext {
struct ucontext { struct ucontext {
unsigned long uc_flags; unsigned long uc_flags;
struct ucontext *uc_link; struct ucontext __user *uc_link;
stack_t uc_stack; stack_t uc_stack;
int uc_pad[7]; int uc_pad[7];
struct mcontext *uc_regs; /* points to uc_mcontext field */ struct mcontext __user *uc_regs;/* points to uc_mcontext field */
sigset_t uc_sigmask; sigset_t uc_sigmask;
/* glibc has 1024-bit signal masks, ours are 64-bit */ /* glibc has 1024-bit signal masks, ours are 64-bit */
int uc_maskext[30]; int uc_maskext[30];
......
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