From nobody Thu Apr 20 17:36:11 2023 X-Original-To: dev-commits-src-main@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 4Q2Pvw07spz46MHK; Thu, 20 Apr 2023 17:36:12 +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 4Q2Pvv5m2jz3JJh; Thu, 20 Apr 2023 17:36:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682012171; 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=MgynPMH6yE7rYZGNJkgsSwk2M63z2SUGn11y82shkvs=; b=SJU9JAsMQBAjXtAdgnEJ36mAqeSXurdOME1QkQyuUIL7VUwCpUJzG2ebNcAymtLsP4ictr njJtnf0UbEwsT/p1AfXYNaz5XL0Ca7RlwId1HXCU5Dujzgn9ACo6WIxn30ORIs9Yc72qxk Pes1jvz0XyaMTuP/2YvtDe+ZlRN6fJes+isSyzRaok/HhyueTmPwGgXzT7PcTnPHnHM04l smb2t6WAQke2qtFe70pv4UNdF+mvymu68j6sDaiyYAEdtzkH7LcbzIyYE4f67giPmLJ9Dc IkbXgRZNWXcPigxRxT4WWKP6kjkn2XrprTGdXqvyjoEwDFQgOM18v0vIo+SsWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682012171; 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=MgynPMH6yE7rYZGNJkgsSwk2M63z2SUGn11y82shkvs=; b=COkZ4aAjSo9NfD7KU/jjXBL6evh4QvZek0vKj2bc+h6mc4S8aOPaAIlAPQBgh/xdXHg7FF 2Q4Bw8vySzFGU/92PzLnaM6F4yfvcVXORm7CJr6OJdfd6iX72mjJF6G9p1bxwZmZvEWxgH hsop5J4RM3OYFyDUYui+LR4h4/PCX78vCGYYc7qWRfbY/rQvqonlcDi9/rZ03gLcqp/X7J YWis85HBK7FbqBYjOA4Wy3cqO/5FRc7FTuXVr+ETEE2FvVV5TP/CO7QIpjIrdy03UOMGwQ YRyMB2bf/b/orr+ehOY+favKQVaYsPzJfxxgPDkbZJZiFVkQuBuLAhZglOPh4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682012171; a=rsa-sha256; cv=none; b=e/TFSLUBt+I7v3W9rXdhr7nkuWGJSBc/xTcKpveYzsn96t57Iyei83rllk0ba8/HUTEMBD iIGq0ScOgJk36IyNs2LKP4UiXFG5KsXsVmloalhg6RyMokjL7fSsmSdK9oNmq/4JEFMJ8O q15/YJSKwrpA7YeXGzF9XZbaSQkErOFT8Ir5xt/z3W+SqlwQ9HgkraMe4ELuYepc1SNuYu Vf86BEv11AnOetaxwXS34aRQNOd+Q+1LRXIMqWmu5YaP4CPrhwH4/MDKglPnS15d1g0D16 AtgIQ8TK16H7IH7/xIMW1h8gcpIGaieJVFgfrqpf2AernaiSGr9zNuWSsMkaPA== 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 4Q2Pvv4q4dzn2Q; Thu, 20 Apr 2023 17:36:11 +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 33KHaBBc077248; Thu, 20 Apr 2023 17:36:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33KHaBjD077247; Thu, 20 Apr 2023 17:36:11 GMT (envelope-from git) Date: Thu, 20 Apr 2023 17:36:11 GMT Message-Id: <202304201736.33KHaBjD077247@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 080e56a6c98c - main - dtrace: expose dtrace_instr_size() to userland and implement it for riscv List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 080e56a6c98c7e7a241a4260d4c19d3cad5b22af Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=080e56a6c98c7e7a241a4260d4c19d3cad5b22af commit 080e56a6c98c7e7a241a4260d4c19d3cad5b22af Author: Christos Margiolis AuthorDate: 2023-04-20 16:21:46 +0000 Commit: Mark Johnston CommitDate: 2023-04-20 17:35:57 +0000 dtrace: expose dtrace_instr_size() to userland and implement it for riscv dtrace_instr_size() is needed by the forthcoming RISC-V port of kinst, as well as by libdtrace in D38825 for both amd64 and RISC-V. Reviewed by: markj, mhorne MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39489 --- cddl/lib/libdtrace/Makefile | 6 +++++- .../contrib/opensolaris/uts/common/sys/dtrace.h | 5 ++++- sys/cddl/dev/dtrace/riscv/instr_size.c | 22 ++++++++++++++++++++++ sys/modules/dtrace/dtrace/Makefile | 4 ++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile index 651609409a3a..84258169e44a 100644 --- a/cddl/lib/libdtrace/Makefile +++ b/cddl/lib/libdtrace/Makefile @@ -122,10 +122,14 @@ CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel .endif .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" -SRCS+= dis_tables.c +SRCS+= dis_tables.c instr_size.c DSRCS+= regs_x86.d .endif +.if ${MACHINE_CPUARCH} == "riscv" +SRCS+= instr_size.c +.endif + YFLAGS+=-d LIBADD= ctf elf proc pthread rtld_db diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h index d3d8fbca6164..7b8da08e9ae9 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h @@ -2399,7 +2399,6 @@ extern void dtrace_safe_synchronous_signal(void); extern int dtrace_mach_aframes(void); #if defined(__i386) || defined(__amd64) -extern int dtrace_instr_size(uint8_t *instr); extern int dtrace_instr_size_isa(uint8_t *, model_t, int *); extern void dtrace_invop_callsite(void); #endif @@ -2428,6 +2427,10 @@ extern void dtrace_helpers_destroy(proc_t *); #endif /* _KERNEL */ +#if defined(__i386) || defined(__amd64) || defined (__riscv) +extern int dtrace_instr_size(uint8_t *instr); +#endif + #endif /* _ASM */ #if defined(__i386) || defined(__amd64) diff --git a/sys/cddl/dev/dtrace/riscv/instr_size.c b/sys/cddl/dev/dtrace/riscv/instr_size.c new file mode 100644 index 000000000000..bfdc962f4aa9 --- /dev/null +++ b/sys/cddl/dev/dtrace/riscv/instr_size.c @@ -0,0 +1,22 @@ +/* + * SPDX-License-Identifier: CDDL 1.0 + * + * Copyright 2023 Christos Margiolis + */ + +#include +#include + +#include + +#define RVC_MASK 0x03 + +int +dtrace_instr_size(uint8_t *instr) +{ + /* Detect compressed instructions. */ + if ((~(*instr) & RVC_MASK) == 0) + return (INSN_SIZE); + else + return (INSN_C_SIZE); +} diff --git a/sys/modules/dtrace/dtrace/Makefile b/sys/modules/dtrace/dtrace/Makefile index 0bd81bb39db0..1513418281ad 100644 --- a/sys/modules/dtrace/dtrace/Makefile +++ b/sys/modules/dtrace/dtrace/Makefile @@ -22,8 +22,12 @@ SRCS+= dis_tables.c \ instr_size.c CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/intel \ -I${SYSDIR}/cddl/dev/dtrace/x86 +.endif +.if ${MACHINE_CPUARCH} == "riscv" +SRCS+= instr_size.c .endif + CFLAGS+= ${OPENZFS_CFLAGS} SRCS+= bus_if.h device_if.h vnode_if.h