Skip to contentSkip to conversation

powerpc: Include all arch-specific syscall prototypes

PATCH Superseded Rohan McLure 3 participants 4 messages Jul 25, 2022 – Aug 10, 2022 PowerPC

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 6/14 powerpc: Include all arch-specific syscall prototypes

Forward declare all syscall handler prototypes where a generic prototype is not provided in either linux/syscalls.h or linux/compat.h in asm/syscalls.h. This is required for compile-time type-checking for syscall handlers, which is implemented later in this series.

32-bit compatibility syscall handlers are expressed in terms of types in ppc32.h. Expose this header globally.

---
V1 -> V2: Explicitly include prototypes.

---
 arch/powerpc/{kernel => include/asm}/ppc32.h |   0
 arch/powerpc/include/asm/syscalls.h          | 104 ++++++++++++-----
 arch/powerpc/kernel/signal_32.c              |   2 +-
 arch/powerpc/perf/callchain_32.c             |   2 +-
 4 files changed, 76 insertions(+), 32 deletions(-)
arch/powerpc/include/asm/ppc32.h renamed from arch/powerpc/kernel/ppc32.h +0 -0
similarity index 100%
rename from arch/powerpc/kernel/ppc32.h
rename to arch/powerpc/include/asm/ppc32.h
arch/powerpc/include/asm/syscalls.h +74 -30

123 lines not on this page · raw message

arch/powerpc/kernel/signal_32.c +1 -1
index 157a7403e3eb..d45c0d7d0a55 100644
@@ -43,7 +43,7 @@
 #include <asm/tm.h>
 #include <asm/asm-prototypes.h>
 #ifdef CONFIG_PPC64
-#include "ppc32.h"
+#include <asm/ppc32.h>
 #include <asm/unistd.h>
 #else
 #include <asm/ucontext.h>
arch/powerpc/perf/callchain_32.c +1 -1
index b83c47b7947f..7e94c32b8398 100644
@@ -19,7 +19,7 @@
 #include "callchain.h"
 
 #ifdef CONFIG_PPC64
-#include "../kernel/ppc32.h"
+#include <asm/ppc32.h>
 #else  /* CONFIG_PPC64 */
 
 #define __SIGNAL_FRAMESIZE32	__SIGNAL_FRAMESIZE
Signature · 1 line
2.34.1
#1 lore raw
Quoted 58 lines · Rohan McLure

Forward declare all syscall handler prototypes where a generic prototype
is not provided in either linux/syscalls.h or linux/compat.h in asm/syscalls.h. This is required for compile-time type-checking for syscall handlers, which is implemented later in this series.

32-bit compatibility syscall handlers are expressed in terms of types in
ppc32.h. Expose this header globally.

---
V1 -> V2: Explicitly include prototypes.
---
 arch/powerpc/{kernel => include/asm}/ppc32.h |   0 arch/powerpc/include/asm/syscalls.h          | 104 ++++++++++++----- arch/powerpc/kernel/signal_32.c              |   2 +- arch/powerpc/perf/callchain_32.c             |   2 +-

 4 files changed, 76 insertions(+), 32 deletions(-)
arch/powerpc/include/asm/ppc32.h renamed from arch/powerpc/kernel/ppc32.h +0 -0
similarity index 100%
rename from arch/powerpc/kernel/ppc32.h
rename to arch/powerpc/include/asm/ppc32.h
arch/powerpc/include/asm/syscalls.h +0 -0
index 025d4b877161..8b2757d7f423 100644
@@ -8,49 +8,93 @@
  #include <linux/types.h>
  #include <linux/compat.h>

arch/powerpc/include/asm/syscalls.h +6 -0
+#ifdef CONFIG_PPC64
+#include <asm/ppc32.h>
+#endif
+#include <asm/unistd.h>
+#include <asm/ucontext.h>
+

 struct rtas_args;

