Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

asm-generic: Move common compat types to asm-generic/compat.h

While converting compat system call handlers to work on 32-bit
architectures, I found a number of types used in those handlers
that are identical between all architectures.

Let's move all the identical ones into asm-generic/compat.h to avoid
having to add even more identical definitions of those types.

For unknown reasons, mips defines __compat_gid32_t, __compat_uid32_t
and compat_caddr_t as signed, while all others have them unsigned.
This seems to be a mistake, but I'm leaving it alone here. The other
types all differ by size or alignment on at least on architecture.

compat_aio_context_t is currently defined in linux/compat.h but
also needed for compat_sys_io_getevents(), so let's move it into
the same place.

While we still have not decided whether the 32-bit time handling
will always use the compat syscalls, or in which form, I think this
is a useful cleanup that we can merge regardless.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+37 -123
+2 -18
arch/arm64/include/asm/compat.h
··· 25 25 #include <linux/sched.h> 26 26 #include <linux/sched/task_stack.h> 27 27 28 + #include <asm-generic/compat.h> 29 + 28 30 #define COMPAT_USER_HZ 100 29 31 #ifdef __AARCH64EB__ 30 32 #define COMPAT_UTS_MACHINE "armv8b\0\0" ··· 34 32 #define COMPAT_UTS_MACHINE "armv8l\0\0" 35 33 #endif 36 34 37 - typedef u32 compat_size_t; 38 - typedef s32 compat_ssize_t; 39 - typedef s32 compat_clock_t; 40 - typedef s32 compat_pid_t; 41 35 typedef u16 __compat_uid_t; 42 36 typedef u16 __compat_gid_t; 43 37 typedef u16 __compat_uid16_t; ··· 41 43 typedef u32 __compat_uid32_t; 42 44 typedef u32 __compat_gid32_t; 43 45 typedef u16 compat_mode_t; 44 - typedef u32 compat_ino_t; 45 46 typedef u32 compat_dev_t; 46 - typedef s32 compat_off_t; 47 - typedef s64 compat_loff_t; 48 47 typedef s32 compat_nlink_t; 49 48 typedef u16 compat_ipc_pid_t; 50 - typedef s32 compat_daddr_t; 51 49 typedef u32 compat_caddr_t; 52 50 typedef __kernel_fsid_t compat_fsid_t; 53 - typedef s32 compat_key_t; 54 - typedef s32 compat_timer_t; 55 - 56 - typedef s16 compat_short_t; 57 - typedef s32 compat_int_t; 58 - typedef s32 compat_long_t; 59 51 typedef s64 compat_s64; 60 - typedef u16 compat_ushort_t; 61 - typedef u32 compat_uint_t; 62 - typedef u32 compat_ulong_t; 63 52 typedef u64 compat_u64; 64 - typedef u32 compat_uptr_t; 65 53 66 54 struct compat_stat { 67 55 #ifdef __AARCH64EB__
+2 -20
arch/mips/include/asm/compat.h
··· 9 9 #include <asm/page.h> 10 10 #include <asm/ptrace.h> 11 11 12 + #include <asm-generic/compat.h> 13 + 12 14 #define COMPAT_USER_HZ 100 13 15 #define COMPAT_UTS_MACHINE "mips\0\0\0" 14 16 15 - typedef u32 compat_size_t; 16 - typedef s32 compat_ssize_t; 17 - typedef s32 compat_clock_t; 18 - typedef s32 compat_suseconds_t; 19 - 20 - typedef s32 compat_pid_t; 21 17 typedef s32 __compat_uid_t; 22 18 typedef s32 __compat_gid_t; 23 19 typedef __compat_uid_t __compat_uid32_t; 24 20 typedef __compat_gid_t __compat_gid32_t; 25 21 typedef u32 compat_mode_t; 26 - typedef u32 compat_ino_t; 27 22 typedef u32 compat_dev_t; 28 - typedef s32 compat_off_t; 29 - typedef s64 compat_loff_t; 30 23 typedef u32 compat_nlink_t; 31 24 typedef s32 compat_ipc_pid_t; 32 - typedef s32 compat_daddr_t; 33 25 typedef s32 compat_caddr_t; 34 26 typedef struct { 35 27 s32 val[2]; 36 28 } compat_fsid_t; 37 - typedef s32 compat_timer_t; 38 - typedef s32 compat_key_t; 39 - 40 - typedef s16 compat_short_t; 41 - typedef s32 compat_int_t; 42 - typedef s32 compat_long_t; 43 29 typedef s64 compat_s64; 44 - typedef u16 compat_ushort_t; 45 - typedef u32 compat_uint_t; 46 - typedef u32 compat_ulong_t; 47 30 typedef u64 compat_u64; 48 - typedef u32 compat_uptr_t; 49 31 50 32 struct compat_stat { 51 33 compat_dev_t st_dev;
+2 -16
arch/parisc/include/asm/compat.h
··· 8 8 #include <linux/sched.h> 9 9 #include <linux/thread_info.h> 10 10 11 + #include <asm-generic/compat.h> 12 + 11 13 #define COMPAT_USER_HZ 100 12 14 #define COMPAT_UTS_MACHINE "parisc\0\0" 13 15 14 - typedef u32 compat_size_t; 15 - typedef s32 compat_ssize_t; 16 - typedef s32 compat_clock_t; 17 - typedef s32 compat_pid_t; 18 16 typedef u32 __compat_uid_t; 19 17 typedef u32 __compat_gid_t; 20 18 typedef u32 __compat_uid32_t; 21 19 typedef u32 __compat_gid32_t; 22 20 typedef u16 compat_mode_t; 23 - typedef u32 compat_ino_t; 24 21 typedef u32 compat_dev_t; 25 - typedef s32 compat_off_t; 26 - typedef s64 compat_loff_t; 27 22 typedef u16 compat_nlink_t; 28 23 typedef u16 compat_ipc_pid_t; 29 - typedef s32 compat_daddr_t; 30 24 typedef u32 compat_caddr_t; 31 - typedef s32 compat_key_t; 32 - typedef s32 compat_timer_t; 33 - 34 - typedef s32 compat_int_t; 35 - typedef s32 compat_long_t; 36 25 typedef s64 compat_s64; 37 - typedef u32 compat_uint_t; 38 - typedef u32 compat_ulong_t; 39 26 typedef u64 compat_u64; 40 - typedef u32 compat_uptr_t; 41 27 42 28 struct compat_stat { 43 29 compat_dev_t st_dev; /* dev_t is 32 bits on parisc */
+2 -16
arch/powerpc/include/asm/compat.h
··· 8 8 #include <linux/types.h> 9 9 #include <linux/sched.h> 10 10 11 + #include <asm-generic/compat.h> 12 + 11 13 #define COMPAT_USER_HZ 100 12 14 #ifdef __BIG_ENDIAN__ 13 15 #define COMPAT_UTS_MACHINE "ppc\0\0" ··· 17 15 #define COMPAT_UTS_MACHINE "ppcle\0\0" 18 16 #endif 19 17 20 - typedef u32 compat_size_t; 21 - typedef s32 compat_ssize_t; 22 - typedef s32 compat_clock_t; 23 - typedef s32 compat_pid_t; 24 18 typedef u32 __compat_uid_t; 25 19 typedef u32 __compat_gid_t; 26 20 typedef u32 __compat_uid32_t; 27 21 typedef u32 __compat_gid32_t; 28 22 typedef u32 compat_mode_t; 29 - typedef u32 compat_ino_t; 30 23 typedef u32 compat_dev_t; 31 - typedef s32 compat_off_t; 32 - typedef s64 compat_loff_t; 33 24 typedef s16 compat_nlink_t; 34 25 typedef u16 compat_ipc_pid_t; 35 - typedef s32 compat_daddr_t; 36 26 typedef u32 compat_caddr_t; 37 27 typedef __kernel_fsid_t compat_fsid_t; 38 - typedef s32 compat_key_t; 39 - typedef s32 compat_timer_t; 40 - 41 - typedef s32 compat_int_t; 42 - typedef s32 compat_long_t; 43 28 typedef s64 compat_s64; 44 - typedef u32 compat_uint_t; 45 - typedef u32 compat_ulong_t; 46 29 typedef u64 compat_u64; 47 - typedef u32 compat_uptr_t; 48 30 49 31 struct compat_stat { 50 32 compat_dev_t st_dev;
+2 -16
arch/s390/include/asm/compat.h
··· 9 9 #include <linux/sched/task_stack.h> 10 10 #include <linux/thread_info.h> 11 11 12 + #include <asm-generic/compat.h> 13 + 12 14 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \ 13 15 typeof(0?(__force t)0:0ULL), u64)) 14 16 ··· 53 51 #define COMPAT_USER_HZ 100 54 52 #define COMPAT_UTS_MACHINE "s390\0\0\0\0" 55 53 56 - typedef u32 compat_size_t; 57 - typedef s32 compat_ssize_t; 58 - typedef s32 compat_clock_t; 59 - typedef s32 compat_pid_t; 60 54 typedef u16 __compat_uid_t; 61 55 typedef u16 __compat_gid_t; 62 56 typedef u32 __compat_uid32_t; 63 57 typedef u32 __compat_gid32_t; 64 58 typedef u16 compat_mode_t; 65 - typedef u32 compat_ino_t; 66 59 typedef u16 compat_dev_t; 67 - typedef s32 compat_off_t; 68 - typedef s64 compat_loff_t; 69 60 typedef u16 compat_nlink_t; 70 61 typedef u16 compat_ipc_pid_t; 71 - typedef s32 compat_daddr_t; 72 62 typedef u32 compat_caddr_t; 73 63 typedef __kernel_fsid_t compat_fsid_t; 74 - typedef s32 compat_key_t; 75 - typedef s32 compat_timer_t; 76 - 77 - typedef s32 compat_int_t; 78 - typedef s32 compat_long_t; 79 64 typedef s64 compat_s64; 80 - typedef u32 compat_uint_t; 81 - typedef u32 compat_ulong_t; 82 65 typedef u64 compat_u64; 83 - typedef u32 compat_uptr_t; 84 66 85 67 typedef struct { 86 68 u32 mask;
+2 -17
arch/sparc/include/asm/compat.h
··· 6 6 */ 7 7 #include <linux/types.h> 8 8 9 + #include <asm-generic/compat.h> 10 + 9 11 #define COMPAT_USER_HZ 100 10 12 #define COMPAT_UTS_MACHINE "sparc\0\0" 11 13 12 - typedef u32 compat_size_t; 13 - typedef s32 compat_ssize_t; 14 - typedef s32 compat_clock_t; 15 - typedef s32 compat_pid_t; 16 14 typedef u16 __compat_uid_t; 17 15 typedef u16 __compat_gid_t; 18 16 typedef u32 __compat_uid32_t; 19 17 typedef u32 __compat_gid32_t; 20 18 typedef u16 compat_mode_t; 21 - typedef u32 compat_ino_t; 22 19 typedef u16 compat_dev_t; 23 - typedef s32 compat_off_t; 24 - typedef s64 compat_loff_t; 25 20 typedef s16 compat_nlink_t; 26 21 typedef u16 compat_ipc_pid_t; 27 - typedef s32 compat_daddr_t; 28 22 typedef u32 compat_caddr_t; 29 23 typedef __kernel_fsid_t compat_fsid_t; 30 - typedef s32 compat_key_t; 31 - typedef s32 compat_timer_t; 32 - 33 - typedef s32 compat_int_t; 34 - typedef s32 compat_long_t; 35 24 typedef s64 compat_s64; 36 - typedef u32 compat_uint_t; 37 - typedef u32 compat_ulong_t; 38 25 typedef u64 compat_u64; 39 - typedef u32 compat_uptr_t; 40 - 41 26 struct compat_stat { 42 27 compat_dev_t st_dev; 43 28 compat_ino_t st_ino;
+2 -17
arch/x86/include/asm/compat.h
··· 12 12 #include <asm/user32.h> 13 13 #include <asm/unistd.h> 14 14 15 + #include <asm-generic/compat.h> 16 + 15 17 #define COMPAT_USER_HZ 100 16 18 #define COMPAT_UTS_MACHINE "i686\0\0" 17 19 18 - typedef u32 compat_size_t; 19 - typedef s32 compat_ssize_t; 20 - typedef s32 compat_clock_t; 21 - typedef s32 compat_pid_t; 22 20 typedef u16 __compat_uid_t; 23 21 typedef u16 __compat_gid_t; 24 22 typedef u32 __compat_uid32_t; 25 23 typedef u32 __compat_gid32_t; 26 24 typedef u16 compat_mode_t; 27 - typedef u32 compat_ino_t; 28 25 typedef u16 compat_dev_t; 29 - typedef s32 compat_off_t; 30 - typedef s64 compat_loff_t; 31 26 typedef u16 compat_nlink_t; 32 27 typedef u16 compat_ipc_pid_t; 33 - typedef s32 compat_daddr_t; 34 28 typedef u32 compat_caddr_t; 35 29 typedef __kernel_fsid_t compat_fsid_t; 36 - typedef s32 compat_timer_t; 37 - typedef s32 compat_key_t; 38 - 39 - typedef s32 compat_int_t; 40 - typedef s32 compat_long_t; 41 30 typedef s64 __attribute__((aligned(4))) compat_s64; 42 - typedef u32 compat_uint_t; 43 - typedef u32 compat_ulong_t; 44 - typedef u32 compat_u32; 45 31 typedef u64 __attribute__((aligned(4))) compat_u64; 46 - typedef u32 compat_uptr_t; 47 32 48 33 struct compat_stat { 49 34 compat_dev_t st_dev;
+23 -1
include/asm-generic/compat.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef __ASM_GENERIC_COMPAT_H 3 + #define __ASM_GENERIC_COMPAT_H 2 4 3 - /* This is an empty stub for 32-bit-only architectures */ 5 + /* These types are common across all compat ABIs */ 6 + typedef u32 compat_size_t; 7 + typedef s32 compat_ssize_t; 8 + typedef s32 compat_clock_t; 9 + typedef s32 compat_pid_t; 10 + typedef u32 compat_ino_t; 11 + typedef s32 compat_off_t; 12 + typedef s64 compat_loff_t; 13 + typedef s32 compat_daddr_t; 14 + typedef s32 compat_timer_t; 15 + typedef s32 compat_key_t; 16 + typedef s16 compat_short_t; 17 + typedef s32 compat_int_t; 18 + typedef s32 compat_long_t; 19 + typedef u16 compat_ushort_t; 20 + typedef u32 compat_uint_t; 21 + typedef u32 compat_ulong_t; 22 + typedef u32 compat_uptr_t; 23 + typedef u32 compat_aio_context_t; 24 + 25 + #endif
-2
include/linux/compat.h
··· 110 110 typedef __compat_uid32_t compat_uid_t; 111 111 typedef __compat_gid32_t compat_gid_t; 112 112 113 - typedef compat_ulong_t compat_aio_context_t; 114 - 115 113 struct compat_sel_arg_struct; 116 114 struct rusage; 117 115