Skip to content

Commit b4b8664

Browse files
author
Al Viro
committed
arm64: don't pull uaccess.h into *.S
Split asm-only parts of arm64 uaccess.h into a new header and use that from *.S. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 7ce7d89 commit b4b8664

File tree

9 files changed

+72
-71
lines changed

9 files changed

+72
-71
lines changed

arch/arm64/include/asm/asm-uaccess.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
28+
alternative_if_not ARM64_HAS_PAN
29+
__uaccess_ttbr0_disable \tmp1
30+
alternative_else_nop_endif
31+
.endm
32+
33+
.macro uaccess_ttbr0_enable, tmp1, tmp2
34+
alternative_if_not ARM64_HAS_PAN
35+
save_and_disable_irq \tmp2 // avoid preemption
36+
__uaccess_ttbr0_enable \tmp1
37+
restore_irq \tmp2
38+
alternative_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
53+
alternative_if ARM64_ALT_PAN_NOT_UAO
54+
SET_PSTATE_PAN(1)
55+
alternative_else_nop_endif
56+
.endm
57+
58+
.macro uaccess_enable_not_uao, tmp1, tmp2
59+
uaccess_ttbr0_enable \tmp1, \tmp2
60+
alternative_if ARM64_ALT_PAN_NOT_UAO
61+
SET_PSTATE_PAN(0)
62+
alternative_else_nop_endif
63+
.endm
64+
65+
#endif

arch/arm64/include/asm/uaccess.h

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <asm/kernel-pgtable.h>
2323
#include <asm/sysreg.h>
2424

25-
#ifndef __ASSEMBLY__
26-
2725
/*
2826
* User space memory access functions
2927
*/
@@ -424,66 +422,4 @@ extern long strncpy_from_user(char *dest, const char __user *src, long count);
424422
extern __must_check long strlen_user(const char __user *str);
425423
extern __must_check long strnlen_user(const char __user *str, long n);
426424

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
450-
alternative_if_not ARM64_HAS_PAN
451-
__uaccess_ttbr0_disable \tmp1
452-
alternative_else_nop_endif
453-
.endm
454-
455-
.macro uaccess_ttbr0_enable, tmp1, tmp2
456-
alternative_if_not ARM64_HAS_PAN
457-
save_and_disable_irq \tmp2 // avoid preemption
458-
__uaccess_ttbr0_enable \tmp1
459-
restore_irq \tmp2
460-
alternative_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
475-
alternative_if ARM64_ALT_PAN_NOT_UAO
476-
SET_PSTATE_PAN(1)
477-
alternative_else_nop_endif
478-
.endm
479-
480-
.macro uaccess_enable_not_uao, tmp1, tmp2
481-
uaccess_ttbr0_enable \tmp1, \tmp2
482-
alternative_if ARM64_ALT_PAN_NOT_UAO
483-
SET_PSTATE_PAN(0)
484-
alternative_else_nop_endif
485-
.endm
486-
487-
#endif /* __ASSEMBLY__ */
488-
489425
#endif /* __ASM_UACCESS_H */

arch/arm64/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <asm/memory.h>
3232
#include <asm/ptrace.h>
3333
#include <asm/thread_info.h>
34-
#include <linux/uaccess.h>
34+
#include <asm/asm-uaccess.h>
3535
#include <asm/unistd.h>
3636

3737
/*

arch/arm64/lib/clear_user.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
#include <linux/linkage.h>
1919

20-
#include <linux/uaccess.h>
20+
#include <asm/asm-uaccess.h>
2121

2222
.text
2323

arch/arm64/lib/copy_from_user.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <linux/linkage.h>
1818

1919
#include <asm/cache.h>
20-
#include <linux/uaccess.h>
20+
#include <asm/asm-uaccess.h>
2121

2222
/*
2323
* Copy from user space to a kernel buffer (alignment handled by the hardware)

arch/arm64/lib/copy_in_user.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/linkage.h>
2020

2121
#include <asm/cache.h>
22-
#include <linux/uaccess.h>
22+
#include <asm/asm-uaccess.h>
2323

2424
/*
2525
* Copy from user space to user space (alignment handled by the hardware)

arch/arm64/lib/copy_to_user.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <linux/linkage.h>
1818

1919
#include <asm/cache.h>
20-
#include <linux/uaccess.h>
20+
#include <asm/asm-uaccess.h>
2121

2222
/*
2323
* Copy to user space from a kernel buffer (alignment handled by the hardware)

arch/arm64/mm/cache.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <asm/assembler.h>
2424
#include <asm/cpufeature.h>
2525
#include <asm/alternative.h>
26-
#include <linux/uaccess.h>
26+
#include <asm/asm-uaccess.h>
2727

2828
/*
2929
* flush_icache_range(start,end)

arch/arm64/xen/hypercall.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
#include <linux/linkage.h>
5151
#include <asm/assembler.h>
52-
#include <linux/uaccess.h>
52+
#include <asm/asm-uaccess.h>
5353
#include <xen/interface/xen.h>
5454

5555

0 commit comments

Comments
 (0)