resume_user_mode: Move to resume_user_mode.h
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 9 Feb 2022 18:20:45 +0000 (12:20 -0600)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 10 Mar 2022 22:51:50 +0000 (16:51 -0600)
Move set_notify_resume and tracehook_notify_resume into resume_user_mode.h.
While doing that rename tracehook_notify_resume to resume_user_mode_work.

Update all of the places that included tracehook.h for these functions to
include resume_user_mode.h instead.

Update all of the callers of tracehook_notify_resume to call
resume_user_mode_work.

Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20220309162454.123006-12-ebiederm@xmission.com
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
35 files changed:
arch/Kconfig
arch/alpha/kernel/signal.c
arch/arc/kernel/signal.c
arch/arm/kernel/signal.c
arch/arm64/kernel/signal.c
arch/csky/kernel/signal.c
arch/h8300/kernel/signal.c
arch/hexagon/kernel/process.c
arch/hexagon/kernel/signal.c
arch/ia64/kernel/process.c
arch/ia64/kernel/ptrace.c
arch/ia64/kernel/signal.c
arch/m68k/kernel/signal.c
arch/microblaze/kernel/signal.c
arch/mips/kernel/signal.c
arch/nds32/kernel/signal.c
arch/nios2/kernel/signal.c
arch/openrisc/kernel/signal.c
arch/parisc/kernel/signal.c
arch/powerpc/kernel/signal.c
arch/riscv/kernel/signal.c
arch/sh/kernel/signal_32.c
arch/sparc/kernel/signal32.c
arch/sparc/kernel/signal_32.c
arch/sparc/kernel/signal_64.c
arch/um/kernel/process.c
arch/xtensa/kernel/signal.c
block/blk-cgroup.c
include/linux/entry-kvm.h
include/linux/resume_user_mode.h [new file with mode: 0644]
include/linux/tracehook.h
kernel/entry/common.c
kernel/entry/kvm.c
kernel/task_work.c
mm/memcontrol.c

index 6382520ef0a587d943a50f78886dd267ae95822f..2e3979c3d66deccf27500521b48ab0d7ea0d57af 100644 (file)
@@ -218,7 +218,7 @@ config TRACE_IRQFLAGS_SUPPORT
 #      linux/regset.h          user_regset interfaces
 #      CORE_DUMP_USE_REGSET    #define'd in linux/elf.h
 #      TIF_SYSCALL_TRACE       calls ptrace_report_syscall_{entry,exit}
-#      TIF_NOTIFY_RESUME       calls tracehook_notify_resume()
+#      TIF_NOTIFY_RESUME       calls resume_user_mode_work()
 #
 config HAVE_ARCH_TRACEHOOK
        bool
index d8ed71d5bed3cfcf50a8ec7d2dcaf07265eed488..6f47f256fe8077cb924e2ed392c57b75e0e8ad3d 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/binfmts.h>
 #include <linux/bitops.h>
 #include <linux/syscalls.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <linux/uaccess.h>
 #include <asm/sigcontext.h>
@@ -531,7 +531,7 @@ do_work_pending(struct pt_regs *regs, unsigned long thread_flags,
                                do_signal(regs, r0, r19);
                                r0 = 0;
                        } else {
-                               tracehook_notify_resume(regs);
+                               resume_user_mode_work(regs);
                        }
                }
                local_irq_disable();
index cb2f88502bafe2797b04a471a07bd7b49dbaa1e2..f748483628f2c22ec98408c056d417f0fe580179 100644 (file)
@@ -49,7 +49,7 @@
 #include <linux/personality.h>
 #include <linux/uaccess.h>
 #include <linux/syscalls.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/sched/task_stack.h>
 
 #include <asm/ucontext.h>
@@ -438,5 +438,5 @@ void do_notify_resume(struct pt_regs *regs)
         * user mode
         */
        if (test_thread_flag(TIF_NOTIFY_RESUME))
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index c532a60410667f64c9acded52cab4d4f0d9fd4a8..459abc5d1819537bad3f92696681074839254aaa 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/signal.h>
 #include <linux/personality.h>
 #include <linux/uaccess.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/uprobes.h>
 #include <linux/syscalls.h>
 
@@ -627,7 +627,7 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
                        } else if (thread_flags & _TIF_UPROBE) {
                                uprobe_notify_resume(regs);
                        } else {
-                               tracehook_notify_resume(regs);
+                               resume_user_mode_work(regs);
                        }
                }
                local_irq_disable();
