[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250129132148.301937-2-npiggin@gmail.com>
Date: Wed, 29 Jan 2025 23:21:42 +1000
From: Nicholas Piggin <npiggin@...il.com>
To: "Dmitry V. Levin" <ldv@...ace.io>
Cc: Nicholas Piggin <npiggin@...il.com>,
Oleg Nesterov <oleg@...hat.com>,
Eugene Syromyatnikov <evgsyr@...il.com>,
Mike Frysinger <vapier@...too.org>,
Renzo Davoli <renzo@...unibo.it>,
Davide Berardi <berardi.dav@...il.com>,
strace-devel@...ts.strace.io,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 1/2] powerpc/signal: Clean up pt_regs access
There are places in signal code that are made more readable by using a
'regs' local variable instead of finding it from the task.
Signed-off-by: Nicholas Piggin <npiggin@...il.com>
---
arch/powerpc/kernel/signal.c | 11 ++++++-----
arch/powerpc/kernel/signal_64.c | 5 +++--
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index aa17e62f3754..193211b04805 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -242,6 +242,7 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
static void do_signal(struct task_struct *tsk)
{
+ struct pt_regs *regs = tsk->thread.regs;
sigset_t *oldset = sigmask_to_save();
struct ksignal ksig = { .sig = 0 };
int ret;
@@ -251,12 +252,12 @@ static void do_signal(struct task_struct *tsk)
get_signal(&ksig);
/* Is there any syscall restart business here ? */
- check_syscall_restart(tsk->thread.regs, &ksig.ka, ksig.sig > 0);
+ check_syscall_restart(regs, &ksig.ka, ksig.sig > 0);
if (ksig.sig <= 0) {
/* No signal to deliver -- put the saved sigmask back */
restore_saved_sigmask();
- set_trap_norestart(tsk->thread.regs);
+ set_trap_norestart(regs);
return; /* no signals delivered */
}
@@ -275,9 +276,9 @@ static void do_signal(struct task_struct *tsk)
}
/* Re-enable the breakpoints for the signal stack */
- thread_change_pc(tsk, tsk->thread.regs);
+ thread_change_pc(tsk, regs);
- rseq_signal_deliver(&ksig, tsk->thread.regs);
+ rseq_signal_deliver(&ksig, regs);
if (is_32bit_task()) {
if (ksig.ka.sa.sa_flags & SA_SIGINFO)
@@ -288,7 +289,7 @@ static void do_signal(struct task_struct *tsk)
ret = handle_rt_signal64(&ksig, oldset, tsk);
}
- set_trap_norestart(tsk->thread.regs);
+ set_trap_norestart(regs);
signal_setup_done(ret, &ksig, test_thread_flag(TIF_SINGLESTEP));
}
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 86bb5bb4c143..1f0c43baeff2 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -748,6 +748,8 @@ SYSCALL_DEFINE0(rt_sigreturn)
sigset_t set;
unsigned long msr;
+ BUG_ON(regs != current->thread.regs);
+
/* Always make any pending restarted system calls return -EINTR */
current->restart_block.fn = do_no_restart_syscall;
@@ -827,8 +829,7 @@ SYSCALL_DEFINE0(rt_sigreturn)
* MSR[TS] set, but without CPU in the proper state,
* causing a TM bad thing.
*/
- regs_set_return_msr(current->thread.regs,
- current->thread.regs->msr & ~MSR_TS_MASK);
+ regs_set_return_msr(regs, regs->msr & ~MSR_TS_MASK);
if (!user_read_access_begin(&uc->uc_mcontext, sizeof(uc->uc_mcontext)))
goto badframe;
--
2.47.1
Powered by blists - more mailing lists