git: ba9cff7aa2eb - main - dtrace: Use size_t instead of uintptr_t to represent buffer offsets
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Jan 2025 19:10:07 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=ba9cff7aa2eb62d84bead503cd606d1586ea8388
commit ba9cff7aa2eb62d84bead503cd606d1586ea8388
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-01-23 19:08:46 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-01-23 19:08:46 +0000
dtrace: Use size_t instead of uintptr_t to represent buffer offsets
This eases porting of DTrace to CHERI, where uintptr_t and size_t aren't
interchangeable.
No functional change intended.
Reviewed by: Domagoj Stolfa <domagoj.stolfa@gmail.com>
MFC after: 2 weeks
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D48625
---
.../contrib/opensolaris/uts/common/dtrace/dtrace.c | 19 +++++++++----------
.../contrib/opensolaris/uts/common/sys/dtrace_impl.h | 6 +++---
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
index 5f635cc088d7..608bff1d23ae 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
@@ -472,7 +472,7 @@ static kmutex_t dtrace_errlock;
#define DT_MASK_LO 0x00000000FFFFFFFFULL
#define DTRACE_STORE(type, tomax, offset, what) \
- *((type *)((uintptr_t)(tomax) + (uintptr_t)offset)) = (type)(what);
+ *((type *)((uintptr_t)(tomax) + (size_t)offset)) = (type)(what);
#if !defined(__x86) && !defined(__aarch64__)
#define DTRACE_ALIGNCHECK(addr, size, flags) \
@@ -601,7 +601,7 @@ static uint64_t dtrace_helper(int, dtrace_mstate_t *,
static dtrace_helpers_t *dtrace_helpers_create(proc_t *);
static void dtrace_buffer_drop(dtrace_buffer_t *);
static int dtrace_buffer_consumed(dtrace_buffer_t *, hrtime_t when);
-static intptr_t dtrace_buffer_reserve(dtrace_buffer_t *, size_t, size_t,
+static ssize_t dtrace_buffer_reserve(dtrace_buffer_t *, size_t, size_t,
dtrace_state_t *, dtrace_mstate_t *);
static int dtrace_state_option(dtrace_state_t *, dtrace_optid_t,
dtrace_optval_t);
@@ -2548,7 +2548,7 @@ dtrace_aggregate(dtrace_aggregation_t *agg, dtrace_buffer_t *dbuf,
caddr_t tomax, data, kdata;
dtrace_actkind_t action;
dtrace_action_t *act;
- uintptr_t offs;
+ size_t offs;
if (buf == NULL)
return;
@@ -2843,7 +2843,7 @@ dtrace_speculation_commit(dtrace_state_t *state, processorid_t cpu,
dtrace_buffer_t *src, *dest;
uintptr_t daddr, saddr, dlimit, slimit;
dtrace_speculation_state_t curstate, new = 0;
- intptr_t offs;
+ ssize_t offs;
uint64_t timestamp;
if (which == 0)
@@ -6910,7 +6910,6 @@ dtrace_action_breakpoint(dtrace_ecb_t *ecb)
char c[DTRACE_FULLNAMELEN + 80], *str;
char *msg = "dtrace: breakpoint action at probe ";
char *ecbmsg = " (ecb ";
- uintptr_t mask = (0xf << (sizeof (uintptr_t) * NBBY / 4));
uintptr_t val = (uintptr_t)ecb;
int shift = (sizeof (uintptr_t) * NBBY) - 4, i = 0;
@@ -6951,9 +6950,9 @@ dtrace_action_breakpoint(dtrace_ecb_t *ecb)
c[i++] = *ecbmsg++;
while (shift >= 0) {
- mask = (uintptr_t)0xf << shift;
+ size_t mask = (size_t)0xf << shift;
- if (val >= ((uintptr_t)1 << shift))
+ if (val >= ((size_t)1 << shift))
c[i++] = "0123456789abcdef"[(val & mask) >> shift];
shift -= 4;
}
@@ -8038,7 +8037,7 @@ dtrace_hash_str(const char *p)
}
static dtrace_hash_t *
-dtrace_hash_create(uintptr_t stroffs, uintptr_t nextoffs, uintptr_t prevoffs)
+dtrace_hash_create(size_t stroffs, size_t nextoffs, size_t prevoffs)
{
dtrace_hash_t *hash = kmem_zalloc(sizeof (dtrace_hash_t), KM_SLEEP);
@@ -12316,11 +12315,11 @@ dtrace_buffer_drop(dtrace_buffer_t *buf)
* mstate. Returns the new offset in the buffer, or a negative value if an
* error has occurred.
*/
-static intptr_t
+static ssize_t
dtrace_buffer_reserve(dtrace_buffer_t *buf, size_t needed, size_t align,
dtrace_state_t *state, dtrace_mstate_t *mstate)
{
- intptr_t offs = buf->dtb_offset, soffs;
+ ssize_t offs = buf->dtb_offset, soffs;
intptr_t woffs;
caddr_t tomax;
size_t total;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
index cfb97c71f262..222f8e206da1 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
@@ -149,9 +149,9 @@ typedef struct dtrace_hash {
int dth_size; /* size of hash table */
int dth_mask; /* mask to index into table */
int dth_nbuckets; /* total number of buckets */
- uintptr_t dth_nextoffs; /* offset of next in probe */
- uintptr_t dth_prevoffs; /* offset of prev in probe */
- uintptr_t dth_stroffs; /* offset of str in probe */
+ size_t dth_nextoffs; /* offset of next in probe */
+ size_t dth_prevoffs; /* offset of prev in probe */
+ size_t dth_stroffs; /* offset of str in probe */
} dtrace_hash_t;
/*