exterr: allow exterr to fit pointers on CHERI targets

Switch to uint64ptr_t which is a uint64_t on traditional architectures
and a uintptr_t on CHERI architectures.  This has no ABI impact on
non-CHERI kernels.

Fix truncation of 64-bit values on 32-bit kernels.

Reviewed by:	kib
Effort:		CHERI upstreaming
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D58056
This commit is contained in:
Brooks Davis committed 2026-07-15 10:32:16 +01:00
1 parent db3eca2be2
commit 844009378d
3 files changed
+8 -8

No files matched your search

+2 -2
View File
@@ -16,8 +16,8 @@
struct kexterr {
int error;
const char *msg;
__uint64_t p1;
__uint64_t p2;
__uint64ptr_t p1;
__uint64ptr_t p2;
unsigned cat;
unsigned src_line;
};
+3 -3
View File
@@ -20,9 +20,9 @@ struct uexterror {
__uint32_t src_line;
__uint32_t flags;
__uint32_t rsrv0;
__uint64_t p1;
__uint64_t p2;
__uint64_t rsrv1[4];
__uint64ptr_t p1;
__uint64ptr_t p2;
__uint64ptr_t rsrv1[4];
char msg[128];
};
+3 -3
View File
@@ -59,7 +59,7 @@
#define _SET_ERROR2(eerror, mmsg, pp1, pp2) \
exterr_set(eerror, EXTERR_CATEGORY, SET_ERROR_MSG(mmsg), \
(uintptr_t)(pp1), (uintptr_t)(pp2), __LINE__)
(uint64ptr_t)(pp1), (uint64ptr_t)(pp2), __LINE__)
#define _SET_ERROR0(eerror, mmsg) _SET_ERROR2(eerror, mmsg, 0, 0)
#define _SET_ERROR1(eerror, mmsg, pp1) _SET_ERROR2(eerror, mmsg, pp1, 0)
@@ -72,8 +72,8 @@
void exterr_clear(struct kexterr *ke);
void exterr_db_print(struct kexterr *ke);
int exterr_set_from(const struct kexterr *ke);
int exterr_set(int eerror, int category, const char *mmsg, uintptr_t pp1,
uintptr_t pp2, int line);
int exterr_set(int eerror, int category, const char *mmsg, uint64ptr_t pp1,
uint64ptr_t pp2, int line);
int exterr_to_ue(struct thread *td, struct uexterror *ue);
void ktrexterr(struct thread *td);