linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: [RFC PATCH 18/19] powerpc: change stack marker memory operations to 32-bit
Date: Mon, 31 Oct 2022 15:54:39 +1000	[thread overview]
Message-ID: <20221031055440.3594315-19-npiggin@gmail.com> (raw)
In-Reply-To: <20221031055440.3594315-1-npiggin@gmail.com>

The marker is a 32-bit constant across all platforms now, so use 32-bit
memory accesses.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/include/asm/ptrace.h    | 1 -
 arch/powerpc/kernel/exceptions-64e.S | 2 +-
 arch/powerpc/kernel/exceptions-64s.S | 2 +-
 arch/powerpc/kernel/interrupt_64.S   | 6 +++---
 arch/powerpc/kernel/process.c        | 6 +++---
 arch/powerpc/kernel/stacktrace.c     | 2 +-
 arch/powerpc/perf/callchain.c        | 2 +-
 7 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index a53c580388e2..ab41d47761c9 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -162,7 +162,6 @@ struct pt_regs
 #endif /* __powerpc64__ */
 
 #define STACK_INT_FRAME_SIZE	(KERNEL_REDZONE_SIZE + STACK_USER_INT_FRAME_SIZE)
-#define STACK_INT_FRAME_MARKER_LONGS	(STACK_INT_FRAME_MARKER/sizeof(long))
 
 #ifndef __ASSEMBLY__
 #include <asm/paca.h>
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index d74c2a53af13..86cf656c6777 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -391,7 +391,7 @@ exc_##n##_common:							    \
 	std	r10,_CCR(r1);		/* store orig CR in stackframe */   \
 	std	r9,GPR1(r1);		/* store stack frame back link */   \
 	std	r11,SOFTE(r1);		/* and save it to stackframe */     \
-	std	r12,STACK_INT_FRAME_MARKER(r1); /* mark the frame */	    \
+	stw	r12,STACK_INT_FRAME_MARKER(r1); /* mark the frame */	    \
 	std	r3,_TRAP(r1);		/* set trap number		*/  \
 	std	r0,RESULT(r1);		/* clear regs->result */	    \
 	SAVE_NVGPRS(r1);
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 39f08ec56126..85bbdfa7e4d3 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -591,7 +591,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 	li	r10,0
 	LOAD_REG_IMMEDIATE(r11, STACK_FRAME_REGS_MARKER)
 	std	r10,RESULT(r1)		/* clear regs->result		*/
-	std	r11,STACK_INT_FRAME_MARKER(r1) /* mark the frame	*/
+	stw	r11,STACK_INT_FRAME_MARKER(r1) /* mark the frame	*/
 .endm
 
 /*
diff --git a/arch/powerpc/kernel/interrupt_64.S b/arch/powerpc/kernel/interrupt_64.S
index 2306b979e71f..ee8cfe17ca37 100644
--- a/arch/powerpc/kernel/interrupt_64.S
+++ b/arch/powerpc/kernel/interrupt_64.S
@@ -78,7 +78,7 @@ _ASM_NOKPROBE_SYMBOL(system_call_vectored_\name)
 	std	r12,_CCR(r1)
 	std	r3,ORIG_GPR3(r1)
 	LOAD_REG_IMMEDIATE(r11, STACK_FRAME_REGS_MARKER)
-	std	r11,STACK_INT_FRAME_MARKER(r1)		/* "regs" marker */
+	stw	r11,STACK_INT_FRAME_MARKER(r1)		/* "regs" marker */
 	/* Calling convention has r3 = regs, r4 = orig r0 */
 	addi	r3,r1,STACK_INT_FRAME_REGS
 	mr	r4,r0
@@ -251,7 +251,7 @@ END_BTB_FLUSH_SECTION
 	std	r12,_CCR(r1)
 	std	r3,ORIG_GPR3(r1)
 	LOAD_REG_IMMEDIATE(r11, STACK_FRAME_REGS_MARKER)
-	std	r11,STACK_INT_FRAME_MARKER(r1)		/* "regs" marker */
+	stw	r11,STACK_INT_FRAME_MARKER(r1)		/* "regs" marker */
 	/* Calling convention has r3 = regs, r4 = orig r0 */
 	addi	r3,r1,STACK_INT_FRAME_REGS
 	mr	r4,r0
@@ -628,7 +628,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
 	 * Leaving a stale STACK_FRAME_REGS_MARKER on the stack can confuse
 	 * the reliable stack unwinder later on. Clear it.
 	 */
-	std	r0,STACK_INT_FRAME_MARKER(r1)
+	stw	r0,STACK_INT_FRAME_MARKER(r1)
 
 	REST_GPRS(2, 5, r1)
 
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 20fdb84759f0..e447bf02f996 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1728,7 +1728,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
 
 	/* Create initial stack frame. */
 	sp -= STACK_USER_INT_FRAME_SIZE;
