From owner-svn-src-stable-12@freebsd.org Wed Jun 5 14:19:56 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 512CC15AF37E; Wed, 5 Jun 2019 14:19:56 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EC5CD84E48; Wed, 5 Jun 2019 14:19:55 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C15746276; Wed, 5 Jun 2019 14:19:55 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55EJtkK050663; Wed, 5 Jun 2019 14:19:55 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55EJsT5050659; Wed, 5 Jun 2019 14:19:54 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201906051419.x55EJsT5050659@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 5 Jun 2019 14:19:54 +0000 (UTC) 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 X-SVN-Group: stable-12 X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: stable/12/sys/powerpc/aim X-SVN-Commit-Revision: 348690 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EC5CD84E48 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 14:19:56 -0000 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: */