index d8aaf4b6f432080d226c9c1185bafe08b5da6ae0..413c51de9d10d1a79c0bfe547bd79617e7c4cf84 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/uaccess.h>
 #include <linux/sizes.h>
 #include <linux/string.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/ratelimit.h>
 #include <linux/syscalls.h>
 
@@ -941,7 +941,7 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
                                do_signal(regs);
 
                        if (thread_flags & _TIF_NOTIFY_RESUME)
-                               tracehook_notify_resume(regs);
+                               resume_user_mode_work(regs);
 
                        if (thread_flags & _TIF_FOREIGN_FPSTATE)
                                fpsimd_restore_current_state();
index c7b763d2f526e661f16b5ad98c5c56bd4c7c257e..7a3149a27e4d3407887c2f6bd10e017174e1172a 100644 (file)
@@ -3,7 +3,7 @@
 #include <linux/signal.h>
 #include <linux/uaccess.h>
 #include <linux/syscalls.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <asm/traps.h>
 #include <asm/ucontext.h>
@@ -265,5 +265,5 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
                do_signal(regs);
 
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index 75a1c36b105a18b3d07347ea576a30b4cb89d2e3..0716fc8a8ce2dd9ffb7bb4a5aa11902aa886bea5 100644 (file)
@@ -39,7 +39,7 @@
 #include <linux/personality.h>
 #include <linux/tty.h>
 #include <linux/binfmts.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <asm/setup.h>
 #include <linux/uaccess.h>
@@ -283,5 +283,5 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags)
                do_signal(regs);
 
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index 232dfd8956aa22bba4adb9b36292f782ceca8710..ae3f728eeca066d1d66870d1d9175ad941729c69 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/tick.h>
 #include <linux/uaccess.h>
 #include <linux/slab.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 /*
  * Program thread launch.  Often defined as a macro in processor.h,
@@ -178,7 +178,7 @@ int do_work_pending(struct pt_regs *regs, u32 thread_info_flags)
        }
 
        if (thread_info_flags & _TIF_NOTIFY_RESUME) {
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
                return 1;
        }
 
index 94cc7ff52dce80eeceec6c1d57f22777704cc840..bcba31e9e0aebc89e8648009d31f1cac4af1195a 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <linux/linkage.h>
 #include <linux/syscalls.h>
-#include <linux/tracehook.h>
 #include <linux/sched/task_stack.h>
 
 #include <asm/registers.h>
index 834df24a88f12cd0514770f51dccd2cea04f773f..d7a256bd9d6b76e555fd53a7bfcb0e06c7b3fea4 100644 (file)
@@ -32,7 +32,7 @@
 #include <linux/delay.h>
 #include <linux/kdebug.h>
 #include <linux/utsname.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/rcupdate.h>
 
 #include <asm/cpu.h>
@@ -179,7 +179,7 @@ do_notify_resume_user(sigset_t *unused, struct sigscratch *scr, long in_syscall)
 
        if (test_thread_flag(TIF_NOTIFY_RESUME)) {
                local_irq_enable();     /* force interrupt enable */
-               tracehook_notify_resume(&scr->pt);
+               resume_user_mode_work(&scr->pt);
        }
 
        /* copy user rbs to kernel rbs */
index 6af64aae087d1cfaa6eb3f07240fff21fe3cd01e..a19acd9f5e1f6ce0399d8e0e4d2a5afa036d38f3 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/signal.h>
 #include <linux/regset.h>
 #include <linux/elf.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <asm/processor.h>
 #include <asm/ptrace_offsets.h>
index c1b299760bf7a91082efc743c9876be81a3fe2c1..51cf6a7ec158ab68ec41c00b25484fbf3f0f5826 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/ptrace.h>
-#include <linux/tracehook.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
 #include <linux/smp.h>
index 338817d0cb3fb100609c1c38dc899d27ff5508ba..49533f65958a64a9710fd3d3c44edef6b63865a5 100644 (file)
@@ -43,7 +43,7 @@
 #include <linux/tty.h>
 #include <linux/binfmts.h>
 #include <linux/extable.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <asm/setup.h>
 #include <linux/uaccess.h>
@@ -1109,5 +1109,5 @@ void do_notify_resume(struct pt_regs *regs)
                do_signal(regs);
 
        if (test_thread_flag(TIF_NOTIFY_RESUME))
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index 23e8a9336a294888685050e428db9f20d31f3754..561eb82d7af67e23650e066cc1305ba8ddd41a20 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/personality.h>
 #include <linux/percpu.h>
 #include <linux/linkage.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <asm/entry.h>
 #include <asm/ucontext.h>
 #include <linux/uaccess.h>