-	*(unsigned long *)(sp + STACK_INT_FRAME_MARKER) = STACK_FRAME_REGS_MARKER;
+	*(u32 *)(sp + STACK_INT_FRAME_MARKER) = STACK_FRAME_REGS_MARKER;
 
 	/* Copy registers */
 	childregs = (struct pt_regs *)(sp + STACK_INT_FRAME_REGS);
@@ -2246,8 +2246,8 @@ void __no_sanitize_address show_stack(struct task_struct *tsk,
 		 * could hold a pt_regs, if that does not fit then it can't
 		 * have regs.
 		 */
-		if (validate_sp_size(sp, tsk, STACK_SWITCH_FRAME_SIZE)
-		    && stack[STACK_INT_FRAME_MARKER_LONGS] == STACK_FRAME_REGS_MARKER) {
+		if (validate_sp_size(sp, tsk, STACK_SWITCH_FRAME_SIZE) &&
+		    *(u32 *)(sp + STACK_INT_FRAME_MARKER) == STACK_FRAME_REGS_MARKER) {
 			struct pt_regs *regs = (struct pt_regs *)
 				(sp + STACK_INT_FRAME_REGS);
 
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 5de8597eaab8..7d975943f5ec 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -136,7 +136,7 @@ int __no_sanitize_address arch_stack_walk_reliable(stack_trace_consume_fn consum
 
 		/* Mark stacktraces with exception frames as unreliable. */
 		if (sp <= stack_end - STACK_INT_FRAME_SIZE &&
-		    stack[STACK_INT_FRAME_MARKER_LONGS] == STACK_FRAME_REGS_MARKER) {
+		    *(u32 *)(sp + STACK_INT_FRAME_MARKER) == STACK_FRAME_REGS_MARKER) {
 			return -EINVAL;
 		}
 
diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
index 6b4434dd0ff3..72eef9accdbb 100644
--- a/arch/powerpc/perf/callchain.c
+++ b/arch/powerpc/perf/callchain.c
@@ -62,7 +62,7 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
 
 		if (next_sp == sp + STACK_INT_FRAME_SIZE &&
 		    validate_sp_size(sp, current, STACK_INT_FRAME_SIZE) &&
-		    fp[STACK_INT_FRAME_MARKER_LONGS] == STACK_FRAME_REGS_MARKER) {
+		    *(u32 *)(sp + STACK_INT_FRAME_MARKER) == STACK_FRAME_REGS_MARKER) {
 			/*
 			 * This looks like an interrupt frame for an
 			 * interrupt that occurred in the kernel
-- 
2.37.2


  parent reply	other threads:[~2022-10-31  6:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31  5:54 [RFC PATCH 00/19] Remove STACK_FRAME_OVERHEAD Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 01/19] powerpc/perf: callchain validate kernel stack pointer bounds Nicholas Piggin
2022-11-04 13:10   ` Segher Boessenkool
2022-10-31  5:54 ` [RFC PATCH 02/19] powerpc: Rearrange copy_thread child stack creation Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 03/19] powerpc/64: Remove asm interrupt tracing call helpers Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 04/19] powerpc/pseries: hvcall stack frame overhead Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 05/19] powerpc/32: Use load and store multiple in GPR save/restore macros Nicholas Piggin
2022-11-03  8:26   ` Christophe Leroy
2022-11-07 12:45     ` Nicholas Piggin
2022-11-07 12:51       ` Christophe Leroy
2022-10-31  5:54 ` [RFC PATCH 06/19] powerpc: simplify ppc_save_regs Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 07/19] powerpc: add definition for pt_regs offset within an interrupt frame Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 08/19] powerpc: add a definition for the marker offset within the " Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 09/19] powerpc: Rename STACK_FRAME_MARKER and derive it from frame offset Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 10/19] powerpc: add a define for the user interrupt frame size Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 11/19] powerpc: add a define for the switch frame size and regs offset Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 12/19] powerpc: copy_thread fill in interrupt frame marker and back chain Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 13/19] powerpc: copy_thread add a back chain to the switch stack frame Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 14/19] powerpc: split validate_sp into two functions Nicholas Piggin
2022-11-07  0:58   ` Russell Currey
2022-11-07 12:29     ` Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 15/19] powerpc: allow minimum sized kernel stack frames Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 16/19] powerpc/64: ELFv2 use minimal stack frames in int and switch frame sizes Nicholas Piggin
2022-10-31  5:54 ` [RFC PATCH 17/19] powerpc: remove STACK_FRAME_OVERHEAD Nicholas Piggin
2022-10-31  5:54 ` Nicholas Piggin [this message]
2022-10-31  5:54 ` [RFC PATCH 19/19] powerpc/64: ELFv2 use reserved word in the stack frame for the regs marker Nicholas Piggin

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=20221031055440.3594315-19-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.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).