aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2015-03-16 12:32:22 -0400
committerWill Deacon <will.deacon@arm.com>2015-03-19 06:43:51 -0400
commit18ccb0cab49ef7868eaf9504f257e1a84683dbbd (patch)
tree54d6aecbdfc68fb7a40d39cb09cee3b11ca87158
parentad08fd494bf00c03ae372e0bbd9cefa37bf608d6 (diff)
arm64: fix implementation of mmap2 compat syscall
The arm mmap2 syscall takes the offset in units of 4K, thus with 64K pages the offset needs to be scaled to units of pages. Signed-off-by: Andreas Schwab <schwab@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de> [will: removed redundant lr parameter, localised PAGE_SHIFT #if check] Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arch/arm64/include/asm/unistd32.h2
-rw-r--r--arch/arm64/kernel/entry32.S18
-rw-r--r--arch/arm64/kernel/sys32.c1
3 files changed, 20 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h
index 27224426e0bf..cef934a90f17 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -406,7 +406,7 @@ __SYSCALL(__NR_vfork, sys_vfork)
406#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ 406#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
407__SYSCALL(__NR_ugetrlimit, compat_sys_getrlimit) /* SuS compliant getrlimit */ 407__SYSCALL(__NR_ugetrlimit, compat_sys_getrlimit) /* SuS compliant getrlimit */
408#define __NR_mmap2 192 408#define __NR_mmap2 192
409__SYSCALL(__NR_mmap2, sys_mmap_pgoff) 409__SYSCALL(__NR_mmap2, compat_sys_mmap2_wrapper)
410#define __NR_truncate64 193 410#define __NR_truncate64 193
411__SYSCALL(__NR_truncate64, compat_sys_truncate64_wrapper) 411__SYSCALL(__NR_truncate64, compat_sys_truncate64_wrapper)
412#define __NR_ftruncate64 194 412#define __NR_ftruncate64 194
diff --git a/arch/arm64/kernel/entry32.S b/arch/arm64/kernel/entry32.S
index 9a8f6ae2530e..bd9bfaa9269b 100644
--- a/arch/arm64/kernel/entry32.S
+++ b/arch/arm64/kernel/entry32.S
@@ -19,9 +19,12 @@
19 */ 19 */
20 20
21#include <linux/linkage.h> 21#include <linux/linkage.h>
22#include <linux/const.h>
22 23
23#include <asm/assembler.h> 24#include <asm/assembler.h>
24#include <asm/asm-offsets.h> 25#include <asm/asm-offsets.h>
26#include <asm/errno.h>
27#include <asm/page.h>
25 28
26/* 29/*
27 * System call wrappers for the AArch32 compatibility layer. 30 * System call wrappers for the AArch32 compatibility layer.
@@ -54,6 +57,21 @@ ENTRY(compat_sys_fstatfs64_wrapper)
54ENDPROC(compat_sys_fstatfs64_wrapper) 57ENDPROC(compat_sys_fstatfs64_wrapper)
55 58
56/* 59/*
60 * Note: off_4k (w5) is always in units of 4K. If we can't do the
61 * requested offset because it is not page-aligned, we return -EINVAL.
62 */
63ENTRY(compat_sys_mmap2_wrapper)
64#if PAGE_SHIFT > 12
65 tst w5, #~PAGE_MASK >> 12
66 b.ne 1f
67 lsr w5, w5, #PAGE_SHIFT - 12
68#endif
69 b sys_mmap_pgoff
701: mov x0, #-EINVAL
71 ret
72ENDPROC(compat_sys_mmap2_wrapper)
73
74/*
57 * Wrappers for AArch32 syscalls that either take 64-bit parameters 75 * Wrappers for AArch32 syscalls that either take 64-bit parameters
58 * in registers or that take 32-bit parameters which require sign 76 * in registers or that take 32-bit parameters which require sign
59 * extension. 77 * extension.
diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c
index 2d5ab3c90b82..a40b1343b819 100644
--- a/arch/arm64/kernel/sys32.c
+++ b/arch/arm64/kernel/sys32.c
@@ -37,6 +37,7 @@ asmlinkage long compat_sys_readahead_wrapper(void);
37asmlinkage long compat_sys_fadvise64_64_wrapper(void); 37asmlinkage long compat_sys_fadvise64_64_wrapper(void);
38asmlinkage long compat_sys_sync_file_range2_wrapper(void); 38asmlinkage long compat_sys_sync_file_range2_wrapper(void);
39asmlinkage long compat_sys_fallocate_wrapper(void); 39asmlinkage long compat_sys_fallocate_wrapper(void);
40asmlinkage long compat_sys_mmap2_wrapper(void);
40 41
41#undef __SYSCALL 42#undef __SYSCALL
42#define __SYSCALL(nr, sym) [nr] = sym, 43#define __SYSCALL(nr, sym) [nr] = sym,