Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jun 2019 14:19:54 +0000 (UTC)
From:      Leandro Lupori <luporl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r348690 - stable/12/sys/powerpc/aim
Message-ID:  <201906051419.x55EJsT5050659@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luporl
Date: Wed Jun  5 14:19:54 2019
New Revision: 348690
URL: https://svnweb.freebsd.org/changeset/base/348690

Log:
  MFC r343744:
  
  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:
  stable/12/sys/powerpc/aim/locore32.S
  stable/12/sys/powerpc/aim/locore64.S
  stable/12/sys/powerpc/aim/trap_subr32.S
  stable/12/sys/powerpc/aim/trap_subr64.S
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/powerpc/aim/locore32.S
==============================================================================
--- stable/12/sys/powerpc/aim/locore32.S	Wed Jun  5 14:08:39 2019	(r348689)
+++ stable/12/sys/powerpc/aim/locore32.S	Wed Jun  5 14:19:54 2019	(r348690)
@@ -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: stable/12/sys/powerpc/aim/locore64.S
==============================================================================
--- stable/12/sys/powerpc/aim/locore64.S	Wed Jun  5 14:08:39 2019	(r348689)
+++ stable/12/sys/powerpc/aim/locore64.S	Wed Jun  5 14:19:54 2019	(r348690)
@@ -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: stable/12/sys/powerpc/aim/trap_subr32.S
==============================================================================
--- stable/12/sys/powerpc/aim/trap_subr32.S	Wed Jun  5 14:08:39 2019	(r348689)
+++ stable/12/sys/powerpc/aim/trap_subr32.S	Wed Jun  5 14:19:54 2019	(r348690)
@@ -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: stable/12/sys/powerpc/aim/trap_subr64.S
==============================================================================
--- stable/12/sys/powerpc/aim/trap_subr64.S	Wed Jun  5 14:08:39 2019	(r348689)
+++ stable/12/sys/powerpc/aim/trap_subr64.S	Wed Jun  5 14:19:54 2019	(r348690)
@@ -900,8 +900,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?201906051419.x55EJsT5050659>