From owner-svn-src-head@freebsd.org Tue Sep 3 14:06:48 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5A2A5DCF74; Tue, 3 Sep 2019 14:06:48 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N7zq6ZDjz4PwB; Tue, 3 Sep 2019 14:06:47 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id B48E41ABC9; Tue, 3 Sep 2019 14:06:17 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 5F9BC9A7; Sat, 13 Apr 2019 03:32:26 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 814E36AD92; Sat, 13 Apr 2019 03:32:25 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 0FDD8951; Sat, 13 Apr 2019 03:32:25 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 8369394D for ; Sat, 13 Apr 2019 03:32:22 +0000 (UTC) (envelope-from jhibbits@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 3532C6AD81; Sat, 13 Apr 2019 03:32:22 +0000 (UTC) (envelope-from jhibbits@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 04CE030E7; Sat, 13 Apr 2019 03:32:22 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3D3WL6d005784; Sat, 13 Apr 2019 03:32:21 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3D3WLgC005780; Sat, 13 Apr 2019 03:32:21 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904130332.x3D3WLgC005780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346173 - head/sys/cddl/dev/dtrace/powerpc X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/cddl/dev/dtrace/powerpc X-SVN-Commit-Revision: 346173 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 814E36AD92 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)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.961,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Status: O X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Tue, 03 Sep 2019 14:06:48 -0000 X-Original-Date: Sat, 13 Apr 2019 03:32:21 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:06:48 -0000 Author: jhibbits Date: Sat Apr 13 03:32:21 2019 New Revision: 346173 URL: https://svnweb.freebsd.org/changeset/base/346173 Log: powerpc/dtrace: Fix dtrace powerpc asm, and simplify stack walking Fix some execution bugs in the dtrace powerpc asm. addme pulls in the carry flag which we don't want, and the result wasn't recorded anyways, so the following beq to check for exit condition wasn't checking the right condition. Simplify the stack walking in dtrace_isa.c, so there's only a single walker that handles both pc and sp. This should make it easier to follow, and any bugfix that may be needed for walking only needs to be made in one place instead of two now. MFC after: 2 weeks Modified: head/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S head/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c Modified: head/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S ============================================================================== --- head/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S Sat Apr 13 02:29:30 2019 (r346172) +++ head/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S Sat Apr 13 03:32:21 2019 (r346173) @@ -148,14 +148,19 @@ dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_ volatile uint16_t *flags) */ ASENTRY_NOPROF(dtrace_copystr) - addme %r7,%r3 - addme %r8,%r4 + subi %r7,%r3,1 + subi %r8,%r4,1 1: lbzu %r3,1(%r7) stbu %r3,1(%r8) - addme %r5,%r5 + subi %r5,%r5,1 +#ifdef __powerpc64__ + cmpldi %r5,0 +#else + cmplwi %r5,0 +#endif beq 2f - or %r3,%r3,%r3 + cmplwi %r3,0 beq 2f andi. %r0,%r5,0x0fff beq 2f Modified: head/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c ============================================================================== --- head/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c Sat Apr 13 02:29:30 2019 (r346172) +++ head/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c Sat Apr 13 03:32:21 2019 (r346173) @@ -94,11 +94,10 @@ dtrace_sp_inkernel(uintptr_t sp) return (1); } -static __inline uintptr_t -dtrace_next_sp(uintptr_t sp) +static __inline void +dtrace_next_sp_pc(uintptr_t sp, uintptr_t *nsp, uintptr_t *pc) { vm_offset_t callpc; - uintptr_t *r1; struct trapframe *frame; #ifdef __powerpc64__ @@ -115,39 +114,17 @@ dtrace_next_sp(uintptr_t sp) callpc + OFFSET == (vm_offset_t) &asttrapexit)) { /* Access the trap frame */ frame = (struct trapframe *)(sp + FRAME_OFFSET); - r1 = (uintptr_t *)frame->fixreg[1]; - if (r1 == NULL) - return (0); - return (*r1); - } - return (*(uintptr_t*)sp); -} - -static __inline uintptr_t -dtrace_get_pc(uintptr_t sp) -{ - struct trapframe *frame; - vm_offset_t callpc; - -#ifdef __powerpc64__ - callpc = *(vm_offset_t *)(sp + RETURN_OFFSET64); -#else - callpc = *(vm_offset_t *)(sp + RETURN_OFFSET); -#endif - - /* - * trapexit() and asttrapexit() are sentinels - * for kernel stack tracing. - */ - if ((callpc + OFFSET == (vm_offset_t) &trapexit || - callpc + OFFSET == (vm_offset_t) &asttrapexit)) { - /* Access the trap frame */ - frame = (struct trapframe *)(sp + FRAME_OFFSET); - return (frame->srr0); + if (nsp != NULL) + *nsp = frame->fixreg[1]; + if (pc != NULL) + *pc = frame->srr0; } - return (callpc); + if (nsp != NULL) + *nsp = *(uintptr_t *)sp; + if (pc != NULL) + *pc = callpc; } greg_t @@ -179,7 +156,8 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, in if (!dtrace_sp_inkernel(sp)) break; - callpc = dtrace_get_pc(sp); + osp = sp; + dtrace_next_sp_pc(osp, &sp, &callpc); if (aframes > 0) { aframes--; @@ -190,9 +168,6 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, in else { pcstack[depth++] = callpc; } - - osp = sp; - sp = dtrace_next_sp(sp); } for (; depth < pcstack_limit; depth++) { @@ -546,7 +521,7 @@ dtrace_getstackdepth(int aframes) else aframes--; osp = sp; - sp = dtrace_next_sp(sp); + dtrace_next_sp_pc(sp, &sp, NULL); } if (depth < aframes) return (0);