Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Feb 2019 16:02:04 +0000 (UTC)
From:      Leandro Lupori <luporl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343744 - head/sys/powerpc/aim
Message-ID:  <201902041602.x14G24bU015064@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luporl
Date: Mon Feb  4 16:02:03 2019
New Revision: 343744
URL: https://svnweb.freebsd.org/changeset/base/343744

Log:
  powerpc64: Add a trap stack area
  
  Currently, the trap code switches to the the temporary stack in the dbtrap
  section. It works in most cases, but in the beginning of the execution, the
  temp stack is being used, as starting in the powerpc_init() code.
  
  In this current scenario, the stack is being overwritten, which causes the
  return of breakpoint() to take abnormal execution.
  
  This current patchset create a small stack to use by the dbtrap: codepath
  avoiding the corruption of the temporary stack.
  
  PR:		224872
  Submitted by:	breno.leitao_gmail.com
  Reviewed by:	jhibbits
  Differential Revision:	https://reviews.freebsd.org/D14484

Modified:
  head/sys/powerpc/aim/locore32.S
  head/sys/powerpc/aim/locore64.S
  head/sys/powerpc/aim/trap_subr32.S
  head/sys/powerpc/aim/trap_subr64.S

Modified: head/sys/powerpc/aim/locore32.S
==============================================================================
--- head/sys/powerpc/aim/locore32.S	Mon Feb  4 14:10:31 2019	(r343743)
+++ head/sys/powerpc/aim/locore32.S	Mon Feb  4 16:02:03 2019	(r343744)
@@ -60,6 +60,12 @@ GLOBAL(__endkernel)
 GLOBAL(tmpstk)
 	.space	TMPSTKSZ
 
+#ifdef KDB
+#define TRAPSTKSZ       4096            /* 4k trap stack */
+GLOBAL(trapstk)
+        .space        TRAPSTKSZ
+#endif
+
 	.text
 	.globl	btext
 btext:

Modified: head/sys/powerpc/aim/locore64.S
==============================================================================
--- head/sys/powerpc/aim/locore64.S	Mon Feb  4 14:10:31 2019	(r343743)
+++ head/sys/powerpc/aim/locore64.S	Mon Feb  4 16:02:03 2019	(r343744)
@@ -65,6 +65,14 @@ GLOBAL(tmpstk)
 TOC_ENTRY(tmpstk)
 TOC_ENTRY(can_wakeup)
 
+#ifdef KDB
+#define TRAPSTKSZ       4096            /* 4k trap stack */
+GLOBAL(trapstk)
+        .space        TRAPSTKSZ
+TOC_ENTRY(trapstk)
+#endif
+
+
 /*
  * Entry point for bootloaders that do not fully implement ELF and start
  * at the beginning of the image (kexec, notably). In its own section so

Modified: head/sys/powerpc/aim/trap_subr32.S
==============================================================================
--- head/sys/powerpc/aim/trap_subr32.S	Mon Feb  4 14:10:31 2019	(r343743)
+++ head/sys/powerpc/aim/trap_subr32.S	Mon Feb  4 16:02:03 2019	(r343744)
@@ -864,8 +864,8 @@ dbtrap:
 	mtsprg3	%r1
 
 	lwz	%r1,TRAP_TOCBASE(0)		/* get new SP */
-	lwz	%r1,tmpstk@got(%r1)
-	addi	%r1,%r1,TMPSTKSZ-16
+	lwz	%r1,trapstk@got(%r1)
+	addi	%r1,%r1,TRAPSTKSZ-16
 
 	FRAME_SETUP(PC_DBSAVE)
 /* Call C trap code: */

Modified: head/sys/powerpc/aim/trap_subr64.S
==============================================================================
--- head/sys/powerpc/aim/trap_subr64.S	Mon Feb  4 14:10:31 2019	(r343743)
+++ head/sys/powerpc/aim/trap_subr64.S	Mon Feb  4 16:02:03 2019	(r343744)
@@ -897,8 +897,8 @@ dbtrap:
 	mtsprg3	%r1
 
 	GET_TOCBASE(%r1)			/* get new SP */
-	ld	%r1,TOC_REF(tmpstk)(%r1)
-	addi	%r1,%r1,(TMPSTKSZ-48)
+	ld	%r1,TOC_REF(trapstk)(%r1)
+	addi	%r1,%r1,(TRAPSTKSZ-48)
 
 	FRAME_SETUP(PC_DBSAVE)
 /* Call C trap code: */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902041602.x14G24bU015064>