powerpc: Include all arch-specific syscall prototypes
authorRohan McLure <rmclure@linux.ibm.com>
Wed, 21 Sep 2022 06:55:56 +0000 (16:55 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 28 Sep 2022 09:22:08 +0000 (19:22 +1000)
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.

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
Acked-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Use standard include guard naming for syscalls_32.h]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220921065605.1051927-17-rmclure@linux.ibm.com
arch/powerpc/include/asm/syscalls.h
arch/powerpc/include/asm/syscalls_32.h [new file with mode: 0644]
arch/powerpc/kernel/ppc32.h [deleted file]
arch/powerpc/kernel/signal_32.c
arch/powerpc/perf/callchain_32.c

index 8e1787ff6c9336fb3d507b5932c16a0b29b83a14..7911738ad4a981e925dc9b4b3c28217ff8a413a5 100644 (file)
@@ -8,6 +8,14 @@
 #include <linux/types.h>
 #include <linux/compat.h>
 
+#ifdef CONFIG_PPC64
+#include <asm/syscalls_32.h>
+#endif
+#include <asm/unistd.h>
+#include <asm/ucontext.h>
+
+struct rtas_args;
+
 /*
  * long long munging:
  * The 32 bit ABI passes long longs in an odd even register pair.
 #define merge_64(high, low) (((u64)high << 32) | low)
 #endif
 
-struct rtas_args;
+long sys_ni_syscall(void);
+
+/*
+ * PowerPC architecture-specific syscalls
+ */
+
+long sys_rtas(struct rtas_args __user *uargs);
 
+#ifdef CONFIG_PPC64
+long sys_ppc64_personality(unsigned long personality);
+#ifdef CONFIG_COMPAT
+long compat_sys_ppc64_personality(unsigned long personality);
+#endif /* CONFIG_COMPAT */
+#endif /* CONFIG_PPC64 */
+
+long sys_swapcontext(struct ucontext __user *old_ctx,
+                    struct ucontext __user *new_ctx, long ctx_size);
 long sys_mmap(unsigned long addr, size_t len,
              unsigned long prot, unsigned long flags,
              unsigned long fd, off_t offset);
 long sys_mmap2(unsigned long addr, size_t len,
               unsigned long prot, unsigned long flags,
               unsigned long fd, unsigned long pgoff);
-long sys_ppc64_personality(unsigned long personality);
-long sys_rtas(struct rtas_args __user *uargs);
-long sys_ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
-                         u32 len_high, u32 len_low);
+long sys_switch_endian(void);
 
-#ifdef CONFIG_COMPAT
-long compat_sys_mmap2(unsigned long addr, size_t len,
-                              unsigned long prot, unsigned long flags,
-                              unsigned long fd, unsigned long pgoff);
-
-compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
-                                 u32 reg6, u32 pos1, u32 pos2);
+#ifdef CONFIG_PPC32
+long sys_sigreturn(void);
+long sys_debug_setcontext(struct ucontext __user *ctx, int ndbg,
+                         struct sig_dbg_op __user *dbg);
+#endif
 
-compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, compat_size_t count,
-                                  u32 reg6, u32 pos1, u32 pos2);
+long sys_rt_sigreturn(void);
 
-compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offset1, u32 offset2, u32 count);
+long sys_subpage_prot(unsigned long addr,
+                     unsigned long len, u32 __user *map);
 
-int compat_sys_truncate64(const char __user *path, u32 reg4,
-                         unsigned long len1, unsigned long len2);
+#ifdef CONFIG_COMPAT
+long compat_sys_swapcontext(struct ucontext32 __user *old_ctx,
+                           struct ucontext32 __user *new_ctx,
+                           int ctx_size);
+long compat_sys_old_getrlimit(unsigned int resource,
+                             struct compat_rlimit __user *rlim);
+long compat_sys_sigreturn(void);
+long compat_sys_rt_sigreturn(void);
+#endif /* CONFIG_COMPAT */
 
-int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long len1,
-                          unsigned long len2);
+/*
+ * Architecture specific signatures required by long long munging:
+ * The 32 bit ABI passes long longs in an odd even register pair.
+ * The following signatures provide a machine long parameter for
+ * each register that will be supplied. The implementation is
+ * responsible for combining parameter pairs.
+ */
 
+#ifdef CONFIG_COMPAT
+long compat_sys_mmap2(unsigned long addr, size_t len,
+                     unsigned long prot, unsigned long flags,
+                     unsigned long fd, unsigned long pgoff);
+long compat_sys_ppc_pread64(unsigned int fd,
+                           char __user *ubuf, compat_size_t count,
+                           u32 reg6, u32 pos1, u32 pos2);
+long compat_sys_ppc_pwrite64(unsigned int fd,
+                            const char __user *ubuf, compat_size_t count,
+                            u32 reg6, u32 pos1, u32 pos2);
+long compat_sys_ppc_readahead(int fd, u32 r4,
+                             u32 offset1, u32 offset2, u32 count);
+long compat_sys_ppc_truncate64(const char __user *path, u32 reg4,
+                              unsigned long len1, unsigned long len2);
+long compat_sys_ppc_ftruncate64(unsigned int fd, u32 reg4,
+                               unsigned long len1, unsigned long len2);
 long compat_sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
                                size_t len, int advice);
+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);
+#if defined(CONFIG_PPC32) || defined(CONFIG_COMPAT)
+long sys_ppc_fadvise64_64(int fd, int advice,
+                         u32 offset_high, u32 offset_low,
+                         u32 len_high, u32 len_low);
 #endif
 
 #endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/syscalls_32.h b/arch/powerpc/include/asm/syscalls_32.h
