From owner-svn-src-head@freebsd.org Fri Sep 11 09:15:50 2020 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 059A93D2EE1; Fri, 11 Sep 2020 09:15:50 +0000 (UTC) (envelope-from kp@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BnqqT6PRsz4451; Fri, 11 Sep 2020 09:15:49 +0000 (UTC) (envelope-from kp@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 C02E62183B; Fri, 11 Sep 2020 09:15:49 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08B9FnYN008498; Fri, 11 Sep 2020 09:15:49 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08B9FnnD008496; Fri, 11 Sep 2020 09:15:49 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202009110915.08B9FnnD008496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 11 Sep 2020 09:15:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365626 - in head/sys/cddl/dev: dtrace/riscv fbt/riscv X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: in head/sys/cddl/dev: dtrace/riscv fbt/riscv X-SVN-Commit-Revision: 365626 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2020 09:15:50 -0000 Author: kp Date: Fri Sep 11 09:15:49 2020 New Revision: 365626 URL: https://svnweb.freebsd.org/changeset/base/365626 Log: dtrace: fix fbt return probes on RISC-V Return values are passed in a0, so read it from there. We also pass a1 through to userspace, as the ABI allows small structs to be returned in registers a0/a1. While here read the register values directly from the trapframe rather than rtval, and remove the now unneeded argument from dtrace_invop(). Set fbtp_roffset so that we get the correct return location in arg0. Reviewed by: markj Sponsored by: Axiado Differential Revision: https://reviews.freebsd.org/D26389 Modified: head/sys/cddl/dev/dtrace/riscv/dtrace_subr.c head/sys/cddl/dev/fbt/riscv/fbt_isa.c Modified: head/sys/cddl/dev/dtrace/riscv/dtrace_subr.c ============================================================================== --- head/sys/cddl/dev/dtrace/riscv/dtrace_subr.c Fri Sep 11 05:45:27 2020 (r365625) +++ head/sys/cddl/dev/dtrace/riscv/dtrace_subr.c Fri Sep 11 09:15:49 2020 (r365626) @@ -53,7 +53,7 @@ extern dtrace_id_t dtrace_probeid_error; extern int (*dtrace_invop_jump_addr)(struct trapframe *); extern void dtrace_getnanotime(struct timespec *tsp); -int dtrace_invop(uintptr_t, struct trapframe *, uintptr_t); +int dtrace_invop(uintptr_t, struct trapframe *); void dtrace_invop_init(void); void dtrace_invop_uninit(void); @@ -65,13 +65,13 @@ typedef struct dtrace_invop_hdlr { dtrace_invop_hdlr_t *dtrace_invop_hdlr; int -dtrace_invop(uintptr_t addr, struct trapframe *frame, uintptr_t eax) +dtrace_invop(uintptr_t addr, struct trapframe *frame) { dtrace_invop_hdlr_t *hdlr; int rval; for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next) - if ((rval = hdlr->dtih_func(addr, frame, eax)) != 0) + if ((rval = hdlr->dtih_func(addr, frame, 0)) != 0) return (rval); return (0); @@ -254,7 +254,7 @@ dtrace_invop_start(struct trapframe *frame) uint32_t imm; int invop; - invop = dtrace_invop(frame->tf_sepc, frame, frame->tf_sepc); + invop = dtrace_invop(frame->tf_sepc, frame); if (invop == 0) return (-1); Modified: head/sys/cddl/dev/fbt/riscv/fbt_isa.c ============================================================================== --- head/sys/cddl/dev/fbt/riscv/fbt_isa.c Fri Sep 11 05:45:27 2020 (r365625) +++ head/sys/cddl/dev/fbt/riscv/fbt_isa.c Fri Sep 11 09:15:49 2020 (r365626) @@ -59,9 +59,14 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uin if ((uintptr_t)fbt->fbtp_patchpoint == addr) { cpu->cpu_dtrace_caller = addr; - dtrace_probe(fbt->fbtp_id, frame->tf_a[0], - frame->tf_a[1], frame->tf_a[2], - frame->tf_a[3], frame->tf_a[4]); + if (fbt->fbtp_roffset == 0) { + dtrace_probe(fbt->fbtp_id, frame->tf_a[0], + frame->tf_a[1], frame->tf_a[2], + frame->tf_a[3], frame->tf_a[4]); + } else { + dtrace_probe(fbt->fbtp_id, fbt->fbtp_roffset, + frame->tf_a[0], frame->tf_a[1], 0, 0); + } cpu->cpu_dtrace_caller = 0; return (fbt->fbtp_savedval); @@ -233,6 +238,7 @@ again: fbt->fbtp_loadcnt = lf->loadcnt; fbt->fbtp_symindx = symindx; fbt->fbtp_rval = rval; + fbt->fbtp_roffset = (uintptr_t)instr - (uintptr_t)symval->value; fbt->fbtp_savedval = *instr; fbt->fbtp_patchval = patchval; fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];