From nobody Wed Sep 10 16:00:52 2025 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 4cMQQY1K7Jz66Wj5; Wed, 10 Sep 2025 16:00:53 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cMQQY0RRKz3K3r; Wed, 10 Sep 2025 16:00:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757520053; 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=A8oRboH4Bzul14oZUmsJ8Rz2L4ho+1532wcTWkALvtk=; b=Mw8Yh06fIQLEWZ0KFuqB1RzBze1DY7P0BbczMLPy8CBOa/Le2ubf4tcdQE/yeRuAzxP/PV zD2wwn7bdCxGhALSj4AnrmIMUuRB2k+30WskDeXHy3otF64YYdIpUDbs2gAPw2hNfK87B7 hAzk4KsZN9l7hoz2HgORbp88ub8xLL7elCmFXtAzXNul/rukV1uRMh9KafIfjJnVUX0ncP c5VVGAI53rc/0SOQoyPQ2YtO2aNd7Q21iRLwPLb1m7ZhHyvFKIDd2EdMzOUK/ePFNcYntY qM3KkhBa2xHiGOnCM0tgFDRDwd8ILEIyCcXbkXIBvjhQzGG4ag8UYW4RW3Oe4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757520053; 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=A8oRboH4Bzul14oZUmsJ8Rz2L4ho+1532wcTWkALvtk=; b=NFzwP6NR9sWJMu8luXLfDJ+78GFxLU5o1k5CKrUl+u5/2cXSqOlnXNxFMbYOGE7+Dk5UWM tb6gULJDX6EKVOX2ujIRDqihTnVNcU4XGfJkNnH4yNP8JpidknMItZ222EnJoDie2Id9dc aT0Iyc9aE6AoKuQuOlSJsNDMSSX0anPWn8z8WZ+r003JeYZ1+ZRVYd/muJ6vmJ3Xh7hqIh y4TCNPx8ERci/GLKN3PWEzPRtpmdZfOoFc26tPoCorxAOzt26EoAfdlDmwdAaSiAezwS9A 8idHTnaQ/FXKftNmOYex1WBRzh6wPcgdSB/TN2pR6FfwT9eaXFbyxIHmM4nq7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757520053; a=rsa-sha256; cv=none; b=Ogdvh704mV119VA8RwTGk7NvmE6l05lVASRc7XVayQOy0x24xPlJT8U+NpFKY4JmvF8g85 23LAgLm0btroNy51yQyHB+e2e8QYgNqM5v6Y9fn1+7r3USy5FjEunezQsX3kPHpQSmAEwE kPPZUSF6PM9v12uhZP+Z+gxGLowg3j0NLSpdpj05DWXnsWIsTjsjf4Amy3J8grNoWyr0st qgIRXPt3zNZSeGnwrEGLTzP2XS8lNpVqEb1PXqKyvGfwdk2EsISK1Cfe2qOZ7mATxtuZjD Ba72eKWBwztgEADZLgcAUONOTtcS0NBlByC/uwyrbhKSBq1z7Q8g/ydxTbikcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cMQQY00xTzC7y; Wed, 10 Sep 2025 16:00:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58AG0qr1058448; Wed, 10 Sep 2025 16:00:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58AG0qjq058443; Wed, 10 Sep 2025 16:00:52 GMT (envelope-from git) Date: Wed, 10 Sep 2025 16:00:52 GMT Message-Id: <202509101600.58AG0qjq058443@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: 3877025f52ee - main - dtrace: Use a size_t to represent a buffer size in the printm action 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 3877025f52ee205fe99ad4ff68229933d57e4bcb Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3877025f52ee205fe99ad4ff68229933d57e4bcb commit 3877025f52ee205fe99ad4ff68229933d57e4bcb Author: Mark Johnston AuthorDate: 2025-09-10 14:33:58 +0000 Commit: Mark Johnston CommitDate: 2025-09-10 16:00:13 +0000 dtrace: Use a size_t to represent a buffer size in the printm action printm is specific to the FreeBSD dtrace port. I believe it's effectively the same as tracemem(), though printm apparently predates it. It stores the size of the buffer of traced data inline. Currently it represents that size using a uintptr_t, which isn't really right and poses challenges when porting to CHERI because `DTRACE_STORE(uintptr_t, ...` requires the destination to be suitably aligned, but this isn't necessary since we're just storing a size. Convert to using a size_t. This should be a no-op since sizeof(uintptr_t) == sizeof(size_t) on non-CHERI platforms (and besides that I don't see a reason to use printm() when tracemem() is available and is simpler to use.) Reviewed by: Domagoj Stolfa, avg MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D52055 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c | 9 ++++----- sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c | 11 ++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index 385c9d78bdfc..b311b5425587 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -2242,11 +2242,10 @@ dt_format_bytes_get(dtrace_hdl_t *dtp, caddr_t addr, size_t nbytes) static int dt_format_memory(dtrace_hdl_t *dtp, caddr_t addr) { - - size_t nbytes = *((uintptr_t *) addr); + size_t nbytes = *((size_t *) addr); char *s; - s = dt_format_bytes_get(dtp, addr + sizeof(uintptr_t), nbytes); + s = dt_format_bytes_get(dtp, addr + sizeof(size_t), nbytes); if (s == NULL) return (-1); @@ -2260,9 +2259,9 @@ static int dt_print_memory(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr) { int quiet = (dtp->dt_options[DTRACEOPT_QUIET] != DTRACEOPT_UNSET); - size_t nbytes = *((uintptr_t *) addr); + size_t nbytes = *((size_t *) addr); - return (dt_print_bytes(dtp, fp, addr + sizeof(uintptr_t), + return (dt_print_bytes(dtp, fp, addr + sizeof(size_t), nbytes, 50, quiet, 1)); } diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 7192df200ae2..8078f3f6d4b1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -7761,7 +7761,8 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1, uintptr_t *memref = (uintptr_t *)(uintptr_t) val; if (!DTRACE_INSCRATCHPTR(&mstate, - (uintptr_t)memref, 2 * sizeof(uintptr_t))) { + (uintptr_t) memref, + sizeof (uintptr_t) + sizeof (size_t))) { *flags |= CPU_DTRACE_BADADDR; continue; } @@ -7773,21 +7774,21 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1, * Check if the size exceeds the allocated * buffer size. */ - if (size + sizeof(uintptr_t) > dp->dtdo_rtype.dtdt_size) { + if (size + sizeof (size_t) > + dp->dtdo_rtype.dtdt_size) { /* Flag a drop! */ *flags |= CPU_DTRACE_DROP; continue; } /* Store the size in the buffer first. */ - DTRACE_STORE(uintptr_t, tomax, - valoffs, size); + DTRACE_STORE(size_t, tomax, valoffs, size); /* * Offset the buffer address to the start * of the data. */ - valoffs += sizeof(uintptr_t); + valoffs += sizeof(size_t); /* * Reset to the memory address rather than