new file mode 100644 (file)
index 0000000..7492555
--- /dev/null
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _ASM_POWERPC_SYSCALLS_32_H
+#define _ASM_POWERPC_SYSCALLS_32_H
+
+#include <linux/compat.h>
+#include <asm/siginfo.h>
+#include <asm/signal.h>
+
+/*
+ * Data types and macros for providing 32b PowerPC support.
+ */
+
+/* These are here to support 32-bit syscalls on a 64-bit kernel. */
+
+struct pt_regs32 {
+       unsigned int gpr[32];
+       unsigned int nip;
+       unsigned int msr;
+       unsigned int orig_gpr3;         /* Used for restarting system calls */
+       unsigned int ctr;
+       unsigned int link;
+       unsigned int xer;
+       unsigned int ccr;
+       unsigned int mq;                /* 601 only (not used at present) */
+       unsigned int trap;              /* Reason for being here */
+       unsigned int dar;               /* Fault registers */
+       unsigned int dsisr;
+       unsigned int result;            /* Result of a system call */
+};
+
+struct sigcontext32 {
+       unsigned int    _unused[4];
+       int             signal;
+       compat_uptr_t   handler;
+       unsigned int    oldmask;
+       compat_uptr_t   regs;  /* 4 byte pointer to the pt_regs32 structure. */
+};
+
+struct mcontext32 {
+       elf_gregset_t32         mc_gregs;
+       elf_fpregset_t          mc_fregs;
+       unsigned int            mc_pad[2];
+       elf_vrregset_t32        mc_vregs __attribute__((__aligned__(16)));
+       elf_vsrreghalf_t32      mc_vsregs __attribute__((__aligned__(16)));
+};
+
+struct ucontext32 { 
+       unsigned int            uc_flags;
+       unsigned int            uc_link;
+       compat_stack_t          uc_stack;
+       int                     uc_pad[7];
+       compat_uptr_t           uc_regs;        /* points to uc_mcontext field */
+       compat_sigset_t         uc_sigmask;     /* mask last for extensibility */
+       /* glibc has 1024-bit signal masks, ours are 64-bit */
+       int                     uc_maskext[30];
+       int                     uc_pad2[3];
+       struct mcontext32       uc_mcontext;
+};
+
+#endif  // _ASM_POWERPC_SYSCALLS_32_H
diff --git a/arch/powerpc/kernel/ppc32.h b/arch/powerpc/kernel/ppc32.h
deleted file mode 100644 (file)
index 2346f8c..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _PPC64_PPC32_H
-#define _PPC64_PPC32_H
-
-#include <linux/compat.h>
-#include <asm/siginfo.h>
-#include <asm/signal.h>
-
-/*
- * Data types and macros for providing 32b PowerPC support.
- */
-
-/* These are here to support 32-bit syscalls on a 64-bit kernel. */
-
-struct pt_regs32 {
-       unsigned int gpr[32];
-       unsigned int nip;
-       unsigned int msr;
-       unsigned int orig_gpr3;         /* Used for restarting system calls */
-       unsigned int ctr;
-       unsigned int link;
-       unsigned int xer;
-       unsigned int ccr;
-       unsigned int mq;                /* 601 only (not used at present) */
-       unsigned int trap;              /* Reason for being here */
-       unsigned int dar;               /* Fault registers */
-       unsigned int dsisr;
-       unsigned int result;            /* Result of a system call */
-};
-
-struct sigcontext32 {
-       unsigned int    _unused[4];
-       int             signal;
-       compat_uptr_t   handler;
-       unsigned int    oldmask;
-       compat_uptr_t   regs;  /* 4 byte pointer to the pt_regs32 structure. */
-};
-
-struct mcontext32 {
-       elf_gregset_t32         mc_gregs;
-       elf_fpregset_t          mc_fregs;
-       unsigned int            mc_pad[2];
-       elf_vrregset_t32        mc_vregs __attribute__((__aligned__(16)));
-       elf_vsrreghalf_t32      mc_vsregs __attribute__((__aligned__(16)));
-};
-
-struct ucontext32 { 
-       unsigned int            uc_flags;
-       unsigned int            uc_link;
-       compat_stack_t          uc_stack;
-       int                     uc_pad[7];
-       compat_uptr_t           uc_regs;        /* points to uc_mcontext field */
-       compat_sigset_t         uc_sigmask;     /* mask last for extensibility */
-       /* glibc has 1024-bit signal masks, ours are 64-bit */
-       int                     uc_maskext[30];
-       int                     uc_pad2[3];
-       struct mcontext32       uc_mcontext;
-};
-
-#endif  /* _PPC64_PPC32_H */
index 157a7403e3eb3e3f39002c2f23e0927323fef6f9..c114c7f25645c0b41f810e0f95705eb906c61fbc 100644 (file)
@@ -43,7 +43,7 @@
 #include <asm/tm.h>
 #include <asm/asm-prototypes.h>
 #ifdef CONFIG_PPC64
-#include "ppc32.h"
+#include <asm/syscalls_32.h>
 #include <asm/unistd.h>
 #else
 #include <asm/ucontext.h>
index b83c47b7947f077a0b13812492c7b433436335b1..ea8cfe3806dce39aaf9e807d4b4699b73b7bda1f 100644 (file)
@@ -19,7 +19,7 @@
 #include "callchain.h"
 
 #ifdef CONFIG_PPC64
-#include "../kernel/ppc32.h"
+#include <asm/syscalls_32.h>
 #else  /* CONFIG_PPC64 */
 
 #define __SIGNAL_FRAMESIZE32   __SIGNAL_FRAMESIZE