Skip to content

Commit 997d79e

Browse files
mrutland-armctmarinas
authored andcommitted
arm64: Move do_notify_resume() to entry-common.c
Currently do_notify_resume() lives in arch/arm64/kernel/signal.c, but it would make more sense for it to live in entry-common.c as it handles more than signals, and is coupled with the rest of the return-to-userspace sequence (e.g. with unusual DAIF masking that matches the exception return requirements). Move do_notify_resume() to entry-common.c. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <[email protected]> Cc: James Morse <[email protected]> Cc: Mark Brown <[email protected]> Cc: Will Deacon <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Tested-by: Itaru Kitayama <[email protected]>
1 parent 270de60 commit 997d79e

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

arch/arm64/include/asm/exception.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void do_el0_fpac(struct pt_regs *regs, unsigned long esr);
7474
void do_el1_fpac(struct pt_regs *regs, unsigned long esr);
7575
void do_el0_mops(struct pt_regs *regs, unsigned long esr);
7676
void do_serror(struct pt_regs *regs, unsigned long esr);
77-
void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags);
77+
void do_signal(struct pt_regs *regs);
7878

7979
void __noreturn panic_bad_stack(struct pt_regs *regs, unsigned long esr, unsigned long far);
8080
#endif /* __ASM_EXCEPTION_H */

arch/arm64/kernel/entry-common.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/linkage.h>
1111
#include <linux/lockdep.h>
1212
#include <linux/ptrace.h>
13+
#include <linux/resume_user_mode.h>
1314
#include <linux/sched.h>
1415
#include <linux/sched/debug.h>
1516
#include <linux/thread_info.h>
@@ -126,6 +127,37 @@ static __always_inline void __exit_to_user_mode(void)
126127
lockdep_hardirqs_on(CALLER_ADDR0);
127128
}
128129

130+
static void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
131+
{
132+
do {
133+
local_daif_restore(DAIF_PROCCTX);
134+
135+
if (thread_flags & _TIF_NEED_RESCHED)
136+
schedule();
137+
138+
if (thread_flags & _TIF_UPROBE)
139+
uprobe_notify_resume(regs);
140+
141+
if (thread_flags & _TIF_MTE_ASYNC_FAULT) {
142+
clear_thread_flag(TIF_MTE_ASYNC_FAULT);
143+
send_sig_fault(SIGSEGV, SEGV_MTEAERR,
144+
(void __user *)NULL, current);
145+
}
146+
147+
if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
148+
do_signal(regs);
149+
150+
if (thread_flags & _TIF_NOTIFY_RESUME)
151+
resume_user_mode_work(regs);
152+
153+
if (thread_flags & _TIF_FOREIGN_FPSTATE)
154+
fpsimd_restore_current_state();
155+
156+
local_daif_mask();
157+
thread_flags = read_thread_flags();
158+
} while (thread_flags & _TIF_WORK_MASK);
159+
}
160+
129161
static __always_inline void exit_to_user_mode_prepare(struct pt_regs *regs)
130162
{
131163
unsigned long flags;

arch/arm64/kernel/signal.c

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include <linux/uaccess.h>
1717
#include <linux/sizes.h>
1818
#include <linux/string.h>
19-
#include <linux/resume_user_mode.h>
2019
#include <linux/ratelimit.h>
20+
#include <linux/rseq.h>
2121
#include <linux/syscalls.h>
2222

2323
#include <asm/daifflags.h>
@@ -1207,7 +1207,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
12071207
* the kernel can handle, and then we build all the user-level signal handling
12081208
* stack-frames in one go after that.
12091209
*/
1210-
static void do_signal(struct pt_regs *regs)
1210+
void do_signal(struct pt_regs *regs)
12111211
{
12121212
unsigned long continue_addr = 0, restart_addr = 0;
12131213
int retval = 0;
@@ -1278,37 +1278,6 @@ static void do_signal(struct pt_regs *regs)
12781278
restore_saved_sigmask();
12791279
}
12801280

1281-
void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
1282-
{
1283-
do {
1284-
local_daif_restore(DAIF_PROCCTX);
1285-
1286-
if (thread_flags & _TIF_NEED_RESCHED)
1287-
schedule();
1288-
1289-
if (thread_flags & _TIF_UPROBE)
1290-
uprobe_notify_resume(regs);
1291-
1292-
if (thread_flags & _TIF_MTE_ASYNC_FAULT) {
1293-
clear_thread_flag(TIF_MTE_ASYNC_FAULT);
1294-
send_sig_fault(SIGSEGV, SEGV_MTEAERR,
1295-
(void __user *)NULL, current);
1296-
}
1297-
1298-
if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
1299-
do_signal(regs);
1300-
1301-
if (thread_flags & _TIF_NOTIFY_RESUME)
1302-
resume_user_mode_work(regs);
1303-
1304-
if (thread_flags & _TIF_FOREIGN_FPSTATE)
1305-
fpsimd_restore_current_state();
1306-
1307-
local_daif_mask();
1308-
thread_flags = read_thread_flags();
1309-
} while (thread_flags & _TIF_WORK_MASK);
1310-
}
1311-
13121281
unsigned long __ro_after_init signal_minsigstksz;
13131282

13141283
/*

0 commit comments

Comments
 (0)