powerpc: Remove direct call to mmap2 syscall handlers
Subsystems (2)
PATCH v2 3/14 powerpc: Remove direct call to mmap2 syscall handlers
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.
---
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(-)
arch/powerpc/kernel/sys_ppc32.c +0 -10
@@ -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.
arch/powerpc/kernel/syscalls.c +11 -0
@@ -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)
arch/powerpc/kernel/syscalls/syscall.tbl +1 -1
@@ -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
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +2 -2
@@ -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 310 nospu subpage_prot sys_subpage_prot 311 32 timerfd_settime sys_timerfd_settime32 311 64 timerfd_settime sys_timerfd_settime
Signature · 1 line
2.34.1
Quoted 24 lines · Rohan McLure
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +0
-0@@ -243,7 +243,7 @@189 nospu vfork sys_vfork 190 common ugetrlimit sys_getrlimit
compat_sys_getrlimit
191 common readahead sys_readaheadcompat_sys_ppc_readahead
-
192 32 mmap2 sys_mmap2compat_sys_ppc_mmap2
+192 32 mmap2 sys_mmap2compat_sys_mmap2
193 32 truncate64 sys_truncate64compat_sys_ppc_truncate64
194 32 ftruncate64 sys_ftruncate64compat_sys_ppc_ftruncate64
195 32 stat64 sys_stat64tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +0
-0@@ -391,7 +391,7 @@306 common timerfd_create sys_timerfd_create
Quoted 8 lines
307 common eventfd sys_eventfd 308 common sync_file_range2 sys_sync_file_range2
compat_sys_ppc_sync_file_range2
-
309 nospu fallocate sys_fallocatecompat_sys_ppc_fallocate
+309 nospu fallocate sys_fallocatecompat_sys_fallocate
This should be in patch 5?
Quoted 3 lines
310 nospu subpage_prot sys_subpage_prot 311 32 timerfd_settime sys_timerfd_settime32 311 64 timerfd_settime sys_timerfd_settime
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Le 25/07/2022 à 08:25, Rohan McLure a écrit :
Quoted 71 lines
Syscall handlers should not be invoked internally by their symbol names, as these symbols defined by the architecture-defined
SYSCALL_DEFINEmacro. Move the compatibility syscall definition for mmap2 tosyscalls.c, so that all mmap implementations can share an inline helper function, as is done with the personality handlers.Signed-off-by Rohan McLure <[email protected]>---
V1 -> V2: Move mmap2 compat implementation toasm/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(-)arch/powerpc/kernel/sys_ppc32.c +0
-10@@ -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. arch/powerpc/kernel/syscalls.c +11
-0@@ -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)arch/powerpc/kernel/syscalls/syscall.tbl +0
-0
arch/powerpc/kernel/syscalls/syscall.tbl line 246
Quoted 5 lines
arch/powerpc/kernel/syscalls/syscall.tbl +1
-1@@ -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 ?
Quoted 17 lines
arch/powerpc/kernel/syscalls/syscall.tbl +0
-0193 32 truncate64 sys_truncate64 compat_sys_ppc_truncate64 194 32 ftruncate64 sys_ftruncate64 compat_sys_ppc_ftruncate64 195 32 stat64 sys_stat64tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +1
-1@@ -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
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl line 394
Quoted 5 lines
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +1
-1@@ -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 ?
Quoted 3 lines
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +0
-0310 nospu subpage_prot sys_subpage_prot 311 32 timerfd_settime sys_timerfd_settime32 311 64 timerfd_settime sys_timerfd_settime