]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uaccess] Change userptr_t to be a pointer type
authorMichael Brown <mcb30@ipxe.org>
Sun, 20 Apr 2025 16:26:48 +0000 (17:26 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 20 Apr 2025 16:28:33 +0000 (17:28 +0100)
The original motivation for the userptr_t type was to be able to
support a pure 16-bit real-mode memory model in which a segment:offset
value could be encoded as an unsigned long, with corresponding
copy_from_user() and copy_to_user() functions used to perform
real-mode segmented memory accesses.

Since this memory model was first created almost twenty years ago, no
serious effort has been made to support a pure 16-bit mode of
operation for iPXE.  The constraints imposed by the memory model are
becoming increasingly cumbersome to work within: for example, the
parsing of devicetree structures is hugely simplified by being able to
use and return direct pointers to the names and property values.  The
devicetree code therefore relies upon virt_to_user(), which is
nominally illegal under the userptr_t memory model.

Drop support for the concept of a memory location that cannot be
reached through a straightforward pointer dereference, by redefining
userptr_t to be a simple pointer type.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/uaccess.h

index d8c57adeba44e93dedafda69a9a5c36894748e81..1790e4066d64720f78a6b7ab67fe946364d1c287 100644 (file)
@@ -6,17 +6,6 @@
  *
  * Access to external ("user") memory
  *
- * iPXE often needs to transfer data between internal and external
- * buffers.  On i386, the external buffers may require access via a
- * different segment, and the buffer address cannot be encoded into a
- * simple void * pointer.  The @c userptr_t type encapsulates the
- * information needed to identify an external buffer, and the
- * copy_to_user() and copy_from_user() functions provide methods for
- * transferring data between internal and external buffers.
- *
- * Note that userptr_t is an opaque type; in particular, performing
- * arithmetic upon a userptr_t is not allowed.
- *
  */
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
@@ -36,7 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  * A pointer to a user buffer
  *
  */
-typedef unsigned long userptr_t;
+typedef void * userptr_t;
 
 /** Equivalent of NULL for user pointers */
 #define UNULL ( ( userptr_t ) 0 )