[PATCH v2 03/14] powerpc: Remove direct call to mmap2 syscall handlers
Christophe Leroy
christophe.leroy at csgroup.eu
Mon Aug 8 19:43:50 AEST 2022
Le 25/07/2022 à 08:25, Rohan McLure a écrit :
> Syscall handlers should not be invoked internally by their symbol names,
> as these symbols defined by the architecture-defined SYSCALL_DEFINE
> macro. Move the compatibility syscall definition for mmap2 to
> syscalls.c, so that all mmap implementations can share an inline helper
> function, as is done with the personality handlers.
>
> Signed-off-by: Rohan McLure <rmclure at linux.ibm.com>
> ---
> V1 -> V2: Move mmap2 compat implementation to asm/kernel/syscalls.c.
> ---
> arch/powerpc/kernel/sys_ppc32.c | 10 ----------
> arch/powerpc/kernel/syscalls.c | 11 +++++++++++
> arch/powerpc/kernel/syscalls/syscall.tbl | 2 +-
> tools/perf/arch/powerpc/entry/syscalls/syscall.tbl | 4 ++--
> 4 files changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
> index c3490adcb158..89e8c478fd6a 100644
> --- a/arch/powerpc/kernel/sys_ppc32.c
> +++ b/arch/powerpc/kernel/sys_ppc32.c
> @@ -25,7 +25,6 @@
> #include <linux/poll.h>
> #include <linux/personality.h>
> #include <linux/stat.h>
> -#include <linux/mman.h>
> #include <linux/in.h>
> #include <linux/syscalls.h>
> #include <linux/unistd.h>
> @@ -48,15 +47,6 @@
> #include <asm/syscalls.h>
> #include <asm/switch_to.h>
>
> -COMPAT_SYSCALL_DEFINE6(mmap2,
> - unsigned long, addr, size_t, len,
> - unsigned long, prot, unsigned long, flags,
> - unsigned long, fd, unsigned long, pgoff)
> -{
> - /* This should remain 12 even if PAGE_SIZE changes */
> - return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
> -}
> -
> /*
> * long long munging:
> * The 32 bit ABI passes long longs in an odd even register pair.
> diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
> index 22755502afc0..9f339bcb433d 100644
> --- a/arch/powerpc/kernel/syscalls.c
> +++ b/arch/powerpc/kernel/syscalls.c
> @@ -56,6 +56,17 @@ SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
> return do_mmap2(addr, len, prot, flags, fd, pgoff, PAGE_SHIFT-12);
> }
>
> +#ifdef CONFIG_COMPAT
> +COMPAT_SYSCALL_DEFINE6(mmap2,
> + unsigned long, addr, size_t, len,
> + unsigned long, prot, unsigned long, flags,
> + unsigned long, fd, unsigned long, pgoff)
> +{
> + /* This should remain 12 even if PAGE_SIZE changes */
> + return do_mmap2(addr, len, prot, flags, fd, pgoff << 12, PAGE_SHIFT-12);
> +}
> +#endif
> +
> SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
> unsigned long, prot, unsigned long, flags,
> unsigned long, fd, off_t, offset)
> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl
> index 54bb5834785f..59d9259dfbb5 100644
> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> @@ -243,7 +243,7 @@
> 189 nospu vfork sys_vfork
> 190 common ugetrlimit sys_getrlimit compat_sys_getrlimit
> 191 common readahead sys_readahead compat_sys_ppc_readahead
> -192 32 mmap2 sys_mmap2 compat_sys_ppc_mmap2
> +192 32 mmap2 sys_mmap2 compat_sys_mmap2
Why a name change here when the function is just move from one C file to
another without any name change ?
This look like the reverse of what was done in patch 1. Could that
change go up front so that patch 1 doesn't need a change at all in the
table ?
> 193 32 truncate64 sys_truncate64 compat_sys_ppc_truncate64
> 194 32 ftruncate64 sys_ftruncate64 compat_sys_ppc_ftruncate64
> 195 32 stat64 sys_stat64
> diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
> index 54bb5834785f..437066f5c4b2 100644
> --- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
> +++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
> @@ -243,7 +243,7 @@
> 189 nospu vfork sys_vfork
> 190 common ugetrlimit sys_getrlimit compat_sys_getrlimit
> 191 common readahead sys_readahead compat_sys_ppc_readahead
> -192 32 mmap2 sys_mmap2 compat_sys_ppc_mmap2
> +192 32 mmap2 sys_mmap2 compat_sys_mmap2
> 193 32 truncate64 sys_truncate64 compat_sys_ppc_truncate64
> 194 32 ftruncate64 sys_ftruncate64 compat_sys_ppc_ftruncate64
> 195 32 stat64 sys_stat64
> @@ -391,7 +391,7 @@
> 306 common timerfd_create sys_timerfd_create
> 307 common eventfd sys_eventfd
> 308 common sync_file_range2 sys_sync_file_range2 compat_sys_ppc_sync_file_range2
> -309 nospu fallocate sys_fallocate compat_sys_ppc_fallocate
> +309 nospu fallocate sys_fallocate compat_sys_fallocate
Why this name change ?
> 310 nospu subpage_prot sys_subpage_prot
> 311 32 timerfd_settime sys_timerfd_settime32
> 311 64 timerfd_settime sys_timerfd_settime
More information about the Linuxppc-dev
mailing list