diff mbox series

[REVIEW,5/9] signal/powerpc: Factor the common exception code into exception_common

Message ID 20180918175850.4437-5-ebiederm@xmission.com (mailing list archive)
State Not Applicable
Headers show
Series signal/powerpc: siginfo cleanups | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied
snowpatch_ozlabs/checkpatch warning Test checkpatch on branch next

Commit Message

Eric W. Biederman Sept. 18, 2018, 5:58 p.m. UTC
It is brittle and wrong to populate si_pkey when there was not a pkey
exception.  The field does not exist for all si_codes and in some
cases another field exists in the same memory location.

So factor out the code that all exceptions handlers must run
into exception_common, leaving the individual exception handlers
to generate the signals themselves.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 arch/powerpc/kernel/traps.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Stephen Rothwell Sept. 21, 2018, 8:38 a.m. UTC | #1
Hi Eric,

On Tue, 18 Sep 2018 19:58:46 +0200 "Eric W. Biederman" <ebiederm@xmission.com> wrote:
>
> It is brittle and wrong to populate si_pkey when there was not a pkey
> exception.  The field does not exist for all si_codes and in some
> cases another field exists in the same memory location.
> 
> So factor out the code that all exceptions handlers must run
> into exception_common, leaving the individual exception handlers
> to generate the signals themselves.
> 
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

Clearly no change in semantics.

Reviewed-by: Stephen Rothwell <sfr@canb.auug.org.au>
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index f651fa91cdc9..f6c778b5144f 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -338,14 +338,12 @@  static void show_signal_msg(int signr, struct pt_regs *regs, int code,
 	show_user_instructions(regs);
 }
 
-void _exception_pkey(int signr, struct pt_regs *regs, int code,
-		     unsigned long addr, int key)
+static bool exception_common(int signr, struct pt_regs *regs, int code,
+			      unsigned long addr)
 {
-	siginfo_t info;
-
 	if (!user_mode(regs)) {
 		die("Exception in kernel mode", regs, signr);
-		return;
+		return false;
 	}
 
 	show_signal_msg(signr, regs, code, addr);
@@ -361,6 +359,16 @@  void _exception_pkey(int signr, struct pt_regs *regs, int code,
 	 */
 	thread_pkey_regs_save(&current->thread);
 
+	return true;
+}
+
+void _exception_pkey(int signr, struct pt_regs *regs, int code, unsigned long addr, int key)
+{
+	siginfo_t info;
+
+	if (!exception_common(signr, regs, code, addr))
+		return;
+
 	clear_siginfo(&info);
 	info.si_signo = signr;
 	info.si_code = code;