svn commit: r343744 - head/sys/powerpc/aim
Leandro Lupori
luporl at FreeBSD.org
Mon Feb 4 16:02:05 UTC 2019
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 at got(%r1)
- addi %r1,%r1,TMPSTKSZ-16
+ lwz %r1,trapstk at 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: */
More information about the svn-src-head
mailing list