@@ -311,5 +311,5 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, int in_syscall)
                do_signal(regs, in_syscall);
 
        if (test_thread_flag(TIF_NOTIFY_RESUME))
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index 5bce782e694c554e508b5146ded0cbff670e655c..1a99f26bf99ffded7c7664d25c9462e9f5804bda 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/compiler.h>
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <asm/abi.h>
 #include <asm/asm.h>
@@ -916,7 +916,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
                do_signal(regs);
 
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 
        user_enter();
 }
index 7e3ca430a2233c7cd530fc7e7192a44f811f4770..551caef595cbb7e9e1e5de8fd2d5fc4400e5a59e 100644 (file)
@@ -6,7 +6,7 @@
 #include <linux/ptrace.h>
 #include <linux/personality.h>
 #include <linux/freezer.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/uaccess.h>
 
 #include <asm/cacheflush.h>
@@ -380,5 +380,5 @@ do_notify_resume(struct pt_regs *regs, unsigned int thread_flags)
                do_signal(regs);
 
        if (thread_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index 2009ae2d3c3bbe55eecbdfaaaacb956855068be4..530b60c9954557ee28fcfabe0cd4f50889315eb5 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/uaccess.h>
 #include <linux/unistd.h>
 #include <linux/personality.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <asm/ucontext.h>
 #include <asm/cacheflush.h>
@@ -319,7 +319,7 @@ asmlinkage int do_notify_resume(struct pt_regs *regs)
                        return restart;
                }
        } else if (test_thread_flag(TIF_NOTIFY_RESUME))
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 
        return 0;
 }
index 92c5b70740f53821acbcd3b0c173d1711690bf59..80f69740c731d3196d0956e821e07ed5a9248068 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
 #include <linux/stddef.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <asm/processor.h>
 #include <asm/syscall.h>
@@ -309,7 +309,7 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
                                }
                                syscall = 0;
                        } else {
-                               tracehook_notify_resume(regs);
+                               resume_user_mode_work(regs);
                        }
                }
                local_irq_disable();
index 46b1050640b80c587abe6758868798c68fa87112..2f7ebe9add2030ab6e670605982f5f5b833db937 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/errno.h>
 #include <linux/wait.h>
 #include <linux/ptrace.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/unistd.h>
 #include <linux/stddef.h>
 #include <linux/compat.h>
@@ -602,5 +602,5 @@ void do_notify_resume(struct pt_regs *regs, long in_syscall)
                do_signal(regs, in_syscall);
 
        if (test_thread_flag(TIF_NOTIFY_RESUME))
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index b93b87df499d7e5dfd4cf33f48f6c58d569451db..f7f8620663c70fd523e1512dd1007e34330ec2ea 100644 (file)
@@ -9,7 +9,7 @@
  * this archive for more details.
  */
 
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/signal.h>
 #include <linux/uprobes.h>
 #include <linux/key.h>
@@ -294,7 +294,7 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
        }
 
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
 
 static unsigned long get_tm_stackpointer(struct task_struct *tsk)
index c2d5ecbe552648aba939530cae95ec1f83361d5c..d80bf5896c6fda6bd630568c95f74049a39bda75 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/signal.h>
 #include <linux/uaccess.h>
 #include <linux/syscalls.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/linkage.h>
 
 #include <asm/ucontext.h>
