CHERI: declare fueptr and suptr

These should replace fueword and suword when manipulating pointers in
memory.  On CHERI targets they will be implemented using capability
aware instructions and otherwise they are defined to fueword and suword.

Reviewed by:	kib, markj
Effort:		CHERI upstreaming
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D57664
This commit is contained in:
Brooks Davis committed 2026-06-29 13:59:44 +01:00
1 parent b517edb8de
commit a1c52e05f5
4 files changed
+34 -2

No files matched your search

+2
View File
@@ -1160,6 +1160,7 @@ MLINKS+=fetch.9 fubyte.9 \
fetch.9 fuword16.9 \
fetch.9 fuword32.9 \
fetch.9 fuword64.9 \
fetch.9 fueptr.9 \
fetch.9 fueword.9 \
fetch.9 fueword32.9 \
fetch.9 fueword64.9
@@ -2190,6 +2191,7 @@ MLINKS+=stack.9 stack_copy.9 \
stack.9 stack_sbuf_print_ddb.9 \
stack.9 stack_zero.9
MLINKS+=store.9 subyte.9 \
store.9 suptr.9 \
store.9 suword.9 \
store.9 suword16.9 \
store.9 suword32.9 \
+13 -1
View File
@@ -32,7 +32,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd July 22, 2021
.Dd June 29, 2026
.Dt FETCH 9
.Os
.Sh NAME
@@ -42,6 +42,7 @@
.Nm fuword16 ,
.Nm fuword32 ,
.Nm fuword64 ,
.Nm fueptr ,
.Nm fueword ,
.Nm fueword32 ,
.Nm fueword64
@@ -60,6 +61,8 @@
.Ft int64_t
.Fn fuword64 "volatile const void *base"
.Ft int
.Fn fueptr "volatile const void *base" "intptr_t *val"
.Ft int
.Fn fueword "volatile const void *base" "long *val"
.Ft int
.Fn fueword32 "volatile const void *base" "int32_t *val"
@@ -96,6 +99,14 @@ Fetches 32 bits of data from the user-space address
.It Fn fuword64
Fetches 64 bits of data from the user-space address
.Pa base .
.It Fn fueptr
Fetches a pointer from the user-space address
.Pa base
and stores the result in the variable pointed by
.Pa val .
.Fn fueptr
preserves the provenance of pointers fetched from users-space
.Pq see Xr memory_model 7 for further information .
.It Fn fueword
Fetches a word of data (long) from the user-space address
.Pa base
@@ -130,6 +141,7 @@ and
.Fn fuword64
functions return the data fetched or -1 on failure.
The
.Fn fueptr ,
.Fn fueword ,
.Fn fueword32
and
+9 -1
View File
@@ -32,12 +32,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd July 22, 2021
.Dd June 29, 2026
.Dt STORE 9
.Os
.Sh NAME
.Nm store ,
.Nm subyte ,
.Nm suptr ,
.Nm suword
.Nd store data to user-space
.Sh SYNOPSIS
@@ -47,6 +48,8 @@
.Ft int
.Fn subyte "volatile void *base" "int byte"
.Ft int
.Fn suptr "volatile void *base" "intptr_t ptr"
.Ft int
.Fn suword "volatile void *base" "long word"
.Ft int
.Fn suword16 "volatile void *base" "int word"
@@ -70,6 +73,11 @@ routines provide the following functionality:
.It Fn subyte
Stores a byte of data to the user-space address
.Pa base .
.It Fn suptr
Stores a pointer to the user-space address
.Pa base
preserving the provenance of that pointer
.Pq see Xr memory_model 7 for further information .
.It Fn suword
Stores a word of data to the user-space address
.Pa base .
+10
View File
@@ -350,11 +350,21 @@ int64_t fuword64(volatile const void *base);
__nodiscard int fueword(volatile const void *base, long *val);
__nodiscard int fueword32(volatile const void *base, int32_t *val);
__nodiscard int fueword64(volatile const void *base, int64_t *val);
#ifdef __CHERI__
__nodiscard int fueptr(volatile const void *base, intptr_t *val);
#else
#define fueptr(base, val) fueword((base), (long *)(val))
#endif
__nodiscard int subyte(volatile void *base, int byte);
__nodiscard int suword(volatile void *base, long word);
__nodiscard int suword16(volatile void *base, int word);
__nodiscard int suword32(volatile void *base, int32_t word);
__nodiscard int suword64(volatile void *base, int64_t word);
#ifdef __CHERI__
__nodiscard int suptr(volatile void *base, intptr_t ptr);
#else
#define suptr(base, val) suword((base), (val))
#endif
uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval);
u_long casuword(volatile u_long *p, u_long oldval, u_long newval);
int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,