arch/powerpc/include/asm/syscalls.h +6 -7
-asmlinkage long sys_mmap(unsigned long addr, size_t len,
-               unsigned long prot, unsigned long flags,
-               unsigned long fd, off_t offset);
-asmlinkage long sys_mmap2(unsigned long addr, size_t len,
-               unsigned long prot, unsigned long flags,
-               unsigned long fd, unsigned long pgoff);
-asmlinkage long sys_ppc64_personality(unsigned long personality);
+#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
+
+/*
+ * PowerPC architecture-specific syscalls
+ */
+
Quoted 4 lines

 asmlinkage long sys_rtas(struct rtas_args __user *uargs); -int sys_ppc_select(int n, fd_set __user *inp, fd_set __user *outp, -                  fd_set __user *exp, struct __kernel_old_timeval __user *tvp);

Move to patch 4?

Quoted 54 lines

-long sys_ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
-                         u32 len_high, u32 len_low); +asmlinkage long sys_ni_syscall(void);

arch/powerpc/include/asm/syscalls.h +2 -0
+#ifdef CONFIG_PPC64
+asmlinkage long sys_ppc64_personality(unsigned long personality);

 #ifdef CONFIG_COMPAT
-unsigned long compat_sys_mmap2(unsigned long addr, size_t len, -                              unsigned long prot, unsigned long flags,
-                              unsigned long fd, unsigned long pgoff);
+asmlinkage long compat_sys_ppc64_personality(unsigned long personality);

arch/powerpc/include/asm/syscalls.h +2 -0
+#endif /* CONFIG_COMPAT */
+#endif /* CONFIG_PPC64 */


-compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
-                                 u32 reg6, u32 pos1, u32 pos2);

arch/powerpc/include/asm/syscalls.h +6 -0
+/* Parameters are reordered for powerpc to avoid padding */
+asmlinkage long sys_ppc_fadvise64_64(int fd, int advice,
+                                    u32 offset_high, u32 offset_low,
+                                    u32 len_high, u32 len_low);
+asmlinkage long sys_swapcontext(struct ucontext __user *old_ctx,
+                               struct ucontext __user *new_ctx, long

ctx_size);

arch/powerpc/include/asm/syscalls.h +7 -0
+asmlinkage long sys_mmap(unsigned long addr, size_t len,
+                        unsigned long prot, unsigned long flags,
+                        unsigned long fd, off_t offset);
+asmlinkage long sys_mmap2(unsigned long addr, size_t len,
+                         unsigned long prot, unsigned long flags,
+                         unsigned long fd, unsigned long pgoff);
+asmlinkage long sys_switch_endian(void);


-compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, compat_size_t count,
-                                  u32 reg6, u32 pos1, u32 pos2);

arch/powerpc/include/asm/syscalls.h +3 -0
+#ifdef CONFIG_PPC32
+asmlinkage long sys_sigreturn(void);
+asmlinkage long sys_debug_setcontext(struct ucontext __user *ctx,

int ndbg,
+                                    struct sig_dbg_op __user *dbg); +#endif

-compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offset1, u32 offset2, u32 count);
+asmlinkage long sys_rt_sigreturn(void);

arch/powerpc/include/asm/syscalls.h +2 -2
-int compat_sys_truncate64(const char __user *path, u32 reg4,
-                         unsigned long len1, unsigned long len2);
+asmlinkage long sys_subpage_prot(unsigned long addr,
+                                unsigned long len, u32 __user *map);
Quoted 3 lines


-long compat_sys_fallocate(int fd, int mode, u32 offset1, u32 offset2, u32 len1, u32 len2);

Move to patch 5?

Quoted 36 lines
arch/powerpc/include/asm/syscalls.h +2 -0
+#ifdef CONFIG_COMPAT
+asmlinkage long compat_sys_swapcontext(struct ucontext32 __user

*old_ctx,
+                                      struct ucontext32 __user *new_ctx,
+                                      int ctx_size); +asmlinkage long compat_sys_old_getrlimit(unsigned int resource, +                                        struct compat_rlimit __user *rlim);