@@ -317,5 +317,5 @@ asmlinkage __visible void do_notify_resume(struct pt_regs *regs,
                do_signal(regs);
 
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index dd3092911efad74200882e1192aa89fd9fe97bdd..90f495d35db29a7e7b139d4541eb20fe053f02ed 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/personality.h>
 #include <linux/binfmts.h>
 #include <linux/io.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <asm/ucontext.h>
 #include <linux/uaccess.h>
 #include <asm/cacheflush.h>
@@ -503,5 +503,5 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
                do_signal(regs, save_r0);
 
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index 6cc124a3bb98a0394ef81d07ba7d1d4b01ca8787..f9fe502b81c65c0818bdd3749dea6434ac1c1ce3 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/binfmts.h>
 #include <linux/compat.h>
 #include <linux/bitops.h>
-#include <linux/tracehook.h>
 
 #include <linux/uaccess.h>
 #include <asm/ptrace.h>
index ffab16369beac82f9fd6cfe243571888f9609a81..80c89b362d8baed49ec93b82a9fdc6dffd9e4532 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/smp.h>
 #include <linux/binfmts.h>     /* do_coredum */
 #include <linux/bitops.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 #include <linux/uaccess.h>
 #include <asm/ptrace.h>
@@ -524,7 +524,7 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,
        if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
                do_signal(regs, orig_i0);
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
 
 asmlinkage int do_sys_sigstack(struct sigstack __user *ssptr,
index 2a78d2af1265525f27a9d08ad88dc23b839968b5..8b9fc76cd3e026c1e2f76256f2b69d820c130399 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/errno.h>
 #include <linux/wait.h>
 #include <linux/ptrace.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/unistd.h>
 #include <linux/mm.h>
 #include <linux/tty.h>
@@ -552,7 +552,7 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long
        if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
                do_signal(regs, orig_i0);
        if (thread_info_flags & _TIF_NOTIFY_RESUME)
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
        user_enter();
 }
 
index 4a420778ed87bb1ef6cabab470e51f0f540e231c..80504680be084f4a7caa7c66b294fc1d0447671c 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/seq_file.h>
 #include <linux/tick.h>
 #include <linux/threads.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <asm/current.h>
 #include <asm/mmu_context.h>
 #include <linux/uaccess.h>
@@ -104,7 +104,7 @@ void interrupt_end(void)
            test_thread_flag(TIF_NOTIFY_SIGNAL))
                do_signal(regs);
        if (test_thread_flag(TIF_NOTIFY_RESUME))
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
 
 int get_current_pid(void)
index f6c949895b3eb197bcf05b6b1610f860d4304446..6f68649e86ba5af13bc130a03ba5c79e1b7b561e 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/errno.h>
 #include <linux/ptrace.h>
 #include <linux/personality.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/sched/task_stack.h>
 
 #include <asm/ucontext.h>
@@ -511,5 +511,5 @@ void do_notify_resume(struct pt_regs *regs)
                do_signal(regs);
 
        if (test_thread_flag(TIF_NOTIFY_RESUME))
-               tracehook_notify_resume(regs);
+               resume_user_mode_work(regs);
 }
index 650f7e27989f1989fa42da3f0a85d21aed221120..4d8be1634bc625a39078b41f23d96bd2c45fdfe7 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/atomic.h>
 #include <linux/ctype.h>
 #include <linux/blk-cgroup.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/psi.h>
 #include <linux/part_stat.h>
 #include "blk.h"
index 07c878d6e323ed0a87eb5033013d3c7755362844..6813171afccb234413cb2fbf18b9cd01e1adbd76 100644 (file)
@@ -3,7 +3,7 @@
 #define __LINUX_ENTRYKVM_H
 
 #include <linux/static_call_types.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/syscalls.h>
 #include <linux/seccomp.h>
 #include <linux/sched.h>
diff --git a/include/linux/resume_user_mode.h b/include/linux/resume_user_mode.h
new file mode 100644 (file)
index 0000000..2851894
--- /dev/null
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef LINUX_RESUME_USER_MODE_H
+#define LINUX_RESUME_USER_MODE_H
+
+#include <linux/sched.h>
+#include <linux/task_work.h>
+#include <linux/memcontrol.h>
+#include <linux/blk-cgroup.h>
+
+/**
+ * set_notify_resume - cause resume_user_mode_work() to be called
+ * @task:              task that will call resume_user_mode_work()
+ *
+ * Calling this arranges that @task will call resume_user_mode_work()
+ * before returning to user mode.  If it's already running in user mode,
+ * it will enter the kernel and call resume_user_mode_work() soon.
+ * If it's blocked, it will not be woken.
+ */
+static inline void set_notify_resume(struct task_struct *task)
+{
+       if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME))
+               kick_process(task);
+}
+
+
+/**
+ * resume_user_mode_work - Perform work before returning to user mode
+ * @regs:              user-mode registers of @current task
+ *
+ * This is called when %TIF_NOTIFY_RESUME has been set.  Now we are
+ * about to return to user mode, and the user state in @regs can be
+ * inspected or adjusted.  The caller in arch code has cleared
+ * %TIF_NOTIFY_RESUME before the call.  If the flag gets set again
+ * asynchronously, this will be called again before we return to
+ * user mode.
+ *
+ * Called without locks.
+ */
+static inline void resume_user_mode_work(struct pt_regs *regs)
+{
+       clear_thread_flag(TIF_NOTIFY_RESUME);
+       /*
+        * This barrier pairs with task_work_add()->set_notify_resume() after
+        * hlist_add_head(task->task_works);
+        */
+       smp_mb__after_atomic();
+       if (unlikely(task_work_pending(current)))
+               task_work_run();
+
+#ifdef CONFIG_KEYS_REQUEST_CACHE
+       if (unlikely(current->cached_requested_key)) {
+               key_put(current->cached_requested_key);
+               current->cached_requested_key = NULL;
+       }
+#endif
+
+       mem_cgroup_handle_over_high();
+       blkcg_maybe_throttle_current();
+
+       rseq_handle_notify_resume(NULL, regs);
+}
+
+#endif /* LINUX_RESUME_USER_MODE_H */
index 946404ebe10b66be3886336093d427d1610878dc..9f6b3fd1880a26538893067820d60838a398b91a 100644 (file)
 struct linux_binprm;
 
 
