linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: "Dmitry V. Levin" <ldv@strace.io>
Cc: Nicholas Piggin <npiggin@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Eugene Syromyatnikov <evgsyr@gmail.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Renzo Davoli <renzo@cs.unibo.it>,
	Davide Berardi <berardi.dav@gmail.com>,
	strace-devel@lists.strace.io,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/2] powerpc/signal: Clean up pt_regs access
Date: Wed, 29 Jan 2025 23:21:42 +1000	[thread overview]
Message-ID: <20250129132148.301937-2-npiggin@gmail.com> (raw)
In-Reply-To: <20250129132148.301937-1-npiggin@gmail.com>

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@gmail.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



  reply	other threads:[~2025-01-29 13:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-29 13:21 [RFC PATCH 0/2] powerpc: change syscall error return scheme Nicholas Piggin
2025-01-29 13:21 ` Nicholas Piggin [this message]
2025-01-29 13:21 ` [RFC PATCH 2/2] powerpc/syscall: rework syscall return value handling Nicholas Piggin
2025-01-29 14:15 ` [RFC PATCH 0/2] powerpc: change syscall error return scheme Dmitry V. Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250129132148.301937-2-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=berardi.dav@gmail.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=evgsyr@gmail.com \
    --cc=ldv@strace.io \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=oleg@redhat.com \
    --cc=renzo@cs.unibo.it \
    --cc=strace-devel@lists.strace.io \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).