arch/powerpc/include/asm/syscalls.h +2 -0
+asmlinkage long compat_sys_sigreturn(void);
+asmlinkage long compat_sys_rt_sigreturn(void);


-int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long len1,
-                          unsigned long len2);
+/* Architecture-specific implementations in sys_ppc32.c */
-long compat_sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
-                               size_t len, int advice); +asmlinkage long compat_sys_mmap2(unsigned long addr, size_t len, +                                    unsigned long prot, unsigned long flags,
+                                    unsigned long fd, unsigned long pgoff);
+asmlinkage long compat_sys_ppc_pread64(unsigned int fd,
+                                      char __user *ubuf, compat_size_t count,
+                                      u32 reg6, u32 pos1, u32 pos2); +asmlinkage long compat_sys_ppc_pwrite64(unsigned int fd, +                                       const char __user *ubuf, compat_size_t count,
+                                       u32 reg6, u32 pos1, u32 pos2);
+asmlinkage long compat_sys_ppc_readahead(int fd, u32 r4, +                                        u32 offset1, u32 offset2,

Quoted 8 lines

u32 count);
+asmlinkage long compat_sys_ppc_truncate64(const char __user *path, u32 reg4,
+                                         unsigned long len1, unsigned long len2);
+asmlinkage long compat_sys_ppc_fallocate(int fd, int mode, u32 offset1, u32 offset2,
+                                        u32 len1, u32 len2);

This should be unnecessary thanks to patch 5?

Quoted 27 lines

+asmlinkage long compat_sys_ppc_ftruncate64(unsigned int fd, u32 reg4,
+                                          unsigned long len1, unsigned long len2);
+asmlinkage long compat_sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
+                                          size_t len, int advice); +asmlinkage long compat_sys_ppc_sync_file_range2(int fd, unsigned int flags,
+                                               unsigned int offset1, +                                               unsigned int offset2, +                                               unsigned int nbytes1, +                                               unsigned int nbytes2);
+#endif /* CONFIG_COMPAT */

-long compat_sys_sync_file_range2(int fd, unsigned int flags, -                                unsigned int offset1, unsigned int offset2,
-                                unsigned int nbytes1, unsigned int nbytes2);

arch/powerpc/include/asm/syscalls.h +1 -1
-#endif
+#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */


 #endif /* __KERNEL__ */
 #endif /* __ASM_POWERPC_SYSCALLS_H */

Signature · 2 lines
Andrew Donnellan    OzLabs, ADL Canberra
[email protected]   IBM Australia Limited
#2 lore raw
Quoted 17 lines · Andrew Donnellan
Quoted 17 lines
arch/powerpc/include/asm/syscalls.h +0 -0
index 025d4b877161..8b2757d7f423 100644
@@ -8,49 +8,93 @@
  #include <linux/types.h>
  #include <linux/compat.h>

arch/powerpc/include/asm/syscalls.h +6 -0
+#ifdef CONFIG_PPC64
+#include <asm/ppc32.h>
+#endif
+#include <asm/unistd.h>
+#include <asm/ucontext.h>
+

 struct rtas_args;

Quoted 8 lines

arch/powerpc/include/asm/syscalls.h line 19

Quoted 8 lines
arch/powerpc/include/asm/syscalls.h +1 -7
-asmlinkage long sys_mmap(unsigned long addr, size_t len,
-               unsigned long prot, unsigned long flags,
-               unsigned long fd, off_t offset);
-asmlinkage long sys_mmap2(unsigned long addr, size_t len,
-               unsigned long prot, unsigned long flags,
-               unsigned long fd, unsigned long pgoff);
-asmlinkage long sys_ppc64_personality(unsigned long personality);
+#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER

Introduce this ifdef once it starts mattering at patch 10, I think.

Signature · 2 lines
Andrew Donnellan    OzLabs, ADL Canberra
[email protected]   IBM Australia Limited
#3 lore raw
In reply to Rohan McLure

Le 25/07/2022 à 08:27, Rohan McLure a écrit :

