linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: set stack limit properly in crit_transfer_to_handler
@ 2012-07-16 19:06 Stuart Yoder
  2012-07-16 20:36 ` Kumar Gala
  0 siblings, 1 reply; 3+ messages in thread
From: Stuart Yoder @ 2012-07-16 19:06 UTC (permalink / raw)
  To: benh; +Cc: sfr, Stuart Yoder, paulus, linuxppc-dev, agraf

From: Stuart Yoder <stuart.yoder@freescale.com>

without setting the stack limit like this there is the possibility
of stack overflow which corrupts the thread info but
is not detected by stack overflow detection

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
---
 arch/powerpc/kernel/entry_32.S |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 5207d5a..ead5016 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -89,10 +89,14 @@ crit_transfer_to_handler:
 	mfspr	r0,SPRN_SRR1
 	stw	r0,_SRR1(r11)
 
+	/* set the stack limit to the current stack
+	 * and set the limit to protect the thread_info
+	 * struct
+	 */
 	mfspr	r8,SPRN_SPRG_THREAD
 	lwz	r0,KSP_LIMIT(r8)
 	stw	r0,SAVED_KSP_LIMIT(r11)
-	CURRENT_THREAD_INFO(r0, r1)
+	rlwimi	r0,r1,0,0,(31-THREAD_SHIFT)
 	stw	r0,KSP_LIMIT(r8)
 	/* fall through */
 #endif
@@ -109,10 +113,14 @@ crit_transfer_to_handler:
 	mfspr	r0,SPRN_SRR1
 	stw	r0,crit_srr1@l(0)
 
+	/* set the stack limit to the current stack
+	 * and set the limit to protect the thread_info
+	 * struct
+	 */
 	mfspr	r8,SPRN_SPRG_THREAD
 	lwz	r0,KSP_LIMIT(r8)
 	stw	r0,saved_ksp_limit@l(0)
-	CURRENT_THREAD_INFO(r0, r1)
+	rlwimi	r0,r1,0,0,(31-THREAD_SHIFT)
 	stw	r0,KSP_LIMIT(r8)
 	/* fall through */
 #endif
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: set stack limit properly in crit_transfer_to_handler
  2012-07-16 19:06 [PATCH] powerpc: set stack limit properly in crit_transfer_to_handler Stuart Yoder
@ 2012-07-16 20:36 ` Kumar Gala
  2012-07-16 21:20   ` Yoder Stuart-B08248
  0 siblings, 1 reply; 3+ messages in thread
From: Kumar Gala @ 2012-07-16 20:36 UTC (permalink / raw)
  To: Stuart Yoder; +Cc: agraf, paulus, linuxppc-dev, sfr


On Jul 16, 2012, at 2:06 PM, Stuart Yoder wrote:

> From: Stuart Yoder <stuart.yoder@freescale.com>
> 
> without setting the stack limit like this there is the possibility
> of stack overflow which corrupts the thread info but
> is not detected by stack overflow detection
> 
> Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
> ---
> arch/powerpc/kernel/entry_32.S |   12 ++++++++++--
> 1 files changed, 10 insertions(+), 2 deletions(-)

Do we need this for debug & mcheck ?

- k

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] powerpc: set stack limit properly in crit_transfer_to_handler
  2012-07-16 20:36 ` Kumar Gala
@ 2012-07-16 21:20   ` Yoder Stuart-B08248
  0 siblings, 0 replies; 3+ messages in thread
From: Yoder Stuart-B08248 @ 2012-07-16 21:20 UTC (permalink / raw)
  To: Kumar Gala
  Cc: agraf@suse.de, paulus@samba.org, linuxppc-dev@lists.ozlabs.org,
	sfr@canb.auug.org.au



> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Monday, July 16, 2012 3:36 PM
> To: Yoder Stuart-B08248
> Cc: benh@kernel.crashing.org; sfr@canb.auug.org.au; paulus@samba.org; lin=
uxppc-dev@lists.ozlabs.org;
> agraf@suse.de
> Subject: Re: [PATCH] powerpc: set stack limit properly in crit_transfer_t=
o_handler
>=20
>=20
> On Jul 16, 2012, at 2:06 PM, Stuart Yoder wrote:
>=20
> > From: Stuart Yoder <stuart.yoder@freescale.com>
> >
> > without setting the stack limit like this there is the possibility
> > of stack overflow which corrupts the thread info but
> > is not detected by stack overflow detection
> >
> > Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
> > ---
> > arch/powerpc/kernel/entry_32.S |   12 ++++++++++--
> > 1 files changed, 10 insertions(+), 2 deletions(-)
>=20
> Do we need this for debug & mcheck ?

Maybe... I don't know the history of this code
and why this is only done in the critical exception
handlers.

But, this particular patch is to undo/fix something I
introduced in:
powerpc: Use CURRENT_THREAD_INFO instead of open coded assembly

Stuart

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-16 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-16 19:06 [PATCH] powerpc: set stack limit properly in crit_transfer_to_handler Stuart Yoder
2012-07-16 20:36 ` Kumar Gala
2012-07-16 21:20   ` Yoder Stuart-B08248

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).