-/**
- * set_notify_resume - cause tracehook_notify_resume() to be called
- * @task:              task that will call tracehook_notify_resume()
- *
- * Calling this arranges that @task will call tracehook_notify_resume()
- * before returning to user mode.  If it's already running in user mode,
- * it will enter the kernel and call tracehook_notify_resume() soon.
- * If it's blocked, it will not be woken.
- */
-static inline void set_notify_resume(struct task_struct *task)
-{
-       if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME))
-               kick_process(task);
-}
-
-/**
- * tracehook_notify_resume - report when about to return to user mode
- * @regs:              user-mode registers of @current task
- *
- * This is called when %TIF_NOTIFY_RESUME has been set.  Now we are
- * about to return to user mode, and the user state in @regs can be
- * inspected or adjusted.  The caller in arch code has cleared
- * %TIF_NOTIFY_RESUME before the call.  If the flag gets set again
- * asynchronously, this will be called again before we return to
- * user mode.
- *
- * Called without locks.
- */
-static inline void tracehook_notify_resume(struct pt_regs *regs)
-{
-       clear_thread_flag(TIF_NOTIFY_RESUME);
-       /*
-        * This barrier pairs with task_work_add()->set_notify_resume() after
-        * hlist_add_head(task->task_works);
-        */
-       smp_mb__after_atomic();
-       if (unlikely(task_work_pending(current)))
-               task_work_run();
-
-#ifdef CONFIG_KEYS_REQUEST_CACHE
-       if (unlikely(current->cached_requested_key)) {
-               key_put(current->cached_requested_key);
-               current->cached_requested_key = NULL;
-       }
-#endif
-
-       mem_cgroup_handle_over_high();
-       blkcg_maybe_throttle_current();
-
-       rseq_handle_notify_resume(NULL, regs);
-}
 
 #endif /* <linux/tracehook.h> */
index 79eaf9b4b10d1504b42b39de8a4032323f438228..a86823cad8531f08b07fecc5a256f5f05c4db1b4 100644 (file)
@@ -2,7 +2,7 @@
 
 #include <linux/context_tracking.h>
 #include <linux/entry-common.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/highmem.h>
 #include <linux/livepatch.h>
 #include <linux/audit.h>
@@ -165,7 +165,7 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs,
                        arch_do_signal_or_restart(regs);
 
                if (ti_work & _TIF_NOTIFY_RESUME)
-                       tracehook_notify_resume(regs);
+                       resume_user_mode_work(regs);
 
                /* Architecture specific TIF work */
                arch_exit_to_user_mode_work(regs, ti_work);
index 3ab5f98988c3b8c5b60d78ac7ba0505ce6204170..9d09f489b60e0c9872466a0ae6bf0a9fc3c7e23a 100644 (file)
@@ -23,7 +23,7 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work)
                        schedule();
 
                if (ti_work & _TIF_NOTIFY_RESUME)
-                       tracehook_notify_resume(NULL);
+                       resume_user_mode_work(NULL);
 
                ret = arch_xfer_to_guest_mode_handle_work(vcpu, ti_work);
                if (ret)
index cc6fccb0e24dbab0f2f245b4d0b9eb431a5ebf12..c59e1a49bc406c7a2cb0e05a36053dd3ad13a9ba 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/spinlock.h>
 #include <linux/task_work.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 
 static struct callback_head work_exited; /* all we need is ->next == NULL */
 
index 09d342c7cbd0d9f23b3c916c8dab2132e1d35ffe..2aaa400f34d6c9dfc988cb56f41f2ca0a691efb9 100644 (file)
@@ -59,7 +59,7 @@
 #include <linux/oom.h>
 #include <linux/lockdep.h>
 #include <linux/file.h>
-#include <linux/tracehook.h>
+#include <linux/resume_user_mode.h>
 #include <linux/psi.h>
 #include <linux/seq_buf.h>
 #include "internal.h"