Quoted 5 lines

Forward declare all syscall handler prototypes where a generic prototype is not provided in either linux/syscalls.h or linux/compat.h in asm/syscalls.h. This is required for compile-time type-checking for syscall handlers, which is implemented later in this series.

Quoted 8 lines

32-bit compatibility syscall handlers are expressed in terms of types in ppc32.h. Expose this header globally.

---
V1 -> V2: Explicitly include prototypes.

---
  arch/powerpc/{kernel => include/asm}/ppc32.h |   0

I think a new name would be welcome, for instance syscalls_32.h ?

Quoted 163 lines
  arch/powerpc/include/asm/syscalls.h          | 104 ++++++++++++-----
  arch/powerpc/kernel/signal_32.c              |   2 +-
  arch/powerpc/perf/callchain_32.c             |   2 +-
  4 files changed, 76 insertions(+), 32 deletions(-)
arch/powerpc/include/asm/ppc32.h renamed from arch/powerpc/kernel/ppc32.h +0 -0
similarity index 100%
rename from arch/powerpc/kernel/ppc32.h
rename to arch/powerpc/include/asm/ppc32.h
arch/powerpc/include/asm/syscalls.h +74 -30
index 025d4b877161..8b2757d7f423 100644
@@ -8,49 +8,93 @@
  #include <linux/types.h>
  #include <linux/compat.h>
 
+#ifdef CONFIG_PPC64
+#include <asm/ppc32.h>
+#endif
+#include <asm/unistd.h>
+#include <asm/ucontext.h>
+
  struct rtas_args;
 
-asmlinkage long sys_mmap(unsigned long addr, size_t len,
-		unsigned long prot, unsigned long flags,
-		unsigned long fd, off_t offset);
-asmlinkage long sys_mmap2(unsigned long addr, size_t len,
-		unsigned long prot, unsigned long flags,
-		unsigned long fd, unsigned long pgoff);
-asmlinkage long sys_ppc64_personality(unsigned long personality);
+#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
+
+/*
+ * PowerPC architecture-specific syscalls
+ */
+
  asmlinkage long sys_rtas(struct rtas_args __user *uargs);
-int sys_ppc_select(int n, fd_set __user *inp, fd_set __user *outp,
-		   fd_set __user *exp, struct __kernel_old_timeval __user *tvp);
-long sys_ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
-			  u32 len_high, u32 len_low);
+asmlinkage long sys_ni_syscall(void);
 
+#ifdef CONFIG_PPC64
+asmlinkage long sys_ppc64_personality(unsigned long personality);
  #ifdef CONFIG_COMPAT
-unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
-			       unsigned long prot, unsigned long flags,
-			       unsigned long fd, unsigned long pgoff);
+asmlinkage long compat_sys_ppc64_personality(unsigned long personality);
+#endif /* CONFIG_COMPAT */
+#endif /* CONFIG_PPC64 */
 
-compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
-				  u32 reg6, u32 pos1, u32 pos2);
+/* Parameters are reordered for powerpc to avoid padding */
+asmlinkage long sys_ppc_fadvise64_64(int fd, int advice,
+				     u32 offset_high, u32 offset_low,
+				     u32 len_high, u32 len_low);
+asmlinkage long sys_swapcontext(struct ucontext __user *old_ctx,
+				struct ucontext __user *new_ctx, long ctx_size);
+asmlinkage long sys_mmap(unsigned long addr, size_t len,
+			 unsigned long prot, unsigned long flags,
+			 unsigned long fd, off_t offset);
+asmlinkage long sys_mmap2(unsigned long addr, size_t len,
+			  unsigned long prot, unsigned long flags,
+			  unsigned long fd, unsigned long pgoff);
+asmlinkage long sys_switch_endian(void);
 
-compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, compat_size_t count,
-				   u32 reg6, u32 pos1, u32 pos2);
+#ifdef CONFIG_PPC32
+asmlinkage long sys_sigreturn(void);
+asmlinkage long sys_debug_setcontext(struct ucontext __user *ctx, int ndbg,
+				     struct sig_dbg_op __user *dbg);
+#endif
 
-compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offset1, u32 offset2, u32 count);
+asmlinkage long sys_rt_sigreturn(void);
 
-int compat_sys_truncate64(const char __user *path, u32 reg4,
-			  unsigned long len1, unsigned long len2);
+asmlinkage long sys_subpage_prot(unsigned long addr,
+				 unsigned long len, u32 __user *map);
 
-long compat_sys_fallocate(int fd, int mode, u32 offset1, u32 offset2, u32 len1, u32 len2);
+#ifdef CONFIG_COMPAT
+asmlinkage long compat_sys_swapcontext(struct ucontext32 __user *old_ctx,
+				       struct ucontext32 __user *new_ctx,
+				       int ctx_size);
+asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
+					 struct compat_rlimit __user *rlim);
+asmlinkage long compat_sys_sigreturn(void);
+asmlinkage long compat_sys_rt_sigreturn(void);
 
-int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long len1,
-			   unsigned long len2);
+/* Architecture-specific implementations in sys_ppc32.c */
 
-long compat_sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
-				size_t len, int advice);
+asmlinkage long compat_sys_mmap2(unsigned long addr, size_t len,
+				     unsigned long prot, unsigned long flags,
+				     unsigned long fd, unsigned long pgoff);
+asmlinkage long compat_sys_ppc_pread64(unsigned int fd,
+				       char __user *ubuf, compat_size_t count,
+				       u32 reg6, u32 pos1, u32 pos2);
+asmlinkage long compat_sys_ppc_pwrite64(unsigned int fd,
+					const char __user *ubuf, compat_size_t count,
+					u32 reg6, u32 pos1, u32 pos2);
+asmlinkage long compat_sys_ppc_readahead(int fd, u32 r4,
+					 u32 offset1, u32 offset2, u32 count);
+asmlinkage long compat_sys_ppc_truncate64(const char __user *path, u32 reg4,
+					  unsigned long len1, unsigned long len2);
+asmlinkage long compat_sys_ppc_fallocate(int fd, int mode, u32 offset1, u32 offset2,
+					 u32 len1, u32 len2);
+asmlinkage long compat_sys_ppc_ftruncate64(unsigned int fd, u32 reg4,
+					   unsigned long len1, unsigned long len2);
+asmlinkage long compat_sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
+					   size_t len, int advice);
+asmlinkage long compat_sys_ppc_sync_file_range2(int fd, unsigned int flags,
+						unsigned int offset1,
+						unsigned int offset2,
+						unsigned int nbytes1,
+						unsigned int nbytes2);
+#endif /* CONFIG_COMPAT */
 
-long compat_sys_sync_file_range2(int fd, unsigned int flags,
-				 unsigned int offset1, unsigned int offset2,
-				 unsigned int nbytes1, unsigned int nbytes2);
-#endif
+#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
 
  #endif /* __KERNEL__ */
  #endif /* __ASM_POWERPC_SYSCALLS_H */
arch/powerpc/kernel/signal_32.c +1 -1
index 157a7403e3eb..d45c0d7d0a55 100644
@@ -43,7 +43,7 @@
  #include <asm/tm.h>
  #include <asm/asm-prototypes.h>
  #ifdef CONFIG_PPC64
-#include "ppc32.h"
+#include <asm/ppc32.h>
  #include <asm/unistd.h>
  #else
  #include <asm/ucontext.h>
arch/powerpc/perf/callchain_32.c +1 -1
index b83c47b7947f..7e94c32b8398 100644
@@ -19,7 +19,7 @@
  #include "callchain.h"
 
  #ifdef CONFIG_PPC64
-#include "../kernel/ppc32.h"
+#include <asm/ppc32.h>
  #else  /* CONFIG_PPC64 */
 
  #define __SIGNAL_FRAMESIZE32	__SIGNAL_FRAMESIZE