aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm64/include/asm/asm-uaccess.h65
-rw-r--r--arch/arm64/include/asm/uaccess.h64
-rw-r--r--arch/arm64/kernel/entry.S2
-rw-r--r--arch/arm64/lib/clear_user.S2
-rw-r--r--arch/arm64/lib/copy_from_user.S2
-rw-r--r--arch/arm64/lib/copy_in_user.S2
-rw-r--r--arch/arm64/lib/copy_to_user.S2
-rw-r--r--arch/arm64/mm/cache.S2
-rw-r--r--arch/arm64/xen/hypercall.S2
9 files changed, 72 insertions, 71 deletions
diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h
new file mode 100644
index 000000000000..df411f3e083c
--- /dev/null
+++ b/arch/arm64/include/asm/asm-uaccess.h
@@ -0,0 +1,65 @@
1#ifndef __ASM_ASM_UACCESS_H
2#define __ASM_ASM_UACCESS_H
3
4#include <asm/alternative.h>
5#include <asm/kernel-pgtable.h>
6#include <asm/sysreg.h>
7#include <asm/assembler.h>
8
9/*
10 * User access enabling/disabling macros.
11 */
12#ifdef CONFIG_ARM64_SW_TTBR0_PAN
13 .macro __uaccess_ttbr0_disable, tmp1
14 mrs \tmp1, ttbr1_el1 // swapper_pg_dir
15 add \tmp1, \tmp1, #SWAPPER_DIR_SIZE // reserved_ttbr0 at the end of swapper_pg_dir
16 msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
17 isb
18 .endm
19
20 .macro __uaccess_ttbr0_enable, tmp1
21 get_thread_info \tmp1
22 ldr \tmp1, [\tmp1, #TSK_TI_TTBR0] // load saved TTBR0_EL1
23 msr ttbr0_el1, \tmp1 // set the non-PAN TTBR0_EL1
24 isb
25 .endm
26
27 .macro uaccess_ttbr0_disable, tmp1
28alternative_if_not ARM64_HAS_PAN
29 __uaccess_ttbr0_disable \tmp1
30alternative_else_nop_endif
31 .endm
32
33 .macro uaccess_ttbr0_enable, tmp1, tmp2
34alternative_if_not ARM64_HAS_PAN
35 save_and_disable_irq \tmp2 // avoid preemption
36 __uaccess_ttbr0_enable \tmp1
37 restore_irq \tmp2
38alternative_else_nop_endif
39 .endm
40#else
41 .macro uaccess_ttbr0_disable, tmp1
42 .endm
43
44 .macro uaccess_ttbr0_enable, tmp1, tmp2
45 .endm
46#endif
47
48/*
49 * These macros are no-ops when UAO is present.
50 */
51 .macro uaccess_disable_not_uao, tmp1
52 uaccess_ttbr0_disable \tmp1
53alternative_if ARM64_ALT_PAN_NOT_UAO
54 SET_PSTATE_PAN(1)
55alternative_else_nop_endif
56 .endm
57
58 .macro uaccess_enable_not_uao, tmp1, tmp2
59 uaccess_ttbr0_enable \tmp1, \tmp2
60alternative_if ARM64_ALT_PAN_NOT_UAO
61 SET_PSTATE_PAN(0)
62alternative_else_nop_endif
63 .endm
64
65#endif
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index d26750ca6e06..46da3ea638bb 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -22,8 +22,6 @@
22#include <asm/kernel-pgtable.h> 22#include <asm/kernel-pgtable.h>
23#include <asm/sysreg.h> 23#include <asm/sysreg.h>
24 24
25#ifndef __ASSEMBLY__
26
27/* 25/*
28 * User space memory access functions 26 * User space memory access functions
29 */ 27 */
@@ -424,66 +422,4 @@ extern long strncpy_from_user(char *dest, const char __user *src, long count);
424extern __must_check long strlen_user(const char __user *str); 422extern __must_check long strlen_user(const char __user *str);
425extern __must_check long strnlen_user(const char __user *str, long n); 423extern __must_check long strnlen_user(const char __user *str, long n);
426 424
427#else /* __ASSEMBLY__ */
428
429#include <asm/assembler.h>
430
431/*
432 * User access enabling/disabling macros.
433 */
434#ifdef CONFIG_ARM64_SW_TTBR0_PAN
435 .macro __uaccess_ttbr0_disable, tmp1
436 mrs \tmp1, ttbr1_el1 // swapper_pg_dir
437 add \tmp1, \tmp1, #SWAPPER_DIR_SIZE // reserved_ttbr0 at the end of swapper_pg_dir
438 msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
439 isb
440 .endm
441
442 .macro __uaccess_ttbr0_enable, tmp1
443 get_thread_info \tmp1
444 ldr \tmp1, [\tmp1, #TSK_TI_TTBR0] // load saved TTBR0_EL1
445 msr ttbr0_el1, \tmp1 // set the non-PAN TTBR0_EL1
446 isb
447 .endm
448
449 .macro uaccess_ttbr0_disable, tmp1
450alternative_if_not ARM64_HAS_PAN
451 __uaccess_ttbr0_disable \tmp1
452alternative_else_nop_endif
453 .endm
454
455 .macro uaccess_ttbr0_enable, tmp1, tmp2
456alternative_if_not ARM64_HAS_PAN
457 save_and_disable_irq \tmp2 // avoid preemption
458 __uaccess_ttbr0_enable \tmp1
459 restore_irq \tmp2
460alternative_else_nop_endif
461 .endm
462#else
463 .macro uaccess_ttbr0_disable, tmp1
464 .endm
465
466 .macro uaccess_ttbr0_enable, tmp1, tmp2
467 .endm
468#endif
469
470/*
471 * These macros are no-ops when UAO is present.
472 */
473 .macro uaccess_disable_not_uao, tmp1
474 uaccess_ttbr0_disable \tmp1
475alternative_if ARM64_ALT_PAN_NOT_UAO
476 SET_PSTATE_PAN(1)
477alternative_else_nop_endif
478 .endm
479
480 .macro uaccess_enable_not_uao, tmp1, tmp2
481 uaccess_ttbr0_enable \tmp1, \tmp2
482alternative_if ARM64_ALT_PAN_NOT_UAO
483 SET_PSTATE_PAN(0)
484alternative_else_nop_endif
485 .endm
486
487#endif /* __ASSEMBLY__ */
488
489#endif /* __ASM_UACCESS_H */ 425#endif /* __ASM_UACCESS_H */
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index a7504f40d7ee..923841ffe4a9 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -31,7 +31,7 @@
31#include <asm/memory.h> 31#include <asm/memory.h>
32#include <asm/ptrace.h> 32#include <asm/ptrace.h>
33#include <asm/thread_info.h> 33#include <asm/thread_info.h>
34#include <linux/uaccess.h> 34#include <asm/asm-uaccess.h>
35#include <asm/unistd.h> 35#include <asm/unistd.h>
36 36
37/* 37/*
diff --git a/arch/arm64/lib/clear_user.S b/arch/arm64/lib/clear_user.S
index add4a1334085..e88fb99c1561 100644
--- a/arch/arm64/lib/clear_user.S
+++ b/arch/arm64/lib/clear_user.S
@@ -17,7 +17,7 @@
17 */ 17 */
18#include <linux/linkage.h> 18#include <linux/linkage.h>
19 19
20#include <linux/uaccess.h> 20#include <asm/asm-uaccess.h>
21 21
22 .text 22 .text
23 23
diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S
index fd6cd05593f9..4b5d826895ff 100644
--- a/arch/arm64/lib/copy_from_user.S
+++ b/arch/arm64/lib/copy_from_user.S
@@ -17,7 +17,7 @@
17#include <linux/linkage.h> 17#include <linux/linkage.h>
18 18
19#include <asm/cache.h> 19#include <asm/cache.h>
20#include <linux/uaccess.h> 20#include <asm/asm-uaccess.h>
21 21
22/* 22/*
23 * Copy from user space to a kernel buffer (alignment handled by the hardware) 23 * Copy from user space to a kernel buffer (alignment handled by the hardware)
diff --git a/arch/arm64/lib/copy_in_user.S b/arch/arm64/lib/copy_in_user.S
index d828540ded6f..47184c3a97da 100644
--- a/arch/arm64/lib/copy_in_user.S
+++ b/arch/arm64/lib/copy_in_user.S
@@ -19,7 +19,7 @@
19#include <linux/linkage.h> 19#include <linux/linkage.h>
20 20
21#include <asm/cache.h> 21#include <asm/cache.h>
22#include <linux/uaccess.h> 22#include <asm/asm-uaccess.h>
23 23
24/* 24/*
25 * Copy from user space to user space (alignment handled by the hardware) 25 * Copy from user space to user space (alignment handled by the hardware)
diff --git a/arch/arm64/lib/copy_to_user.S b/arch/arm64/lib/copy_to_user.S
index 3e6ae2663b82..351f0766f7a6 100644
--- a/arch/arm64/lib/copy_to_user.S
+++ b/arch/arm64/lib/copy_to_user.S
@@ -17,7 +17,7 @@
17#include <linux/linkage.h> 17#include <linux/linkage.h>
18 18
19#include <asm/cache.h> 19#include <asm/cache.h>
20#include <linux/uaccess.h> 20#include <asm/asm-uaccess.h>
21 21
22/* 22/*
23 * Copy to user space from a kernel buffer (alignment handled by the hardware) 23 * Copy to user space from a kernel buffer (alignment handled by the hardware)
diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S
index 17f422a4dc55..83c27b6e6dca 100644
--- a/arch/arm64/mm/cache.S
+++ b/arch/arm64/mm/cache.S
@@ -23,7 +23,7 @@
23#include <asm/assembler.h> 23#include <asm/assembler.h>
24#include <asm/cpufeature.h> 24#include <asm/cpufeature.h>
25#include <asm/alternative.h> 25#include <asm/alternative.h>
26#include <linux/uaccess.h> 26#include <asm/asm-uaccess.h>
27 27
28/* 28/*
29 * flush_icache_range(start,end) 29 * flush_icache_range(start,end)
diff --git a/arch/arm64/xen/hypercall.S b/arch/arm64/xen/hypercall.S
index 47cf3f9d89ff..947830a459d2 100644
--- a/arch/arm64/xen/hypercall.S
+++ b/arch/arm64/xen/hypercall.S
@@ -49,7 +49,7 @@
49 49
50#include <linux/linkage.h> 50#include <linux/linkage.h>
51#include <asm/assembler.h> 51#include <asm/assembler.h>
52#include <linux/uaccess.h> 52#include <asm/asm-uaccess.h>
53#include <xen/interface/xen.h> 53#include <xen/interface/xen.h>
54 54
55 55