[PATCH] arm64:ilp32: force sync_file_range2

From: Bamvor Jian Zhang
Date: Sat Aug 27 2016 - 00:26:31 EST


Define __ARCH_WANT_SYNC_FILE_RANGE2 in order to select correct
sync_file_range parameters sequence in glibc and kernel.

Tested-by: Jianguo Chen <chenjianguo3@xxxxxxxxxx>
Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@xxxxxxxxxx>
---
arch/arm64/include/uapi/asm/unistd.h | 5 +++++
arch/arm64/kernel/sys_ilp32.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h
index 043d17a..78bea1d 100644
--- a/arch/arm64/include/uapi/asm/unistd.h
+++ b/arch/arm64/include/uapi/asm/unistd.h
@@ -16,4 +16,9 @@

#define __ARCH_WANT_RENAMEAT

+/* We need to make sure it works for both userspace and kernel(sys_ilp32.c) */
+#if defined(__ILP32__) || defined(__SYSCALL_COMPAT)
+#define __ARCH_WANT_SYNC_FILE_RANGE2
+#endif
+
#include <asm-generic/unistd.h>
diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c
index 10fc0ca..13c9c9d 100644
--- a/arch/arm64/kernel/sys_ilp32.c
+++ b/arch/arm64/kernel/sys_ilp32.c
@@ -42,7 +42,7 @@
#define compat_sys_pwrite64 compat_sys_pwrite64_wrapper
#define compat_sys_readahead compat_sys_readahead_wrapper
#define compat_sys_shmat sys_shmat
-#define compat_sys_sync_file_range compat_sys_sync_file_range2_wrapper
+#define compat_sys_sync_file_range2 compat_sys_sync_file_range2_wrapper
#define compat_sys_truncate64 compat_sys_truncate64_wrapper
#define sys_mmap2 compat_sys_mmap2_wrapper
#define sys_ptrace compat_sys_ptrace
--
1.8.4.5

> +#define sys_mmap2 compat_sys_mmap2_wrapper
> +#define sys_ptrace compat_sys_ptrace
> +
> +/*
> + * Use non-compat syscall handlers where rlimit, stat and statfs
> + * structure pointers are passed, as their layout is identical to LP64.
> + */
> +#define compat_sys_fstatfs64 sys_fstatfs
> +#define compat_sys_statfs64 sys_statfs
> +#define sys_fstat64 sys_newfstat
> +#define sys_fstatat64 sys_newfstatat
> +#define compat_sys_getrlimit sys_getrlimit
> +#define compat_sys_setrlimit sys_setrlimit
> +
> +asmlinkage long compat_sys_fadvise64_64_wrapper(void);
> +asmlinkage long compat_sys_fallocate_wrapper(void);
> +asmlinkage long compat_sys_ftruncate64_wrapper(void);
> +asmlinkage long compat_sys_mmap2_wrapper(void);
> +asmlinkage long compat_sys_pread64_wrapper(void);
> +asmlinkage long compat_sys_pwrite64_wrapper(void);
> +asmlinkage long compat_sys_readahead_wrapper(void);
> +asmlinkage long compat_sys_sync_file_range2_wrapper(void);
> +asmlinkage long compat_sys_truncate64_wrapper(void);
> +
> +asmlinkage long ilp32_sys_rt_sigreturn_wrapper(void);
> +#define compat_sys_rt_sigreturn ilp32_sys_rt_sigreturn_wrapper
> +
> +#include <asm/syscall.h>
> +
> +#undef __SYSCALL
> +#define __SYSCALL(nr, sym) [nr] = sym,
> +
> +/*
> + * The sys_call_ilp32_table array must be 4K aligned to be accessible from
> + * kernel/entry.S.
> + */
> +void *sys_call_ilp32_table[__NR_syscalls] __aligned(4096) = {
> + [0 ... __NR_syscalls - 1] = sys_ni_syscall,
> +#include <asm/unistd.h>
> +};
>