aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-04 23:27:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-04 23:27:54 -0400
commit0bbcce5d1ef3f771a349896f1c7574d20dc6f4bd (patch)
tree8a26c5f63eac55cbedff506bba22d32f8669fd5c
parent0ef283d4c7808cb264f904de5e29a0b661747fc4 (diff)
parente45e778f078efaac085e50366fe06d7b83c8b881 (diff)
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timers and timekeeping updates from Thomas Gleixner: - Core infrastucture work for Y2038 to address the COMPAT interfaces: + Add a new Y2038 safe __kernel_timespec and use it in the core code + Introduce config switches which allow to control the various compat mechanisms + Use the new config switch in the posix timer code to control the 32bit compat syscall implementation. - Prevent bogus selection of CPU local clocksources which causes an endless reselection loop - Remove the extra kthread in the clocksource code which has no value and just adds another level of indirection - The usual bunch of trivial updates, cleanups and fixlets all over the place - More SPDX conversions * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits) clocksource/drivers/mxs_timer: Switch to SPDX identifier clocksource/drivers/timer-imx-tpm: Switch to SPDX identifier clocksource/drivers/timer-imx-gpt: Switch to SPDX identifier clocksource/drivers/timer-imx-gpt: Remove outdated file path clocksource/drivers/arc_timer: Add comments about locking while read GFRC clocksource/drivers/mips-gic-timer: Add pr_fmt and reword pr_* messages clocksource/drivers/sprd: Fix Kconfig dependency clocksource: Move inline keyword to the beginning of function declarations timer_list: Remove unused function pointer typedef timers: Adjust a kernel-doc comment tick: Prefer a lower rating device only if it's CPU local device clocksource: Remove kthread time: Change nanosleep to safe __kernel_* types time: Change types to new y2038 safe __kernel_* types time: Fix get_timespec64() for y2038 safe compat interfaces time: Add new y2038 safe __kernel_timespec posix-timers: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME time: Introduce CONFIG_COMPAT_32BIT_TIME time: Introduce CONFIG_64BIT_TIME in architectures compat: Enable compat_get/put_timespec64 always ...
-rw-r--r--arch/Kconfig15
-rw-r--r--arch/alpha/include/asm/Kbuild1
-rw-r--r--arch/arc/include/asm/Kbuild1
-rw-r--r--arch/arm/include/asm/Kbuild1
-rw-r--r--arch/arm64/include/asm/compat.h11
-rw-r--r--arch/arm64/include/asm/stat.h1
-rw-r--r--arch/arm64/kernel/hw_breakpoint.c1
-rw-r--r--arch/arm64/kernel/perf_regs.c2
-rw-r--r--arch/c6x/include/asm/Kbuild1
-rw-r--r--arch/h8300/include/asm/Kbuild1
-rw-r--r--arch/hexagon/include/asm/Kbuild1
-rw-r--r--arch/ia64/include/asm/Kbuild1
-rw-r--r--arch/m68k/include/asm/Kbuild1
-rw-r--r--arch/microblaze/include/asm/Kbuild1
-rw-r--r--arch/mips/include/asm/compat.h11
-rw-r--r--arch/mips/kernel/signal32.c2
-rw-r--r--arch/nds32/include/asm/Kbuild1
-rw-r--r--arch/nios2/include/asm/Kbuild1
-rw-r--r--arch/openrisc/include/asm/Kbuild1
-rw-r--r--arch/parisc/include/asm/compat.h11
-rw-r--r--arch/powerpc/include/asm/compat.h11
-rw-r--r--arch/powerpc/kernel/asm-offsets.c2
-rw-r--r--arch/powerpc/oprofile/backtrace.c1
-rw-r--r--arch/s390/hypfs/hypfs_sprp.c1
-rw-r--r--arch/s390/include/asm/compat.h11
-rw-r--r--arch/s390/include/asm/elf.h4
-rw-r--r--arch/s390/kvm/priv.c1
-rw-r--r--arch/s390/pci/pci_clp.c1
-rw-r--r--arch/sh/include/asm/Kbuild1
-rw-r--r--arch/sparc/include/asm/compat.h15
-rw-r--r--arch/um/include/asm/Kbuild1
-rw-r--r--arch/unicore32/include/asm/Kbuild1
-rw-r--r--arch/x86/events/core.c2
-rw-r--r--arch/x86/include/asm/compat.h11
-rw-r--r--arch/x86/include/asm/ftrace.h2
-rw-r--r--arch/x86/kernel/sys_x86_64.c2
-rw-r--r--arch/xtensa/include/asm/Kbuild1
-rw-r--r--drivers/clocksource/Kconfig4
-rw-r--r--drivers/clocksource/arc_timer.c14
-rw-r--r--drivers/clocksource/mips-gic-timer.c18
-rw-r--r--drivers/clocksource/mxs_timer.c28
-rw-r--r--drivers/clocksource/timer-imx-gpt.c28
-rw-r--r--drivers/clocksource/timer-imx-tpm.c13
-rw-r--r--drivers/s390/block/dasd_ioctl.c1
-rw-r--r--drivers/s390/char/fs3270.c1
-rw-r--r--drivers/s390/char/sclp_ctl.c1
-rw-r--r--drivers/s390/char/vmcp.c1
-rw-r--r--drivers/s390/cio/chsc_sch.c1
-rw-r--r--drivers/s390/net/qeth_core_main.c2
-rw-r--r--include/asm-generic/compat.h3
-rw-r--r--include/linux/compat.h12
-rw-r--r--include/linux/compat_time.h23
-rw-r--r--include/linux/restart_block.h7
-rw-r--r--include/linux/syscalls.h13
-rw-r--r--include/linux/time.h4
-rw-r--r--include/linux/time64.h10
-rw-r--r--include/uapi/asm-generic/posix_types.h1
-rw-r--r--include/uapi/linux/time.h7
-rw-r--r--kernel/compat.c52
-rw-r--r--kernel/time/clocksource.c35
-rw-r--r--kernel/time/hrtimer.c10
-rw-r--r--kernel/time/posix-stubs.c12
-rw-r--r--kernel/time/posix-timers.c24
-rw-r--r--kernel/time/tick-common.c3
-rw-r--r--kernel/time/time.c58
-rw-r--r--kernel/time/timer.c14
-rw-r--r--kernel/time/timer_list.c2
67 files changed, 266 insertions, 270 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index b624634daea6..b695a3e3e922 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -871,6 +871,21 @@ config OLD_SIGACTION
871config COMPAT_OLD_SIGACTION 871config COMPAT_OLD_SIGACTION
872 bool 872 bool
873 873
874config 64BIT_TIME
875 def_bool ARCH_HAS_64BIT_TIME
876 help
877 This should be selected by all architectures that need to support
878 new system calls with a 64-bit time_t. This is relevant on all 32-bit
879 architectures, and 64-bit architectures as part of compat syscall
880 handling.
881
882config COMPAT_32BIT_TIME
883 def_bool (!64BIT && 64BIT_TIME) || COMPAT
884 help
885 This enables 32 bit time_t support in addition to 64 bit time_t support.
886 This is relevant on all 32-bit architectures, and 64-bit architectures
887 as part of compat syscall handling.
888
874config ARCH_NO_COHERENT_DMA_MMAP 889config ARCH_NO_COHERENT_DMA_MMAP
875 bool 890 bool
876 891
diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index 9b68790013e2..0580cb8c84b2 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -1,6 +1,7 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2 2
3 3
4generic-y += compat.h
4generic-y += exec.h 5generic-y += exec.h
5generic-y += export.h 6generic-y += export.h
6generic-y += fb.h 7generic-y += fb.h
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index bbdcb955e18f..feed50ce89fa 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -1,5 +1,6 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2generic-y += bugs.h 2generic-y += bugs.h
3generic-y += compat.h
3generic-y += device.h 4generic-y += device.h
4generic-y += div64.h 5generic-y += div64.h
5generic-y += dma-mapping.h 6generic-y += dma-mapping.h
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 873e3c189279..1d66db9c9db5 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -1,3 +1,4 @@
1generic-y += compat.h
1generic-y += current.h 2generic-y += current.h
2generic-y += early_ioremap.h 3generic-y += early_ioremap.h
3generic-y += emergency-restart.h 4generic-y += emergency-restart.h
diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index c00c62e1a4a3..0030f79808b3 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -34,7 +34,6 @@
34 34
35typedef u32 compat_size_t; 35typedef u32 compat_size_t;
36typedef s32 compat_ssize_t; 36typedef s32 compat_ssize_t;
37typedef s32 compat_time_t;
38typedef s32 compat_clock_t; 37typedef s32 compat_clock_t;
39typedef s32 compat_pid_t; 38typedef s32 compat_pid_t;
40typedef u16 __compat_uid_t; 39typedef u16 __compat_uid_t;
@@ -66,16 +65,6 @@ typedef u32 compat_ulong_t;
66typedef u64 compat_u64; 65typedef u64 compat_u64;
67typedef u32 compat_uptr_t; 66typedef u32 compat_uptr_t;
68 67
69struct compat_timespec {
70 compat_time_t tv_sec;
71 s32 tv_nsec;
72};
73
74struct compat_timeval {
75 compat_time_t tv_sec;
76 s32 tv_usec;
77};
78
79struct compat_stat { 68struct compat_stat {
80#ifdef __AARCH64EB__ 69#ifdef __AARCH64EB__
81 short st_dev; 70 short st_dev;
diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h
index 15e35598ac40..eab738019707 100644
--- a/arch/arm64/include/asm/stat.h
+++ b/arch/arm64/include/asm/stat.h
@@ -20,6 +20,7 @@
20 20
21#ifdef CONFIG_COMPAT 21#ifdef CONFIG_COMPAT
22 22
23#include <linux/compat_time.h>
23#include <asm/compat.h> 24#include <asm/compat.h>
24 25
25/* 26/*
diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index 74bb56f656ef..413dbe530da8 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -30,7 +30,6 @@
30#include <linux/smp.h> 30#include <linux/smp.h>
31#include <linux/uaccess.h> 31#include <linux/uaccess.h>
32 32
33#include <asm/compat.h>
34#include <asm/current.h> 33#include <asm/current.h>
35#include <asm/debug-monitors.h> 34#include <asm/debug-monitors.h>
36#include <asm/hw_breakpoint.h> 35#include <asm/hw_breakpoint.h>
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
index 1d091d048d04..0bbac612146e 100644
--- a/arch/arm64/kernel/perf_regs.c
+++ b/arch/arm64/kernel/perf_regs.c
@@ -1,11 +1,11 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/compat.h>
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/kernel.h> 4#include <linux/kernel.h>
4#include <linux/perf_event.h> 5#include <linux/perf_event.h>
5#include <linux/bug.h> 6#include <linux/bug.h>
6#include <linux/sched/task_stack.h> 7#include <linux/sched/task_stack.h>
7 8
8#include <asm/compat.h>
9#include <asm/perf_regs.h> 9#include <asm/perf_regs.h>
10#include <asm/ptrace.h> 10#include <asm/ptrace.h>
11 11
diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild
index 434600e47662..33a2c94fed0d 100644
--- a/arch/c6x/include/asm/Kbuild
+++ b/arch/c6x/include/asm/Kbuild
@@ -1,6 +1,7 @@
1generic-y += atomic.h 1generic-y += atomic.h
2generic-y += barrier.h 2generic-y += barrier.h
3generic-y += bugs.h 3generic-y += bugs.h
4generic-y += compat.h
4generic-y += current.h 5generic-y += current.h
5generic-y += device.h 6generic-y += device.h
6generic-y += div64.h 7generic-y += div64.h
diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild
index 14bac06b7116..a5d0b2991f47 100644
--- a/arch/h8300/include/asm/Kbuild
+++ b/arch/h8300/include/asm/Kbuild
@@ -3,6 +3,7 @@ generic-y += barrier.h
3generic-y += bugs.h 3generic-y += bugs.h
4generic-y += cacheflush.h 4generic-y += cacheflush.h
5generic-y += checksum.h 5generic-y += checksum.h
6generic-y += compat.h
6generic-y += current.h 7generic-y += current.h
7generic-y += delay.h 8generic-y += delay.h
8generic-y += device.h 9generic-y += device.h
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index e9743f689fb8..dd2fd9c0d292 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -2,6 +2,7 @@
2generic-y += barrier.h 2generic-y += barrier.h
3generic-y += bug.h 3generic-y += bug.h
4generic-y += bugs.h 4generic-y += bugs.h
5generic-y += compat.h
5generic-y += current.h 6generic-y += current.h
6generic-y += device.h 7generic-y += device.h
7generic-y += div64.h 8generic-y += div64.h
diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild
index 6dd867873364..557bbc8ba9f5 100644
--- a/arch/ia64/include/asm/Kbuild
+++ b/arch/ia64/include/asm/Kbuild
@@ -1,3 +1,4 @@
1generic-y += compat.h
1generic-y += exec.h 2generic-y += exec.h
2generic-y += irq_work.h 3generic-y += irq_work.h
3generic-y += mcs_spinlock.h 4generic-y += mcs_spinlock.h
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index 88a9d27df1ac..4d8d68c4e3dd 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -1,4 +1,5 @@
1generic-y += barrier.h 1generic-y += barrier.h
2generic-y += compat.h
2generic-y += device.h 3generic-y += device.h
3generic-y += emergency-restart.h 4generic-y += emergency-restart.h
4generic-y += exec.h 5generic-y += exec.h
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild
index 3c80a5a308ed..fe6a6c6e5003 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -2,6 +2,7 @@ generic-y += barrier.h
2generic-y += bitops.h 2generic-y += bitops.h
3generic-y += bug.h 3generic-y += bug.h
4generic-y += bugs.h 4generic-y += bugs.h
5generic-y += compat.h
5generic-y += device.h 6generic-y += device.h
6generic-y += div64.h 7generic-y += div64.h
7generic-y += emergency-restart.h 8generic-y += emergency-restart.h
diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
index 9a0fa66b81ac..3e548ee99a2f 100644
--- a/arch/mips/include/asm/compat.h
+++ b/arch/mips/include/asm/compat.h
@@ -14,7 +14,6 @@
14 14
15typedef u32 compat_size_t; 15typedef u32 compat_size_t;
16typedef s32 compat_ssize_t; 16typedef s32 compat_ssize_t;
17typedef s32 compat_time_t;
18typedef s32 compat_clock_t; 17typedef s32 compat_clock_t;
19typedef s32 compat_suseconds_t; 18typedef s32 compat_suseconds_t;
20 19
@@ -46,16 +45,6 @@ typedef u32 compat_ulong_t;
46typedef u64 compat_u64; 45typedef u64 compat_u64;
47typedef u32 compat_uptr_t; 46typedef u32 compat_uptr_t;
48 47
49struct compat_timespec {
50 compat_time_t tv_sec;
51 s32 tv_nsec;
52};
53
54struct compat_timeval {
55 compat_time_t tv_sec;
56 s32 tv_usec;
57};
58
59struct compat_stat { 48struct compat_stat {
60 compat_dev_t st_dev; 49 compat_dev_t st_dev;
61 s32 st_pad1[3]; 50 s32 st_pad1[3];
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index c4db910a8794..b5d9e1784aff 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -8,13 +8,13 @@
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 2016, Imagination Technologies Ltd. 9 * Copyright (C) 2016, Imagination Technologies Ltd.
10 */ 10 */
11#include <linux/compat.h>
11#include <linux/compiler.h> 12#include <linux/compiler.h>
12#include <linux/errno.h> 13#include <linux/errno.h>
13#include <linux/kernel.h> 14#include <linux/kernel.h>
14#include <linux/signal.h> 15#include <linux/signal.h>
15#include <linux/syscalls.h> 16#include <linux/syscalls.h>
16 17
17#include <asm/compat.h>
18#include <asm/compat-signal.h> 18#include <asm/compat-signal.h>
19#include <linux/uaccess.h> 19#include <linux/uaccess.h>
20#include <asm/unistd.h> 20#include <asm/unistd.h>
diff --git a/arch/nds32/include/asm/Kbuild b/arch/nds32/include/asm/Kbuild
index 6f5cc29ed07f..dbc4e5422550 100644
--- a/arch/nds32/include/asm/Kbuild
+++ b/arch/nds32/include/asm/Kbuild
@@ -9,6 +9,7 @@ generic-y += checksum.h
9generic-y += clkdev.h 9generic-y += clkdev.h
10generic-y += cmpxchg.h 10generic-y += cmpxchg.h
11generic-y += cmpxchg-local.h 11generic-y += cmpxchg-local.h
12generic-y += compat.h
12generic-y += cputime.h 13generic-y += cputime.h
13generic-y += device.h 14generic-y += device.h
14generic-y += div64.h 15generic-y += div64.h
diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild
index d232da2cbb38..64ed3d656956 100644
--- a/arch/nios2/include/asm/Kbuild
+++ b/arch/nios2/include/asm/Kbuild
@@ -4,6 +4,7 @@ generic-y += bitops.h
4generic-y += bug.h 4generic-y += bug.h
5generic-y += bugs.h 5generic-y += bugs.h
6generic-y += cmpxchg.h 6generic-y += cmpxchg.h
7generic-y += compat.h
7generic-y += current.h 8generic-y += current.h
8generic-y += device.h 9generic-y += device.h
9generic-y += div64.h 10generic-y += div64.h
diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild
index f05c722a21f8..65964d390b10 100644
--- a/arch/openrisc/include/asm/Kbuild
+++ b/arch/openrisc/include/asm/Kbuild
@@ -2,6 +2,7 @@ generic-y += barrier.h
2generic-y += bug.h 2generic-y += bug.h
3generic-y += bugs.h 3generic-y += bugs.h
4generic-y += checksum.h 4generic-y += checksum.h
5generic-y += compat.h
5generic-y += current.h 6generic-y += current.h
6generic-y += device.h 7generic-y += device.h
7generic-y += div64.h 8generic-y += div64.h
diff --git a/arch/parisc/include/asm/compat.h b/arch/parisc/include/asm/compat.h
index 57b8b2a2fd4e..0cdfec8857bd 100644
--- a/arch/parisc/include/asm/compat.h
+++ b/arch/parisc/include/asm/compat.h
@@ -13,7 +13,6 @@
13 13
14typedef u32 compat_size_t; 14typedef u32 compat_size_t;
15typedef s32 compat_ssize_t; 15typedef s32 compat_ssize_t;
16typedef s32 compat_time_t;
17typedef s32 compat_clock_t; 16typedef s32 compat_clock_t;
18typedef s32 compat_pid_t; 17typedef s32 compat_pid_t;
19typedef u32 __compat_uid_t; 18typedef u32 __compat_uid_t;
@@ -40,16 +39,6 @@ typedef u32 compat_ulong_t;
40typedef u64 compat_u64; 39typedef u64 compat_u64;
41typedef u32 compat_uptr_t; 40typedef u32 compat_uptr_t;
42 41
43struct compat_timespec {
44 compat_time_t tv_sec;
45 s32 tv_nsec;
46};
47
48struct compat_timeval {
49 compat_time_t tv_sec;
50 s32 tv_usec;
51};
52
53struct compat_stat { 42struct compat_stat {
54 compat_dev_t st_dev; /* dev_t is 32 bits on parisc */ 43 compat_dev_t st_dev; /* dev_t is 32 bits on parisc */
55 compat_ino_t st_ino; /* 32 bits */ 44 compat_ino_t st_ino; /* 32 bits */
diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
index 62168e1158f1..b4773c81f7d5 100644
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -17,7 +17,6 @@
17 17
18typedef u32 compat_size_t; 18typedef u32 compat_size_t;
19typedef s32 compat_ssize_t; 19typedef s32 compat_ssize_t;
20typedef s32 compat_time_t;
21typedef s32 compat_clock_t; 20typedef s32 compat_clock_t;
22typedef s32 compat_pid_t; 21typedef s32 compat_pid_t;
23typedef u32 __compat_uid_t; 22typedef u32 __compat_uid_t;
@@ -45,16 +44,6 @@ typedef u32 compat_ulong_t;
45typedef u64 compat_u64; 44typedef u64 compat_u64;
46typedef u32 compat_uptr_t; 45typedef u32 compat_uptr_t;
47 46
48struct compat_timespec {
49 compat_time_t tv_sec;
50 s32 tv_nsec;
51};
52
53struct compat_timeval {
54 compat_time_t tv_sec;
55 s32 tv_usec;
56};
57
58struct compat_stat { 47struct compat_stat {
59 compat_dev_t st_dev; 48 compat_dev_t st_dev;
60 compat_ino_t st_ino; 49 compat_ino_t st_ino;
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 373dc1d6ef44..8817c5a6bcc2 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -13,6 +13,7 @@
13 * 2 of the License, or (at your option) any later version. 13 * 2 of the License, or (at your option) any later version.
14 */ 14 */
15 15
16#include <linux/compat.h>
16#include <linux/signal.h> 17#include <linux/signal.h>
17#include <linux/sched.h> 18#include <linux/sched.h>
18#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -42,7 +43,6 @@
42#include <asm/paca.h> 43#include <asm/paca.h>
43#include <asm/lppaca.h> 44#include <asm/lppaca.h>
44#include <asm/cache.h> 45#include <asm/cache.h>
45#include <asm/compat.h>
46#include <asm/mmu.h> 46#include <asm/mmu.h>
47#include <asm/hvcall.h> 47#include <asm/hvcall.h>
48#include <asm/xics.h> 48#include <asm/xics.h>
diff --git a/arch/powerpc/oprofile/backtrace.c b/arch/powerpc/oprofile/backtrace.c
index ecc66d5f02c9..ad054dd0d666 100644
--- a/arch/powerpc/oprofile/backtrace.c
+++ b/arch/powerpc/oprofile/backtrace.c
@@ -7,6 +7,7 @@
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8**/ 8**/
9 9
10#include <linux/compat_time.h>
10#include <linux/oprofile.h> 11#include <linux/oprofile.h>
11#include <linux/sched.h> 12#include <linux/sched.h>
12#include <asm/processor.h> 13#include <asm/processor.h>
diff --git a/arch/s390/hypfs/hypfs_sprp.c b/arch/s390/hypfs/hypfs_sprp.c
index ae0ed8dd5f1b..5d85a039391c 100644
--- a/arch/s390/hypfs/hypfs_sprp.c
+++ b/arch/s390/hypfs/hypfs_sprp.c
@@ -13,7 +13,6 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/uaccess.h> 15#include <linux/uaccess.h>
16#include <asm/compat.h>
17#include <asm/diag.h> 16#include <asm/diag.h>
18#include <asm/sclp.h> 17#include <asm/sclp.h>
19#include "hypfs.h" 18#include "hypfs.h"
diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
index 9830fb6b076e..501aaff85304 100644
--- a/arch/s390/include/asm/compat.h
+++ b/arch/s390/include/asm/compat.h
@@ -53,7 +53,6 @@
53 53
54typedef u32 compat_size_t; 54typedef u32 compat_size_t;
55typedef s32 compat_ssize_t; 55typedef s32 compat_ssize_t;
56typedef s32 compat_time_t;
57typedef s32 compat_clock_t; 56typedef s32 compat_clock_t;
58typedef s32 compat_pid_t; 57typedef s32 compat_pid_t;
59typedef u16 __compat_uid_t; 58typedef u16 __compat_uid_t;
@@ -97,16 +96,6 @@ typedef struct {
97 u32 gprs_high[NUM_GPRS]; 96 u32 gprs_high[NUM_GPRS];
98} s390_compat_regs_high; 97} s390_compat_regs_high;
99 98
100struct compat_timespec {
101 compat_time_t tv_sec;
102 s32 tv_nsec;
103};
104
105struct compat_timeval {
106 compat_time_t tv_sec;
107 s32 tv_usec;
108};
109
110struct compat_stat { 99struct compat_stat {
111 compat_dev_t st_dev; 100 compat_dev_t st_dev;
112 u16 __pad1; 101 u16 __pad1;
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index 1a61b1b997f2..7d22a474a040 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -125,8 +125,9 @@
125 * ELF register definitions.. 125 * ELF register definitions..
126 */ 126 */
127 127
128#include <linux/compat.h>
129
128#include <asm/ptrace.h> 130#include <asm/ptrace.h>
129#include <asm/compat.h>
130#include <asm/syscall.h> 131#include <asm/syscall.h>
131#include <asm/user.h> 132#include <asm/user.h>
132 133
@@ -136,7 +137,6 @@ typedef s390_regs elf_gregset_t;
136typedef s390_fp_regs compat_elf_fpregset_t; 137typedef s390_fp_regs compat_elf_fpregset_t;
137typedef s390_compat_regs compat_elf_gregset_t; 138typedef s390_compat_regs compat_elf_gregset_t;
138 139
139#include <linux/compat.h>
140#include <linux/sched/mm.h> /* for task_struct */ 140#include <linux/sched/mm.h> /* for task_struct */
141#include <asm/mmu_context.h> 141#include <asm/mmu_context.h>
142 142
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index ebfa0442e569..a3bce0e84346 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -26,7 +26,6 @@
26#include <asm/gmap.h> 26#include <asm/gmap.h>
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/ptrace.h> 28#include <asm/ptrace.h>
29#include <asm/compat.h>
30#include <asm/sclp.h> 29#include <asm/sclp.h>
31#include "gaccess.h" 30#include "gaccess.h"
32#include "kvm-s390.h" 31#include "kvm-s390.h"
diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c
index 93cd0f1ca12b..19b2d2a9b43d 100644
--- a/arch/s390/pci/pci_clp.c
+++ b/arch/s390/pci/pci_clp.c
@@ -19,7 +19,6 @@
19#include <linux/uaccess.h> 19#include <linux/uaccess.h>
20#include <asm/pci_debug.h> 20#include <asm/pci_debug.h>
21#include <asm/pci_clp.h> 21#include <asm/pci_clp.h>
22#include <asm/compat.h>
23#include <asm/clp.h> 22#include <asm/clp.h>
24#include <uapi/asm/clp.h> 23#include <uapi/asm/clp.h>
25 24
diff --git a/arch/sh/include/asm/Kbuild b/arch/sh/include/asm/Kbuild
index 1efcce74997b..46dd82ab2c29 100644
--- a/arch/sh/include/asm/Kbuild
+++ b/arch/sh/include/asm/Kbuild
@@ -1,3 +1,4 @@
1generic-y += compat.h
1generic-y += current.h 2generic-y += current.h
2generic-y += delay.h 3generic-y += delay.h
3generic-y += div64.h 4generic-y += div64.h
diff --git a/arch/sparc/include/asm/compat.h b/arch/sparc/include/asm/compat.h
index 615283e16f22..1910c44521e3 100644
--- a/arch/sparc/include/asm/compat.h
+++ b/arch/sparc/include/asm/compat.h
@@ -11,7 +11,6 @@
11 11
12typedef u32 compat_size_t; 12typedef u32 compat_size_t;
13typedef s32 compat_ssize_t; 13typedef s32 compat_ssize_t;
14typedef s32 compat_time_t;
15typedef s32 compat_clock_t; 14typedef s32 compat_clock_t;
16typedef s32 compat_pid_t; 15typedef s32 compat_pid_t;
17typedef u16 __compat_uid_t; 16typedef u16 __compat_uid_t;
@@ -39,16 +38,6 @@ typedef u32 compat_ulong_t;
39typedef u64 compat_u64; 38typedef u64 compat_u64;
40typedef u32 compat_uptr_t; 39typedef u32 compat_uptr_t;
41 40
42struct compat_timespec {
43 compat_time_t tv_sec;
44 s32 tv_nsec;
45};
46
47struct compat_timeval {
48 compat_time_t tv_sec;
49 s32 tv_usec;
50};
51
52struct compat_stat { 41struct compat_stat {
53 compat_dev_t st_dev; 42 compat_dev_t st_dev;
54 compat_ino_t st_ino; 43 compat_ino_t st_ino;
@@ -168,6 +157,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
168 return (u32)(unsigned long)uptr; 157 return (u32)(unsigned long)uptr;
169} 158}
170 159
160#ifdef CONFIG_COMPAT
171static inline void __user *arch_compat_alloc_user_space(long len) 161static inline void __user *arch_compat_alloc_user_space(long len)
172{ 162{
173 struct pt_regs *regs = current_thread_info()->kregs; 163 struct pt_regs *regs = current_thread_info()->kregs;
@@ -184,6 +174,7 @@ static inline void __user *arch_compat_alloc_user_space(long len)
184 174
185 return (void __user *) usp; 175 return (void __user *) usp;
186} 176}
177#endif
187 178
188struct compat_ipc64_perm { 179struct compat_ipc64_perm {
189 compat_key_t key; 180 compat_key_t key;
@@ -243,6 +234,7 @@ struct compat_shmid64_ds {
243 unsigned int __unused2; 234 unsigned int __unused2;
244}; 235};
245 236
237#ifdef CONFIG_COMPAT
246static inline int is_compat_task(void) 238static inline int is_compat_task(void)
247{ 239{
248 return test_thread_flag(TIF_32BIT); 240 return test_thread_flag(TIF_32BIT);
@@ -254,5 +246,6 @@ static inline bool in_compat_syscall(void)
254 return pt_regs_trap_type(current_pt_regs()) == 0x110; 246 return pt_regs_trap_type(current_pt_regs()) == 0x110;
255} 247}
256#define in_compat_syscall in_compat_syscall 248#define in_compat_syscall in_compat_syscall
249#endif
257 250
258#endif /* _ASM_SPARC64_COMPAT_H */ 251#endif /* _ASM_SPARC64_COMPAT_H */
diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index bb5a196c3061..b10dde6cb793 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -1,6 +1,7 @@
1generic-y += barrier.h 1generic-y += barrier.h
2generic-y += bpf_perf_event.h 2generic-y += bpf_perf_event.h
3generic-y += bug.h 3generic-y += bug.h
4generic-y += compat.h
4generic-y += current.h 5generic-y += current.h
5generic-y += delay.h 6generic-y += delay.h
6generic-y += device.h 7generic-y += device.h
diff --git a/arch/unicore32/include/asm/Kbuild b/arch/unicore32/include/asm/Kbuild
index 6f70c76c81fc..bfc7abe77905 100644
--- a/arch/unicore32/include/asm/Kbuild
+++ b/arch/unicore32/include/asm/Kbuild
@@ -1,5 +1,6 @@
1generic-y += atomic.h 1generic-y += atomic.h
2generic-y += bugs.h 2generic-y += bugs.h
3generic-y += compat.h
3generic-y += current.h 4generic-y += current.h
4generic-y += device.h 5generic-y += device.h
5generic-y += div64.h 6generic-y += div64.h
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 45b2b1c93d04..6e461fb1e0d4 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2397,7 +2397,7 @@ static unsigned long get_segment_base(unsigned int segment)
2397 2397
2398#ifdef CONFIG_IA32_EMULATION 2398#ifdef CONFIG_IA32_EMULATION
2399 2399
2400#include <asm/compat.h> 2400#include <linux/compat.h>
2401 2401
2402static inline int 2402static inline int
2403perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *entry) 2403perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *entry)
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index e1c8dab86670..7cd314b71c51 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -17,7 +17,6 @@
17 17
18typedef u32 compat_size_t; 18typedef u32 compat_size_t;
19typedef s32 compat_ssize_t; 19typedef s32 compat_ssize_t;
20typedef s32 compat_time_t;
21typedef s32 compat_clock_t; 20typedef s32 compat_clock_t;
22typedef s32 compat_pid_t; 21typedef s32 compat_pid_t;
23typedef u16 __compat_uid_t; 22typedef u16 __compat_uid_t;
@@ -46,16 +45,6 @@ typedef u32 compat_u32;
46typedef u64 __attribute__((aligned(4))) compat_u64; 45typedef u64 __attribute__((aligned(4))) compat_u64;
47typedef u32 compat_uptr_t; 46typedef u32 compat_uptr_t;
48 47
49struct compat_timespec {
50 compat_time_t tv_sec;
51 s32 tv_nsec;
52};
53
54struct compat_timeval {
55 compat_time_t tv_sec;
56 s32 tv_usec;
57};
58
59struct compat_stat { 48struct compat_stat {
60 compat_dev_t st_dev; 49 compat_dev_t st_dev;
61 u16 __pad1; 50 u16 __pad1;
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index cc8f8fcf9b4a..c18ed65287d5 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -63,7 +63,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
63#ifndef COMPILE_OFFSETS 63#ifndef COMPILE_OFFSETS
64 64
65#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION) 65#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
66#include <asm/compat.h> 66#include <linux/compat.h>
67 67
68/* 68/*
69 * Because ia32 syscalls do not map to x86_64 syscall numbers 69 * Because ia32 syscalls do not map to x86_64 syscall numbers
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index a3f15ed545b5..6a78d4b36a79 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -1,4 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/compat.h>
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/sched.h> 4#include <linux/sched.h>
4#include <linux/sched/mm.h> 5#include <linux/sched/mm.h>
@@ -19,7 +20,6 @@
19#include <linux/elf.h> 20#include <linux/elf.h>
20 21
21#include <asm/elf.h> 22#include <asm/elf.h>
22#include <asm/compat.h>
23#include <asm/ia32.h> 23#include <asm/ia32.h>
24#include <asm/syscalls.h> 24#include <asm/syscalls.h>
25#include <asm/mpx.h> 25#include <asm/mpx.h>
diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild
index 436b20337168..e5e1e61c538c 100644
--- a/arch/xtensa/include/asm/Kbuild
+++ b/arch/xtensa/include/asm/Kbuild
@@ -1,4 +1,5 @@
1generic-y += bug.h 1generic-y += bug.h
2generic-y += compat.h
2generic-y += device.h 3generic-y += device.h
3generic-y += div64.h 4generic-y += div64.h
4generic-y += dma-contiguous.h 5generic-y += dma-contiguous.h
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 8e8a09755d10..dec0dd88ec15 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -450,8 +450,10 @@ config MTK_TIMER
450 Support for Mediatek timer driver. 450 Support for Mediatek timer driver.
451 451
452config SPRD_TIMER 452config SPRD_TIMER
453 bool "Spreadtrum timer driver" if COMPILE_TEST 453 bool "Spreadtrum timer driver" if EXPERT
454 depends on HAS_IOMEM 454 depends on HAS_IOMEM
455 depends on (ARCH_SPRD || COMPILE_TEST)
456 default ARCH_SPRD
455 select TIMER_OF 457 select TIMER_OF
456 help 458 help
457 Enables support for the Spreadtrum timer driver. 459 Enables support for the Spreadtrum timer driver.
diff --git a/drivers/clocksource/arc_timer.c b/drivers/clocksource/arc_timer.c
index 471b428d8034..20da9b1d7f7d 100644
--- a/drivers/clocksource/arc_timer.c
+++ b/drivers/clocksource/arc_timer.c
@@ -61,6 +61,20 @@ static u64 arc_read_gfrc(struct clocksource *cs)
61 unsigned long flags; 61 unsigned long flags;
62 u32 l, h; 62 u32 l, h;
63 63
64 /*
65 * From a programming model pov, there seems to be just one instance of
66 * MCIP_CMD/MCIP_READBACK however micro-architecturally there's
67 * an instance PER ARC CORE (not per cluster), and there are dedicated
68 * hardware decode logic (per core) inside ARConnect to handle
69 * simultaneous read/write accesses from cores via those two registers.
70 * So several concurrent commands to ARConnect are OK if they are
71 * trying to access two different sub-components (like GFRC,
72 * inter-core interrupt, etc...). HW also supports simultaneously
73 * accessing GFRC by multiple cores.
74 * That's why it is safe to disable hard interrupts on the local CPU
75 * before access to GFRC instead of taking global MCIP spinlock
76 * defined in arch/arc/kernel/mcip.c
77 */
64 local_irq_save(flags); 78 local_irq_save(flags);
65 79
66 __mcip_cmd(CMD_GFRC_READ_LO, 0); 80 __mcip_cmd(CMD_GFRC_READ_LO, 0);
diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index 986b6796b631..54f8a331b53a 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -5,6 +5,9 @@
5 * 5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. 6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 */ 7 */
8
9#define pr_fmt(fmt) "mips-gic-timer: " fmt
10
8#include <linux/clk.h> 11#include <linux/clk.h>
9#include <linux/clockchips.h> 12#include <linux/clockchips.h>
10#include <linux/cpu.h> 13#include <linux/cpu.h>
@@ -136,8 +139,7 @@ static int gic_clockevent_init(void)
136 139
137 ret = setup_percpu_irq(gic_timer_irq, &gic_compare_irqaction); 140 ret = setup_percpu_irq(gic_timer_irq, &gic_compare_irqaction);
138 if (ret < 0) { 141 if (ret < 0) {
139 pr_err("GIC timer IRQ %d setup failed: %d\n", 142 pr_err("IRQ %d setup failed (%d)\n", gic_timer_irq, ret);
140 gic_timer_irq, ret);
141 return ret; 143 return ret;
142 } 144 }
143 145
@@ -176,7 +178,7 @@ static int __init __gic_clocksource_init(void)
176 178
177 ret = clocksource_register_hz(&gic_clocksource, gic_frequency); 179 ret = clocksource_register_hz(&gic_clocksource, gic_frequency);
178 if (ret < 0) 180 if (ret < 0)
179 pr_warn("GIC: Unable to register clocksource\n"); 181 pr_warn("Unable to register clocksource\n");
180 182
181 return ret; 183 return ret;
182} 184}
@@ -188,7 +190,7 @@ static int __init gic_clocksource_of_init(struct device_node *node)
188 190
189 if (!mips_gic_present() || !node->parent || 191 if (!mips_gic_present() || !node->parent ||
190 !of_device_is_compatible(node->parent, "mti,gic")) { 192 !of_device_is_compatible(node->parent, "mti,gic")) {
191 pr_warn("No DT definition for the mips gic driver\n"); 193 pr_warn("No DT definition\n");
192 return -ENXIO; 194 return -ENXIO;
193 } 195 }
194 196
@@ -196,7 +198,7 @@ static int __init gic_clocksource_of_init(struct device_node *node)
196 if (!IS_ERR(clk)) { 198 if (!IS_ERR(clk)) {
197 ret = clk_prepare_enable(clk); 199 ret = clk_prepare_enable(clk);
198 if (ret < 0) { 200 if (ret < 0) {
199 pr_err("GIC failed to enable clock\n"); 201 pr_err("Failed to enable clock\n");
200 clk_put(clk); 202 clk_put(clk);
201 return ret; 203 return ret;
202 } 204 }
@@ -204,12 +206,12 @@ static int __init gic_clocksource_of_init(struct device_node *node)
204 gic_frequency = clk_get_rate(clk); 206 gic_frequency = clk_get_rate(clk);
205 } else if (of_property_read_u32(node, "clock-frequency", 207 } else if (of_property_read_u32(node, "clock-frequency",
206 &gic_frequency)) { 208 &gic_frequency)) {
207 pr_err("GIC frequency not specified.\n"); 209 pr_err("Frequency not specified\n");
208 return -EINVAL; 210 return -EINVAL;
209 } 211 }
210 gic_timer_irq = irq_of_parse_and_map(node, 0); 212 gic_timer_irq = irq_of_parse_and_map(node, 0);
211 if (!gic_timer_irq) { 213 if (!gic_timer_irq) {
212 pr_err("GIC timer IRQ not specified.\n"); 214 pr_err("IRQ not specified\n");
213 return -EINVAL; 215 return -EINVAL;
214 } 216 }
215 217
@@ -220,7 +222,7 @@ static int __init gic_clocksource_of_init(struct device_node *node)
220 ret = gic_clockevent_init(); 222 ret = gic_clockevent_init();
221 if (!ret && !IS_ERR(clk)) { 223 if (!ret && !IS_ERR(clk)) {
222 if (clk_notifier_register(clk, &gic_clk_nb) < 0) 224 if (clk_notifier_register(clk, &gic_clk_nb) < 0)
223 pr_warn("GIC: Unable to register clock notifier\n"); 225 pr_warn("Unable to register clock notifier\n");
224 } 226 }
225 227
226 /* And finally start the counter */ 228 /* And finally start the counter */
diff --git a/drivers/clocksource/mxs_timer.c b/drivers/clocksource/mxs_timer.c
index a03434e9fe8f..f6ddae30933f 100644
--- a/drivers/clocksource/mxs_timer.c
+++ b/drivers/clocksource/mxs_timer.c
@@ -1,24 +1,10 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright (C) 2000-2001 Deep Blue Solutions 2//
3 * Copyright (C) 2002 Shane Nay (shane@minirl.com) 3// Copyright (C) 2000-2001 Deep Blue Solutions
4 * Copyright (C) 2006-2007 Pavel Pisa (ppisa@pikron.com) 4// Copyright (C) 2002 Shane Nay (shane@minirl.com)
5 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) 5// Copyright (C) 2006-2007 Pavel Pisa (ppisa@pikron.com)
6 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. 6// Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
7 * 7// Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22 8
23#include <linux/err.h> 9#include <linux/err.h>
24#include <linux/interrupt.h> 10#include <linux/interrupt.h>
diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index 6ec6d79b237c..165fbbb1c9a0 100644
--- a/drivers/clocksource/timer-imx-gpt.c
+++ b/drivers/clocksource/timer-imx-gpt.c
@@ -1,25 +1,9 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * linux/arch/arm/plat-mxc/time.c 2//
3 * 3// Copyright (C) 2000-2001 Deep Blue Solutions
4 * Copyright (C) 2000-2001 Deep Blue Solutions 4// Copyright (C) 2002 Shane Nay (shane@minirl.com)
5 * Copyright (C) 2002 Shane Nay (shane@minirl.com) 5// Copyright (C) 2006-2007 Pavel Pisa (ppisa@pikron.com)
6 * Copyright (C) 2006-2007 Pavel Pisa (ppisa@pikron.com) 6// Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
7 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 */
23 7
24#include <linux/interrupt.h> 8#include <linux/interrupt.h>
25#include <linux/irq.h> 9#include <linux/irq.h>
diff --git a/drivers/clocksource/timer-imx-tpm.c b/drivers/clocksource/timer-imx-tpm.c
index 6c8318470b48..b7aa2b817078 100644
--- a/drivers/clocksource/timer-imx-tpm.c
+++ b/drivers/clocksource/timer-imx-tpm.c
@@ -1,12 +1,7 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Copyright 2016 Freescale Semiconductor, Inc. 2//
3 * Copyright 2017 NXP 3// Copyright 2016 Freescale Semiconductor, Inc.
4 * 4// Copyright 2017 NXP
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 */
10 5
11#include <linux/clk.h> 6#include <linux/clk.h>
12#include <linux/clockchips.h> 7#include <linux/clockchips.h>
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 7bdc6aaa0ba3..2016e0ed5865 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -18,7 +18,6 @@
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/blkpg.h> 19#include <linux/blkpg.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <asm/compat.h>
22#include <asm/ccwdev.h> 21#include <asm/ccwdev.h>
23#include <asm/schid.h> 22#include <asm/schid.h>
24#include <asm/cmb.h> 23#include <asm/cmb.h>
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 61822480a2a0..16a4e8528bbc 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -19,7 +19,6 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/types.h> 20#include <linux/types.h>
21 21
22#include <asm/compat.h>
23#include <asm/ccwdev.h> 22#include <asm/ccwdev.h>
24#include <asm/cio.h> 23#include <asm/cio.h>
25#include <asm/ebcdic.h> 24#include <asm/ebcdic.h>
diff --git a/drivers/s390/char/sclp_ctl.c b/drivers/s390/char/sclp_ctl.c
index a78cea0c3a09..248b5db3eaa8 100644
--- a/drivers/s390/char/sclp_ctl.c
+++ b/drivers/s390/char/sclp_ctl.c
@@ -14,7 +14,6 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/ioctl.h> 15#include <linux/ioctl.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <asm/compat.h>
18#include <asm/sclp_ctl.h> 17#include <asm/sclp_ctl.h>
19#include <asm/sclp.h> 18#include <asm/sclp.h>
20 19
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c
index 17e411c57576..948ce82a7725 100644
--- a/drivers/s390/char/vmcp.c
+++ b/drivers/s390/char/vmcp.c
@@ -23,7 +23,6 @@
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/cma.h> 24#include <linux/cma.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <asm/compat.h>
27#include <asm/cpcmd.h> 26#include <asm/cpcmd.h>
28#include <asm/debug.h> 27#include <asm/debug.h>
29#include <asm/vmcp.h> 28#include <asm/vmcp.h>
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index 0015729d917d..8d9f36625ba5 100644
--- a/drivers/s390/cio/chsc_sch.c
+++ b/drivers/s390/cio/chsc_sch.c
@@ -16,7 +16,6 @@
16#include <linux/miscdevice.h> 16#include <linux/miscdevice.h>
17#include <linux/kernel_stat.h> 17#include <linux/kernel_stat.h>
18 18
19#include <asm/compat.h>
20#include <asm/cio.h> 19#include <asm/cio.h>
21#include <asm/chsc.h> 20#include <asm/chsc.h>
22#include <asm/isc.h> 21#include <asm/isc.h>
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index dffd820731f2..f5a0d894d9ad 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -10,6 +10,7 @@
10#define KMSG_COMPONENT "qeth" 10#define KMSG_COMPONENT "qeth"
11#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 11#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 12
13#include <linux/compat.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
15#include <linux/string.h> 16#include <linux/string.h>
@@ -32,7 +33,6 @@
32#include <asm/chpid.h> 33#include <asm/chpid.h>
33#include <asm/io.h> 34#include <asm/io.h>
34#include <asm/sysinfo.h> 35#include <asm/sysinfo.h>
35#include <asm/compat.h>
36#include <asm/diag.h> 36#include <asm/diag.h>
37#include <asm/cio.h> 37#include <asm/cio.h>
38#include <asm/ccwdev.h> 38#include <asm/ccwdev.h>
diff --git a/include/asm-generic/compat.h b/include/asm-generic/compat.h
new file mode 100644
index 000000000000..28819451b6d1
--- /dev/null
+++ b/include/asm-generic/compat.h
@@ -0,0 +1,3 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2
3/* This is an empty stub for 32-bit-only architectures */
diff --git a/include/linux/compat.h b/include/linux/compat.h
index ad192057b887..b1a5562b3215 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -7,8 +7,7 @@
7 */ 7 */
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10 10#include <linux/compat_time.h>
11#ifdef CONFIG_COMPAT
12 11
13#include <linux/stat.h> 12#include <linux/stat.h>
14#include <linux/param.h> /* for HZ */ 13#include <linux/param.h> /* for HZ */
@@ -21,8 +20,11 @@
21#include <linux/unistd.h> 20#include <linux/unistd.h>
22 21
23#include <asm/compat.h> 22#include <asm/compat.h>
23
24#ifdef CONFIG_COMPAT
24#include <asm/siginfo.h> 25#include <asm/siginfo.h>
25#include <asm/signal.h> 26#include <asm/signal.h>
27#endif
26 28
27#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER 29#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
28/* 30/*
@@ -83,6 +85,8 @@
83 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 85 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
84#endif /* COMPAT_SYSCALL_DEFINEx */ 86#endif /* COMPAT_SYSCALL_DEFINEx */
85 87
88#ifdef CONFIG_COMPAT
89
86#ifndef compat_user_stack_pointer 90#ifndef compat_user_stack_pointer
87#define compat_user_stack_pointer() current_user_stack_pointer() 91#define compat_user_stack_pointer() current_user_stack_pointer()
88#endif 92#endif
@@ -290,8 +294,6 @@ extern int compat_get_timespec(struct timespec *, const void __user *);
290extern int compat_put_timespec(const struct timespec *, void __user *); 294extern int compat_put_timespec(const struct timespec *, void __user *);
291extern int compat_get_timeval(struct timeval *, const void __user *); 295extern int compat_get_timeval(struct timeval *, const void __user *);
292extern int compat_put_timeval(const struct timeval *, void __user *); 296extern int compat_put_timeval(const struct timeval *, void __user *);
293extern int compat_get_timespec64(struct timespec64 *, const void __user *);
294extern int compat_put_timespec64(const struct timespec64 *, void __user *);
295extern int get_compat_itimerspec64(struct itimerspec64 *its, 297extern int get_compat_itimerspec64(struct itimerspec64 *its,
296 const struct compat_itimerspec __user *uits); 298 const struct compat_itimerspec __user *uits);
297extern int put_compat_itimerspec64(const struct itimerspec64 *its, 299extern int put_compat_itimerspec64(const struct itimerspec64 *its,
@@ -1023,7 +1025,9 @@ static inline struct compat_timeval ns_to_compat_timeval(s64 nsec)
1023#else /* !CONFIG_COMPAT */ 1025#else /* !CONFIG_COMPAT */
1024 1026
1025#define is_compat_task() (0) 1027#define is_compat_task() (0)
1028#ifndef in_compat_syscall
1026static inline bool in_compat_syscall(void) { return false; } 1029static inline bool in_compat_syscall(void) { return false; }
1030#endif
1027 1031
1028#endif /* CONFIG_COMPAT */ 1032#endif /* CONFIG_COMPAT */
1029 1033
diff --git a/include/linux/compat_time.h b/include/linux/compat_time.h
new file mode 100644
index 000000000000..31f2774f1994
--- /dev/null
+++ b/include/linux/compat_time.h
@@ -0,0 +1,23 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_COMPAT_TIME_H
3#define _LINUX_COMPAT_TIME_H
4
5#include <linux/types.h>
6#include <linux/time64.h>
7
8typedef s32 compat_time_t;
9
10struct compat_timespec {
11 compat_time_t tv_sec;
12 s32 tv_nsec;
13};
14
15struct compat_timeval {
16 compat_time_t tv_sec;
17 s32 tv_usec;
18};
19
20extern int compat_get_timespec64(struct timespec64 *, const void __user *);
21extern int compat_put_timespec64(const struct timespec64 *, void __user *);
22
23#endif /* _LINUX_COMPAT_TIME_H */
diff --git a/include/linux/restart_block.h b/include/linux/restart_block.h
index bcfdb918cd81..5d83d0c1d06c 100644
--- a/include/linux/restart_block.h
+++ b/include/linux/restart_block.h
@@ -7,6 +7,7 @@
7 7
8#include <linux/compiler.h> 8#include <linux/compiler.h>
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/time64.h>
10 11
11struct timespec; 12struct timespec;
12struct compat_timespec; 13struct compat_timespec;
@@ -15,9 +16,7 @@ struct pollfd;
15enum timespec_type { 16enum timespec_type {
16 TT_NONE = 0, 17 TT_NONE = 0,
17 TT_NATIVE = 1, 18 TT_NATIVE = 1,
18#ifdef CONFIG_COMPAT
19 TT_COMPAT = 2, 19 TT_COMPAT = 2,
20#endif
21}; 20};
22 21
23/* 22/*
@@ -40,10 +39,8 @@ struct restart_block {
40 clockid_t clockid; 39 clockid_t clockid;
41 enum timespec_type type; 40 enum timespec_type type;
42 union { 41 union {
43 struct timespec __user *rmtp; 42 struct __kernel_timespec __user *rmtp;
44#ifdef CONFIG_COMPAT
45 struct compat_timespec __user *compat_rmtp; 43 struct compat_timespec __user *compat_rmtp;
46#endif
47 }; 44 };
48 u64 expires; 45 u64 expires;
49 } nanosleep; 46 } nanosleep;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 811172fcb916..796ea267f1c7 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -542,7 +542,8 @@ asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
542 size_t len); 542 size_t len);
543 543
544/* kernel/hrtimer.c */ 544/* kernel/hrtimer.c */
545asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp); 545asmlinkage long sys_nanosleep(struct __kernel_timespec __user *rqtp,
546 struct __kernel_timespec __user *rmtp);
546 547
547/* kernel/itimer.c */ 548/* kernel/itimer.c */
548asmlinkage long sys_getitimer(int which, struct itimerval __user *value); 549asmlinkage long sys_getitimer(int which, struct itimerval __user *value);
@@ -573,14 +574,14 @@ asmlinkage long sys_timer_settime(timer_t timer_id, int flags,
573 struct itimerspec __user *old_setting); 574 struct itimerspec __user *old_setting);
574asmlinkage long sys_timer_delete(timer_t timer_id); 575asmlinkage long sys_timer_delete(timer_t timer_id);
575asmlinkage long sys_clock_settime(clockid_t which_clock, 576asmlinkage long sys_clock_settime(clockid_t which_clock,
576 const struct timespec __user *tp); 577 const struct __kernel_timespec __user *tp);
577asmlinkage long sys_clock_gettime(clockid_t which_clock, 578asmlinkage long sys_clock_gettime(clockid_t which_clock,
578 struct timespec __user *tp); 579 struct __kernel_timespec __user *tp);
579asmlinkage long sys_clock_getres(clockid_t which_clock, 580asmlinkage long sys_clock_getres(clockid_t which_clock,
580 struct timespec __user *tp); 581 struct __kernel_timespec __user *tp);
581asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags, 582asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
582 const struct timespec __user *rqtp, 583 const struct __kernel_timespec __user *rqtp,
583 struct timespec __user *rmtp); 584 struct __kernel_timespec __user *rmtp);
584 585
585/* kernel/printk.c */ 586/* kernel/printk.c */
586asmlinkage long sys_syslog(int type, char __user *buf, int len); 587asmlinkage long sys_syslog(int type, char __user *buf, int len);
diff --git a/include/linux/time.h b/include/linux/time.h
index 4b62a2c0a661..aed74463592d 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -10,9 +10,9 @@
10extern struct timezone sys_tz; 10extern struct timezone sys_tz;
11 11
12int get_timespec64(struct timespec64 *ts, 12int get_timespec64(struct timespec64 *ts,
13 const struct timespec __user *uts); 13 const struct __kernel_timespec __user *uts);
14int put_timespec64(const struct timespec64 *ts, 14int put_timespec64(const struct timespec64 *ts,
15 struct timespec __user *uts); 15 struct __kernel_timespec __user *uts);
16int get_itimerspec64(struct itimerspec64 *it, 16int get_itimerspec64(struct itimerspec64 *it,
17 const struct itimerspec __user *uit); 17 const struct itimerspec __user *uit);
18int put_itimerspec64(const struct itimerspec64 *it, 18int put_itimerspec64(const struct itimerspec64 *it,
diff --git a/include/linux/time64.h b/include/linux/time64.h
index 93d39499838e..0d96887ba4e0 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -2,12 +2,20 @@
2#ifndef _LINUX_TIME64_H 2#ifndef _LINUX_TIME64_H
3#define _LINUX_TIME64_H 3#define _LINUX_TIME64_H
4 4
5#include <uapi/linux/time.h>
6#include <linux/math64.h> 5#include <linux/math64.h>
7 6
8typedef __s64 time64_t; 7typedef __s64 time64_t;
9typedef __u64 timeu64_t; 8typedef __u64 timeu64_t;
10 9
10/* CONFIG_64BIT_TIME enables new 64 bit time_t syscalls in the compat path
11 * and 32-bit emulation.
12 */
13#ifndef CONFIG_64BIT_TIME
14#define __kernel_timespec timespec
15#endif
16
17#include <uapi/linux/time.h>
18
11#if __BITS_PER_LONG == 64 19#if __BITS_PER_LONG == 64
12/* this trick allows us to optimize out timespec64_to_timespec */ 20/* this trick allows us to optimize out timespec64_to_timespec */
13# define timespec64 timespec 21# define timespec64 timespec
diff --git a/include/uapi/asm-generic/posix_types.h b/include/uapi/asm-generic/posix_types.h
index 5e6ea22bd525..f0733a26ebfc 100644
--- a/include/uapi/asm-generic/posix_types.h
+++ b/include/uapi/asm-generic/posix_types.h
@@ -87,6 +87,7 @@ typedef struct {
87typedef __kernel_long_t __kernel_off_t; 87typedef __kernel_long_t __kernel_off_t;
88typedef long long __kernel_loff_t; 88typedef long long __kernel_loff_t;
89typedef __kernel_long_t __kernel_time_t; 89typedef __kernel_long_t __kernel_time_t;
90typedef long long __kernel_time64_t;
90typedef __kernel_long_t __kernel_clock_t; 91typedef __kernel_long_t __kernel_clock_t;
91typedef int __kernel_timer_t; 92typedef int __kernel_timer_t;
92typedef int __kernel_clockid_t; 93typedef int __kernel_clockid_t;
diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h
index 4c0338ea308a..fcf936656493 100644
--- a/include/uapi/linux/time.h
+++ b/include/uapi/linux/time.h
@@ -42,6 +42,13 @@ struct itimerval {
42 struct timeval it_value; /* current value */ 42 struct timeval it_value; /* current value */
43}; 43};
44 44
45#ifndef __kernel_timespec
46struct __kernel_timespec {
47 __kernel_time64_t tv_sec; /* seconds */
48 long long tv_nsec; /* nanoseconds */
49};
50#endif
51
45/* 52/*
46 * legacy timeval structure, only embedded in structures that 53 * legacy timeval structure, only embedded in structures that
47 * traditionally used 'timeval' to pass time intervals (not absolute 54 * traditionally used 'timeval' to pass time intervals (not absolute
diff --git a/kernel/compat.c b/kernel/compat.c
index 92d8c98c0f57..702aa846ddac 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -121,50 +121,6 @@ static int __compat_put_timespec(const struct timespec *ts, struct compat_timesp
121 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; 121 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
122} 122}
123 123
124static int __compat_get_timespec64(struct timespec64 *ts64,
125 const struct compat_timespec __user *cts)
126{
127 struct compat_timespec ts;
128 int ret;
129
130 ret = copy_from_user(&ts, cts, sizeof(ts));
131 if (ret)
132 return -EFAULT;
133
134 ts64->tv_sec = ts.tv_sec;
135 ts64->tv_nsec = ts.tv_nsec;
136
137 return 0;
138}
139
140static int __compat_put_timespec64(const struct timespec64 *ts64,
141 struct compat_timespec __user *cts)
142{
143 struct compat_timespec ts = {
144 .tv_sec = ts64->tv_sec,
145 .tv_nsec = ts64->tv_nsec
146 };
147 return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0;
148}
149
150int compat_get_timespec64(struct timespec64 *ts, const void __user *uts)
151{
152 if (COMPAT_USE_64BIT_TIME)
153 return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
154 else
155 return __compat_get_timespec64(ts, uts);
156}
157EXPORT_SYMBOL_GPL(compat_get_timespec64);
158
159int compat_put_timespec64(const struct timespec64 *ts, void __user *uts)
160{
161 if (COMPAT_USE_64BIT_TIME)
162 return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
163 else
164 return __compat_put_timespec64(ts, uts);
165}
166EXPORT_SYMBOL_GPL(compat_put_timespec64);
167
168int compat_get_timeval(struct timeval *tv, const void __user *utv) 124int compat_get_timeval(struct timeval *tv, const void __user *utv)
169{ 125{
170 if (COMPAT_USE_64BIT_TIME) 126 if (COMPAT_USE_64BIT_TIME)
@@ -368,6 +324,14 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len,
368 return ret; 324 return ret;
369} 325}
370 326
327/* Todo: Delete these extern declarations when get/put_compat_itimerspec64()
328 * are moved to kernel/time/time.c .
329 */
330extern int __compat_get_timespec64(struct timespec64 *ts64,
331 const struct compat_timespec __user *cts);
332extern int __compat_put_timespec64(const struct timespec64 *ts64,
333 struct compat_timespec __user *cts);
334
371int get_compat_itimerspec64(struct itimerspec64 *its, 335int get_compat_itimerspec64(struct itimerspec64 *its,
372 const struct compat_itimerspec __user *uits) 336 const struct compat_itimerspec __user *uits)
373{ 337{
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 84f37420fcf5..f89a78e2792b 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -129,31 +129,19 @@ static void inline clocksource_watchdog_unlock(unsigned long *flags)
129 spin_unlock_irqrestore(&watchdog_lock, *flags); 129 spin_unlock_irqrestore(&watchdog_lock, *flags);
130} 130}
131 131
132static int clocksource_watchdog_kthread(void *data);
133static void __clocksource_change_rating(struct clocksource *cs, int rating);
134
135/* 132/*
136 * Interval: 0.5sec Threshold: 0.0625s 133 * Interval: 0.5sec Threshold: 0.0625s
137 */ 134 */
138#define WATCHDOG_INTERVAL (HZ >> 1) 135#define WATCHDOG_INTERVAL (HZ >> 1)
139#define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4) 136#define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4)
140 137
141static void clocksource_watchdog_work(struct work_struct *work)
142{
143 /*
144 * If kthread_run fails the next watchdog scan over the
145 * watchdog_list will find the unstable clock again.
146 */
147 kthread_run(clocksource_watchdog_kthread, NULL, "kwatchdog");
148}
149
150static void __clocksource_unstable(struct clocksource *cs) 138static void __clocksource_unstable(struct clocksource *cs)
151{ 139{
152 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); 140 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
153 cs->flags |= CLOCK_SOURCE_UNSTABLE; 141 cs->flags |= CLOCK_SOURCE_UNSTABLE;
154 142
155 /* 143 /*
156 * If the clocksource is registered clocksource_watchdog_kthread() will 144 * If the clocksource is registered clocksource_watchdog_work() will
157 * re-rate and re-select. 145 * re-rate and re-select.
158 */ 146 */
159 if (list_empty(&cs->list)) { 147 if (list_empty(&cs->list)) {
@@ -164,7 +152,7 @@ static void __clocksource_unstable(struct clocksource *cs)
164 if (cs->mark_unstable) 152 if (cs->mark_unstable)
165 cs->mark_unstable(cs); 153 cs->mark_unstable(cs);
166 154
167 /* kick clocksource_watchdog_kthread() */ 155 /* kick clocksource_watchdog_work() */
168 if (finished_booting) 156 if (finished_booting)
169 schedule_work(&watchdog_work); 157 schedule_work(&watchdog_work);
170} 158}
@@ -174,7 +162,7 @@ static void __clocksource_unstable(struct clocksource *cs)
174 * @cs: clocksource to be marked unstable 162 * @cs: clocksource to be marked unstable
175 * 163 *
176 * This function is called by the x86 TSC code to mark clocksources as unstable; 164 * This function is called by the x86 TSC code to mark clocksources as unstable;
177 * it defers demotion and re-selection to a kthread. 165 * it defers demotion and re-selection to a work.
178 */ 166 */
179void clocksource_mark_unstable(struct clocksource *cs) 167void clocksource_mark_unstable(struct clocksource *cs)
180{ 168{
@@ -399,7 +387,9 @@ static void clocksource_dequeue_watchdog(struct clocksource *cs)
399 } 387 }
400} 388}
401 389
402static int __clocksource_watchdog_kthread(void) 390static void __clocksource_change_rating(struct clocksource *cs, int rating);
391
392static int __clocksource_watchdog_work(void)
403{ 393{
404 struct clocksource *cs, *tmp; 394 struct clocksource *cs, *tmp;
405 unsigned long flags; 395 unsigned long flags;
@@ -424,13 +414,12 @@ static int __clocksource_watchdog_kthread(void)
424 return select; 414 return select;
425} 415}
426 416
427static int clocksource_watchdog_kthread(void *data) 417static void clocksource_watchdog_work(struct work_struct *work)
428{ 418{
429 mutex_lock(&clocksource_mutex); 419 mutex_lock(&clocksource_mutex);
430 if (__clocksource_watchdog_kthread()) 420 if (__clocksource_watchdog_work())
431 clocksource_select(); 421 clocksource_select();
432 mutex_unlock(&clocksource_mutex); 422 mutex_unlock(&clocksource_mutex);
433 return 0;
434} 423}
435 424
436static bool clocksource_is_watchdog(struct clocksource *cs) 425static bool clocksource_is_watchdog(struct clocksource *cs)
@@ -449,12 +438,12 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs)
449static void clocksource_select_watchdog(bool fallback) { } 438static void clocksource_select_watchdog(bool fallback) { }
450static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } 439static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { }
451static inline void clocksource_resume_watchdog(void) { } 440static inline void clocksource_resume_watchdog(void) { }
452static inline int __clocksource_watchdog_kthread(void) { return 0; } 441static inline int __clocksource_watchdog_work(void) { return 0; }
453static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } 442static bool clocksource_is_watchdog(struct clocksource *cs) { return false; }
454void clocksource_mark_unstable(struct clocksource *cs) { } 443void clocksource_mark_unstable(struct clocksource *cs) { }
455 444
456static void inline clocksource_watchdog_lock(unsigned long *flags) { } 445static inline void clocksource_watchdog_lock(unsigned long *flags) { }
457static void inline clocksource_watchdog_unlock(unsigned long *flags) { } 446static inline void clocksource_watchdog_unlock(unsigned long *flags) { }
458 447
459#endif /* CONFIG_CLOCKSOURCE_WATCHDOG */ 448#endif /* CONFIG_CLOCKSOURCE_WATCHDOG */
460 449
@@ -683,7 +672,7 @@ static int __init clocksource_done_booting(void)
683 /* 672 /*
684 * Run the watchdog first to eliminate unstable clock sources 673 * Run the watchdog first to eliminate unstable clock sources
685 */ 674 */
686 __clocksource_watchdog_kthread(); 675 __clocksource_watchdog_work();
687 clocksource_select(); 676 clocksource_select();
688 mutex_unlock(&clocksource_mutex); 677 mutex_unlock(&clocksource_mutex);
689 return 0; 678 return 0;
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 14e858753d76..055a4a728c00 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1759,8 +1759,10 @@ out:
1759 return ret; 1759 return ret;
1760} 1760}
1761 1761
1762SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp, 1762#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
1763 struct timespec __user *, rmtp) 1763
1764SYSCALL_DEFINE2(nanosleep, struct __kernel_timespec __user *, rqtp,
1765 struct __kernel_timespec __user *, rmtp)
1764{ 1766{
1765 struct timespec64 tu; 1767 struct timespec64 tu;
1766 1768
@@ -1775,7 +1777,9 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
1775 return hrtimer_nanosleep(&tu, HRTIMER_MODE_REL, CLOCK_MONOTONIC); 1777 return hrtimer_nanosleep(&tu, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
1776} 1778}
1777 1779
1778#ifdef CONFIG_COMPAT 1780#endif
1781
1782#ifdef CONFIG_COMPAT_32BIT_TIME
1779 1783
1780COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp, 1784COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
1781 struct compat_timespec __user *, rmtp) 1785 struct compat_timespec __user *, rmtp)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index 69a937c3cd81..26aa9569e24a 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -59,7 +59,7 @@ SYS_NI(alarm);
59 */ 59 */
60 60
61SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, 61SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
62 const struct timespec __user *, tp) 62 const struct __kernel_timespec __user *, tp)
63{ 63{
64 struct timespec64 new_tp; 64 struct timespec64 new_tp;
65 65
@@ -90,7 +90,7 @@ int do_clock_gettime(clockid_t which_clock, struct timespec64 *tp)
90 return 0; 90 return 0;
91} 91}
92SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, 92SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
93 struct timespec __user *, tp) 93 struct __kernel_timespec __user *, tp)
94{ 94{
95 int ret; 95 int ret;
96 struct timespec64 kernel_tp; 96 struct timespec64 kernel_tp;
@@ -104,7 +104,7 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
104 return 0; 104 return 0;
105} 105}
106 106
107SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct timespec __user *, tp) 107SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct __kernel_timespec __user *, tp)
108{ 108{
109 struct timespec64 rtn_tp = { 109 struct timespec64 rtn_tp = {
110 .tv_sec = 0, 110 .tv_sec = 0,
@@ -124,8 +124,8 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct timespec __us
124} 124}
125 125
126SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags, 126SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
127 const struct timespec __user *, rqtp, 127 const struct __kernel_timespec __user *, rqtp,
128 struct timespec __user *, rmtp) 128 struct __kernel_timespec __user *, rmtp)
129{ 129{
130 struct timespec64 t; 130 struct timespec64 t;
131 131
@@ -158,7 +158,9 @@ COMPAT_SYS_NI(timer_settime);
158COMPAT_SYS_NI(timer_gettime); 158COMPAT_SYS_NI(timer_gettime);
159COMPAT_SYS_NI(getitimer); 159COMPAT_SYS_NI(getitimer);
160COMPAT_SYS_NI(setitimer); 160COMPAT_SYS_NI(setitimer);
161#endif
161 162
163#ifdef CONFIG_COMPAT_32BIT_TIME
162COMPAT_SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, 164COMPAT_SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
163 struct compat_timespec __user *, tp) 165 struct compat_timespec __user *, tp)
164{ 166{
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 10b7186d0638..e08ce3f27447 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -1040,7 +1040,7 @@ void exit_itimers(struct signal_struct *sig)
1040} 1040}
1041 1041
1042SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, 1042SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
1043 const struct timespec __user *, tp) 1043 const struct __kernel_timespec __user *, tp)
1044{ 1044{
1045 const struct k_clock *kc = clockid_to_kclock(which_clock); 1045 const struct k_clock *kc = clockid_to_kclock(which_clock);
1046 struct timespec64 new_tp; 1046 struct timespec64 new_tp;
@@ -1055,7 +1055,7 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
1055} 1055}
1056 1056
1057SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, 1057SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
1058 struct timespec __user *,tp) 1058 struct __kernel_timespec __user *, tp)
1059{ 1059{
1060 const struct k_clock *kc = clockid_to_kclock(which_clock); 1060 const struct k_clock *kc = clockid_to_kclock(which_clock);
1061 struct timespec64 kernel_tp; 1061 struct timespec64 kernel_tp;
@@ -1096,7 +1096,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
1096} 1096}
1097 1097
1098SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, 1098SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
1099 struct timespec __user *, tp) 1099 struct __kernel_timespec __user *, tp)
1100{ 1100{
1101 const struct k_clock *kc = clockid_to_kclock(which_clock); 1101 const struct k_clock *kc = clockid_to_kclock(which_clock);
1102 struct timespec64 rtn_tp; 1102 struct timespec64 rtn_tp;
@@ -1113,7 +1113,7 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
1113 return error; 1113 return error;
1114} 1114}
1115 1115
1116#ifdef CONFIG_COMPAT 1116#ifdef CONFIG_COMPAT_32BIT_TIME
1117 1117
1118COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock, 1118COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
1119 struct compat_timespec __user *, tp) 1119 struct compat_timespec __user *, tp)
@@ -1148,6 +1148,10 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
1148 return err; 1148 return err;
1149} 1149}
1150 1150
1151#endif
1152
1153#ifdef CONFIG_COMPAT
1154
1151COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock, 1155COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
1152 struct compat_timex __user *, utp) 1156 struct compat_timex __user *, utp)
1153{ 1157{
@@ -1172,6 +1176,10 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
1172 return err; 1176 return err;
1173} 1177}
1174 1178
1179#endif
1180
1181#ifdef CONFIG_COMPAT_32BIT_TIME
1182
1175COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock, 1183COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
1176 struct compat_timespec __user *, tp) 1184 struct compat_timespec __user *, tp)
1177{ 1185{
@@ -1203,8 +1211,8 @@ static int common_nsleep(const clockid_t which_clock, int flags,
1203} 1211}
1204 1212
1205SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags, 1213SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
1206 const struct timespec __user *, rqtp, 1214 const struct __kernel_timespec __user *, rqtp,
1207 struct timespec __user *, rmtp) 1215 struct __kernel_timespec __user *, rmtp)
1208{ 1216{
1209 const struct k_clock *kc = clockid_to_kclock(which_clock); 1217 const struct k_clock *kc = clockid_to_kclock(which_clock);
1210 struct timespec64 t; 1218 struct timespec64 t;
@@ -1227,7 +1235,8 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
1227 return kc->nsleep(which_clock, flags, &t); 1235 return kc->nsleep(which_clock, flags, &t);
1228} 1236}
1229 1237
1230#ifdef CONFIG_COMPAT 1238#ifdef CONFIG_COMPAT_32BIT_TIME
1239
1231COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags, 1240COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
1232 struct compat_timespec __user *, rqtp, 1241 struct compat_timespec __user *, rqtp,
1233 struct compat_timespec __user *, rmtp) 1242 struct compat_timespec __user *, rmtp)
@@ -1252,6 +1261,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
1252 1261
1253 return kc->nsleep(which_clock, flags, &t); 1262 return kc->nsleep(which_clock, flags, &t);
1254} 1263}
1264
1255#endif 1265#endif
1256 1266
1257static const struct k_clock clock_realtime = { 1267static const struct k_clock clock_realtime = {
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 49edc1c4f3e6..78e598334007 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -277,7 +277,8 @@ static bool tick_check_preferred(struct clock_event_device *curdev,
277 */ 277 */
278 return !curdev || 278 return !curdev ||
279 newdev->rating > curdev->rating || 279 newdev->rating > curdev->rating ||
280 !cpumask_equal(curdev->cpumask, newdev->cpumask); 280 (!cpumask_equal(curdev->cpumask, newdev->cpumask) &&
281 !tick_check_percpu(curdev, newdev, smp_processor_id()));
281} 282}
282 283
283/* 284/*
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 3044d48ebe56..ccd751e95fcb 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -853,9 +853,9 @@ struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
853} 853}
854 854
855int get_timespec64(struct timespec64 *ts, 855int get_timespec64(struct timespec64 *ts,
856 const struct timespec __user *uts) 856 const struct __kernel_timespec __user *uts)
857{ 857{
858 struct timespec kts; 858 struct __kernel_timespec kts;
859 int ret; 859 int ret;
860 860
861 ret = copy_from_user(&kts, uts, sizeof(kts)); 861 ret = copy_from_user(&kts, uts, sizeof(kts));
@@ -863,6 +863,11 @@ int get_timespec64(struct timespec64 *ts,
863 return -EFAULT; 863 return -EFAULT;
864 864
865 ts->tv_sec = kts.tv_sec; 865 ts->tv_sec = kts.tv_sec;
866
867 /* Zero out the padding for 32 bit systems or in compat mode */
868 if (IS_ENABLED(CONFIG_64BIT_TIME) && (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()))
869 kts.tv_nsec &= 0xFFFFFFFFUL;
870
866 ts->tv_nsec = kts.tv_nsec; 871 ts->tv_nsec = kts.tv_nsec;
867 872
868 return 0; 873 return 0;
@@ -870,16 +875,61 @@ int get_timespec64(struct timespec64 *ts,
870EXPORT_SYMBOL_GPL(get_timespec64); 875EXPORT_SYMBOL_GPL(get_timespec64);
871 876
872int put_timespec64(const struct timespec64 *ts, 877int put_timespec64(const struct timespec64 *ts,
873 struct timespec __user *uts) 878 struct __kernel_timespec __user *uts)
874{ 879{
875 struct timespec kts = { 880 struct __kernel_timespec kts = {
876 .tv_sec = ts->tv_sec, 881 .tv_sec = ts->tv_sec,
877 .tv_nsec = ts->tv_nsec 882 .tv_nsec = ts->tv_nsec
878 }; 883 };
884
879 return copy_to_user(uts, &kts, sizeof(kts)) ? -EFAULT : 0; 885 return copy_to_user(uts, &kts, sizeof(kts)) ? -EFAULT : 0;
880} 886}
881EXPORT_SYMBOL_GPL(put_timespec64); 887EXPORT_SYMBOL_GPL(put_timespec64);
882 888
889int __compat_get_timespec64(struct timespec64 *ts64,
890 const struct compat_timespec __user *cts)
891{
892 struct compat_timespec ts;
893 int ret;
894
895 ret = copy_from_user(&ts, cts, sizeof(ts));
896 if (ret)
897 return -EFAULT;
898
899 ts64->tv_sec = ts.tv_sec;
900 ts64->tv_nsec = ts.tv_nsec;
901
902 return 0;
903}
904
905int __compat_put_timespec64(const struct timespec64 *ts64,
906 struct compat_timespec __user *cts)
907{
908 struct compat_timespec ts = {
909 .tv_sec = ts64->tv_sec,
910 .tv_nsec = ts64->tv_nsec
911 };
912 return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0;
913}
914
915int compat_get_timespec64(struct timespec64 *ts, const void __user *uts)
916{
917 if (COMPAT_USE_64BIT_TIME)
918 return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
919 else
920 return __compat_get_timespec64(ts, uts);
921}
922EXPORT_SYMBOL_GPL(compat_get_timespec64);
923
924int compat_put_timespec64(const struct timespec64 *ts, void __user *uts)
925{
926 if (COMPAT_USE_64BIT_TIME)
927 return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
928 else
929 return __compat_put_timespec64(ts, uts);
930}
931EXPORT_SYMBOL_GPL(compat_put_timespec64);
932
883int get_itimerspec64(struct itimerspec64 *it, 933int get_itimerspec64(struct itimerspec64 *it,
884 const struct itimerspec __user *uit) 934 const struct itimerspec __user *uit)
885{ 935{
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 4a4fd567fb26..cc2d23e6ff61 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1251,18 +1251,18 @@ EXPORT_SYMBOL(try_to_del_timer_sync);
1251 * 1251 *
1252 * Note: For !irqsafe timers, you must not hold locks that are held in 1252 * Note: For !irqsafe timers, you must not hold locks that are held in
1253 * interrupt context while calling this function. Even if the lock has 1253 * interrupt context while calling this function. Even if the lock has
1254 * nothing to do with the timer in question. Here's why: 1254 * nothing to do with the timer in question. Here's why::
1255 * 1255 *
1256 * CPU0 CPU1 1256 * CPU0 CPU1
1257 * ---- ---- 1257 * ---- ----
1258 * <SOFTIRQ> 1258 * <SOFTIRQ>
1259 * call_timer_fn(); 1259 * call_timer_fn();
1260 * base->running_timer = mytimer; 1260 * base->running_timer = mytimer;
1261 * spin_lock_irq(somelock); 1261 * spin_lock_irq(somelock);
1262 * <IRQ> 1262 * <IRQ>
1263 * spin_lock(somelock); 1263 * spin_lock(somelock);
1264 * del_timer_sync(mytimer); 1264 * del_timer_sync(mytimer);
1265 * while (base->running_timer == mytimer); 1265 * while (base->running_timer == mytimer);
1266 * 1266 *
1267 * Now del_timer_sync() will never return and never release somelock. 1267 * Now del_timer_sync() will never return and never release somelock.
1268 * The interrupt on the other CPU is waiting to grab somelock but 1268 * The interrupt on the other CPU is waiting to grab somelock but
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 675c4e9563a9..d647dabdac97 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -28,8 +28,6 @@ struct timer_list_iter {
28 u64 now; 28 u64 now;
29}; 29};
30 30
31typedef void (*print_fn_t)(struct seq_file *m, unsigned int *classes);
32
33/* 31/*
34 * This allows printing both to /proc/timer_list and 32 * This allows printing both to /proc/timer_list and
35 * to the console (on SysRq-Q): 33 * to the console (on SysRq-Q):