]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uaccess] Add explicit casts to and from userptr_t where needed
authorMichael Brown <mcb30@ipxe.org>
Sun, 20 Apr 2025 12:39:32 +0000 (13:39 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 20 Apr 2025 16:21:53 +0000 (17:21 +0100)
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>
src/arch/x86/include/librm.h
src/arch/x86/interface/pcbios/memtop_umalloc.c
src/drivers/infiniband/golan.c
src/include/ipxe/linux/linux_uaccess.h
src/include/ipxe/uaccess.h
src/interface/efi/efi_umalloc.c

index c664bff2c24d5bfeed5015546186f3b797324cd0..23ca4650ff9356ea7b7e663349beab3f239fde3d 100644 (file)
@@ -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
index 1d3f40a1cff213a88ec0eb739783632c348f2a51..1cc3aff915ef48e1e062d472efd7e9ff0f013474 100644 (file)
@@ -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 {
index 68a7c4f5d8ada33eea3ea1ea171e23df5dcf27b7..81fc6c0f08ce4dd0938b946e3ef011c707430aa1 100755 (executable)
@@ -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);
                }
index b29aa14bdaaee557031bda2cddab4607eec7d21b..1e31afd9ce93bfa7e703a13e81862bafa18ed243 100644 (file)
@@ -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
index 2575faca5ea1cfb2cec9faf93f472efcd7b00883..d8c57adeba44e93dedafda69a9a5c36894748e81 100644 (file)
@@ -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
index e3f1dacc2e41597db58f22426c7b68396079b28f..175ae367e4eada231aef6367cfb4f9091bc70655 100644 (file)
@@ -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