From nobody Wed Mar 15 20:47:03 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PcMrm0lvBz3xlxH; Wed, 15 Mar 2023 20:47:04 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PcMrl72VSz3vcK; Wed, 15 Mar 2023 20:47:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678913224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0HQZt51Y1CJ0iZmE/gfg+083rB07iD0gF6t2/0gmzQQ=; b=lMDDGiD+nQx28yYnw8jnGhHdNzhh4u581trL1z8rpk9cG4VcCqxNjflV/PpBEY2H6Xy1iA 5KewWTJCd4KIYpwx5F6O9skZTvmEYJWz60TlP2D8uNEB4cb2OWjHpLIaEYeLqo02YQ39mc b0p097Ja1hFsxQzNegkyTmpjTx3vxyBv8AfEuHMBDDdSDnWJOcAonzjL2jT8eiEPXi9yuq s5iFYJ5CP8gv9OeOpAs9OxR1VX1CWv4spg3bdlNEm74tjslUOhKKb8U2KNMF2M+liyd0B4 MJntr+Ra4dgwEbp0a+5Kl4R3kGcTZrBKKo/oF7hltd/uA4iJSm8Uo450XxkzqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678913224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0HQZt51Y1CJ0iZmE/gfg+083rB07iD0gF6t2/0gmzQQ=; b=cXN+CGqmFB7LYR8YtF79ZV+gUMlJfAGOwVeoOR4v05ypXJ98jHJQweUhGClPyHXkA0GCR0 eHrL4M4EVl3aQ6AsQMOEp9XZSOXGYv7PiRKLJOdML8HvC7JeiB3unrtsNgu8MDV0Q5Uwd5 9sMZ2RuYh/9SrQwWI4yDY9lcHgOBmFslkoeqhVBizUWF40ccG396PsYfLSwp95Vl/zoPDe 6OsKHXSubg5b4tHxT2HNWlBv5TKKz667nVGFvXRGyUPrI+0wSVESt5BcG5YS+Vcl4Kkl7n QPQrmtcrDrgPlEnsnvfZmJJ1b91sJuOdb4pnVFvTv4IfxzxMFZCrrGGXND/5HA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678913224; a=rsa-sha256; cv=none; b=gSnTInrd/Zg5GfjLLH5bHIElUZq3ctqSYF7bkkVJIKzhMZb3bystCGSf7uCb4Ij0+iS6Qb pPNMMruHONpnjjvutmAKyVRI/HPed+DQbF+39YANFeMeG8WIkp8JihLVLf00ti0StozLBV OpbzMPSW32YZofRgFggIrMsvW2diZ7ap2M3mN5tbhsnEZjbeQrAI0+BTDTSO9lTeCdjw4l V2t/GKZws4Q51DmGAUp0Ocy5rzenxHut0svcraZz4lFf32agk2OVJ5WyHzFPm7GDg7wf1E aDJdOOnpYV74Pxk++yKp4L1gXDvojTeYTvuZcV7Crto2L3/fELX8TiJfY9r1DQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PcMrl5zL5zGfL; Wed, 15 Mar 2023 20:47:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32FKl3KK051865; Wed, 15 Mar 2023 20:47:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32FKl32C051864; Wed, 15 Mar 2023 20:47:03 GMT (envelope-from git) Date: Wed, 15 Mar 2023 20:47:03 GMT Message-Id: <202303152047.32FKl32C051864@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Justin Hibbits Subject: git: fcd94047f33b - releng/13.2 - dtrace/powerpc: "Fix" stack traces across trap frames List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: fcd94047f33beb98f1eee4d09e29d6c8de31c4a6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.2 has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=fcd94047f33beb98f1eee4d09e29d6c8de31c4a6 commit fcd94047f33beb98f1eee4d09e29d6c8de31c4a6 Author: Justin Hibbits AuthorDate: 2023-03-11 16:30:00 +0000 Commit: Justin Hibbits CommitDate: 2023-03-15 20:27:37 +0000 dtrace/powerpc: "Fix" stack traces across trap frames In function boundary tracing the link register is not yet saved to the save stack location, so the save point contains whatever the previous 'lr' save was, or even garbage, at the time the trap is taken. Address this by explicitly loading the link register from the trap frame instead of the stack, and propagate that out. Approved by: re (cperciva) (cherry picked from commit 3e1155ade1baab51458374efd0295bdf6db455fc) (cherry picked from commit e620e088cbd1c062655eee825aaf4f80bd255e1f) (cherry picked from commit 0a21a6659e5dfe503da587fb0460ae19bd765859) --- sys/cddl/dev/dtrace/powerpc/dtrace_isa.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c index cce1c907b5d8..1fca72e5b7fd 100644 --- a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c @@ -97,15 +97,18 @@ dtrace_sp_inkernel(uintptr_t sp) } static __inline void -dtrace_next_sp_pc(uintptr_t sp, uintptr_t *nsp, uintptr_t *pc) +dtrace_next_sp_pc(uintptr_t sp, uintptr_t *nsp, uintptr_t *pc, uintptr_t *lr) { vm_offset_t callpc; struct trapframe *frame; + if (lr != 0 && *lr != 0) + callpc = *lr; + else #ifdef __powerpc64__ - callpc = *(vm_offset_t *)(sp + RETURN_OFFSET64); + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET64); #else - callpc = *(vm_offset_t *)(sp + RETURN_OFFSET); + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET); #endif /* @@ -121,6 +124,8 @@ dtrace_next_sp_pc(uintptr_t sp, uintptr_t *nsp, uintptr_t *pc) *nsp = frame->fixreg[1]; if (pc != NULL) *pc = frame->srr0; + if (lr != NULL) + *lr = frame->lr; return; } @@ -128,6 +133,9 @@ dtrace_next_sp_pc(uintptr_t sp, uintptr_t *nsp, uintptr_t *pc) *nsp = *(uintptr_t *)sp; if (pc != NULL) *pc = callpc; + /* lr is only valid for trap frames */ + if (lr != NULL) + *lr = 0; } void @@ -135,7 +143,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, uint32_t *intrpc) { int depth = 0; - uintptr_t osp, sp; + uintptr_t osp, sp, lr = 0; vm_offset_t callpc; pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller; @@ -154,7 +162,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, if (!dtrace_sp_inkernel(sp)) break; osp = sp; - dtrace_next_sp_pc(osp, &sp, &callpc); + dtrace_next_sp_pc(osp, &sp, &callpc, &lr); if (aframes > 0) { aframes--; @@ -513,7 +521,7 @@ dtrace_getstackdepth(int aframes) depth++; osp = sp; - dtrace_next_sp_pc(sp, &sp, NULL); + dtrace_next_sp_pc(sp, &sp, NULL, NULL); } if (depth < aframes) return (0);