Skip to content

Commit

Permalink
arm64: don't pull uaccess.h into *.S
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro committed Dec 26, 2016
1 parent 7ce7d89 commit b4b8664
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 71 deletions.
65 changes: 65 additions & 0 deletions arch/arm64/include/asm/asm-uaccess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef __ASM_ASM_UACCESS_H
#define __ASM_ASM_UACCESS_H

#include <asm/alternative.h>
#include <asm/kernel-pgtable.h>
#include <asm/sysreg.h>
#include <asm/assembler.h>

/*
* User access enabling/disabling macros.
*/
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
.macro __uaccess_ttbr0_disable, tmp1
mrs \tmp1, ttbr1_el1 // swapper_pg_dir
add \tmp1, \tmp1, #SWAPPER_DIR_SIZE // reserved_ttbr0 at the end of swapper_pg_dir
msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
isb
.endm

.macro __uaccess_ttbr0_enable, tmp1
get_thread_info \tmp1
ldr \tmp1, [\tmp1, #TSK_TI_TTBR0] // load saved TTBR0_EL1
msr ttbr0_el1, \tmp1 // set the non-PAN TTBR0_EL1
isb
.endm

.macro uaccess_ttbr0_disable, tmp1
alternative_if_not ARM64_HAS_PAN
__uaccess_ttbr0_disable \tmp1
alternative_else_nop_endif
.endm

.macro uaccess_ttbr0_enable, tmp1, tmp2
alternative_if_not ARM64_HAS_PAN
save_and_disable_irq \tmp2 // avoid preemption
__uaccess_ttbr0_enable \tmp1
restore_irq \tmp2
alternative_else_nop_endif
.endm
#else
.macro uaccess_ttbr0_disable, tmp1
.endm

.macro uaccess_ttbr0_enable, tmp1, tmp2
.endm
#endif

/*
* These macros are no-ops when UAO is present.
*/
.macro uaccess_disable_not_uao, tmp1
uaccess_ttbr0_disable \tmp1
alternative_if ARM64_ALT_PAN_NOT_UAO
SET_PSTATE_PAN(1)
alternative_else_nop_endif
.endm

.macro uaccess_enable_not_uao, tmp1, tmp2
uaccess_ttbr0_enable \tmp1, \tmp2
alternative_if ARM64_ALT_PAN_NOT_UAO
SET_PSTATE_PAN(0)
alternative_else_nop_endif
.endm

#endif
64 changes: 0 additions & 64 deletions arch/arm64/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <asm/kernel-pgtable.h>
#include <asm/sysreg.h>

#ifndef __ASSEMBLY__

/*
* User space memory access functions
*/
Expand Down Expand Up @@ -424,66 +422,4 @@ extern long strncpy_from_user(char *dest, const char __user *src, long count);
extern __must_check long strlen_user(const char __user *str);
extern __must_check long strnlen_user(const char __user *str, long n);

#else /* __ASSEMBLY__ */

#include <asm/assembler.h>

/*
* User access enabling/disabling macros.
*/
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
.macro __uaccess_ttbr0_disable, tmp1
mrs \tmp1, ttbr1_el1 // swapper_pg_dir
add \tmp1, \tmp1, #SWAPPER_DIR_SIZE // reserved_ttbr0 at the end of swapper_pg_dir
msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
isb
.endm

.macro __uaccess_ttbr0_enable, tmp1
get_thread_info \tmp1
ldr \tmp1, [\tmp1, #TSK_TI_TTBR0] // load saved TTBR0_EL1
msr ttbr0_el1, \tmp1 // set the non-PAN TTBR0_EL1
isb
.endm

.macro uaccess_ttbr0_disable, tmp1
alternative_if_not ARM64_HAS_PAN
__uaccess_ttbr0_disable \tmp1
alternative_else_nop_endif
.endm

.macro uaccess_ttbr0_enable, tmp1, tmp2
alternative_if_not ARM64_HAS_PAN
save_and_disable_irq \tmp2 // avoid preemption
__uaccess_ttbr0_enable \tmp1
restore_irq \tmp2
alternative_else_nop_endif
.endm
#else
.macro uaccess_ttbr0_disable, tmp1
.endm

.macro uaccess_ttbr0_enable, tmp1, tmp2
.endm
#endif

/*
* These macros are no-ops when UAO is present.
*/
.macro uaccess_disable_not_uao, tmp1
uaccess_ttbr0_disable \tmp1
alternative_if ARM64_ALT_PAN_NOT_UAO
SET_PSTATE_PAN(1)
alternative_else_nop_endif
.endm

.macro uaccess_enable_not_uao, tmp1, tmp2
uaccess_ttbr0_enable \tmp1, \tmp2
alternative_if ARM64_ALT_PAN_NOT_UAO
SET_PSTATE_PAN(0)
alternative_else_nop_endif
.endm

#endif /* __ASSEMBLY__ */

#endif /* __ASM_UACCESS_H */
2 changes: 1 addition & 1 deletion arch/arm64/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <asm/memory.h>
#include <asm/ptrace.h>
#include <asm/thread_info.h>
#include <linux/uaccess.h>
#include <asm/asm-uaccess.h>
#include <asm/unistd.h>

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/lib/clear_user.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
#include <linux/linkage.h>

#include <linux/uaccess.h>
#include <asm/asm-uaccess.h>

.text

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/lib/copy_from_user.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/linkage.h>

#include <asm/cache.h>
#include <linux/uaccess.h>
#include <asm/asm-uaccess.h>

/*
* Copy from user space to a kernel buffer (alignment handled by the hardware)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/lib/copy_in_user.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <linux/linkage.h>

#include <asm/cache.h>
#include <linux/uaccess.h>
#include <asm/asm-uaccess.h>

/*
* Copy from user space to user space (alignment handled by the hardware)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/lib/copy_to_user.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/linkage.h>

#include <asm/cache.h>
#include <linux/uaccess.h>
#include <asm/asm-uaccess.h>

/*
* Copy to user space from a kernel buffer (alignment handled by the hardware)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/mm/cache.S
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <asm/assembler.h>
#include <asm/cpufeature.h>
#include <asm/alternative.h>
#include <linux/uaccess.h>
#include <asm/asm-uaccess.h>

/*
* flush_icache_range(start,end)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/xen/hypercall.S
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

#include <linux/linkage.h>
#include <asm/assembler.h>
#include <linux/uaccess.h>
#include <asm/asm-uaccess.h>
#include <xen/interface/xen.h>


Expand Down

0 comments on commit b4b8664

Please sign in to comment.