summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2025-04-20 14:39:32 +0200
committerMichael Brown2025-04-20 18:21:53 +0200
commit71174e19d8c93dc99221c5fe32db6a78c6a7ffb3 (patch)
treeb3cc53e39f65fb6fb9ae0da4aba13b60c3f48e55
parent[uaccess] Rename userptr_sub() to userptr_diff() (diff)
downloadipxe-71174e19d8c93dc99221c5fe32db6a78c6a7ffb3.tar.gz
ipxe-71174e19d8c93dc99221c5fe32db6a78c6a7ffb3.tar.xz
ipxe-71174e19d8c93dc99221c5fe32db6a78c6a7ffb3.zip
[uaccess] Add explicit casts to and from userptr_t where needed
Allow for the possibility of userptr_t becoming a pointer type by adding explicit casts where necessary. Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/arch/x86/include/librm.h6
-rw-r--r--src/arch/x86/interface/pcbios/memtop_umalloc.c2
-rwxr-xr-xsrc/drivers/infiniband/golan.c2
-rw-r--r--src/include/ipxe/linux/linux_uaccess.h4
-rw-r--r--src/include/ipxe/uaccess.h4
-rw-r--r--src/interface/efi/efi_umalloc.c2
6 files changed, 10 insertions, 10 deletions
diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h
index c664bff2c..23ca4650f 100644
--- a/src/arch/x86/include/librm.h
+++ b/src/arch/x86/include/librm.h
@@ -96,10 +96,10 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
* identity-mapped.
*/
if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) )
- return phys_addr;
+ return ( ( userptr_t ) phys_addr );
/* In a 32-bit build, subtract virt_offset */
- return ( phys_addr - virt_offset );
+ return ( ( userptr_t ) ( phys_addr - virt_offset ) );
}
/**
@@ -111,7 +111,7 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
*/
static inline __always_inline unsigned long
UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) {
- unsigned long addr = ( userptr + offset );
+ unsigned long addr = ( ( unsigned long ) ( userptr + offset ) );
/* In a 64-bit build, any virtual address in the low 4GB is
* directly usable as a physical address, since the low 4GB is
diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c
index 1d3f40a1c..1cc3aff91 100644
--- a/src/arch/x86/interface/pcbios/memtop_umalloc.c
+++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c
@@ -45,7 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define EM_ALIGN ( 4 * 1024 )
/** Equivalent of NOWHERE for user pointers */
-#define UNOWHERE ( ~UNULL )
+#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) )
/** An external memory block */
struct external_memory {
diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c
index 68a7c4f5d..81fc6c0f0 100755
--- a/src/drivers/infiniband/golan.c
+++ b/src/drivers/infiniband/golan.c
@@ -487,7 +487,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages
next_page_addr += GOLAN_PAGE_SIZE ) {
addr = next_page_addr;
if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) {
- DBGC (golan ,"Addr not Page alligned [%lx %lx]\n", user_to_phys(addr, 0), addr);
+ DBGC (golan ,"Addr not Page alligned [%lx]\n", user_to_phys(addr, 0));
}
mailbox->mblock.data[j] = USR_2_BE64_BUS(addr);
}
diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h
index b29aa14bd..1e31afd9c 100644
--- a/src/include/ipxe/linux/linux_uaccess.h
+++ b/src/include/ipxe/linux/linux_uaccess.h
@@ -43,7 +43,7 @@ UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) {
* virtual address will suffice for the purpose of determining
* alignment.
*/
- return ( userptr + offset );
+ return ( ( unsigned long ) ( userptr + offset ) );
}
/**
@@ -56,7 +56,7 @@ static inline __always_inline userptr_t
UACCESS_INLINE ( linux, phys_to_user ) ( physaddr_t phys_addr ) {
/* For symmetry with the stub user_to_phys() */
- return phys_addr;
+ return ( ( userptr_t ) phys_addr );
}
static inline __always_inline userptr_t
diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h
index 2575faca5..d8c57adeb 100644
--- a/src/include/ipxe/uaccess.h
+++ b/src/include/ipxe/uaccess.h
@@ -224,12 +224,12 @@ trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
static inline __always_inline userptr_t
UACCESS_INLINE ( flat, phys_to_user ) ( unsigned long phys_addr ) {
- return phys_addr;
+ return ( ( userptr_t ) phys_addr );
}
static inline __always_inline unsigned long
UACCESS_INLINE ( flat, user_to_phys ) ( userptr_t userptr, off_t offset ) {
- return ( userptr + offset );
+ return ( ( unsigned long ) ( userptr + offset ) );
}
static inline __always_inline userptr_t
diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c
index e3f1dacc2..175ae367e 100644
--- a/src/interface/efi/efi_umalloc.c
+++ b/src/interface/efi/efi_umalloc.c
@@ -36,7 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
/** Equivalent of NOWHERE for user pointers */
-#define UNOWHERE ( ~UNULL )
+#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) )
/**
* Reallocate external memory