Merge branch 'linus' into timers/2038
authorThomas Gleixner <tglx@linutronix.de>
Sat, 19 May 2018 11:55:40 +0000 (13:55 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 19 May 2018 11:55:40 +0000 (13:55 +0200)
Merge upstream to pick up changes on which pending patches depend on.

96 files changed:
arch/Kconfig
arch/alpha/include/asm/Kbuild
arch/alpha/include/uapi/asm/Kbuild
arch/alpha/include/uapi/asm/ipcbuf.h [deleted file]
arch/alpha/include/uapi/asm/msgbuf.h [deleted file]
arch/alpha/include/uapi/asm/sembuf.h [deleted file]
arch/alpha/include/uapi/asm/shmbuf.h [deleted file]
arch/arc/include/asm/Kbuild
arch/arm/include/asm/Kbuild
arch/arm64/include/asm/compat.h
arch/arm64/include/asm/stat.h
arch/arm64/kernel/hw_breakpoint.c
arch/arm64/kernel/perf_regs.c
arch/c6x/include/asm/Kbuild
arch/h8300/include/asm/Kbuild
arch/hexagon/include/asm/Kbuild
arch/ia64/include/asm/Kbuild
arch/ia64/include/uapi/asm/Kbuild
arch/ia64/include/uapi/asm/ipcbuf.h [deleted file]
arch/ia64/include/uapi/asm/msgbuf.h [deleted file]
arch/ia64/include/uapi/asm/sembuf.h [deleted file]
arch/ia64/include/uapi/asm/shmbuf.h [deleted file]
arch/m68k/include/asm/Kbuild
arch/microblaze/include/asm/Kbuild
arch/mips/include/asm/compat.h
arch/mips/include/uapi/asm/msgbuf.h
arch/mips/include/uapi/asm/sembuf.h
arch/mips/include/uapi/asm/shmbuf.h
arch/mips/kernel/signal32.c
arch/nds32/include/asm/Kbuild
arch/nios2/include/asm/Kbuild
arch/openrisc/include/asm/Kbuild
arch/parisc/include/asm/compat.h
arch/parisc/include/uapi/asm/msgbuf.h
arch/parisc/include/uapi/asm/sembuf.h
arch/parisc/include/uapi/asm/shmbuf.h
arch/powerpc/include/asm/compat.h
arch/powerpc/include/uapi/asm/msgbuf.h
arch/powerpc/include/uapi/asm/sembuf.h
arch/powerpc/include/uapi/asm/shmbuf.h
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/oprofile/backtrace.c
arch/s390/hypfs/hypfs_sprp.c
arch/s390/include/asm/compat.h
arch/s390/include/asm/elf.h
arch/s390/include/uapi/asm/Kbuild
arch/s390/include/uapi/asm/msgbuf.h [deleted file]
arch/s390/include/uapi/asm/sembuf.h [deleted file]
arch/s390/include/uapi/asm/shmbuf.h [deleted file]
arch/s390/kvm/priv.c
arch/s390/pci/pci_clp.c
arch/sh/include/asm/Kbuild
arch/sparc/include/asm/compat.h
arch/sparc/include/uapi/asm/msgbuf.h
arch/sparc/include/uapi/asm/sembuf.h
arch/sparc/include/uapi/asm/shmbuf.h
arch/um/include/asm/Kbuild
arch/unicore32/include/asm/Kbuild
arch/x86/events/core.c
arch/x86/include/asm/compat.h
arch/x86/include/asm/ftrace.h
arch/x86/include/uapi/asm/sembuf.h
arch/x86/kernel/sys_x86_64.c
arch/xtensa/include/asm/Kbuild
arch/xtensa/include/uapi/asm/msgbuf.h
arch/xtensa/include/uapi/asm/sembuf.h
arch/xtensa/include/uapi/asm/shmbuf.h
drivers/s390/block/dasd_ioctl.c
drivers/s390/char/fs3270.c
drivers/s390/char/sclp_ctl.c
drivers/s390/char/vmcp.c
drivers/s390/cio/chsc_sch.c
drivers/s390/net/qeth_core_main.c
include/asm-generic/compat.h [new file with mode: 0644]
include/linux/compat.h
include/linux/compat_time.h [new file with mode: 0644]
include/linux/restart_block.h
include/linux/syscalls.h
include/linux/time.h
include/linux/time64.h
include/uapi/asm-generic/msgbuf.h
include/uapi/asm-generic/posix_types.h
include/uapi/asm-generic/sembuf.h
include/uapi/asm-generic/shmbuf.h
include/uapi/linux/time.h
ipc/mqueue.c
ipc/msg.c
ipc/sem.c
ipc/shm.c
ipc/syscall.c
ipc/util.h
kernel/compat.c
kernel/time/hrtimer.c
kernel/time/posix-stubs.c
kernel/time/posix-timers.c
kernel/time/time.c

index 75dd23a..e30c3fa 100644 (file)
@@ -874,6 +874,21 @@ config OLD_SIGACTION
 config COMPAT_OLD_SIGACTION
        bool
 
+config 64BIT_TIME
+       def_bool ARCH_HAS_64BIT_TIME
+       help
+         This should be selected by all architectures that need to support
+         new system calls with a 64-bit time_t. This is relevant on all 32-bit
+         architectures, and 64-bit architectures as part of compat syscall
+         handling.
+
+config COMPAT_32BIT_TIME
+       def_bool (!64BIT && 64BIT_TIME) || COMPAT
+       help
+         This enables 32 bit time_t support in addition to 64 bit time_t support.
+         This is relevant on all 32-bit architectures, and 64-bit architectures
+         as part of compat syscall handling.
+
 config ARCH_NO_COHERENT_DMA_MMAP
        bool
 
index 9b68790..0580cb8 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 
+generic-y += compat.h
 generic-y += exec.h
 generic-y += export.h
 generic-y += fb.h
index 9afaba5..1a5b753 100644 (file)
@@ -2,4 +2,8 @@
 include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += bpf_perf_event.h
+generic-y += ipcbuf.h
+generic-y += msgbuf.h
 generic-y += poll.h
+generic-y += sembuf.h
+generic-y += shmbuf.h
diff --git a/arch/alpha/include/uapi/asm/ipcbuf.h b/arch/alpha/include/uapi/asm/ipcbuf.h
deleted file mode 100644 (file)
index 90d6445..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#include <asm-generic/ipcbuf.h>
diff --git a/arch/alpha/include/uapi/asm/msgbuf.h b/arch/alpha/include/uapi/asm/msgbuf.h
deleted file mode 100644 (file)
index 8c5d4d8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ALPHA_MSGBUF_H
-#define _ALPHA_MSGBUF_H
-
-/* 
- * The msqid64_ds structure for alpha architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
- */
-
-struct msqid64_ds {
-       struct ipc64_perm msg_perm;
-       __kernel_time_t msg_stime;      /* last msgsnd time */
-       __kernel_time_t msg_rtime;      /* last msgrcv time */
-       __kernel_time_t msg_ctime;      /* last change time */
-       unsigned long  msg_cbytes;      /* current number of bytes on queue */
-       unsigned long  msg_qnum;        /* number of messages in queue */
-       unsigned long  msg_qbytes;      /* max number of bytes on queue */
-       __kernel_pid_t msg_lspid;       /* pid of last msgsnd */
-       __kernel_pid_t msg_lrpid;       /* last receive pid */
-       unsigned long  __unused1;
-       unsigned long  __unused2;
-};
-
-#endif /* _ALPHA_MSGBUF_H */
diff --git a/arch/alpha/include/uapi/asm/sembuf.h b/arch/alpha/include/uapi/asm/sembuf.h
deleted file mode 100644 (file)
index f28ffa6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ALPHA_SEMBUF_H
-#define _ALPHA_SEMBUF_H
-
-/* 
- * The semid64_ds structure for alpha architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
- */
-
-struct semid64_ds {
-       struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
-       __kernel_time_t sem_otime;              /* last semop time */
-       __kernel_time_t sem_ctime;              /* last change time */
-       unsigned long   sem_nsems;              /* no. of semaphores in array */
-       unsigned long   __unused1;
-       unsigned long   __unused2;
-};
-
-#endif /* _ALPHA_SEMBUF_H */
diff --git a/arch/alpha/include/uapi/asm/shmbuf.h b/arch/alpha/include/uapi/asm/shmbuf.h
deleted file mode 100644 (file)
index 7e041ca..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ALPHA_SHMBUF_H
-#define _ALPHA_SHMBUF_H
-
-/* 
- * The shmid64_ds structure for alpha architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
- */
-
-struct shmid64_ds {
-       struct ipc64_perm       shm_perm;       /* operation perms */
-       size_t                  shm_segsz;      /* size of segment (bytes) */
-       __kernel_time_t         shm_atime;      /* last attach time */
-       __kernel_time_t         shm_dtime;      /* last detach time */
-       __kernel_time_t         shm_ctime;      /* last change time */
-       __kernel_pid_t          shm_cpid;       /* pid of creator */
-       __kernel_pid_t          shm_lpid;       /* pid of last operator */
-       unsigned long           shm_nattch;     /* no. of current attaches */
-       unsigned long           __unused1;
-       unsigned long           __unused2;
-};
-
-struct shminfo64 {
-       unsigned long   shmmax;
-       unsigned long   shmmin;
-       unsigned long   shmmni;
-       unsigned long   shmseg;
-       unsigned long   shmall;
-       unsigned long   __unused1;
-       unsigned long   __unused2;
-       unsigned long   __unused3;
-       unsigned long   __unused4;
-};
-
-#endif /* _ALPHA_SHMBUF_H */
index 4bd5d43..d51bc22 100644 (file)
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 generic-y += bugs.h
+generic-y += compat.h
 generic-y += device.h
 generic-y += div64.h
 generic-y += emergency-restart.h
index 873e3c1..1d66db9 100644 (file)
@@ -1,3 +1,4 @@
+generic-y += compat.h
 generic-y += current.h
 generic-y += early_ioremap.h
 generic-y += emergency-restart.h
index c00c62e..1a037b9 100644 (file)
@@ -34,7 +34,6 @@
 
 typedef u32            compat_size_t;
 typedef s32            compat_ssize_t;
-typedef s32            compat_time_t;
 typedef s32            compat_clock_t;
 typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
@@ -66,16 +65,6 @@ typedef u32          compat_ulong_t;
 typedef u64            compat_u64;
 typedef u32            compat_uptr_t;
 
-struct compat_timespec {
-       compat_time_t   tv_sec;
-       s32             tv_nsec;
-};
-
-struct compat_timeval {
-       compat_time_t   tv_sec;
-       s32             tv_usec;
-};
-
 struct compat_stat {
 #ifdef __AARCH64EB__
        short           st_dev;
@@ -192,10 +181,10 @@ struct compat_ipc64_perm {
 
 struct compat_semid64_ds {
        struct compat_ipc64_perm sem_perm;
-       compat_time_t  sem_otime;
-       compat_ulong_t __unused1;
-       compat_time_t  sem_ctime;
-       compat_ulong_t __unused2;
+       compat_ulong_t sem_otime;
+       compat_ulong_t sem_otime_high;
+       compat_ulong_t sem_ctime;
+       compat_ulong_t sem_ctime_high;
        compat_ulong_t sem_nsems;
        compat_ulong_t __unused3;
        compat_ulong_t __unused4;
@@ -203,12 +192,12 @@ struct compat_semid64_ds {
 
 struct compat_msqid64_ds {
        struct compat_ipc64_perm msg_perm;
-       compat_time_t  msg_stime;
-       compat_ulong_t __unused1;
-       compat_time_t  msg_rtime;
-       compat_ulong_t __unused2;
-       compat_time_t  msg_ctime;
-       compat_ulong_t __unused3;
+       compat_ulong_t msg_stime;
+       compat_ulong_t msg_stime_high;
+       compat_ulong_t msg_rtime;
+       compat_ulong_t msg_rtime_high;
+       compat_ulong_t msg_ctime;
+       compat_ulong_t msg_ctime_high;
        compat_ulong_t msg_cbytes;
        compat_ulong_t msg_qnum;
        compat_ulong_t msg_qbytes;
@@ -221,12 +210,12 @@ struct compat_msqid64_ds {
 struct compat_shmid64_ds {
        struct compat_ipc64_perm shm_perm;
        compat_size_t  shm_segsz;
-       compat_time_t  shm_atime;
-       compat_ulong_t __unused1;
-       compat_time_t  shm_dtime;
-       compat_ulong_t __unused2;
-       compat_time_t  shm_ctime;
-       compat_ulong_t __unused3;
+       compat_ulong_t shm_atime;
+       compat_ulong_t shm_atime_high;
+       compat_ulong_t shm_dtime;
+       compat_ulong_t shm_dtime_high;
+       compat_ulong_t shm_ctime;
+       compat_ulong_t shm_ctime_high;
        compat_pid_t   shm_cpid;
        compat_pid_t   shm_lpid;
        compat_ulong_t shm_nattch;
index 15e3559..eab7380 100644 (file)
@@ -20,6 +20,7 @@
 
 #ifdef CONFIG_COMPAT
 
+#include <linux/compat_time.h>
 #include <asm/compat.h>
 
 /*
index 74bb56f..413dbe5 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/smp.h>
 #include <linux/uaccess.h>
 
-#include <asm/compat.h>
 #include <asm/current.h>
 #include <asm/debug-monitors.h>
 #include <asm/hw_breakpoint.h>
index 1d091d0..0bbac61 100644 (file)
@@ -1,11 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <linux/compat.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/perf_event.h>
 #include <linux/bug.h>
 #include <linux/sched/task_stack.h>
 
-#include <asm/compat.h>
 #include <asm/perf_regs.h>
 #include <asm/ptrace.h>
 
index fd4c840..2403748 100644 (file)
@@ -1,6 +1,7 @@
 generic-y += atomic.h
 generic-y += barrier.h
 generic-y += bugs.h
+generic-y += compat.h
 generic-y += current.h
 generic-y += device.h
 generic-y += div64.h
index 14bac06..a5d0b29 100644 (file)
@@ -3,6 +3,7 @@ generic-y += barrier.h
 generic-y += bugs.h
 generic-y += cacheflush.h
 generic-y += checksum.h
+generic-y += compat.h
 generic-y += current.h
 generic-y += delay.h
 generic-y += device.h
index e9743f6..dd2fd9c 100644 (file)
@@ -2,6 +2,7 @@
 generic-y += barrier.h
 generic-y += bug.h
 generic-y += bugs.h
+generic-y += compat.h
 generic-y += current.h
 generic-y += device.h
 generic-y += div64.h
index 6dd8678..557bbc8 100644 (file)
@@ -1,3 +1,4 @@
+generic-y += compat.h
 generic-y += exec.h
 generic-y += irq_work.h
 generic-y += mcs_spinlock.h
index c0527cf..3982e67 100644 (file)
@@ -2,5 +2,9 @@
 include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += bpf_perf_event.h
+generic-y += ipcbuf.h
 generic-y += kvm_para.h
+generic-y += msgbuf.h
 generic-y += poll.h
+generic-y += sembuf.h
+generic-y += shmbuf.h
diff --git a/arch/ia64/include/uapi/asm/ipcbuf.h b/arch/ia64/include/uapi/asm/ipcbuf.h
deleted file mode 100644 (file)
index 90d6445..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#include <asm-generic/ipcbuf.h>
diff --git a/arch/ia64/include/uapi/asm/msgbuf.h b/arch/ia64/include/uapi/asm/msgbuf.h
deleted file mode 100644 (file)
index aa25df9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ASM_IA64_MSGBUF_H
-#define _ASM_IA64_MSGBUF_H
-
-/*
- * The msqid64_ds structure for IA-64 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
- */
-
-struct msqid64_ds {
-       struct ipc64_perm msg_perm;
-       __kernel_time_t msg_stime;      /* last msgsnd time */
-       __kernel_time_t msg_rtime;      /* last msgrcv time */
-       __kernel_time_t msg_ctime;      /* last change time */
-       unsigned long  msg_cbytes;      /* current number of bytes on queue */
-       unsigned long  msg_qnum;        /* number of messages in queue */
-       unsigned long  msg_qbytes;      /* max number of bytes on queue */
-       __kernel_pid_t msg_lspid;       /* pid of last msgsnd */
-       __kernel_pid_t msg_lrpid;       /* last receive pid */
-       unsigned long  __unused1;
-       unsigned long  __unused2;
-};
-
-#endif /* _ASM_IA64_MSGBUF_H */
diff --git a/arch/ia64/include/uapi/asm/sembuf.h b/arch/ia64/include/uapi/asm/sembuf.h
deleted file mode 100644 (file)
index 6ed0587..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ASM_IA64_SEMBUF_H
-#define _ASM_IA64_SEMBUF_H
-
-/*
- * The semid64_ds structure for IA-64 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
- */
-
-struct semid64_ds {
-       struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
-       __kernel_time_t sem_otime;              /* last semop time */
-       __kernel_time_t sem_ctime;              /* last change time */
-       unsigned long   sem_nsems;              /* no. of semaphores in array */
-       unsigned long   __unused1;
-       unsigned long   __unused2;
-};
-
-#endif /* _ASM_IA64_SEMBUF_H */
diff --git a/arch/ia64/include/uapi/asm/shmbuf.h b/arch/ia64/include/uapi/asm/shmbuf.h
deleted file mode 100644 (file)
index 6ef57cb..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ASM_IA64_SHMBUF_H
-#define _ASM_IA64_SHMBUF_H
-
-/*
- * The shmid64_ds structure for IA-64 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
- */
-
-struct shmid64_ds {
-       struct ipc64_perm       shm_perm;       /* operation perms */
-       size_t                  shm_segsz;      /* size of segment (bytes) */
-       __kernel_time_t         shm_atime;      /* last attach time */
-       __kernel_time_t         shm_dtime;      /* last detach time */
-       __kernel_time_t         shm_ctime;      /* last change time */
-       __kernel_pid_t          shm_cpid;       /* pid of creator */
-       __kernel_pid_t          shm_lpid;       /* pid of last operator */
-       unsigned long           shm_nattch;     /* no. of current attaches */
-       unsigned long           __unused1;
-       unsigned long           __unused2;
-};
-
-struct shminfo64 {
-       unsigned long   shmmax;
-       unsigned long   shmmin;
-       unsigned long   shmmni;
-       unsigned long   shmseg;
-       unsigned long   shmall;
-       unsigned long   __unused1;
-       unsigned long   __unused2;
-       unsigned long   __unused3;
-       unsigned long   __unused4;
-};
-
-#endif /* _ASM_IA64_SHMBUF_H */
index 88a9d27..4d8d68c 100644 (file)
@@ -1,4 +1,5 @@
 generic-y += barrier.h
+generic-y += compat.h
 generic-y += device.h
 generic-y += emergency-restart.h
 generic-y += exec.h
index 3c80a5a..fe6a6c6 100644 (file)
@@ -2,6 +2,7 @@ generic-y += barrier.h
 generic-y += bitops.h
 generic-y += bug.h
 generic-y += bugs.h
+generic-y += compat.h
 generic-y += device.h
 generic-y += div64.h
 generic-y += emergency-restart.h
index 9a0fa66..78675f1 100644 (file)
@@ -14,7 +14,6 @@
 
 typedef u32            compat_size_t;
 typedef s32            compat_ssize_t;
-typedef s32            compat_time_t;
 typedef s32            compat_clock_t;
 typedef s32            compat_suseconds_t;
 
@@ -38,24 +37,16 @@ typedef struct {
 typedef s32            compat_timer_t;
 typedef s32            compat_key_t;
 
+typedef s16            compat_short_t;
 typedef s32            compat_int_t;
 typedef s32            compat_long_t;
 typedef s64            compat_s64;
+typedef u16            compat_ushort_t;
 typedef u32            compat_uint_t;
 typedef u32            compat_ulong_t;
 typedef u64            compat_u64;
 typedef u32            compat_uptr_t;
 
-struct compat_timespec {
-       compat_time_t   tv_sec;
-       s32             tv_nsec;
-};
-
-struct compat_timeval {
-       compat_time_t   tv_sec;
-       s32             tv_usec;
-};
-
 struct compat_stat {
        compat_dev_t    st_dev;
        s32             st_pad1[3];
@@ -168,35 +159,35 @@ struct compat_ipc64_perm {
 
 struct compat_semid64_ds {
        struct compat_ipc64_perm sem_perm;
-       compat_time_t   sem_otime;
-       compat_time_t   sem_ctime;
+       compat_ulong_t  sem_otime;
+       compat_ulong_t  sem_ctime;
        compat_ulong_t  sem_nsems;
-       compat_ulong_t  __unused1;
-       compat_ulong_t  __unused2;
+       compat_ulong_t  sem_otime_high;
+       compat_ulong_t  sem_ctime_high;
 };
 
 struct compat_msqid64_ds {
        struct compat_ipc64_perm msg_perm;
 #ifndef CONFIG_CPU_LITTLE_ENDIAN
-       compat_ulong_t  __unused1;
+       compat_ulong_t  msg_stime_high;
 #endif
-       compat_time_t   msg_stime;
+       compat_ulong_t  msg_stime;
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-       compat_ulong_t  __unused1;
+       compat_ulong_t  msg_stime_high;
 #endif
 #ifndef CONFIG_CPU_LITTLE_ENDIAN
-       compat_ulong_t  __unused2;
+       compat_ulong_t  msg_rtime_high;
 #endif
-       compat_time_t   msg_rtime;
+       compat_ulong_t  msg_rtime;
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-       compat_ulong_t  __unused2;
+       compat_ulong_t  msg_rtime_high;
 #endif
 #ifndef CONFIG_CPU_LITTLE_ENDIAN
-       compat_ulong_t  __unused3;
+       compat_ulong_t  msg_ctime_high;
 #endif
-       compat_time_t   msg_ctime;
+       compat_ulong_t  msg_ctime;
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-       compat_ulong_t  __unused3;
+       compat_ulong_t  msg_ctime_high;
 #endif
        compat_ulong_t  msg_cbytes;
        compat_ulong_t  msg_qnum;
@@ -210,14 +201,16 @@ struct compat_msqid64_ds {
 struct compat_shmid64_ds {
        struct compat_ipc64_perm shm_perm;
        compat_size_t   shm_segsz;
-       compat_time_t   shm_atime;
-       compat_time_t   shm_dtime;
-       compat_time_t   shm_ctime;
+       compat_ulong_t  shm_atime;
+       compat_ulong_t  shm_dtime;
+       compat_ulong_t  shm_ctime;
        compat_pid_t    shm_cpid;
        compat_pid_t    shm_lpid;
        compat_ulong_t  shm_nattch;
-       compat_ulong_t  __unused1;
-       compat_ulong_t  __unused2;
+       compat_ushort_t shm_atime_high;
+       compat_ushort_t shm_dtime_high;
+       compat_ushort_t shm_ctime_high;
+       compat_ushort_t __unused2;
 };
 
 /* MIPS has unusual order of fields in stack_t */
index eb4d0f9..46aa15b 100644 (file)
@@ -9,33 +9,15 @@
  * between kernel and user space.
  *
  * Pad space is left for:
- * - extension of time_t to 64-bit on 32-bitsystem to solve the y2038 problem
  * - 2 miscellaneous unsigned long values
  */
 
+#if defined(__mips64)
 struct msqid64_ds {
        struct ipc64_perm msg_perm;
-#if !defined(__mips64) && defined(__MIPSEB__)
-       unsigned long   __unused1;
-#endif
        __kernel_time_t msg_stime;      /* last msgsnd time */
-#if !defined(__mips64) && defined(__MIPSEL__)
-       unsigned long   __unused1;
-#endif
-#if !defined(__mips64) && defined(__MIPSEB__)
-       unsigned long   __unused2;
-#endif
        __kernel_time_t msg_rtime;      /* last msgrcv time */
-#if !defined(__mips64) && defined(__MIPSEL__)
-       unsigned long   __unused2;
-#endif
-#if !defined(__mips64) && defined(__MIPSEB__)
-       unsigned long   __unused3;
-#endif
        __kernel_time_t msg_ctime;      /* last change time */
-#if !defined(__mips64) && defined(__MIPSEL__)
-       unsigned long   __unused3;
-#endif
        unsigned long  msg_cbytes;      /* current number of bytes on queue */
        unsigned long  msg_qnum;        /* number of messages in queue */
        unsigned long  msg_qbytes;      /* max number of bytes on queue */
@@ -44,5 +26,42 @@ struct msqid64_ds {
        unsigned long  __unused4;
        unsigned long  __unused5;
 };
+#elif defined (__MIPSEB__)
+struct msqid64_ds {
+       struct ipc64_perm msg_perm;
+       unsigned long  msg_stime_high;
+       unsigned long  msg_stime;       /* last msgsnd time */
+       unsigned long  msg_rtime_high;
+       unsigned long  msg_rtime;       /* last msgrcv time */
+       unsigned long  msg_ctime_high;
+       unsigned long  msg_ctime;       /* last change time */
+       unsigned long  msg_cbytes;      /* current number of bytes on queue */
+       unsigned long  msg_qnum;        /* number of messages in queue */
+       unsigned long  msg_qbytes;      /* max number of bytes on queue */
+       __kernel_pid_t msg_lspid;       /* pid of last msgsnd */
+       __kernel_pid_t msg_lrpid;       /* last receive pid */
+       unsigned long  __unused4;
+       unsigned long  __unused5;
+};
+#elif defined (__MIPSEL__)
+struct msqid64_ds {
+       struct ipc64_perm msg_perm;
+       unsigned long  msg_stime;       /* last msgsnd time */
+       unsigned long  msg_stime_high;
+       unsigned long  msg_rtime;       /* last msgrcv time */
+       unsigned long  msg_rtime_high;
+       unsigned long  msg_ctime;       /* last change time */
+       unsigned long  msg_ctime_high;
+       unsigned long  msg_cbytes;      /* current number of bytes on queue */
+       unsigned long  msg_qnum;        /* number of messages in queue */
+       unsigned long  msg_qbytes;      /* max number of bytes on queue */
+       __kernel_pid_t msg_lspid;       /* pid of last msgsnd */
+       __kernel_pid_t msg_lrpid;       /* last receive pid */
+       unsigned long  __unused4;
+       unsigned long  __unused5;
+};
+#else
+#warning no endianess set
+#endif
 
 #endif /* _ASM_MSGBUF_H */
index 2c0f507..60c89e6 100644 (file)
@@ -7,10 +7,11 @@
  * Note extra padding because this structure is passed back and forth
  * between kernel and user space.
  *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
+ * Pad space is left for 2 miscellaneous 64-bit values on mips64,
+ * but used for the upper 32 bit of the time values on mips32.
  */
 
+#ifdef __mips64
 struct semid64_ds {
        struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
        __kernel_time_t sem_otime;              /* last semop time */
@@ -19,5 +20,15 @@ struct semid64_ds {
        unsigned long   __unused1;
        unsigned long   __unused2;
 };
+#else
+struct semid64_ds {
+       struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
+       unsigned long   sem_otime;              /* last semop time */
+       unsigned long   sem_ctime;              /* last change time */
+       unsigned long   sem_nsems;              /* no. of semaphores in array */
+       unsigned long   sem_otime_high;
+       unsigned long   sem_ctime_high;
+};
+#endif
 
 #endif /* _ASM_SEMBUF_H */
index 379e6bc..9b9bba3 100644 (file)
@@ -7,10 +7,13 @@
  * Note extra padding because this structure is passed back and forth
  * between kernel and user space.
  *
- * Pad space is left for:
- * - 2 miscellaneous 32-bit rsp. 64-bit values
+ * As MIPS was lacking proper padding after shm_?time, we use 48 bits
+ * of the padding at the end to store a few additional bits of the time.
+ * libc implementations need to take care to convert this into a proper
+ * data structure when moving to 64-bit time_t.
  */
 
+#ifdef __mips64
 struct shmid64_ds {
        struct ipc64_perm       shm_perm;       /* operation perms */
        size_t                  shm_segsz;      /* size of segment (bytes) */
@@ -23,6 +26,22 @@ struct shmid64_ds {
        unsigned long           __unused1;
        unsigned long           __unused2;
 };
+#else
+struct shmid64_ds {
+       struct ipc64_perm       shm_perm;       /* operation perms */
+       size_t                  shm_segsz;      /* size of segment (bytes) */
+       unsigned long           shm_atime;      /* last attach time */
+       unsigned long           shm_dtime;      /* last detach time */
+       unsigned long           shm_ctime;      /* last change time */
+       __kernel_pid_t          shm_cpid;       /* pid of creator */
+       __kernel_pid_t          shm_lpid;       /* pid of last operator */
+       unsigned long           shm_nattch;     /* no. of current attaches */
+       unsigned short          shm_atime_high;
+       unsigned short          shm_dtime_high;
+       unsigned short          shm_ctime_high;
+       unsigned short          __unused1;
+};
+#endif
 
 struct shminfo64 {
        unsigned long   shmmax;
index c4db910..b5d9e17 100644 (file)
@@ -8,13 +8,13 @@
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  * Copyright (C) 2016, Imagination Technologies Ltd.
  */
+#include <linux/compat.h>
 #include <linux/compiler.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
 #include <linux/syscalls.h>
 
-#include <asm/compat.h>
 #include <asm/compat-signal.h>
 #include <linux/uaccess.h>
 #include <asm/unistd.h>
index 06bdf81..d1b1f89 100644 (file)
@@ -9,6 +9,7 @@ generic-y += checksum.h
 generic-y += clkdev.h
 generic-y += cmpxchg.h
 generic-y += cmpxchg-local.h
+generic-y += compat.h
 generic-y += cputime.h
 generic-y += device.h
 generic-y += div64.h
index d232da2..64ed3d6 100644 (file)
@@ -4,6 +4,7 @@ generic-y += bitops.h
 generic-y += bug.h
 generic-y += bugs.h
 generic-y += cmpxchg.h
+generic-y += compat.h
 generic-y += current.h
 generic-y += device.h
 generic-y += div64.h
index f05c722..65964d3 100644 (file)
@@ -2,6 +2,7 @@ generic-y += barrier.h
 generic-y += bug.h
 generic-y += bugs.h
 generic-y += checksum.h
+generic-y += compat.h
 generic-y += current.h
 generic-y += device.h
 generic-y += div64.h
index 57b8b2a..ab8a547 100644 (file)
@@ -13,7 +13,6 @@
 
 typedef u32    compat_size_t;
 typedef s32    compat_ssize_t;
-typedef s32    compat_time_t;
 typedef s32    compat_clock_t;
 typedef s32    compat_pid_t;
 typedef u32    __compat_uid_t;
@@ -40,16 +39,6 @@ typedef u32  compat_ulong_t;
 typedef u64    compat_u64;
 typedef u32    compat_uptr_t;
 
-struct compat_timespec {
-       compat_time_t           tv_sec;
-       s32                     tv_nsec;
-};
-
-struct compat_timeval {
-       compat_time_t           tv_sec;
-       s32                     tv_usec;
-};
-
 struct compat_stat {
        compat_dev_t            st_dev; /* dev_t is 32 bits on parisc */
        compat_ino_t            st_ino; /* 32 bits */
@@ -149,10 +138,10 @@ struct compat_ipc64_perm {
 
 struct compat_semid64_ds {
        struct compat_ipc64_perm sem_perm;
-       unsigned int __unused1;
-       compat_time_t sem_otime;
-       unsigned int __unused2;
-       compat_time_t sem_ctime;
+       unsigned int sem_otime_high;
+       unsigned int sem_otime;
+       unsigned int sem_ctime_high;
+       unsigned int sem_ctime;
        compat_ulong_t sem_nsems;
        compat_ulong_t __unused3;
        compat_ulong_t __unused4;
@@ -160,12 +149,12 @@ struct compat_semid64_ds {
 
 struct compat_msqid64_ds {
        struct compat_ipc64_perm msg_perm;
-       unsigned int __unused1;
-       compat_time_t msg_stime;
-       unsigned int __unused2;
-       compat_time_t msg_rtime;
-       unsigned int __unused3;
-       compat_time_t msg_ctime;
+       unsigned int msg_stime_high;
+       unsigned int msg_stime;
+       unsigned int msg_rtime_high;
+       unsigned int msg_rtime;
+       unsigned int msg_ctime_high;
+       unsigned int msg_ctime;
        compat_ulong_t msg_cbytes;
        compat_ulong_t msg_qnum;
        compat_ulong_t msg_qbytes;
@@ -177,12 +166,12 @@ struct compat_msqid64_ds {
 
 struct compat_shmid64_ds {
        struct compat_ipc64_perm shm_perm;
-       unsigned int __unused1;
-       compat_time_t shm_atime;
-       unsigned int __unused2;
-       compat_time_t shm_dtime;
-       unsigned int __unused3;
-       compat_time_t shm_ctime;
+       unsigned int shm_atime_high;
+       unsigned int shm_atime;
+       unsigned int shm_dtime_high;
+       unsigned int shm_dtime;
+       unsigned int shm_ctime_high;
+       unsigned int shm_ctime;
        unsigned int __unused4;
        compat_size_t shm_segsz;
        compat_pid_t shm_cpid;
index b48b810..6a2e9ab 100644 (file)
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
 
 struct msqid64_ds {
        struct ipc64_perm msg_perm;
-#if __BITS_PER_LONG != 64
-       unsigned int   __pad1;
-#endif
+#if __BITS_PER_LONG == 64
        __kernel_time_t msg_stime;      /* last msgsnd time */
-#if __BITS_PER_LONG != 64
-       unsigned int   __pad2;
-#endif
        __kernel_time_t msg_rtime;      /* last msgrcv time */
-#if __BITS_PER_LONG != 64
-       unsigned int   __pad3;
-#endif
        __kernel_time_t msg_ctime;      /* last change time */
-       unsigned long msg_cbytes;       /* current number of bytes on queue */
-       unsigned long msg_qnum;         /* number of messages in queue */
-       unsigned long msg_qbytes;       /* max number of bytes on queue */
-       __kernel_pid_t msg_lspid;       /* pid of last msgsnd */
-       __kernel_pid_t msg_lrpid;       /* last receive pid */
-       unsigned long __unused1;
-       unsigned long __unused2;
+#else
+       unsigned long   msg_stime_high;
+       unsigned long   msg_stime;      /* last msgsnd time */
+       unsigned long   msg_rtime_high;
+       unsigned long   msg_rtime;      /* last msgrcv time */
+       unsigned long   msg_ctime_high;
+       unsigned long   msg_ctime;      /* last change time */
+#endif
+       unsigned long   msg_cbytes;     /* current number of bytes on queue */
+       unsigned long   msg_qnum;       /* number of messages in queue */
+       unsigned long   msg_qbytes;     /* max number of bytes on queue */
+       __kernel_pid_t  msg_lspid;      /* pid of last msgsnd */
+       __kernel_pid_t  msg_lrpid;      /* last receive pid */
+       unsigned long   __unused1;
+       unsigned long   __unused2;
 };
 
 #endif /* _PARISC_MSGBUF_H */
index 746c5d8..3c31163 100644 (file)
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
 
 struct semid64_ds {
        struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
-#if __BITS_PER_LONG != 64
-       unsigned int    __pad1;
-#endif
+#if __BITS_PER_LONG == 64
        __kernel_time_t sem_otime;              /* last semop time */
-#if __BITS_PER_LONG != 64
-       unsigned int    __pad2;
-#endif
        __kernel_time_t sem_ctime;              /* last change time */
-       unsigned long   sem_nsems;              /* no. of semaphores in array */
+#else
+       unsigned long   sem_otime_high;
+       unsigned long   sem_otime;              /* last semop time */
+       unsigned long   sem_ctime_high;
+       unsigned long   sem_ctime;              /* last change time */
+#endif
+       unsigned long   sem_nsems;              /* no. of semaphores in array */
        unsigned long   __unused1;
        unsigned long   __unused2;
 };
index cd4dbce..c89b3dd 100644 (file)
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
 
 struct shmid64_ds {
        struct ipc64_perm       shm_perm;       /* operation perms */
-#if __BITS_PER_LONG != 64
-       unsigned int            __pad1;
-#endif
+#if __BITS_PER_LONG == 64
        __kernel_time_t         shm_atime;      /* last attach time */
-#if __BITS_PER_LONG != 64
-       unsigned int            __pad2;
-#endif
        __kernel_time_t         shm_dtime;      /* last detach time */
-#if __BITS_PER_LONG != 64
-       unsigned int            __pad3;
-#endif
        __kernel_time_t         shm_ctime;      /* last change time */
-#if __BITS_PER_LONG != 64
+#else
+       unsigned long           shm_atime_high;
+       unsigned long           shm_atime;      /* last attach time */
+       unsigned long           shm_dtime_high;
+       unsigned long           shm_dtime;      /* last detach time */
+       unsigned long           shm_ctime_high;
+       unsigned long           shm_ctime;      /* last change time */
        unsigned int            __pad4;
 #endif
        __kernel_size_t         shm_segsz;      /* size of segment (bytes) */
index 62168e1..85c8af2 100644 (file)
@@ -17,7 +17,6 @@
 
 typedef u32            compat_size_t;
 typedef s32            compat_ssize_t;
-typedef s32            compat_time_t;
 typedef s32            compat_clock_t;
 typedef s32            compat_pid_t;
 typedef u32            __compat_uid_t;
@@ -45,16 +44,6 @@ typedef u32          compat_ulong_t;
 typedef u64            compat_u64;
 typedef u32            compat_uptr_t;
 
-struct compat_timespec {
-       compat_time_t   tv_sec;
-       s32             tv_nsec;
-};
-
-struct compat_timeval {
-       compat_time_t   tv_sec;
-       s32             tv_usec;
-};
-
 struct compat_stat {
        compat_dev_t    st_dev;
        compat_ino_t    st_ino;
@@ -173,10 +162,10 @@ struct compat_ipc64_perm {
 
 struct compat_semid64_ds {
        struct compat_ipc64_perm sem_perm;
-       unsigned int __unused1;
-       compat_time_t sem_otime;
-       unsigned int __unused2;
-       compat_time_t sem_ctime;
+       unsigned int sem_otime_high;
+       unsigned int sem_otime;
+       unsigned int sem_ctime_high;
+       unsigned int sem_ctime;
        compat_ulong_t sem_nsems;
        compat_ulong_t __unused3;
        compat_ulong_t __unused4;
@@ -184,12 +173,12 @@ struct compat_semid64_ds {
 
 struct compat_msqid64_ds {
        struct compat_ipc64_perm msg_perm;
-       unsigned int __unused1;
-       compat_time_t msg_stime;
-       unsigned int __unused2;
-       compat_time_t msg_rtime;
-       unsigned int __unused3;
-       compat_time_t msg_ctime;
+       unsigned int msg_stime_high;
+       unsigned int msg_stime;
+       unsigned int msg_rtime_high;
+       unsigned int msg_rtime;
+       unsigned int msg_ctime_high;
+       unsigned int msg_ctime;
        compat_ulong_t msg_cbytes;
        compat_ulong_t msg_qnum;
        compat_ulong_t msg_qbytes;
@@ -201,12 +190,12 @@ struct compat_msqid64_ds {
 
 struct compat_shmid64_ds {
        struct compat_ipc64_perm shm_perm;
-       unsigned int __unused1;
-       compat_time_t shm_atime;
-       unsigned int __unused2;
-       compat_time_t shm_dtime;
-       unsigned int __unused3;
-       compat_time_t shm_ctime;
+       unsigned int shm_atime_high;
+       unsigned int shm_atime;
+       unsigned int shm_dtime_high;
+       unsigned int shm_dtime;
+       unsigned int shm_ctime_high;
+       unsigned int shm_ctime;
        unsigned int __unused4;
        compat_size_t shm_segsz;
        compat_pid_t shm_cpid;
index 65beb09..2b1b377 100644 (file)
 
 struct msqid64_ds {
        struct ipc64_perm msg_perm;
-#ifndef __powerpc64__
-       unsigned int    __unused1;
-#endif
+#ifdef __powerpc64__
        __kernel_time_t msg_stime;      /* last msgsnd time */
-#ifndef __powerpc64__
-       unsigned int    __unused2;
-#endif
        __kernel_time_t msg_rtime;      /* last msgrcv time */
-#ifndef __powerpc64__
-       unsigned int    __unused3;
-#endif
        __kernel_time_t msg_ctime;      /* last change time */
+#else
+       unsigned long  msg_stime_high;
+       unsigned long  msg_stime;       /* last msgsnd time */
+       unsigned long  msg_rtime_high;
+       unsigned long  msg_rtime;       /* last msgrcv time */
+       unsigned long  msg_ctime_high;
+       unsigned long  msg_ctime;       /* last change time */
+#endif
        unsigned long  msg_cbytes;      /* current number of bytes on queue */
        unsigned long  msg_qnum;        /* number of messages in queue */
        unsigned long  msg_qbytes;      /* max number of bytes on queue */
index 8f393d6..3f60946 100644 (file)
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
- * - 2 miscellaneous 32-bit values
+ * - 2 miscellaneous 32/64-bit values
  */
 
 struct semid64_ds {
        struct ipc64_perm sem_perm;     /* permissions .. see ipc.h */
 #ifndef __powerpc64__
-       unsigned long   __unused1;
-#endif
+       unsigned long   sem_otime_high;
+       unsigned long   sem_otime;      /* last semop time */
+       unsigned long   sem_ctime_high;
+       unsigned long   sem_ctime;      /* last change time */
+#else
        __kernel_time_t sem_otime;      /* last semop time */
-#ifndef __powerpc64__
-       unsigned long   __unused2;
-#endif
        __kernel_time_t sem_ctime;      /* last change time */
+#endif
        unsigned long   sem_nsems;      /* no. of semaphores in array */
        unsigned long   __unused3;
        unsigned long   __unused4;
index deb1c3e..b591c4d 100644 (file)
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
 
 struct shmid64_ds {
        struct ipc64_perm       shm_perm;       /* operation perms */
-#ifndef __powerpc64__
-       unsigned long           __unused1;
-#endif
+#ifdef __powerpc64__
        __kernel_time_t         shm_atime;      /* last attach time */
-#ifndef __powerpc64__
-       unsigned long           __unused2;
-#endif
        __kernel_time_t         shm_dtime;      /* last detach time */
-#ifndef __powerpc64__
-       unsigned long           __unused3;
-#endif
        __kernel_time_t         shm_ctime;      /* last change time */
-#ifndef __powerpc64__
+#else
+       unsigned long           shm_atime_high;
+       unsigned long           shm_atime;      /* last attach time */
+       unsigned long           shm_dtime_high;
+       unsigned long           shm_dtime;      /* last detach time */
+       unsigned long           shm_ctime_high;
+       unsigned long           shm_ctime;      /* last change time */
        unsigned long           __unused4;
 #endif
        size_t                  shm_segsz;      /* size of segment (bytes) */
index 6bee65f..a77528d 100644 (file)
@@ -13,6 +13,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/compat.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
@@ -42,7 +43,6 @@
 #include <asm/paca.h>
 #include <asm/lppaca.h>
 #include <asm/cache.h>
-#include <asm/compat.h>
 #include <asm/mmu.h>
 #include <asm/hvcall.h>
 #include <asm/xics.h>
index ecc66d5..ad054dd 100644 (file)
@@ -7,6 +7,7 @@
  * 2 of the License, or (at your option) any later version.
 **/
 
+#include <linux/compat_time.h>
 #include <linux/oprofile.h>
 #include <linux/sched.h>
 #include <asm/processor.h>
index ae0ed8d..5d85a03 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
-#include <asm/compat.h>
 #include <asm/diag.h>
 #include <asm/sclp.h>
 #include "hypfs.h"
index 9830fb6..97db2fb 100644 (file)
@@ -53,7 +53,6 @@
 
 typedef u32            compat_size_t;
 typedef s32            compat_ssize_t;
-typedef s32            compat_time_t;
 typedef s32            compat_clock_t;
 typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
@@ -97,16 +96,6 @@ typedef struct {
        u32 gprs_high[NUM_GPRS];
 } s390_compat_regs_high;
 
-struct compat_timespec {
-       compat_time_t   tv_sec;
-       s32             tv_nsec;
-};
-
-struct compat_timeval {
-       compat_time_t   tv_sec;
-       s32             tv_usec;
-};
-
 struct compat_stat {
        compat_dev_t    st_dev;
        u16             __pad1;
@@ -243,10 +232,10 @@ struct compat_ipc64_perm {
 
 struct compat_semid64_ds {
        struct compat_ipc64_perm sem_perm;
-       compat_time_t  sem_otime;
-       compat_ulong_t __pad1;
-       compat_time_t  sem_ctime;
-       compat_ulong_t __pad2;
+       compat_ulong_t sem_otime;
+       compat_ulong_t sem_otime_high;
+       compat_ulong_t sem_ctime;
+       compat_ulong_t sem_ctime_high;
        compat_ulong_t sem_nsems;
        compat_ulong_t __unused1;
        compat_ulong_t __unused2;
@@ -254,12 +243,12 @@ struct compat_semid64_ds {
 
 struct compat_msqid64_ds {
        struct compat_ipc64_perm msg_perm;
-       compat_time_t   msg_stime;
-       compat_ulong_t __pad1;
-       compat_time_t   msg_rtime;
-       compat_ulong_t __pad2;
-       compat_time_t   msg_ctime;
-       compat_ulong_t __pad3;
+       compat_ulong_t msg_stime;
+       compat_ulong_t msg_stime_high;
+       compat_ulong_t msg_rtime;
+       compat_ulong_t msg_rtime_high;
+       compat_ulong_t msg_ctime;
+       compat_ulong_t msg_ctime_high;
        compat_ulong_t msg_cbytes;
        compat_ulong_t msg_qnum;
        compat_ulong_t msg_qbytes;
@@ -272,12 +261,12 @@ struct compat_msqid64_ds {
 struct compat_shmid64_ds {
        struct compat_ipc64_perm shm_perm;
        compat_size_t  shm_segsz;
-       compat_time_t  shm_atime;
-       compat_ulong_t __pad1;
-       compat_time_t  shm_dtime;
-       compat_ulong_t __pad2;
-       compat_time_t  shm_ctime;
-       compat_ulong_t __pad3;
+       compat_ulong_t shm_atime;
+       compat_ulong_t shm_atime_high;
+       compat_ulong_t shm_dtime;
+       compat_ulong_t shm_dtime_high;
+       compat_ulong_t shm_ctime;
+       compat_ulong_t shm_ctime_high;
        compat_pid_t   shm_cpid;
        compat_pid_t   shm_lpid;
        compat_ulong_t shm_nattch;
index 1a61b1b..7d22a47 100644 (file)
  * ELF register definitions..
  */
 
+#include <linux/compat.h>
+
 #include <asm/ptrace.h>
-#include <asm/compat.h>
 #include <asm/syscall.h>
 #include <asm/user.h>
 
@@ -136,7 +137,6 @@ typedef s390_regs elf_gregset_t;
 typedef s390_fp_regs compat_elf_fpregset_t;
 typedef s390_compat_regs compat_elf_gregset_t;
 
-#include <linux/compat.h>
 #include <linux/sched/mm.h>    /* for task_struct */
 #include <asm/mmu_context.h>
 
index faef3f7..e364873 100644 (file)
@@ -9,9 +9,12 @@ generic-y += errno.h
 generic-y += fcntl.h
 generic-y += ioctl.h
 generic-y += mman.h
+generic-y += msgbuf.h
 generic-y += param.h
 generic-y += poll.h
 generic-y += resource.h
+generic-y += sembuf.h
+generic-y += shmbuf.h
 generic-y += sockios.h
 generic-y += swab.h
 generic-y += termbits.h
diff --git a/arch/s390/include/uapi/asm/msgbuf.h b/arch/s390/include/uapi/asm/msgbuf.h
deleted file mode 100644 (file)
index 604f847..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _S390_MSGBUF_H
-#define _S390_MSGBUF_H
-
-/* 
- * The msqid64_ds structure for S/390 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
- * - 2 miscellaneous 32-bit values
- */
-
-struct msqid64_ds {
-       struct ipc64_perm msg_perm;
-       __kernel_time_t msg_stime;      /* last msgsnd time */
-#ifndef __s390x__
-       unsigned long   __unused1;
-#endif /* ! __s390x__ */
-       __kernel_time_t msg_rtime;      /* last msgrcv time */
-#ifndef __s390x__
-       unsigned long   __unused2;
-#endif /* ! __s390x__ */
-       __kernel_time_t msg_ctime;      /* last change time */
-#ifndef __s390x__
-       unsigned long   __unused3;
-#endif /* ! __s390x__ */
-       unsigned long  msg_cbytes;      /* current number of bytes on queue */
-       unsigned long  msg_qnum;        /* number of messages in queue */
-       unsigned long  msg_qbytes;      /* max number of bytes on queue */
-       __kernel_pid_t msg_lspid;       /* pid of last msgsnd */
-       __kernel_pid_t msg_lrpid;       /* last receive pid */
-       unsigned long  __unused4;
-       unsigned long  __unused5;
-};
-
-#endif /* _S390_MSGBUF_H */
diff --git a/arch/s390/include/uapi/asm/sembuf.h b/arch/s390/include/uapi/asm/sembuf.h
deleted file mode 100644 (file)
index 3e91769..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _S390_SEMBUF_H
-#define _S390_SEMBUF_H
-
-/* 
- * The semid64_ds structure for S/390 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem (for !__s390x__)
- * - 2 miscellaneous 32-bit values
- */
-
-struct semid64_ds {
-       struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
-       __kernel_time_t sem_otime;              /* last semop time */
-#ifndef __s390x__
-       unsigned long   __unused1;
-#endif /* ! __s390x__ */
-       __kernel_time_t sem_ctime;              /* last change time */
-#ifndef __s390x__
-       unsigned long   __unused2;
-#endif /* ! __s390x__ */
-       unsigned long   sem_nsems;              /* no. of semaphores in array */
-       unsigned long   __unused3;
-       unsigned long   __unused4;
-};
-
-#endif /* _S390_SEMBUF_H */
diff --git a/arch/s390/include/uapi/asm/shmbuf.h b/arch/s390/include/uapi/asm/shmbuf.h
deleted file mode 100644 (file)
index 9cdce8d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _S390_SHMBUF_H
-#define _S390_SHMBUF_H
-
-/* 
- * The shmid64_ds structure for S/390 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem (for !__s390x__)
- * - 2 miscellaneous 32-bit values
- */
-
-struct shmid64_ds {
-       struct ipc64_perm       shm_perm;       /* operation perms */
-       size_t                  shm_segsz;      /* size of segment (bytes) */
-       __kernel_time_t         shm_atime;      /* last attach time */
-#ifndef __s390x__
-       unsigned long           __unused1;
-#endif /* ! __s390x__ */
-       __kernel_time_t         shm_dtime;      /* last detach time */
-#ifndef __s390x__
-       unsigned long           __unused2;
-#endif /* ! __s390x__ */
-       __kernel_time_t         shm_ctime;      /* last change time */
-#ifndef __s390x__
-       unsigned long           __unused3;
-#endif /* ! __s390x__ */
-       __kernel_pid_t          shm_cpid;       /* pid of creator */
-       __kernel_pid_t          shm_lpid;       /* pid of last operator */
-       unsigned long           shm_nattch;     /* no. of current attaches */
-       unsigned long           __unused4;
-       unsigned long           __unused5;
-};
-
-struct shminfo64 {
-       unsigned long   shmmax;
-       unsigned long   shmmin;
-       unsigned long   shmmni;
-       unsigned long   shmseg;
-       unsigned long   shmall;
-       unsigned long   __unused1;
-       unsigned long   __unused2;
-       unsigned long   __unused3;
-       unsigned long   __unused4;
-};
-
-#endif /* _S390_SHMBUF_H */
index ebfa044..a3bce0e 100644 (file)
@@ -26,7 +26,6 @@
 #include <asm/gmap.h>
 #include <asm/io.h>
 #include <asm/ptrace.h>
-#include <asm/compat.h>
 #include <asm/sclp.h>
 #include "gaccess.h"
 #include "kvm-s390.h"
index 93cd0f1..19b2d2a 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/uaccess.h>
 #include <asm/pci_debug.h>
 #include <asm/pci_clp.h>
-#include <asm/compat.h>
 #include <asm/clp.h>
 #include <uapi/asm/clp.h>
 
index 1efcce7..46dd82a 100644 (file)
@@ -1,3 +1,4 @@
+generic-y += compat.h
 generic-y += current.h
 generic-y += delay.h
 generic-y += div64.h
index 615283e..4eb51d2 100644 (file)
@@ -11,7 +11,6 @@
 
 typedef u32            compat_size_t;
 typedef s32            compat_ssize_t;
-typedef s32            compat_time_t;
 typedef s32            compat_clock_t;
 typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
@@ -39,16 +38,6 @@ typedef u32          compat_ulong_t;
 typedef u64            compat_u64;
 typedef u32            compat_uptr_t;
 
-struct compat_timespec {
-       compat_time_t   tv_sec;
-       s32             tv_nsec;
-};
-
-struct compat_timeval {
-       compat_time_t   tv_sec;
-       s32             tv_usec;
-};
-
 struct compat_stat {
        compat_dev_t    st_dev;
        compat_ino_t    st_ino;
@@ -168,6 +157,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
        return (u32)(unsigned long)uptr;
 }
 
+#ifdef CONFIG_COMPAT
 static inline void __user *arch_compat_alloc_user_space(long len)
 {
        struct pt_regs *regs = current_thread_info()->kregs;
@@ -184,6 +174,7 @@ static inline void __user *arch_compat_alloc_user_space(long len)
 
        return (void __user *) usp;
 }
+#endif
 
 struct compat_ipc64_perm {
        compat_key_t key;
@@ -201,10 +192,10 @@ struct compat_ipc64_perm {
 
 struct compat_semid64_ds {
        struct compat_ipc64_perm sem_perm;
-       unsigned int    __pad1;
-       compat_time_t   sem_otime;
-       unsigned int    __pad2;
-       compat_time_t   sem_ctime;
+       unsigned int    sem_otime_high;
+       unsigned int    sem_otime;
+       unsigned int    sem_ctime_high;
+       unsigned int    sem_ctime;
        u32             sem_nsems;
        u32             __unused1;
        u32             __unused2;
@@ -212,12 +203,12 @@ struct compat_semid64_ds {
 
 struct compat_msqid64_ds {
        struct compat_ipc64_perm msg_perm;
-       unsigned int    __pad1;
-       compat_time_t   msg_stime;
-       unsigned int    __pad2;
-       compat_time_t   msg_rtime;
-       unsigned int    __pad3;
-       compat_time_t   msg_ctime;
+       unsigned int    msg_stime_high;
+       unsigned int    msg_stime;
+       unsigned int    msg_rtime_high;
+       unsigned int    msg_rtime;
+       unsigned int    msg_ctime_high;
+       unsigned int    msg_ctime;
        unsigned int    msg_cbytes;
        unsigned int    msg_qnum;
        unsigned int    msg_qbytes;
@@ -229,12 +220,12 @@ struct compat_msqid64_ds {
 
 struct compat_shmid64_ds {
        struct compat_ipc64_perm shm_perm;
-       unsigned int    __pad1;
-       compat_time_t   shm_atime;
-       unsigned int    __pad2;
-       compat_time_t   shm_dtime;
-       unsigned int    __pad3;
-       compat_time_t   shm_ctime;
+       unsigned int    shm_atime_high;
+       unsigned int    shm_atime;
+       unsigned int    shm_dtime_high;
+       unsigned int    shm_dtime;
+       unsigned int    shm_ctime_high;
+       unsigned int    shm_ctime;
        compat_size_t   shm_segsz;
        compat_pid_t    shm_cpid;
        compat_pid_t    shm_lpid;
@@ -243,6 +234,7 @@ struct compat_shmid64_ds {
        unsigned int    __unused2;
 };
 
+#ifdef CONFIG_COMPAT
 static inline int is_compat_task(void)
 {
        return test_thread_flag(TIF_32BIT);
@@ -254,5 +246,6 @@ static inline bool in_compat_syscall(void)
        return pt_regs_trap_type(current_pt_regs()) == 0x110;
 }
 #define in_compat_syscall in_compat_syscall
+#endif
 
 #endif /* _ASM_SPARC64_COMPAT_H */
index b601c4f..ffc46c2 100644 (file)
@@ -8,25 +8,22 @@
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
-
-#if defined(__sparc__) && defined(__arch64__)
-# define PADDING(x)
-#else
-# define PADDING(x) unsigned int x;
-#endif
-
-
 struct msqid64_ds {
        struct ipc64_perm msg_perm;
-       PADDING(__pad1)
+#if defined(__sparc__) && defined(__arch64__)
        __kernel_time_t msg_stime;      /* last msgsnd time */
-       PADDING(__pad2)
        __kernel_time_t msg_rtime;      /* last msgrcv time */
-       PADDING(__pad3)
        __kernel_time_t msg_ctime;      /* last change time */
+#else
+       unsigned long msg_stime_high;
+       unsigned long msg_stime;        /* last msgsnd time */
+       unsigned long msg_rtime_high;
+       unsigned long msg_rtime;        /* last msgrcv time */
+       unsigned long msg_ctime_high;
+       unsigned long msg_ctime;        /* last change time */
+#endif
        unsigned long  msg_cbytes;      /* current number of bytes on queue */
        unsigned long  msg_qnum;        /* number of messages in queue */
        unsigned long  msg_qbytes;      /* max number of bytes on queue */
@@ -35,5 +32,4 @@ struct msqid64_ds {
        unsigned long  __unused1;
        unsigned long  __unused2;
 };
-#undef PADDING
 #endif /* _SPARC_MSGBUF_H */
index f49b0ff..f3d309c 100644 (file)
@@ -8,25 +8,23 @@
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
-#if defined(__sparc__) && defined(__arch64__)
-# define PADDING(x)
-#else
-# define PADDING(x) unsigned int x;
-#endif
 
 struct semid64_ds {
        struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
-       PADDING(__pad1)
+#if defined(__sparc__) && defined(__arch64__)
        __kernel_time_t sem_otime;              /* last semop time */
-       PADDING(__pad2)
        __kernel_time_t sem_ctime;              /* last change time */
+#else
+       unsigned long   sem_otime_high;
+       unsigned long   sem_otime;              /* last semop time */
+       unsigned long   sem_ctime_high;
+       unsigned long   sem_ctime;              /* last change time */
+#endif
        unsigned long   sem_nsems;              /* no. of semaphores in array */
        unsigned long   __unused1;
        unsigned long   __unused2;
 };
-#undef PADDING
 
 #endif /* _SPARC64_SEMBUF_H */
index 286631d..06618b8 100644 (file)
@@ -8,24 +8,23 @@
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
 
-#if defined(__sparc__) && defined(__arch64__)
-# define PADDING(x)
-#else
-# define PADDING(x) unsigned int x;
-#endif
-
 struct shmid64_ds {
        struct ipc64_perm       shm_perm;       /* operation perms */
-       PADDING(__pad1)
+#if defined(__sparc__) && defined(__arch64__)
        __kernel_time_t         shm_atime;      /* last attach time */
-       PADDING(__pad2)
        __kernel_time_t         shm_dtime;      /* last detach time */
-       PADDING(__pad3)
        __kernel_time_t         shm_ctime;      /* last change time */
+#else
+       unsigned long           shm_atime_high;
+       unsigned long           shm_atime;      /* last attach time */
+       unsigned long           shm_dtime_high;
+       unsigned long           shm_dtime;      /* last detach time */
+       unsigned long           shm_ctime_high;
+       unsigned long           shm_ctime;      /* last change time */
+#endif
        size_t                  shm_segsz;      /* size of segment (bytes) */
        __kernel_pid_t          shm_cpid;       /* pid of creator */
        __kernel_pid_t          shm_lpid;       /* pid of last operator */
@@ -46,6 +45,4 @@ struct shminfo64 {
        unsigned long   __unused4;
 };
 
-#undef PADDING
-
 #endif /* _SPARC_SHMBUF_H */
index bb5a196..b10dde6 100644 (file)
@@ -1,6 +1,7 @@
 generic-y += barrier.h
 generic-y += bpf_perf_event.h
 generic-y += bug.h
+generic-y += compat.h
 generic-y += current.h
 generic-y += delay.h
 generic-y += device.h
index 6f70c76..bfc7abe 100644 (file)
@@ -1,5 +1,6 @@
 generic-y += atomic.h
 generic-y += bugs.h
+generic-y += compat.h
 generic-y += current.h
 generic-y += device.h
 generic-y += div64.h
index 45b2b1c..6e461fb 100644 (file)
@@ -2397,7 +2397,7 @@ static unsigned long get_segment_base(unsigned int segment)
 
 #ifdef CONFIG_IA32_EMULATION
 
-#include <asm/compat.h>
+#include <linux/compat.h>
 
 static inline int
 perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *entry)
index e1c8dab..fb97cf7 100644 (file)
@@ -17,7 +17,6 @@
 
 typedef u32            compat_size_t;
 typedef s32            compat_ssize_t;
-typedef s32            compat_time_t;
 typedef s32            compat_clock_t;
 typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
@@ -46,16 +45,6 @@ typedef u32          compat_u32;
 typedef u64 __attribute__((aligned(4))) compat_u64;
 typedef u32            compat_uptr_t;
 
-struct compat_timespec {
-       compat_time_t   tv_sec;
-       s32             tv_nsec;
-};
-
-struct compat_timeval {
-       compat_time_t   tv_sec;
-       s32             tv_usec;
-};
-
 struct compat_stat {
        compat_dev_t    st_dev;
        u16             __pad1;
@@ -145,10 +134,10 @@ struct compat_ipc64_perm {
 
 struct compat_semid64_ds {
        struct compat_ipc64_perm sem_perm;
-       compat_time_t  sem_otime;
-       compat_ulong_t __unused1;
-       compat_time_t  sem_ctime;
-       compat_ulong_t __unused2;
+       compat_ulong_t sem_otime;
+       compat_ulong_t sem_otime_high;
+       compat_ulong_t sem_ctime;
+       compat_ulong_t sem_ctime_high;
        compat_ulong_t sem_nsems;
        compat_ulong_t __unused3;
        compat_ulong_t __unused4;
@@ -156,12 +145,12 @@ struct compat_semid64_ds {
 
 struct compat_msqid64_ds {
        struct compat_ipc64_perm msg_perm;
-       compat_time_t  msg_stime;
-       compat_ulong_t __unused1;
-       compat_time_t  msg_rtime;
-       compat_ulong_t __unused2;
-       compat_time_t  msg_ctime;
-       compat_ulong_t __unused3;
+       compat_ulong_t msg_stime;
+       compat_ulong_t msg_stime_high;
+       compat_ulong_t msg_rtime;
+       compat_ulong_t msg_rtime_high;
+       compat_ulong_t msg_ctime;
+       compat_ulong_t msg_ctime_high;
        compat_ulong_t msg_cbytes;
        compat_ulong_t msg_qnum;
        compat_ulong_t msg_qbytes;
@@ -174,12 +163,12 @@ struct compat_msqid64_ds {
 struct compat_shmid64_ds {
        struct compat_ipc64_perm shm_perm;
        compat_size_t  shm_segsz;
-       compat_time_t  shm_atime;
-       compat_ulong_t __unused1;
-       compat_time_t  shm_dtime;
-       compat_ulong_t __unused2;
-       compat_time_t  shm_ctime;
-       compat_ulong_t __unused3;
+       compat_ulong_t shm_atime;
+       compat_ulong_t shm_atime_high;
+       compat_ulong_t shm_dtime;
+       compat_ulong_t shm_dtime_high;
+       compat_ulong_t shm_ctime;
+       compat_ulong_t shm_ctime_high;
        compat_pid_t   shm_cpid;
        compat_pid_t   shm_lpid;
        compat_ulong_t shm_nattch;
index cc8f8fc..c18ed65 100644 (file)
@@ -63,7 +63,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
 #ifndef COMPILE_OFFSETS
 
 #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
-#include <asm/compat.h>
+#include <linux/compat.h>
 
 /*
  * Because ia32 syscalls do not map to x86_64 syscall numbers
index cabd747..89de6cd 100644 (file)
@@ -8,15 +8,24 @@
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
+ *
+ * x86_64 and x32 incorrectly added padding here, so the structures
+ * are still incompatible with the padding on x86.
  */
 struct semid64_ds {
        struct ipc64_perm sem_perm;     /* permissions .. see ipc.h */
+#ifdef __i386__
+       unsigned long   sem_otime;      /* last semop time */
+       unsigned long   sem_otime_high;
+       unsigned long   sem_ctime;      /* last change time */
+       unsigned long   sem_ctime_high;
+#else
        __kernel_time_t sem_otime;      /* last semop time */
        __kernel_ulong_t __unused1;
        __kernel_time_t sem_ctime;      /* last change time */
        __kernel_ulong_t __unused2;
+#endif
        __kernel_ulong_t sem_nsems;     /* no. of semaphores in array */
        __kernel_ulong_t __unused3;
        __kernel_ulong_t __unused4;
index a3f15ed..6a78d4b 100644 (file)
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <linux/compat.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
@@ -19,7 +20,6 @@
 #include <linux/elf.h>
 
 #include <asm/elf.h>
-#include <asm/compat.h>
 #include <asm/ia32.h>
 #include <asm/syscalls.h>
 #include <asm/mpx.h>
index 436b203..e5e1e61 100644 (file)
@@ -1,4 +1,5 @@
 generic-y += bug.h
+generic-y += compat.h
 generic-y += device.h
 generic-y += div64.h
 generic-y += dma-contiguous.h
index 36e2e10..d6915e9 100644 (file)
@@ -7,7 +7,6 @@
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  *
  * This file is subject to the terms and conditions of the GNU General
 struct msqid64_ds {
        struct ipc64_perm msg_perm;
 #ifdef __XTENSA_EB__
-       unsigned int    __unused1;
-       __kernel_time_t msg_stime;      /* last msgsnd time */
-       unsigned int    __unused2;
-       __kernel_time_t msg_rtime;      /* last msgrcv time */
-       unsigned int    __unused3;
-       __kernel_time_t msg_ctime;      /* last change time */
+       unsigned long  msg_stime_high;
+       unsigned long  msg_stime;       /* last msgsnd time */
+       unsigned long  msg_rtime_high;
+       unsigned long  msg_rtime;       /* last msgrcv time */
+       unsigned long  msg_ctime_high;
+       unsigned long  msg_ctime;       /* last change time */
 #elif defined(__XTENSA_EL__)
-       __kernel_time_t msg_stime;      /* last msgsnd time */
-       unsigned int    __unused1;
-       __kernel_time_t msg_rtime;      /* last msgrcv time */
-       unsigned int    __unused2;
-       __kernel_time_t msg_ctime;      /* last change time */
-       unsigned int    __unused3;
+       unsigned long  msg_stime;       /* last msgsnd time */
+       unsigned long  msg_stime_high;
+       unsigned long  msg_rtime;       /* last msgrcv time */
+       unsigned long  msg_rtime_high;
+       unsigned long  msg_ctime;       /* last change time */
+       unsigned long  msg_ctime_high;
 #else
 # error processor byte order undefined!
 #endif
index f61b633..09f348d 100644 (file)
@@ -14,7 +14,6 @@
  * between kernel and user space.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  *
  */
 struct semid64_ds {
        struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
 #ifdef __XTENSA_EL__
-       __kernel_time_t sem_otime;              /* last semop time */
-       unsigned long   __unused1;
-       __kernel_time_t sem_ctime;              /* last change time */
-       unsigned long   __unused2;
+       unsigned long   sem_otime;              /* last semop time */
+       unsigned long   sem_otime_high;
+       unsigned long   sem_ctime;              /* last change time */
+       unsigned long   sem_ctime_high;
 #else
-       unsigned long   __unused1;
-       __kernel_time_t sem_otime;              /* last semop time */
-       unsigned long   __unused2;
-       __kernel_time_t sem_ctime;              /* last change time */
+       unsigned long   sem_otime_high;
+       unsigned long   sem_otime;              /* last semop time */
+       unsigned long   sem_ctime_high;
+       unsigned long   sem_ctime;              /* last change time */
 #endif
        unsigned long   sem_nsems;              /* no. of semaphores in array */
        unsigned long   __unused3;
index 26550bd..554a57a 100644 (file)
@@ -4,10 +4,10 @@
  *
  * The shmid64_ds structure for Xtensa architecture.
  * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
+ * between kernel and user space, but the padding is on the wrong
+ * side for big-endian xtensa, for historic reasons.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  *
  * This file is subject to the terms and conditions of the GNU General Public
 #ifndef _XTENSA_SHMBUF_H
 #define _XTENSA_SHMBUF_H
 
-#if defined (__XTENSA_EL__)
 struct shmid64_ds {
        struct ipc64_perm       shm_perm;       /* operation perms */
        size_t                  shm_segsz;      /* size of segment (bytes) */
-       __kernel_time_t         shm_atime;      /* last attach time */
-       unsigned long           __unused1;
-       __kernel_time_t         shm_dtime;      /* last detach time */
-       unsigned long           __unused2;
-       __kernel_time_t         shm_ctime;      /* last change time */
-       unsigned long           __unused3;
+       unsigned long           shm_atime;      /* last attach time */
+       unsigned long           shm_atime_high;
+       unsigned long           shm_dtime;      /* last detach time */
+       unsigned long           shm_dtime_high;
+       unsigned long           shm_ctime;      /* last change time */
+       unsigned long           shm_ctime_high;
        __kernel_pid_t          shm_cpid;       /* pid of creator */
        __kernel_pid_t          shm_lpid;       /* pid of last operator */
        unsigned long           shm_nattch;     /* no. of current attaches */
        unsigned long           __unused4;
        unsigned long           __unused5;
 };
-#elif defined (__XTENSA_EB__)
-struct shmid64_ds {
-       struct ipc64_perm       shm_perm;       /* operation perms */
-       size_t                  shm_segsz;      /* size of segment (bytes) */
-       __kernel_time_t         shm_atime;      /* last attach time */
-       unsigned long           __unused1;
-       __kernel_time_t         shm_dtime;      /* last detach time */
-       unsigned long           __unused2;
-       __kernel_time_t         shm_ctime;      /* last change time */
-       unsigned long           __unused3;
-       __kernel_pid_t          shm_cpid;       /* pid of creator */
-       __kernel_pid_t          shm_lpid;       /* pid of last operator */
-       unsigned long           shm_nattch;     /* no. of current attaches */
-       unsigned long           __unused4;
-       unsigned long           __unused5;
-};
-#else
-# error endian order not defined
-#endif
-
 
 struct shminfo64 {
        unsigned long   shmmax;
index 7bdc6aa..2016e0e 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/fs.h>
 #include <linux/blkpg.h>
 #include <linux/slab.h>
-#include <asm/compat.h>
 #include <asm/ccwdev.h>
 #include <asm/schid.h>
 #include <asm/cmb.h>
index 6182248..16a4e85 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 
-#include <asm/compat.h>
 #include <asm/ccwdev.h>
 #include <asm/cio.h>
 #include <asm/ebcdic.h>
index a78cea0..248b5db 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/init.h>
 #include <linux/ioctl.h>
 #include <linux/fs.h>
-#include <asm/compat.h>
 #include <asm/sclp_ctl.h>
 #include <asm/sclp.h>
 
index 17e411c..948ce82 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/mutex.h>
 #include <linux/cma.h>
 #include <linux/mm.h>
-#include <asm/compat.h>
 #include <asm/cpcmd.h>
 #include <asm/debug.h>
 #include <asm/vmcp.h>
index 0015729..8d9f366 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/miscdevice.h>
 #include <linux/kernel_stat.h>
 
-#include <asm/compat.h>
 #include <asm/cio.h>
 #include <asm/chsc.h>
 #include <asm/isc.h>
index dffd820..f5a0d89 100644 (file)
@@ -10,6 +10,7 @@
 #define KMSG_COMPONENT "qeth"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/compat.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/string.h>
@@ -32,7 +33,6 @@
 #include <asm/chpid.h>
 #include <asm/io.h>
 #include <asm/sysinfo.h>
-#include <asm/compat.h>
 #include <asm/diag.h>
 #include <asm/cio.h>
 #include <asm/ccwdev.h>
diff --git a/include/asm-generic/compat.h b/include/asm-generic/compat.h
new file mode 100644 (file)
index 0000000..2881945
--- /dev/null
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+/* This is an empty stub for 32-bit-only architectures */
index 081281a..cfc1b63 100644 (file)
@@ -7,8 +7,7 @@
  */
 
 #include <linux/types.h>
-
-#ifdef CONFIG_COMPAT
+#include <linux/compat_time.h>
 
 #include <linux/stat.h>
 #include <linux/param.h>       /* for HZ */
 #include <linux/unistd.h>
 
 #include <asm/compat.h>
+
+#ifdef CONFIG_COMPAT
 #include <asm/siginfo.h>
 #include <asm/signal.h>
+#endif
 
 #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
 /*
@@ -83,6 +85,8 @@
        static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
 #endif /* COMPAT_SYSCALL_DEFINEx */
 
+#ifdef CONFIG_COMPAT
+
 #ifndef compat_user_stack_pointer
 #define compat_user_stack_pointer() current_user_stack_pointer()
 #endif
@@ -290,8 +294,6 @@ extern int compat_get_timespec(struct timespec *, const void __user *);
 extern int compat_put_timespec(const struct timespec *, void __user *);
 extern int compat_get_timeval(struct timeval *, const void __user *);
 extern int compat_put_timeval(const struct timeval *, void __user *);
-extern int compat_get_timespec64(struct timespec64 *, const void __user *);
-extern int compat_put_timespec64(const struct timespec64 *, void __user *);
 extern int get_compat_itimerspec64(struct itimerspec64 *its,
                        const struct compat_itimerspec __user *uits);
 extern int put_compat_itimerspec64(const struct itimerspec64 *its,
@@ -1016,7 +1018,9 @@ static inline struct compat_timeval ns_to_compat_timeval(s64 nsec)
 #else /* !CONFIG_COMPAT */
 
 #define is_compat_task() (0)
+#ifndef in_compat_syscall
 static inline bool in_compat_syscall(void) { return false; }
+#endif
 
 #endif /* CONFIG_COMPAT */
 
diff --git a/include/linux/compat_time.h b/include/linux/compat_time.h
new file mode 100644 (file)
index 0000000..31f2774
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_COMPAT_TIME_H
+#define _LINUX_COMPAT_TIME_H
+
+#include <linux/types.h>
+#include <linux/time64.h>
+
+typedef s32            compat_time_t;
+
+struct compat_timespec {
+       compat_time_t   tv_sec;
+       s32             tv_nsec;
+};
+
+struct compat_timeval {
+       compat_time_t   tv_sec;
+       s32             tv_usec;
+};
+
+extern int compat_get_timespec64(struct timespec64 *, const void __user *);
+extern int compat_put_timespec64(const struct timespec64 *, void __user *);
+
+#endif /* _LINUX_COMPAT_TIME_H */
index bcfdb91..5d83d0c 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/compiler.h>
 #include <linux/types.h>
+#include <linux/time64.h>
 
 struct timespec;
 struct compat_timespec;
@@ -15,9 +16,7 @@ struct pollfd;
 enum timespec_type {
        TT_NONE         = 0,
        TT_NATIVE       = 1,
-#ifdef CONFIG_COMPAT
        TT_COMPAT       = 2,
-#endif
 };
 
 /*
@@ -40,10 +39,8 @@ struct restart_block {
                        clockid_t clockid;
                        enum timespec_type type;
                        union {
-                               struct timespec __user *rmtp;
-#ifdef CONFIG_COMPAT
+                               struct __kernel_timespec __user *rmtp;
                                struct compat_timespec __user *compat_rmtp;
-#endif
                        };
                        u64 expires;
                } nanosleep;
index 70fcda1..b92cb79 100644 (file)
@@ -536,7 +536,8 @@ asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
                                    size_t len);
 
 /* kernel/hrtimer.c */
-asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp);
+asmlinkage long sys_nanosleep(struct __kernel_timespec __user *rqtp,
+                             struct __kernel_timespec __user *rmtp);
 
 /* kernel/itimer.c */
 asmlinkage long sys_getitimer(int which, struct itimerval __user *value);
@@ -567,14 +568,14 @@ asmlinkage long sys_timer_settime(timer_t timer_id, int flags,
                                struct itimerspec __user *old_setting);
 asmlinkage long sys_timer_delete(timer_t timer_id);
 asmlinkage long sys_clock_settime(clockid_t which_clock,
-                               const struct timespec __user *tp);
+                               const struct __kernel_timespec __user *tp);
 asmlinkage long sys_clock_gettime(clockid_t which_clock,
-                               struct timespec __user *tp);
+                               struct __kernel_timespec __user *tp);
 asmlinkage long sys_clock_getres(clockid_t which_clock,
-                               struct timespec __user *tp);
+                               struct __kernel_timespec __user *tp);
 asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
-                               const struct timespec __user *rqtp,
-                               struct timespec __user *rmtp);
+                               const struct __kernel_timespec __user *rqtp,
+                               struct __kernel_timespec __user *rmtp);
 
 /* kernel/printk.c */
 asmlinkage long sys_syslog(int type, char __user *buf, int len);
@@ -679,8 +680,8 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info);
 /* ipc/mqueue.c */
 asmlinkage long sys_mq_open(const char __user *name, int oflag, umode_t mode, struct mq_attr __user *attr);
 asmlinkage long sys_mq_unlink(const char __user *name);
-asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec __user *abs_timeout);
-asmlinkage long sys_mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct timespec __user *abs_timeout);
+asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct __kernel_timespec __user *abs_timeout);
+asmlinkage long sys_mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct __kernel_timespec __user *abs_timeout);
 asmlinkage long sys_mq_notify(mqd_t mqdes, const struct sigevent __user *notification);
 asmlinkage long sys_mq_getsetattr(mqd_t mqdes, const struct mq_attr __user *mqstat, struct mq_attr __user *omqstat);
 
@@ -697,7 +698,7 @@ asmlinkage long sys_semget(key_t key, int nsems, int semflg);
 asmlinkage long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
                                unsigned nsops,
-                               const struct timespec __user *timeout);
+                               const struct __kernel_timespec __user *timeout);
 asmlinkage long sys_semop(int semid, struct sembuf __user *sops,
                                unsigned nsops);
 
index 4b62a2c..aed7446 100644 (file)
@@ -10,9 +10,9 @@
 extern struct timezone sys_tz;
 
 int get_timespec64(struct timespec64 *ts,
-               const struct timespec __user *uts);
+               const struct __kernel_timespec __user *uts);
 int put_timespec64(const struct timespec64 *ts,
-               struct timespec __user *uts);
+               struct __kernel_timespec __user *uts);
 int get_itimerspec64(struct itimerspec64 *it,
                        const struct itimerspec __user *uit);
 int put_itimerspec64(const struct itimerspec64 *it,
index 93d3949..0d96887 100644 (file)
@@ -2,12 +2,20 @@
 #ifndef _LINUX_TIME64_H
 #define _LINUX_TIME64_H
 
-#include <uapi/linux/time.h>
 #include <linux/math64.h>
 
 typedef __s64 time64_t;
 typedef __u64 timeu64_t;
 
+/* CONFIG_64BIT_TIME enables new 64 bit time_t syscalls in the compat path
+ * and 32-bit emulation.
+ */
+#ifndef CONFIG_64BIT_TIME
+#define __kernel_timespec timespec
+#endif
+
+#include <uapi/linux/time.h>
+
 #if __BITS_PER_LONG == 64
 /* this trick allows us to optimize out timespec64_to_timespec */
 # define timespec64 timespec
index fb306eb..9fe4881 100644 (file)
  * On big-endian systems, the padding is in the wrong place.
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
 
 struct msqid64_ds {
        struct ipc64_perm msg_perm;
+#if __BITS_PER_LONG == 64
        __kernel_time_t msg_stime;      /* last msgsnd time */
-#if __BITS_PER_LONG != 64
-       unsigned long   __unused1;
-#endif
        __kernel_time_t msg_rtime;      /* last msgrcv time */
-#if __BITS_PER_LONG != 64
-       unsigned long   __unused2;
-#endif
        __kernel_time_t msg_ctime;      /* last change time */
-#if __BITS_PER_LONG != 64
-       unsigned long   __unused3;
+#else
+       unsigned long   msg_stime;      /* last msgsnd time */
+       unsigned long   msg_stime_high;
+       unsigned long   msg_rtime;      /* last msgrcv time */
+       unsigned long   msg_rtime_high;
+       unsigned long   msg_ctime;      /* last change time */
+       unsigned long   msg_ctime_high;
 #endif
-       __kernel_ulong_t msg_cbytes;    /* current number of bytes on queue */
-       __kernel_ulong_t msg_qnum;      /* number of messages in queue */
-       __kernel_ulong_t msg_qbytes;    /* max number of bytes on queue */
+       unsigned long   msg_cbytes;     /* current number of bytes on queue */
+       unsigned long   msg_qnum;       /* number of messages in queue */
+       unsigned long    msg_qbytes;    /* max number of bytes on queue */
        __kernel_pid_t msg_lspid;       /* pid of last msgsnd */
        __kernel_pid_t msg_lrpid;       /* last receive pid */
-       __kernel_ulong_t __unused4;
-       __kernel_ulong_t __unused5;
+       unsigned long    __unused4;
+       unsigned long    __unused5;
 };
 
 #endif /* __ASM_GENERIC_MSGBUF_H */
index 5e6ea22..f0733a2 100644 (file)
@@ -87,6 +87,7 @@ typedef struct {
 typedef __kernel_long_t        __kernel_off_t;
 typedef long long      __kernel_loff_t;
 typedef __kernel_long_t        __kernel_time_t;
+typedef long long __kernel_time64_t;
 typedef __kernel_long_t        __kernel_clock_t;
 typedef int            __kernel_timer_t;
 typedef int            __kernel_clockid_t;
index cbf9cfe..0bae010 100644 (file)
  * everyone just ended up making identical copies without specific
  * optimizations, so we may just as well all use the same one.
  *
- * 64 bit architectures typically define a 64 bit __kernel_time_t,
+ * 64 bit architectures use a 64-bit __kernel_time_t here, while
+ * 32 bit architectures have a pair of unsigned long values.
  * so they do not need the first two padding words.
- * On big-endian systems, the padding is in the wrong place.
  *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
- * - 2 miscellaneous 32-bit values
+ * On big-endian systems, the padding is in the wrong place for
+ * historic reasons, so user space has to reconstruct a time_t
+ * value using
+ *
+ * user_semid_ds.sem_otime = kernel_semid64_ds.sem_otime +
+ *             ((long long)kernel_semid64_ds.sem_otime_high << 32)
+ *
+ * Pad space is left for 2 miscellaneous 32-bit values
  */
 struct semid64_ds {
        struct ipc64_perm sem_perm;     /* permissions .. see ipc.h */
+#if __BITS_PER_LONG == 64
        __kernel_time_t sem_otime;      /* last semop time */
-#if __BITS_PER_LONG != 64
-       unsigned long   __unused1;
-#endif
        __kernel_time_t sem_ctime;      /* last change time */
-#if __BITS_PER_LONG != 64
-       unsigned long   __unused2;
+#else
+       unsigned long   sem_otime;      /* last semop time */
+       unsigned long   sem_otime_high;
+       unsigned long   sem_ctime;      /* last change time */
+       unsigned long   sem_ctime_high;
 #endif
        unsigned long   sem_nsems;      /* no. of semaphores in array */
        unsigned long   __unused3;
index 2b6c3bb..e504422 100644 (file)
  *
  *
  * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
 
 struct shmid64_ds {
        struct ipc64_perm       shm_perm;       /* operation perms */
        size_t                  shm_segsz;      /* size of segment (bytes) */
+#if __BITS_PER_LONG == 64
        __kernel_time_t         shm_atime;      /* last attach time */
-#if __BITS_PER_LONG != 64
-       unsigned long           __unused1;
-#endif
        __kernel_time_t         shm_dtime;      /* last detach time */
-#if __BITS_PER_LONG != 64
-       unsigned long           __unused2;
-#endif
        __kernel_time_t         shm_ctime;      /* last change time */
-#if __BITS_PER_LONG != 64
-       unsigned long           __unused3;
+#else
+       unsigned long           shm_atime;      /* last attach time */
+       unsigned long           shm_atime_high;
+       unsigned long           shm_dtime;      /* last detach time */
+       unsigned long           shm_dtime_high;
+       unsigned long           shm_ctime;      /* last change time */
+       unsigned long           shm_ctime_high;
 #endif
        __kernel_pid_t          shm_cpid;       /* pid of creator */
        __kernel_pid_t          shm_lpid;       /* pid of last operator */
-       __kernel_ulong_t        shm_nattch;     /* no. of current attaches */
-       __kernel_ulong_t        __unused4;
-       __kernel_ulong_t        __unused5;
+       unsigned long           shm_nattch;     /* no. of current attaches */
+       unsigned long           __unused4;
+       unsigned long           __unused5;
 };
 
 struct shminfo64 {
-       __kernel_ulong_t        shmmax;
-       __kernel_ulong_t        shmmin;
-       __kernel_ulong_t        shmmni;
-       __kernel_ulong_t        shmseg;
-       __kernel_ulong_t        shmall;
-       __kernel_ulong_t        __unused1;
-       __kernel_ulong_t        __unused2;
-       __kernel_ulong_t        __unused3;
-       __kernel_ulong_t        __unused4;
+       unsigned long           shmmax;
+       unsigned long           shmmin;
+       unsigned long           shmmni;
+       unsigned long           shmseg;
+       unsigned long           shmall;
+       unsigned long           __unused1;
+       unsigned long           __unused2;
+       unsigned long           __unused3;
+       unsigned long           __unused4;
 };
 
 #endif /* __ASM_GENERIC_SHMBUF_H */
index 4c0338e..fcf9366 100644 (file)
@@ -42,6 +42,13 @@ struct itimerval {
        struct timeval it_value;        /* current value */
 };
 
+#ifndef __kernel_timespec
+struct __kernel_timespec {
+       __kernel_time64_t       tv_sec;                 /* seconds */
+       long long               tv_nsec;                /* nanoseconds */
+};
+#endif
+
 /*
  * legacy timeval structure, only embedded in structures that
  * traditionally used 'timeval' to pass time intervals (not absolute
index a808f29..c0d58f3 100644 (file)
@@ -691,7 +691,7 @@ static void __do_notify(struct mqueue_inode_info *info)
        wake_up(&info->wait_q);
 }
 
-static int prepare_timeout(const struct timespec __user *u_abs_timeout,
+static int prepare_timeout(const struct __kernel_timespec __user *u_abs_timeout,
                           struct timespec64 *ts)
 {
        if (get_timespec64(ts, u_abs_timeout))
@@ -1128,7 +1128,7 @@ out:
 
 SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
                size_t, msg_len, unsigned int, msg_prio,
-               const struct timespec __user *, u_abs_timeout)
+               const struct __kernel_timespec __user *, u_abs_timeout)
 {
        struct timespec64 ts, *p = NULL;
        if (u_abs_timeout) {
@@ -1142,7 +1142,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
 
 SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
                size_t, msg_len, unsigned int __user *, u_msg_prio,
-               const struct timespec __user *, u_abs_timeout)
+               const struct __kernel_timespec __user *, u_abs_timeout)
 {
        struct timespec64 ts, *p = NULL;
        if (u_abs_timeout) {
@@ -1420,6 +1420,47 @@ COMPAT_SYSCALL_DEFINE4(mq_open, const char __user *, u_name,
        return do_mq_open(u_name, oflag, mode, p);
 }
 
+COMPAT_SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
+                      const struct compat_sigevent __user *, u_notification)
+{
+       struct sigevent n, *p = NULL;
+       if (u_notification) {
+               if (get_compat_sigevent(&n, u_notification))
+                       return -EFAULT;
+               if (n.sigev_notify == SIGEV_THREAD)
+                       n.sigev_value.sival_ptr = compat_ptr(n.sigev_value.sival_int);
+               p = &n;
+       }
+       return do_mq_notify(mqdes, p);
+}
+
+COMPAT_SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
+                      const struct compat_mq_attr __user *, u_mqstat,
+                      struct compat_mq_attr __user *, u_omqstat)
+{
+       int ret;
+       struct mq_attr mqstat, omqstat;
+       struct mq_attr *new = NULL, *old = NULL;
+
+       if (u_mqstat) {
+               new = &mqstat;
+               if (get_compat_mq_attr(new, u_mqstat))
+                       return -EFAULT;
+       }
+       if (u_omqstat)
+               old = &omqstat;
+
+       ret = do_mq_getsetattr(mqdes, new, old);
+       if (ret || !old)
+               return ret;
+
+       if (put_compat_mq_attr(old, u_omqstat))
+               return -EFAULT;
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_COMPAT_32BIT_TIME
 static int compat_prepare_timeout(const struct compat_timespec __user *p,
                                   struct timespec64 *ts)
 {
@@ -1459,45 +1500,6 @@ COMPAT_SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes,
        }
        return do_mq_timedreceive(mqdes, u_msg_ptr, msg_len, u_msg_prio, p);
 }
-
-COMPAT_SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
-                      const struct compat_sigevent __user *, u_notification)
-{
-       struct sigevent n, *p = NULL;
-       if (u_notification) {
-               if (get_compat_sigevent(&n, u_notification))
-                       return -EFAULT;
-               if (n.sigev_notify == SIGEV_THREAD)
-                       n.sigev_value.sival_ptr = compat_ptr(n.sigev_value.sival_int);
-               p = &n;
-       }
-       return do_mq_notify(mqdes, p);
-}
-
-COMPAT_SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
-                      const struct compat_mq_attr __user *, u_mqstat,
-                      struct compat_mq_attr __user *, u_omqstat)
-{
-       int ret;
-       struct mq_attr mqstat, omqstat;
-       struct mq_attr *new = NULL, *old = NULL;
-
-       if (u_mqstat) {
-               new = &mqstat;
-               if (get_compat_mq_attr(new, u_mqstat))
-                       return -EFAULT;
-       }
-       if (u_omqstat)
-               old = &omqstat;
-
-       ret = do_mq_getsetattr(mqdes, new, old);
-       if (ret || !old)
-               return ret;
-
-       if (put_compat_mq_attr(old, u_omqstat))
-               return -EFAULT;
-       return 0;
-}
 #endif
 
 static const struct inode_operations mqueue_dir_inode_operations = {
index 56fd1c7..3b65453 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -537,6 +537,11 @@ static int msgctl_stat(struct ipc_namespace *ns, int msqid,
        p->msg_stime  = msq->q_stime;
        p->msg_rtime  = msq->q_rtime;
        p->msg_ctime  = msq->q_ctime;
+#ifndef CONFIG_64BIT
+       p->msg_stime_high = msq->q_stime >> 32;
+       p->msg_rtime_high = msq->q_rtime >> 32;
+       p->msg_ctime_high = msq->q_ctime >> 32;
+#endif
        p->msg_cbytes = msq->q_cbytes;
        p->msg_qnum   = msq->q_qnum;
        p->msg_qbytes = msq->q_qbytes;
@@ -646,9 +651,12 @@ static int copy_compat_msqid_to_user(void __user *buf, struct msqid64_ds *in,
                struct compat_msqid64_ds v;
                memset(&v, 0, sizeof(v));
                to_compat_ipc64_perm(&v.msg_perm, &in->msg_perm);
-               v.msg_stime = in->msg_stime;
-               v.msg_rtime = in->msg_rtime;
-               v.msg_ctime = in->msg_ctime;
+               v.msg_stime      = lower_32_bits(in->msg_stime);
+               v.msg_stime_high = upper_32_bits(in->msg_stime);
+               v.msg_rtime      = lower_32_bits(in->msg_rtime);
+               v.msg_rtime_high = upper_32_bits(in->msg_rtime);
+               v.msg_ctime      = lower_32_bits(in->msg_ctime);
+               v.msg_ctime_high = upper_32_bits(in->msg_ctime);
                v.msg_cbytes = in->msg_cbytes;
                v.msg_qnum = in->msg_qnum;
                v.msg_qbytes = in->msg_qbytes;
@@ -758,7 +766,7 @@ static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg,
                                WRITE_ONCE(msr->r_msg, ERR_PTR(-E2BIG));
                        } else {
                                ipc_update_pid(&msq->q_lrpid, task_pid(msr->r_tsk));
-                               msq->q_rtime = get_seconds();
+                               msq->q_rtime = ktime_get_real_seconds();
 
                                wake_q_add(wake_q, msr->r_tsk);
                                WRITE_ONCE(msr->r_msg, msg);
@@ -859,7 +867,7 @@ static long do_msgsnd(int msqid, long mtype, void __user *mtext,
        }
 
        ipc_update_pid(&msq->q_lspid, task_tgid(current));
-       msq->q_stime = get_seconds();
+       msq->q_stime = ktime_get_real_seconds();
 
        if (!pipelined_send(msq, msg, &wake_q)) {
                /* no one is waiting for this message, enqueue it */
@@ -1087,7 +1095,7 @@ static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, in
 
                        list_del(&msg->m_list);
                        msq->q_qnum--;
-                       msq->q_rtime = get_seconds();
+                       msq->q_rtime = ktime_get_real_seconds();
                        ipc_update_pid(&msq->q_lrpid, task_tgid(current));
                        msq->q_cbytes -= msg->m_ts;
                        atomic_sub(msg->m_ts, &ns->msg_bytes);
index 06be75d..cfd94d4 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -70,6 +70,7 @@
  *   The worst-case behavior is nevertheless O(N^2) for N wakeups.
  */
 
+#include <linux/compat.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/init.h>
@@ -104,7 +105,7 @@ struct sem {
                                        /* that alter the semaphore */
        struct list_head pending_const; /* pending single-sop operations */
                                        /* that do not alter the semaphore*/
-       time_t  sem_otime;      /* candidate for sem_otime */
+       time64_t         sem_otime;     /* candidate for sem_otime */
 } ____cacheline_aligned_in_smp;
 
 /* One sem_array data structure for each set of semaphores in the system. */
@@ -984,10 +985,10 @@ again:
 static void set_semotime(struct sem_array *sma, struct sembuf *sops)
 {
        if (sops == NULL) {
-               sma->sems[0].sem_otime = get_seconds();
+               sma->sems[0].sem_otime = ktime_get_real_seconds();
        } else {
                sma->sems[sops[0].sem_num].sem_otime =
-                                                       get_seconds();
+                                               ktime_get_real_seconds();
        }
 }
 
@@ -1214,6 +1215,7 @@ static int semctl_stat(struct ipc_namespace *ns, int semid,
                         int cmd, struct semid64_ds *semid64)
 {
        struct sem_array *sma;
+       time64_t semotime;
        int id = 0;
        int err;
 
@@ -1257,8 +1259,13 @@ static int semctl_stat(struct ipc_namespace *ns, int semid,
        }
 
        kernel_to_ipc64_perm(&sma->sem_perm, &semid64->sem_perm);
-       semid64->sem_otime = get_semotime(sma);
+       semotime = get_semotime(sma);
+       semid64->sem_otime = semotime;
        semid64->sem_ctime = sma->sem_ctime;
+#ifndef CONFIG_64BIT
+       semid64->sem_otime_high = semotime >> 32;
+       semid64->sem_ctime_high = sma->sem_ctime >> 32;
+#endif
        semid64->sem_nsems = sma->sem_nsems;
 
        ipc_unlock_object(&sma->sem_perm);
@@ -1704,8 +1711,10 @@ static int copy_compat_semid_to_user(void __user *buf, struct semid64_ds *in,
                struct compat_semid64_ds v;
                memset(&v, 0, sizeof(v));
                to_compat_ipc64_perm(&v.sem_perm, &in->sem_perm);
-               v.sem_otime = in->sem_otime;
-               v.sem_ctime = in->sem_ctime;
+               v.sem_otime      = lower_32_bits(in->sem_otime);
+               v.sem_otime_high = upper_32_bits(in->sem_otime);
+               v.sem_ctime      = lower_32_bits(in->sem_ctime);
+               v.sem_ctime_high = upper_32_bits(in->sem_ctime);
                v.sem_nsems = in->sem_nsems;
                return copy_to_user(buf, &v, sizeof(v));
        } else {
@@ -2168,7 +2177,7 @@ out_free:
 }
 
 long ksys_semtimedop(int semid, struct sembuf __user *tsops,
-                    unsigned int nsops, const struct timespec __user *timeout)
+                    unsigned int nsops, const struct __kernel_timespec __user *timeout)
 {
        if (timeout) {
                struct timespec64 ts;
@@ -2180,12 +2189,12 @@ long ksys_semtimedop(int semid, struct sembuf __user *tsops,
 }
 
 SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
-               unsigned int, nsops, const struct timespec __user *, timeout)
+               unsigned int, nsops, const struct __kernel_timespec __user *, timeout)
 {
        return ksys_semtimedop(semid, tsops, nsops, timeout);
 }
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_32BIT_TIME
 long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
                            unsigned int nsops,
                            const struct compat_timespec __user *timeout)
index 3cf4898..0075990 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1002,6 +1002,11 @@ static int shmctl_stat(struct ipc_namespace *ns, int shmid,
        tbuf->shm_atime = shp->shm_atim;
        tbuf->shm_dtime = shp->shm_dtim;
        tbuf->shm_ctime = shp->shm_ctim;
+#ifndef CONFIG_64BIT
+       tbuf->shm_atime_high = shp->shm_atim >> 32;
+       tbuf->shm_dtime_high = shp->shm_dtim >> 32;
+       tbuf->shm_ctime_high = shp->shm_ctim >> 32;
+#endif
        tbuf->shm_cpid  = pid_vnr(shp->shm_cprid);
        tbuf->shm_lpid  = pid_vnr(shp->shm_lprid);
        tbuf->shm_nattch = shp->shm_nattch;
@@ -1233,9 +1238,12 @@ static int copy_compat_shmid_to_user(void __user *buf, struct shmid64_ds *in,
                struct compat_shmid64_ds v;
                memset(&v, 0, sizeof(v));
                to_compat_ipc64_perm(&v.shm_perm, &in->shm_perm);
-               v.shm_atime = in->shm_atime;
-               v.shm_dtime = in->shm_dtime;
-               v.shm_ctime = in->shm_ctime;
+               v.shm_atime      = lower_32_bits(in->shm_atime);
+               v.shm_atime_high = upper_32_bits(in->shm_atime);
+               v.shm_dtime      = lower_32_bits(in->shm_dtime);
+               v.shm_dtime_high = upper_32_bits(in->shm_dtime);
+               v.shm_ctime      = lower_32_bits(in->shm_ctime);
+               v.shm_ctime_high = upper_32_bits(in->shm_ctime);
                v.shm_segsz = in->shm_segsz;
                v.shm_nattch = in->shm_nattch;
                v.shm_cpid = in->shm_cpid;
index 77a883e..65d405f 100644 (file)
@@ -30,9 +30,14 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,
                return ksys_semtimedop(first, (struct sembuf __user *)ptr,
                                       second, NULL);
        case SEMTIMEDOP:
-               return ksys_semtimedop(first, (struct sembuf __user *)ptr,
-                                      second,
-                                      (const struct timespec __user *)fifth);
+               if (IS_ENABLED(CONFIG_64BIT) || !IS_ENABLED(CONFIG_64BIT_TIME))
+                       return ksys_semtimedop(first, ptr, second,
+                               (const struct __kernel_timespec __user *)fifth);
+               else if (IS_ENABLED(CONFIG_COMPAT_32BIT_TIME))
+                       return compat_ksys_semtimedop(first, ptr, second,
+                               (const struct compat_timespec __user *)fifth);
+               else
+                       return -ENOSYS;
 
        case SEMGET:
                return ksys_semget(first, second, third);
@@ -130,6 +135,8 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
                /* struct sembuf is the same on 32 and 64bit :)) */
                return ksys_semtimedop(first, compat_ptr(ptr), second, NULL);
        case SEMTIMEDOP:
+               if (!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME))
+                       return -ENOSYS;
                return compat_ksys_semtimedop(first, compat_ptr(ptr), second,
                                                compat_ptr(fifth));
        case SEMGET:
index acc5159..0aba323 100644 (file)
@@ -251,7 +251,7 @@ static inline int compat_ipc_parse_version(int *cmd)
 /* for __ARCH_WANT_SYS_IPC */
 long ksys_semtimedop(int semid, struct sembuf __user *tsops,
                     unsigned int nsops,
-                    const struct timespec __user *timeout);
+                    const struct __kernel_timespec __user *timeout);
 long ksys_semget(key_t key, int nsems, int semflg);
 long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg);
 long ksys_msgget(key_t key, int msgflg);
@@ -265,10 +265,10 @@ long ksys_shmdt(char __user *shmaddr);
 long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
 
 /* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */
-#ifdef CONFIG_COMPAT
 long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
                            unsigned int nsops,
                            const struct compat_timespec __user *timeout);
+#ifdef CONFIG_COMPAT
 long compat_ksys_semctl(int semid, int semnum, int cmd, int arg);
 long compat_ksys_msgctl(int msqid, int cmd, void __user *uptr);
 long compat_ksys_msgrcv(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz,
index 92d8c98..702aa84 100644 (file)
@@ -121,50 +121,6 @@ static int __compat_put_timespec(const struct timespec *ts, struct compat_timesp
                        __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
 }
 
-static int __compat_get_timespec64(struct timespec64 *ts64,
-                                  const struct compat_timespec __user *cts)
-{
-       struct compat_timespec ts;
-       int ret;
-
-       ret = copy_from_user(&ts, cts, sizeof(ts));
-       if (ret)
-               return -EFAULT;
-
-       ts64->tv_sec = ts.tv_sec;
-       ts64->tv_nsec = ts.tv_nsec;
-
-       return 0;
-}
-
-static int __compat_put_timespec64(const struct timespec64 *ts64,
-                                  struct compat_timespec __user *cts)
-{
-       struct compat_timespec ts = {
-               .tv_sec = ts64->tv_sec,
-               .tv_nsec = ts64->tv_nsec
-       };
-       return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0;
-}
-
-int compat_get_timespec64(struct timespec64 *ts, const void __user *uts)
-{
-       if (COMPAT_USE_64BIT_TIME)
-               return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
-       else
-               return __compat_get_timespec64(ts, uts);
-}
-EXPORT_SYMBOL_GPL(compat_get_timespec64);
-
-int compat_put_timespec64(const struct timespec64 *ts, void __user *uts)
-{
-       if (COMPAT_USE_64BIT_TIME)
-               return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
-       else
-               return __compat_put_timespec64(ts, uts);
-}
-EXPORT_SYMBOL_GPL(compat_put_timespec64);
-
 int compat_get_timeval(struct timeval *tv, const void __user *utv)
 {
        if (COMPAT_USE_64BIT_TIME)
@@ -368,6 +324,14 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t,  pid, unsigned int, len,
        return ret;
 }
 
+/* Todo: Delete these extern declarations when get/put_compat_itimerspec64()
+ * are moved to kernel/time/time.c .
+ */
+extern int __compat_get_timespec64(struct timespec64 *ts64,
+                                  const struct compat_timespec __user *cts);
+extern int __compat_put_timespec64(const struct timespec64 *ts64,
+                                  struct compat_timespec __user *cts);
+
 int get_compat_itimerspec64(struct itimerspec64 *its,
                        const struct compat_itimerspec __user *uits)
 {
index 14e8587..055a4a7 100644 (file)
@@ -1759,8 +1759,10 @@ out:
        return ret;
 }
 
-SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
-               struct timespec __user *, rmtp)
+#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
+
+SYSCALL_DEFINE2(nanosleep, struct __kernel_timespec __user *, rqtp,
+               struct __kernel_timespec __user *, rmtp)
 {
        struct timespec64 tu;
 
@@ -1775,7 +1777,9 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
        return hrtimer_nanosleep(&tu, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
 }
 
-#ifdef CONFIG_COMPAT
+#endif
+
+#ifdef CONFIG_COMPAT_32BIT_TIME
 
 COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
                       struct compat_timespec __user *, rmtp)
index 69a937c..26aa956 100644 (file)
@@ -59,7 +59,7 @@ SYS_NI(alarm);
  */
 
 SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
-               const struct timespec __user *, tp)
+               const struct __kernel_timespec __user *, tp)
 {
        struct timespec64 new_tp;
 
@@ -90,7 +90,7 @@ int do_clock_gettime(clockid_t which_clock, struct timespec64 *tp)
        return 0;
 }
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-               struct timespec __user *, tp)
+               struct __kernel_timespec __user *, tp)
 {
        int ret;
        struct timespec64 kernel_tp;
@@ -104,7 +104,7 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
        return 0;
 }
 
-SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct timespec __user *, tp)
+SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct __kernel_timespec __user *, tp)
 {
        struct timespec64 rtn_tp = {
                .tv_sec = 0,
@@ -124,8 +124,8 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct timespec __us
 }
 
 SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
-               const struct timespec __user *, rqtp,
-               struct timespec __user *, rmtp)
+               const struct __kernel_timespec __user *, rqtp,
+               struct __kernel_timespec __user *, rmtp)
 {
        struct timespec64 t;
 
@@ -158,7 +158,9 @@ COMPAT_SYS_NI(timer_settime);
 COMPAT_SYS_NI(timer_gettime);
 COMPAT_SYS_NI(getitimer);
 COMPAT_SYS_NI(setitimer);
+#endif
 
+#ifdef CONFIG_COMPAT_32BIT_TIME
 COMPAT_SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
                       struct compat_timespec __user *, tp)
 {
index 10b7186..e08ce3f 100644 (file)
@@ -1040,7 +1040,7 @@ void exit_itimers(struct signal_struct *sig)
 }
 
 SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
-               const struct timespec __user *, tp)
+               const struct __kernel_timespec __user *, tp)
 {
        const struct k_clock *kc = clockid_to_kclock(which_clock);
        struct timespec64 new_tp;
@@ -1055,7 +1055,7 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-               struct timespec __user *,tp)
+               struct __kernel_timespec __user *, tp)
 {
        const struct k_clock *kc = clockid_to_kclock(which_clock);
        struct timespec64 kernel_tp;
@@ -1096,7 +1096,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
 }
 
 SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
-               struct timespec __user *, tp)
+               struct __kernel_timespec __user *, tp)
 {
        const struct k_clock *kc = clockid_to_kclock(which_clock);
        struct timespec64 rtn_tp;
@@ -1113,7 +1113,7 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
        return error;
 }
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_32BIT_TIME
 
 COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
                       struct compat_timespec __user *, tp)
@@ -1148,6 +1148,10 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
        return err;
 }
 
+#endif
+
+#ifdef CONFIG_COMPAT
+
 COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
                       struct compat_timex __user *, utp)
 {
@@ -1172,6 +1176,10 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
        return err;
 }
 
+#endif
+
+#ifdef CONFIG_COMPAT_32BIT_TIME
+
 COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
                       struct compat_timespec __user *, tp)
 {
@@ -1203,8 +1211,8 @@ static int common_nsleep(const clockid_t which_clock, int flags,
 }
 
 SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
-               const struct timespec __user *, rqtp,
-               struct timespec __user *, rmtp)
+               const struct __kernel_timespec __user *, rqtp,
+               struct __kernel_timespec __user *, rmtp)
 {
        const struct k_clock *kc = clockid_to_kclock(which_clock);
        struct timespec64 t;
@@ -1227,7 +1235,8 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
        return kc->nsleep(which_clock, flags, &t);
 }
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_32BIT_TIME
+
 COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
                       struct compat_timespec __user *, rqtp,
                       struct compat_timespec __user *, rmtp)
@@ -1252,6 +1261,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
 
        return kc->nsleep(which_clock, flags, &t);
 }
+
 #endif
 
 static const struct k_clock clock_realtime = {
index 3044d48..ccd751e 100644 (file)
@@ -853,9 +853,9 @@ struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
 }
 
 int get_timespec64(struct timespec64 *ts,
-                  const struct timespec __user *uts)
+                  const struct __kernel_timespec __user *uts)
 {
-       struct timespec kts;
+       struct __kernel_timespec kts;
        int ret;
 
        ret = copy_from_user(&kts, uts, sizeof(kts));
@@ -863,6 +863,11 @@ int get_timespec64(struct timespec64 *ts,
                return -EFAULT;
 
        ts->tv_sec = kts.tv_sec;
+
+       /* Zero out the padding for 32 bit systems or in compat mode */
+       if (IS_ENABLED(CONFIG_64BIT_TIME) && (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()))
+               kts.tv_nsec &= 0xFFFFFFFFUL;
+
        ts->tv_nsec = kts.tv_nsec;
 
        return 0;
@@ -870,16 +875,61 @@ int get_timespec64(struct timespec64 *ts,
 EXPORT_SYMBOL_GPL(get_timespec64);
 
 int put_timespec64(const struct timespec64 *ts,
-                  struct timespec __user *uts)
+                  struct __kernel_timespec __user *uts)
 {
-       struct timespec kts = {
+       struct __kernel_timespec kts = {
                .tv_sec = ts->tv_sec,
                .tv_nsec = ts->tv_nsec
        };
+
        return copy_to_user(uts, &kts, sizeof(kts)) ? -EFAULT : 0;
 }
 EXPORT_SYMBOL_GPL(put_timespec64);
 
+int __compat_get_timespec64(struct timespec64 *ts64,
+                                  const struct compat_timespec __user *cts)
+{
+       struct compat_timespec ts;
+       int ret;
+
+       ret = copy_from_user(&ts, cts, sizeof(ts));
+       if (ret)
+               return -EFAULT;
+
+       ts64->tv_sec = ts.tv_sec;
+       ts64->tv_nsec = ts.tv_nsec;
+
+       return 0;
+}
+
+int __compat_put_timespec64(const struct timespec64 *ts64,
+                                  struct compat_timespec __user *cts)
+{
+       struct compat_timespec ts = {
+               .tv_sec = ts64->tv_sec,
+               .tv_nsec = ts64->tv_nsec
+       };
+       return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0;
+}
+
+int compat_get_timespec64(struct timespec64 *ts, const void __user *uts)
+{
+       if (COMPAT_USE_64BIT_TIME)
+               return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
+       else
+               return __compat_get_timespec64(ts, uts);
+}
+EXPORT_SYMBOL_GPL(compat_get_timespec64);
+
+int compat_put_timespec64(const struct timespec64 *ts, void __user *uts)
+{
+       if (COMPAT_USE_64BIT_TIME)
+               return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
+       else
+               return __compat_put_timespec64(ts, uts);
+}
+EXPORT_SYMBOL_GPL(compat_put_timespec64);
+
 int get_itimerspec64(struct itimerspec64 *it,
                        const struct itimerspec __user *uit)
 {