From 4806f8bb8d58821bd70c32126813b99962ad185a Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Fri, 16 Jan 2015 15:34:55 +0100 Subject: [PATCH 1/8] CRIS: Export csum_partial_copy_nocheck Allows that symbol to be used in modules, and fixes the following on allmodconfig: ERROR: "csum_partial_copy_nocheck" [net/ipv6/ipv6.ko] undefined! Signed-off-by: Jesper Nilsson --- arch/cris/kernel/crisksyms.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/cris/kernel/crisksyms.c b/arch/cris/kernel/crisksyms.c index 3908b942fd4c..e704f81f85cc 100644 --- a/arch/cris/kernel/crisksyms.c +++ b/arch/cris/kernel/crisksyms.c @@ -67,3 +67,4 @@ EXPORT_SYMBOL(schedule_usleep); #endif EXPORT_SYMBOL(csum_partial); EXPORT_SYMBOL(csum_partial_copy_from_user); +EXPORT_SYMBOL(csum_partial_copy_nocheck); From 134115cd609d53c25fef99dba75857961a63d8a7 Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Thu, 15 Jan 2015 17:54:00 +0100 Subject: [PATCH 2/8] CRIS: Avoid warning in cris mm/fault.c Move declaration of waitqueue to beginning of block, avoids warning about mixing declarations and code. Signed-off-by: Jesper Nilsson --- arch/cris/mm/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c index 1790f22e71a2..46a6ade5d0e4 100644 --- a/arch/cris/mm/fault.c +++ b/arch/cris/mm/fault.c @@ -217,6 +217,9 @@ retry: /* User mode accesses just cause a SIGSEGV */ if (user_mode(regs)) { +#ifdef CONFIG_NO_SEGFAULT_TERMINATION + DECLARE_WAIT_QUEUE_HEAD(wq); +#endif printk(KERN_NOTICE "%s (pid %d) segfaults for page " "address %08lx at pc %08lx\n", tsk->comm, tsk->pid, @@ -227,7 +230,6 @@ retry: show_registers(regs); #ifdef CONFIG_NO_SEGFAULT_TERMINATION - DECLARE_WAIT_QUEUE_HEAD(wq); wait_event_interruptible(wq, 0 == 1); #else info.si_signo = SIGSEGV; From 00c5794d2df7a8586d4c1dc11c54ea5714fbe17f Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Thu, 15 Jan 2015 17:49:02 +0100 Subject: [PATCH 3/8] CRISv32: Avoid warning of unused variable Avoids the warning about: warning: 'bite_in_progress' defined but not used [-Wunused-variable] Variable is only used if the Kconfig CONFIG_ETRAX_WATCHDOG_NICE_DOGGY is set. Signed-off-by: Jesper Nilsson --- arch/cris/arch-v32/kernel/time.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/cris/arch-v32/kernel/time.c b/arch/cris/arch-v32/kernel/time.c index eb74dabbeb96..c17b01abdc3b 100644 --- a/arch/cris/arch-v32/kernel/time.c +++ b/arch/cris/arch-v32/kernel/time.c @@ -107,8 +107,10 @@ static short int watchdog_key = 42; /* arbitrary 7 bit number */ * is used though, so set this really low. */ #define WATCHDOG_MIN_FREE_PAGES 8 +#if defined(CONFIG_ETRAX_WATCHDOG_NICE_DOGGY) /* for reliable NICE_DOGGY behaviour */ static int bite_in_progress; +#endif void reset_watchdog(void) { @@ -155,7 +157,9 @@ void handle_watchdog_bite(struct pt_regs *regs) nmi_enter(); oops_in_progress = 1; +#if defined(CONFIG_ETRAX_WATCHDOG_NICE_DOGGY) bite_in_progress = 1; +#endif printk(KERN_WARNING "Watchdog bite\n"); /* Check if forced restart or unexpected watchdog */ From dd82094cced036801d56bf4e1f64f83f210475ee Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Thu, 15 Jan 2015 17:30:40 +0100 Subject: [PATCH 4/8] CRIS: Fix missing NR_CPUS in menuconfig The time Kconfig expects that NR_CPUS is defined. This patch removes this config warning: "kernel/time/Kconfig:163:warning: range is invalid" Signed-off-by: Jesper Nilsson --- arch/cris/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 52731e221851..4a03911053ab 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig @@ -57,6 +57,10 @@ config HZ int default 100 +config NR_CPUS + int + default "1" + source "init/Kconfig" source "kernel/Kconfig.freezer" From 10b309767271cf05442d48b38dbe0f79ee8cfb74 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 27 Jan 2015 15:16:31 +0100 Subject: [PATCH 5/8] CRISv32: Remove unnecessary KERN_INFO from sync_serial Remove unnecessary KERN_INFO in sync_serial.c Signed-off-by: Masanari Iida Signed-off-by: Jesper Nilsson --- arch/cris/arch-v32/drivers/sync_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c index f772068d9e79..4dda9bd6b8fb 100644 --- a/arch/cris/arch-v32/drivers/sync_serial.c +++ b/arch/cris/arch-v32/drivers/sync_serial.c @@ -1286,7 +1286,7 @@ static void start_dma_out(struct sync_port *port, const char *data, int count) tr_cfg.tr_en = regk_sser_yes; REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); - DEBUGTRDMA(pr_info(KERN_INFO "dma s\n");); + DEBUGTRDMA(pr_info("dma s\n");); } else { DMA_CONTINUE_DATA(port->regi_dmaout); DEBUGTRDMA(pr_info("dma c\n");); @@ -1443,7 +1443,7 @@ static inline void handle_rx_packet(struct sync_port *port) reg_dma_rw_ack_intr ack_intr = { .data = regk_dma_yes }; unsigned long flags; - DEBUGRXINT(pr_info(KERN_INFO "!")); + DEBUGRXINT(pr_info("!")); spin_lock_irqsave(&port->lock, flags); /* If we overrun the user experience is crap regardless if we From 458e3192455547bb4dce27e060c24cc22a2bd87d Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Tue, 27 Jan 2015 17:20:10 +0100 Subject: [PATCH 6/8] CRIS: uaccess: fix sparse errors virtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer. Fix that up using __force. Signed-off-by: Michael S. Tsirkin Signed-off-by: Jesper Nilsson --- arch/cris/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h index 914540801c5e..9cf5a23baed3 100644 --- a/arch/cris/include/asm/uaccess.h +++ b/arch/cris/include/asm/uaccess.h @@ -153,7 +153,7 @@ struct __large_struct { unsigned long buf[100]; }; ({ \ long __gu_err, __gu_val; \ __get_user_size(__gu_val,(ptr),(size),__gu_err); \ - (x) = (__typeof__(*(ptr)))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ }) @@ -163,7 +163,7 @@ struct __large_struct { unsigned long buf[100]; }; const __typeof__(*(ptr)) *__gu_addr = (ptr); \ if (access_ok(VERIFY_READ,__gu_addr,size)) \ __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \ - (x) = (__typeof__(*(ptr)))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ }) From 83f1588e9f770832b3446324110ff5b71e5f017c Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Tue, 27 Jan 2015 17:29:18 +0100 Subject: [PATCH 7/8] CRIS: macro whitespace fixes in uaccess.h While working on arch/cris/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma. Fix it up. Signed-off-by: Michael S. Tsirkin Signed-off-by: Jesper Nilsson --- arch/cris/include/asm/uaccess.h | 113 ++++++++++++++++---------------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h index 9cf5a23baed3..a21344ab8616 100644 --- a/arch/cris/include/asm/uaccess.h +++ b/arch/cris/include/asm/uaccess.h @@ -47,12 +47,13 @@ #define get_fs() (current_thread_info()->addr_limit) #define set_fs(x) (current_thread_info()->addr_limit = (x)) -#define segment_eq(a,b) ((a).seg == (b).seg) +#define segment_eq(a, b) ((a).seg == (b).seg) #define __kernel_ok (segment_eq(get_fs(), KERNEL_DS)) -#define __user_ok(addr,size) (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size))) -#define __access_ok(addr,size) (__kernel_ok || __user_ok((addr),(size))) -#define access_ok(type,addr,size) __access_ok((unsigned long)(addr),(size)) +#define __user_ok(addr, size) \ + (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size))) +#define __access_ok(addr, size) (__kernel_ok || __user_ok((addr), (size))) +#define access_ok(type, addr, size) __access_ok((unsigned long)(addr), (size)) #include @@ -92,56 +93,56 @@ struct exception_table_entry * CRIS, we can just do these as direct assignments. (Of course, the * exception handling means that it's no longer "just"...) */ -#define get_user(x,ptr) \ - __get_user_check((x),(ptr),sizeof(*(ptr))) -#define put_user(x,ptr) \ - __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) +#define get_user(x, ptr) \ + __get_user_check((x), (ptr), sizeof(*(ptr))) +#define put_user(x, ptr) \ + __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) -#define __get_user(x,ptr) \ - __get_user_nocheck((x),(ptr),sizeof(*(ptr))) -#define __put_user(x,ptr) \ - __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) +#define __get_user(x, ptr) \ + __get_user_nocheck((x), (ptr), sizeof(*(ptr))) +#define __put_user(x, ptr) \ + __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) extern long __put_user_bad(void); -#define __put_user_size(x,ptr,size,retval) \ -do { \ - retval = 0; \ - switch (size) { \ - case 1: __put_user_asm(x,ptr,retval,"move.b"); break; \ - case 2: __put_user_asm(x,ptr,retval,"move.w"); break; \ - case 4: __put_user_asm(x,ptr,retval,"move.d"); break; \ - case 8: __put_user_asm_64(x,ptr,retval); break; \ - default: __put_user_bad(); \ - } \ +#define __put_user_size(x, ptr, size, retval) \ +do { \ + retval = 0; \ + switch (size) { \ + case 1: __put_user_asm(x, ptr, retval, "move.b"); break; \ + case 2: __put_user_asm(x, ptr, retval, "move.w"); break; \ + case 4: __put_user_asm(x, ptr, retval, "move.d"); break; \ + case 8: __put_user_asm_64(x, ptr, retval); break; \ + default: __put_user_bad(); \ + } \ } while (0) -#define __get_user_size(x,ptr,size,retval) \ -do { \ - retval = 0; \ - switch (size) { \ - case 1: __get_user_asm(x,ptr,retval,"move.b"); break; \ - case 2: __get_user_asm(x,ptr,retval,"move.w"); break; \ - case 4: __get_user_asm(x,ptr,retval,"move.d"); break; \ - case 8: __get_user_asm_64(x,ptr,retval); break; \ - default: (x) = __get_user_bad(); \ - } \ +#define __get_user_size(x, ptr, size, retval) \ +do { \ + retval = 0; \ + switch (size) { \ + case 1: __get_user_asm(x, ptr, retval, "move.b"); break; \ + case 2: __get_user_asm(x, ptr, retval, "move.w"); break; \ + case 4: __get_user_asm(x, ptr, retval, "move.d"); break; \ + case 8: __get_user_asm_64(x, ptr, retval); break; \ + default: (x) = __get_user_bad(); \ + } \ } while (0) -#define __put_user_nocheck(x,ptr,size) \ +#define __put_user_nocheck(x, ptr, size) \ ({ \ long __pu_err; \ - __put_user_size((x),(ptr),(size),__pu_err); \ + __put_user_size((x), (ptr), (size), __pu_err); \ __pu_err; \ }) -#define __put_user_check(x,ptr,size) \ -({ \ - long __pu_err = -EFAULT; \ - __typeof__(*(ptr)) *__pu_addr = (ptr); \ - if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ - __put_user_size((x),__pu_addr,(size),__pu_err); \ - __pu_err; \ +#define __put_user_check(x, ptr, size) \ +({ \ + long __pu_err = -EFAULT; \ + __typeof__(*(ptr)) *__pu_addr = (ptr); \ + if (access_ok(VERIFY_WRITE, __pu_addr, size)) \ + __put_user_size((x), __pu_addr, (size), __pu_err); \ + __pu_err; \ }) struct __large_struct { unsigned long buf[100]; }; @@ -149,20 +150,20 @@ struct __large_struct { unsigned long buf[100]; }; -#define __get_user_nocheck(x,ptr,size) \ +#define __get_user_nocheck(x, ptr, size) \ ({ \ long __gu_err, __gu_val; \ - __get_user_size(__gu_val,(ptr),(size),__gu_err); \ + __get_user_size(__gu_val, (ptr), (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ }) -#define __get_user_check(x,ptr,size) \ +#define __get_user_check(x, ptr, size) \ ({ \ long __gu_err = -EFAULT, __gu_val = 0; \ const __typeof__(*(ptr)) *__gu_addr = (ptr); \ - if (access_ok(VERIFY_READ,__gu_addr,size)) \ - __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \ + if (access_ok(VERIFY_READ, __gu_addr, size)) \ + __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ }) @@ -180,7 +181,7 @@ static inline unsigned long __generic_copy_to_user(void __user *to, const void *from, unsigned long n) { if (access_ok(VERIFY_WRITE, to, n)) - return __copy_user(to,from,n); + return __copy_user(to, from, n); return n; } @@ -188,7 +189,7 @@ static inline unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n) { if (access_ok(VERIFY_READ, from, n)) - return __copy_user_zeroing(to,from,n); + return __copy_user_zeroing(to, from, n); return n; } @@ -196,7 +197,7 @@ static inline unsigned long __generic_clear_user(void __user *to, unsigned long n) { if (access_ok(VERIFY_WRITE, to, n)) - return __do_clear_user(to,n); + return __do_clear_user(to, n); return n; } @@ -373,29 +374,31 @@ static inline unsigned long __generic_copy_from_user_nocheck(void *to, const void __user *from, unsigned long n) { - return __copy_user_zeroing(to,from,n); + return __copy_user_zeroing(to, from, n); } static inline unsigned long __generic_copy_to_user_nocheck(void __user *to, const void *from, unsigned long n) { - return __copy_user(to,from,n); + return __copy_user(to, from, n); } static inline unsigned long __generic_clear_user_nocheck(void __user *to, unsigned long n) { - return __do_clear_user(to,n); + return __do_clear_user(to, n); } /* without checking */ -#define __copy_to_user(to,from,n) __generic_copy_to_user_nocheck((to),(from),(n)) -#define __copy_from_user(to,from,n) __generic_copy_from_user_nocheck((to),(from),(n)) +#define __copy_to_user(to, from, n) \ + __generic_copy_to_user_nocheck((to), (from), (n)) +#define __copy_from_user(to, from, n) \ + __generic_copy_from_user_nocheck((to), (from), (n)) #define __copy_to_user_inatomic __copy_to_user #define __copy_from_user_inatomic __copy_from_user -#define __clear_user(to,n) __generic_clear_user_nocheck((to),(n)) +#define __clear_user(to, n) __generic_clear_user_nocheck((to), (n)) #define strlen_user(str) strnlen_user((str), 0x7ffffffe) From 9987c19ed9a71693bf3efce2957666b2513a5252 Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Mon, 9 Feb 2015 13:02:38 +0100 Subject: [PATCH 8/8] CRIS: Whitespace cleanup No functional change, just clean up the most obvious. Signed-off-by: Jesper Nilsson --- arch/cris/include/asm/uaccess.h | 83 +++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 31 deletions(-) diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h index a21344ab8616..e3530d0f13ee 100644 --- a/arch/cris/include/asm/uaccess.h +++ b/arch/cris/include/asm/uaccess.h @@ -1,4 +1,4 @@ -/* +/* * Authors: Bjorn Wesen (bjornw@axis.com) * Hans-Peter Nilsson (hp@axis.com) */ @@ -35,7 +35,7 @@ #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) /* addr_limit is the maximum accessible address for the task. we misuse - * the KERNEL_DS and USER_DS values to both assign and compare the + * the KERNEL_DS and USER_DS values to both assign and compare the * addr_limit values through the equally misnamed get/set_fs macros. * (see above) */ @@ -51,7 +51,7 @@ #define __kernel_ok (segment_eq(get_fs(), KERNEL_DS)) #define __user_ok(addr, size) \ - (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size))) + (((size) <= TASK_SIZE) && ((addr) <= TASK_SIZE-(size))) #define __access_ok(addr, size) (__kernel_ok || __user_ok((addr), (size))) #define access_ok(type, addr, size) __access_ok((unsigned long)(addr), (size)) @@ -70,8 +70,7 @@ * on our cache or tlb entries. */ -struct exception_table_entry -{ +struct exception_table_entry { unsigned long insn, fixup; }; @@ -94,14 +93,14 @@ struct exception_table_entry * exception handling means that it's no longer "just"...) */ #define get_user(x, ptr) \ - __get_user_check((x), (ptr), sizeof(*(ptr))) + __get_user_check((x), (ptr), sizeof(*(ptr))) #define put_user(x, ptr) \ - __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) + __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) #define __get_user(x, ptr) \ - __get_user_nocheck((x), (ptr), sizeof(*(ptr))) + __get_user_nocheck((x), (ptr), sizeof(*(ptr))) #define __put_user(x, ptr) \ - __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) + __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) extern long __put_user_bad(void); @@ -109,11 +108,20 @@ extern long __put_user_bad(void); do { \ retval = 0; \ switch (size) { \ - case 1: __put_user_asm(x, ptr, retval, "move.b"); break; \ - case 2: __put_user_asm(x, ptr, retval, "move.w"); break; \ - case 4: __put_user_asm(x, ptr, retval, "move.d"); break; \ - case 8: __put_user_asm_64(x, ptr, retval); break; \ - default: __put_user_bad(); \ + case 1: \ + __put_user_asm(x, ptr, retval, "move.b"); \ + break; \ + case 2: \ + __put_user_asm(x, ptr, retval, "move.w"); \ + break; \ + case 4: \ + __put_user_asm(x, ptr, retval, "move.d"); \ + break; \ + case 8: \ + __put_user_asm_64(x, ptr, retval); \ + break; \ + default: \ + __put_user_bad(); \ } \ } while (0) @@ -121,11 +129,20 @@ do { \ do { \ retval = 0; \ switch (size) { \ - case 1: __get_user_asm(x, ptr, retval, "move.b"); break; \ - case 2: __get_user_asm(x, ptr, retval, "move.w"); break; \ - case 4: __get_user_asm(x, ptr, retval, "move.d"); break; \ - case 8: __get_user_asm_64(x, ptr, retval); break; \ - default: (x) = __get_user_bad(); \ + case 1: \ + __get_user_asm(x, ptr, retval, "move.b"); \ + break; \ + case 2: \ + __get_user_asm(x, ptr, retval, "move.w"); \ + break; \ + case 4: \ + __get_user_asm(x, ptr, retval, "move.d"); \ + break; \ + case 8: \ + __get_user_asm_64(x, ptr, retval); \ + break; \ + default: \ + (x) = __get_user_bad(); \ } \ } while (0) @@ -211,6 +228,7 @@ static inline long strncpy_from_user(char *dst, const char __user *src, long count) { long res = -EFAULT; + if (access_ok(VERIFY_READ, src, 1)) res = __do_strncpy_from_user(dst, src, count); return res; @@ -224,6 +242,7 @@ static inline unsigned long __constant_copy_from_user(void *to, const void __user *from, unsigned long n) { unsigned long ret = 0; + if (n == 0) ; else if (n == 1) @@ -274,6 +293,7 @@ static inline unsigned long __constant_copy_to_user(void __user *to, const void *from, unsigned long n) { unsigned long ret = 0; + if (n == 0) ; else if (n == 1) @@ -324,6 +344,7 @@ static inline unsigned long __constant_clear_user(void __user *to, unsigned long n) { unsigned long ret = 0; + if (n == 0) ; else if (n == 1) @@ -351,20 +372,20 @@ __constant_clear_user(void __user *to, unsigned long n) } -#define clear_user(to, n) \ -(__builtin_constant_p(n) ? \ - __constant_clear_user(to, n) : \ - __generic_clear_user(to, n)) +#define clear_user(to, n) \ + (__builtin_constant_p(n) ? \ + __constant_clear_user(to, n) : \ + __generic_clear_user(to, n)) -#define copy_from_user(to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_copy_from_user(to, from, n) : \ - __generic_copy_from_user(to, from, n)) +#define copy_from_user(to, from, n) \ + (__builtin_constant_p(n) ? \ + __constant_copy_from_user(to, from, n) : \ + __generic_copy_from_user(to, from, n)) -#define copy_to_user(to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_copy_to_user(to, from, n) : \ - __generic_copy_to_user(to, from, n)) +#define copy_to_user(to, from, n) \ + (__builtin_constant_p(n) ? \ + __constant_copy_to_user(to, from, n) : \ + __generic_copy_to_user(to, from, n)) /* We let the __ versions of copy_from/to_user inline, because they're often * used in fast paths and have only a small space overhead.