brcm2708: update linux 4.4 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0215-copy_from_user-CPU_SW_DOMAIN_PAN-compatibility.patch
1 From cfe94ad9e10d75790f783296006c60fb89beb321 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 29 Mar 2016 15:32:30 +0100
4 Subject: [PATCH] copy_from_user: CPU_SW_DOMAIN_PAN compatibility
5
6 The downstream copy_from_user acceleration must also play nice with
7 CONFIG_CPU_SW_DOMAIN_PAN.
8
9 See: https://github.com/raspberrypi/linux/issues/1381
10
11 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
12 ---
13 arch/arm/lib/uaccess_with_memcpy.c | 14 +++++++++++---
14 1 file changed, 11 insertions(+), 3 deletions(-)
15
16 --- a/arch/arm/lib/uaccess_with_memcpy.c
17 +++ b/arch/arm/lib/uaccess_with_memcpy.c
18 @@ -186,6 +186,7 @@ out:
19 unsigned long noinline
20 __copy_from_user_memcpy(void *to, const void __user *from, unsigned long n)
21 {
22 + unsigned long ua_flags;
23 int atomic;
24
25 if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
26 @@ -217,7 +218,9 @@ __copy_from_user_memcpy(void *to, const
27 if (tocopy > n)
28 tocopy = n;
29
30 + ua_flags = uaccess_save_and_enable();
31 memcpy(to, (const void *)from, tocopy);
32 + uaccess_restore(ua_flags);
33 to += tocopy;
34 from += tocopy;
35 n -= tocopy;
36 @@ -261,9 +264,14 @@ arm_copy_from_user(void *to, const void
37 * With frame pointer disabled, tail call optimization kicks in
38 * as well making this test almost invisible.
39 */
40 - if (n < COPY_FROM_USER_THRESHOLD)
41 - return __copy_from_user_std(to, from, n);
42 - return __copy_from_user_memcpy(to, from, n);
43 + if (n < COPY_TO_USER_THRESHOLD) {
44 + unsigned long ua_flags = uaccess_save_and_enable();
45 + n = __copy_from_user_std(to, from, n);
46 + uaccess_restore(ua_flags);
47 + } else {
48 + n = __copy_from_user_memcpy(to, from, n);
49 + }
50 + return n;
51 }
52
53 static unsigned long noinline