diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2022-01-31 09:24:50 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2022-02-02 13:11:42 +0100 |
commit | 1fb85d06ad6754796cd1b920639ca9d8840abefd (patch) | |
tree | ccf0da8a52c5e498ff19c86c317e616c66ebbf1c /arch/x86/mm/maccess.c | |
parent | c243cecb58e3905baeace8827201c14df8481e2a (diff) |
x86: Share definition of __is_canonical_address()
Reduce code duplication by moving canonical address code to a common header
file.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220131072453.2839535-3-adrian.hunter@intel.com
Diffstat (limited to 'arch/x86/mm/maccess.c')
-rw-r--r-- | arch/x86/mm/maccess.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/arch/x86/mm/maccess.c b/arch/x86/mm/maccess.c index 92ec176a7293..5a53c2cc169c 100644 --- a/arch/x86/mm/maccess.c +++ b/arch/x86/mm/maccess.c @@ -4,11 +4,6 @@ #include <linux/kernel.h> #ifdef CONFIG_X86_64 -static __always_inline u64 canonical_address(u64 vaddr, u8 vaddr_bits) -{ - return ((s64)vaddr << (64 - vaddr_bits)) >> (64 - vaddr_bits); -} - bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) { unsigned long vaddr = (unsigned long)unsafe_src; @@ -19,7 +14,7 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) * we also need to include the userspace guard page. */ return vaddr >= TASK_SIZE_MAX + PAGE_SIZE && - canonical_address(vaddr, boot_cpu_data.x86_virt_bits) == vaddr; + __is_canonical_address(vaddr, boot_cpu_data.x86_virt_bits); } #else bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) |