]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uaccess] Remove trivial uses of userptr_t
authorMichael Brown <mcb30@ipxe.org>
Thu, 24 Apr 2025 00:30:50 +0000 (01:30 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 24 Apr 2025 00:40:05 +0000 (01:40 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
34 files changed:
src/arch/x86/core/vram_settings.c
src/arch/x86/image/pxe_image.c
src/arch/x86/include/realmode.h
src/arch/x86/interface/pxe/pxe_preboot.c
src/arch/x86/interface/pxe/pxe_tftp.c
src/arch/x86/interface/pxe/pxe_udp.c
src/core/cachedhcp.c
src/core/dma.c
src/core/fdt.c
src/drivers/infiniband/arbel.c
src/drivers/infiniband/arbel.h
src/drivers/infiniband/golan.c
src/drivers/infiniband/golan.h
src/drivers/infiniband/hermon.c
src/drivers/infiniband/hermon.h
src/drivers/net/efi/nii.c
src/drivers/net/netvsc.c
src/drivers/net/netvsc.h
src/drivers/usb/xhci.h
src/image/segment.c
src/include/ipxe/cachedhcp.h
src/include/ipxe/linux_sysfs.h
src/include/ipxe/memblock.h
src/include/ipxe/segment.h
src/include/ipxe/vmbus.h
src/interface/efi/efi_block.c
src/interface/efi/efi_bofm.c
src/interface/efi/efi_cachedhcp.c
src/interface/efi/efi_file.c
src/interface/hyperv/vmbus.c
src/interface/linux/linux_acpi.c
src/interface/linux/linux_smbios.c
src/interface/linux/linux_sysfs.c
src/tests/bofm_test.c

index ceeada46733d36c6a400aa7e29dc01c54ec43292..a97a463fe89865100ece8a3619ab023ada6beaf6 100644 (file)
@@ -23,6 +23,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
+#include <string.h>
 #include <ipxe/uaccess.h>
 #include <ipxe/settings.h>
 
@@ -47,12 +48,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  * @ret len            Length of setting data, or negative error
  */
 static int vram_fetch ( void *data, size_t len ) {
-       userptr_t vram = phys_to_virt ( VRAM_BASE );
+       const void *vram = phys_to_virt ( VRAM_BASE );
 
        /* Copy video RAM */
        if ( len > VRAM_LEN )
                len = VRAM_LEN;
-       copy_from_user ( data, vram, 0, len );
+       memcpy ( data, vram, len );
 
        return VRAM_LEN;
 }
index 5472ea594864b99166c3dd1a30288eb7be06fd0c..9f8044fa1727acc62151ad710641483f89656d0f 100644 (file)
@@ -54,7 +54,7 @@ const char *pxe_cmdline;
  * @ret rc             Return status code
  */
 static int pxe_exec ( struct image *image ) {
-       userptr_t buffer = real_to_virt ( 0, 0x7c00 );
+       void *buffer = real_to_virt ( 0, 0x7c00 );
        struct net_device *netdev;
        int rc;
 
index 0017b42c09a1c9391d61ed7e2f9946dfe32d542b..75f7d16e7ae153c9275f8af35757ebb272ba60bc 100644 (file)
@@ -87,7 +87,7 @@ real_to_virt ( unsigned int segment, unsigned int offset ) {
 static inline __always_inline void
 copy_to_real ( unsigned int dest_seg, unsigned int dest_off,
               void *src, size_t n ) {
-       copy_to_user ( real_to_virt ( dest_seg, dest_off ), 0, src, n );
+       memcpy ( real_to_virt ( dest_seg, dest_off ), src, n );
 }
 
 /**
@@ -101,7 +101,7 @@ copy_to_real ( unsigned int dest_seg, unsigned int dest_off,
 static inline __always_inline void
 copy_from_real ( void *dest, unsigned int src_seg,
                 unsigned int src_off, size_t n ) {
-       copy_from_user ( dest, real_to_virt ( src_seg, src_off ), 0, n );
+       memcpy ( dest, real_to_virt ( src_seg, src_off ), n );
 }
 
 /**
index 727d8e1ea1f6b25eb7d59251ab125cd9f142eb68..77dcf66e75be70449ba9bef48aa4ff28a8be31d0 100644 (file)
@@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/dhcp.h>
 #include <ipxe/fakedhcp.h>
 #include <ipxe/device.h>
@@ -184,7 +183,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) {
        union pxe_cached_info *info;
        unsigned int idx;
        size_t len;
-       userptr_t buffer;
+       void *buffer;
 
        DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO %s to %04x:%04x+%x",
               pxenv_get_cached_info_name ( get_cached_info->PacketType ),
@@ -245,7 +244,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) {
                        DBGC ( &pxe_netdev, " buffer may be too short" );
                buffer = real_to_virt ( get_cached_info->Buffer.segment,
                                        get_cached_info->Buffer.offset );
-               copy_to_user ( buffer, 0, info, len );
+               memcpy ( buffer, info, len );
                get_cached_info->BufferSize = len;
        }
 
index 073414dce15182c5321bec26e7719b31f0d19053..aa675fd13a631cf69b492064c2bc65cab51b9194 100644 (file)
@@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <stdio.h>
 #include <errno.h>
 #include <byteswap.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/in.h>
 #include <ipxe/tftp.h>
 #include <ipxe/iobuf.h>
@@ -49,7 +48,7 @@ struct pxe_tftp_connection {
        /** Data transfer interface */
        struct interface xfer;
        /** Data buffer */
-       userptr_t buffer;
+       void *buffer;
        /** Size of data buffer */
        size_t size;
        /** Starting offset of data buffer */
@@ -121,9 +120,8 @@ static int pxe_tftp_xfer_deliver ( struct pxe_tftp_connection *pxe_tftp,
                      ( pxe_tftp->start + pxe_tftp->size ) );
                rc = -ENOBUFS;
        } else {
-               copy_to_user ( pxe_tftp->buffer,
-                              ( pxe_tftp->offset - pxe_tftp->start ),
-                              iobuf->data, len );
+               memcpy ( ( pxe_tftp->buffer + pxe_tftp->offset -
+                          pxe_tftp->start ), iobuf->data, len );
        }
 
        /* Calculate new buffer position */
@@ -385,7 +383,7 @@ static PXENV_EXIT_t pxenv_tftp_read ( struct s_PXENV_TFTP_READ *tftp_read ) {
        while ( ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) &&
                ( pxe_tftp.offset == pxe_tftp.start ) )
                step();
-       pxe_tftp.buffer = UNULL;
+       pxe_tftp.buffer = NULL;
        tftp_read->BufferSize = ( pxe_tftp.offset - pxe_tftp.start );
        tftp_read->PacketNumber = ++pxe_tftp.blkidx;
 
@@ -496,7 +494,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
        pxe_tftp.size = tftp_read_file->BufferSize;
        while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS )
                step();
-       pxe_tftp.buffer = UNULL;
+       pxe_tftp.buffer = NULL;
        tftp_read_file->BufferSize = pxe_tftp.max_offset;
 
        /* Close TFTP file */
index 47abb7df45fe01675b67f4f948378874d0748ad8..61c858ddec936130586a367fc5185d5a8865a3d3 100644 (file)
@@ -9,7 +9,6 @@
 #include <ipxe/iobuf.h>
 #include <ipxe/xfer.h>
 #include <ipxe/udp.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/process.h>
 #include <ipxe/netdevice.h>
 #include <ipxe/malloc.h>
@@ -296,7 +295,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) {
        };
        size_t len;
        struct io_buffer *iobuf;
-       userptr_t buffer;
+       const void *buffer;
        int rc;
 
        DBG ( "PXENV_UDP_WRITE" );
@@ -330,7 +329,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) {
        }
        buffer = real_to_virt ( pxenv_udp_write->buffer.segment,
                                pxenv_udp_write->buffer.offset );
-       copy_from_user ( iob_put ( iobuf, len ), buffer, 0, len );
+       memcpy ( iob_put ( iobuf, len ), buffer, len );
 
        DBG ( " %04x:%04x+%x %d->%s:%d\n", pxenv_udp_write->buffer.segment,
              pxenv_udp_write->buffer.offset, pxenv_udp_write->buffer_size,
@@ -400,7 +399,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) {
        struct pxe_udp_pseudo_header *pshdr;
        uint16_t d_port_wanted = pxenv_udp_read->d_port;
        uint16_t d_port;
-       userptr_t buffer;
+       void *buffer;
        size_t len;
 
        /* Try receiving a packet, if the queue is empty */
@@ -443,7 +442,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) {
        len = iob_len ( iobuf );
        if ( len > pxenv_udp_read->buffer_size )
                len = pxenv_udp_read->buffer_size;
-       copy_to_user ( buffer, 0, iobuf->data, len );
+       memcpy ( buffer, iobuf->data, len );
        pxenv_udp_read->buffer_size = len;
 
        /* Fill in source/dest information */
index 07589f0b84329050beb53a56c7def334f5e107da..0d400db1641ad022d54035579540de51f6381c67 100644 (file)
@@ -198,7 +198,7 @@ static int cachedhcp_apply ( struct cached_dhcp_packet *cache,
  * @ret rc             Return status code
  */
 int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan,
-                      userptr_t data, size_t max_len ) {
+                      const void *data, size_t max_len ) {
        struct dhcp_packet *dhcppkt;
        struct dhcp_packet *tmp;
        struct dhcphdr *dhcphdr;
@@ -216,7 +216,7 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan,
                return -ENOMEM;
        }
        dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) );
-       copy_from_user ( dhcphdr, data, 0, max_len );
+       memcpy ( dhcphdr, data, max_len );
        dhcppkt_init ( dhcppkt, dhcphdr, max_len );
 
        /* Shrink packet to required length.  If reallocation fails,
index 1f3c1d8a641f1f9b46e29d0a078a356298440d00..cf4b20379926271bec928ea1ce2a19d093d6e423 100644 (file)
@@ -136,7 +136,7 @@ static void * dma_op_umalloc ( struct dma_device *dma,
        struct dma_operations *op = dma->op;
 
        if ( ! op )
-               return UNULL;
+               return NULL;
        return op->umalloc ( dma, map, len, align );
 }
 
index 4c709b34258bde0de5817b20ccf3bd0c7ab78349..7c7127aed86d25256a29a1d4acc3c58a6b4cd2ab 100644 (file)
@@ -1037,7 +1037,7 @@ static int fdt_urealloc ( struct fdt *fdt, size_t len ) {
        assert ( len >= fdt->used );
 
        /* Attempt reallocation */
-       new = urealloc ( virt_to_user ( fdt->raw ), len );
+       new = urealloc ( fdt->raw, len );
        if ( ! new ) {
                DBGC ( fdt, "FDT could not reallocate from +%#04zx to "
                       "+%#04zx\n", fdt->len, len );
@@ -1129,7 +1129,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) {
        return 0;
 
  err_bootargs:
-       ufree ( virt_to_user ( fdt.raw ) );
+       ufree ( fdt.raw );
  err_alloc:
  err_image:
        return rc;
@@ -1143,7 +1143,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) {
 void fdt_remove ( struct fdt_header *hdr ) {
 
        /* Free modifiable copy */
-       ufree ( virt_to_user ( hdr ) );
+       ufree ( hdr );
 }
 
 /* Drag in objects via fdt_describe() */
index 4cb4167e06d72a48576cb89d92e955db25e51cf7..0789ea593bc3a9694d90755d04af1c2eeb915e60 100644 (file)
@@ -2119,7 +2119,7 @@ static void arbel_stop_firmware ( struct arbel *arbel ) {
                DBGC ( arbel, "Arbel %p FATAL could not stop firmware: %s\n",
                       arbel, strerror ( rc ) );
                /* Leak memory and return; at least we avoid corruption */
-               arbel->firmware_area = UNULL;
+               arbel->firmware_area = NULL;
                return;
        }
 }
index 8a5a996a39afaed16d81f6df98ed2505ecc45c5d..a31e599348d92af7d800395fdb565e573a455faf 100644 (file)
@@ -10,7 +10,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
 #include <stdint.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/ib_packet.h>
 #include "mlx_bitops.h"
 #include "MT25218_PRM.h"
@@ -492,7 +491,7 @@ struct arbel {
         * final teardown, in order to avoid memory map changes at
         * runtime.
         */
-       userptr_t firmware_area;
+       void *firmware_area;
        /** ICM size */
        size_t icm_len;
        /** ICM AUX size */
@@ -503,7 +502,7 @@ struct arbel {
         * final teardown, in order to avoid memory map changes at
         * runtime.
         */
-       userptr_t icm;
+       void *icm;
        /** Offset within ICM of doorbell records */
        size_t db_rec_offset;
        /** Doorbell records */
index a33bad9ff84246218a4cfdc903fd0cce9de81cd4..ffa78fabfa4e78e3469e065d7befeb0178811d73 100755 (executable)
@@ -52,7 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 struct golan_page {
        struct list_head list;
-       userptr_t addr;
+       void *addr;
 };
 
 static void golan_free_fw_areas ( struct golan *golan ) {
@@ -61,7 +61,7 @@ static void golan_free_fw_areas ( struct golan *golan ) {
        for (i = 0; i < GOLAN_FW_AREAS_NUM; i++) {
                if ( golan->fw_areas[i].area ) {
                        ufree ( golan->fw_areas[i].area );
-                       golan->fw_areas[i].area = UNULL;
+                       golan->fw_areas[i].area = NULL;
                }
        }
 }
@@ -75,7 +75,7 @@ static int golan_init_fw_areas ( struct golan *golan ) {
        }
 
        for (i = 0; i < GOLAN_FW_AREAS_NUM; i++)
-               golan->fw_areas[i].area = UNULL;
+               golan->fw_areas[i].area = NULL;
 
        return rc;
 
@@ -448,12 +448,12 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages
        int size_ibox = 0;
        int size_obox = 0;
        int rc = 0;
-       userptr_t next_page_addr = UNULL;
+       void *next_page_addr = NULL;
 
        DBGC(golan, "%s\n", __FUNCTION__);
        if ( ! fw_area->area ) {
                fw_area->area = umalloc ( GOLAN_PAGE_SIZE * pages );
-               if ( fw_area->area == UNULL ) {
+               if ( fw_area->area == NULL ) {
                        rc = -ENOMEM;
                        DBGC (golan ,"Failed to allocated %d pages \n",pages);
                        goto err_golan_alloc_fw_area;
@@ -467,7 +467,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages
                unsigned i, j;
                struct golan_cmd_layout *cmd;
                struct golan_manage_pages_inbox *in;
-               userptr_t addr = 0;
+               void *addr = NULL;
 
                mailbox = GET_INBOX(golan, MEM_MBOX);
                size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE);
index f7da1e96070425f3e6041c4dbf8e266327020925..8122f8d38f1baac024baf1fadedc77edd4e3f5e1 100755 (executable)
@@ -121,7 +121,7 @@ struct golan_firmware_area {
         * final teardown, in order to avoid memory map changes at
         * runtime.
         */
-       userptr_t area;
+       void *area;
 };
 /* Queue Pair */
 #define GOLAN_SEND_WQE_BB_SIZE                 64
index 3138d8bfb1d5c239653fb0350fcecaf349e07021..d25f4f011736322d47cd0423c6ba8d8a3574f450 100644 (file)
@@ -2422,7 +2422,7 @@ static void hermon_stop_firmware ( struct hermon *hermon ) {
                DBGC ( hermon, "Hermon %p FATAL could not stop firmware: %s\n",
                       hermon, strerror ( rc ) );
                /* Leak memory and return; at least we avoid corruption */
-               hermon->firmware_area = UNULL;
+               hermon->firmware_area = NULL;
                return;
        }
 }
index a952bbd8158d0988c32502c353693eba4ded2c81..be79ff9d0b3ef87891a123d14fabeb1f799db586 100644 (file)
@@ -10,7 +10,6 @@
 FILE_LICENCE ( GPL2_OR_LATER );
 
 #include <stdint.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/ib_packet.h>
 #include <ipxe/bofm.h>
 #include <ipxe/nvsvpd.h>
@@ -887,7 +886,7 @@ struct hermon {
         * final teardown, in order to avoid memory map changes at
         * runtime.
         */
-       userptr_t firmware_area;
+       void *firmware_area;
        /** ICM map */
        struct hermon_icm_map icm_map[HERMON_ICM_NUM_REGIONS];
        /** ICM size */
@@ -900,7 +899,7 @@ struct hermon {
         * final teardown, in order to avoid memory map changes at
         * runtime.
         */
-       userptr_t icm;
+       void *icm;
 
        /** Event queue */
        struct hermon_event_queue eq;
index 6381fb2dd31ed10ca2701b9fe2c096649ea59bb4..c60d4ca1893b8edafef69cd37ab91b094154ab19 100644 (file)
@@ -177,7 +177,7 @@ struct nii_nic {
        size_t mtu;
 
        /** Hardware transmit/receive buffer */
-       userptr_t buffer;
+       void *buffer;
        /** Hardware transmit/receive buffer length */
        size_t buffer_len;
 
index 5be52fb8ec909ac787ab6c13b8c85fe22082337d..4bdf7b51748e7e635a446aa52700a1d047c3e7a1 100644 (file)
@@ -622,7 +622,7 @@ static int netvsc_buffer_copy ( struct vmbus_xfer_pages *pages, void *data,
                return -ERANGE;
 
        /* Copy data from buffer */
-       copy_from_user ( data, buffer->data, offset, len );
+       memcpy ( data, ( buffer->data + offset ), len );
 
        return 0;
 }
index 93192357fe16f3dbb4f9bdc562144ca25fd50d18..41db49af7bd24a0e06206e461a24c5b5d76ef4b4 100644 (file)
@@ -305,7 +305,7 @@ struct netvsc_buffer {
        /** Buffer length */
        size_t len;
        /** Buffer */
-       userptr_t data;
+       void *data;
        /** GPADL ID */
        unsigned int gpadl;
 };
index a3c8888af0eadbc62f842b1b08f69b735b31e309..22bc115c2df1c9c8e6c763050cdf0b63dc54ffa3 100644 (file)
@@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
 #include <assert.h>
 #include <ipxe/pci.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/usb.h>
 
 /** Minimum alignment required for data structures
@@ -1054,7 +1053,7 @@ struct xhci_scratchpad {
        /** Number of page-sized scratchpad buffers */
        unsigned int count;
        /** Scratchpad buffer area */
-       userptr_t buffer;
+       void *buffer;
        /** Buffer DMA mapping */
        struct dma_mapping buffer_map;
        /** Scratchpad array */
index ebc2b703dd548772cfb491026528f8cddca698ad..2cb637dc22609c5ca048f9abad0bcec9d53f3161 100644 (file)
@@ -57,7 +57,7 @@ struct errortab segment_errors[] __errortab = {
  * @v memsz            Size of the segment
  * @ret rc             Return status code
  */
-int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) {
+int prep_segment ( void *segment, size_t filesz, size_t memsz ) {
        struct memory_map memmap;
        physaddr_t start = virt_to_phys ( segment );
        physaddr_t mid = ( start + filesz );
index 8ebee3b7b4af926e55b94eac5328038fd8a457e6..5b19bc59e7d286d4eb410523f5f69e2540faa9e8 100644 (file)
@@ -10,7 +10,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
 #include <stddef.h>
-#include <ipxe/uaccess.h>
 
 struct net_device;
 struct cached_dhcp_packet;
@@ -20,7 +19,7 @@ extern struct cached_dhcp_packet cached_proxydhcp;
 extern struct cached_dhcp_packet cached_pxebs;
 
 extern int cachedhcp_record ( struct cached_dhcp_packet *cache,
-                             unsigned int vlan, userptr_t data,
+                             unsigned int vlan, const void *data,
                              size_t max_len );
 extern void cachedhcp_recycle ( struct net_device *netdev );
 
index d97b649c0fde44fabebbb15b829a3abfb6ab2f31..fbe1e6e8a68800f3f47e581639229f5050543fab 100644 (file)
@@ -9,8 +9,6 @@
 
 FILE_LICENCE ( GPL2_OR_LATER );
 
-#include <ipxe/uaccess.h>
-
-extern int linux_sysfs_read ( const char *filename, userptr_t *data );
+extern int linux_sysfs_read ( const char *filename, void **data );
 
 #endif /* _IPXE_LINUX_SYSFS_H */
index 2bb38c460e2e517adf9753ed2b31639f7bed45dc..4b6c64156a0258827e2d42daf9575ff616de02c9 100644 (file)
@@ -10,8 +10,7 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
 #include <stdint.h>
-#include <ipxe/uaccess.h>
 
-extern size_t largest_memblock ( userptr_t *start );
+extern size_t largest_memblock ( void **start );
 
 #endif /* _IPXE_MEMBLOCK_H */
index 9d5ecbd9be9adc42c005ecfbde4631c12a15c384..b37c93c93a5ce29c75bc20e5e6031a276f15b061 100644 (file)
@@ -10,8 +10,8 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
-#include <ipxe/uaccess.h>
+#include <stdint.h>
 
-extern int prep_segment ( userptr_t segment, size_t filesz, size_t memsz );
+extern int prep_segment ( void *segment, size_t filesz, size_t memsz );
 
 #endif /* _IPXE_SEGMENT_H */
index 682441857032208814a34fe44201b4ba2fdefe2e..5eee230fef3e39712fae6abd787cda04dc72f4e5 100644 (file)
@@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/uuid.h>
 #include <ipxe/device.h>
 #include <ipxe/tables.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/iobuf.h>
 #include <ipxe/hyperv.h>
 
@@ -634,7 +633,7 @@ vmbus_gpadl_is_obsolete ( unsigned int gpadl ) {
        return ( gpadl <= vmbus_obsolete_gpadl );
 }
 
-extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data,
+extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data,
                                   size_t len );
 extern int vmbus_gpadl_teardown ( struct vmbus_device *vmdev,
                                  unsigned int gpadl );
index 5165bd804bb33bdb90a9ab8aec4477b23c90e1b6..94e2aae06f0856278ed3cc3d756e83bca6486c39 100644 (file)
@@ -110,8 +110,7 @@ static int efi_block_rw ( struct san_device *sandev, uint64_t lba,
        }
 
        /* Read from / write to block device */
-       if ( ( rc = sandev_rw ( sandev, lba, count,
-                               virt_to_user ( data ) ) ) != 0 ) {
+       if ( ( rc = sandev_rw ( sandev, lba, count, data ) ) != 0 ) {
                DBGC ( sandev->drive, "EFIBLK %#02x I/O failed: %s\n",
                       sandev->drive, strerror ( rc ) );
                return rc;
index b64770d8aa5546d9fbdd5d20f4e7b610289f327a..7d1d3619f5e8205d0018ca3d36641d68b25a98db 100644 (file)
@@ -284,8 +284,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
                        efi_handle_name ( device ) );
                DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
        }
-       bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ),
-                       &efipci.pci );
+       bofmrc = bofm ( ( bofmtab2 ? bofmtab2 : bofmtab ), &efipci.pci );
        DBGC ( device, "EFIBOFM %s status %08x\n",
               efi_handle_name ( device ), bofmrc );
        DBGC2 ( device, "EFIBOFM %s version 1 after processing:\n",
index eb41a8e43f37708d4885f25adc8ba62a3d9455ef..6bba4173a570dc94e2f7a23ad0988e3294e882d0 100644 (file)
@@ -72,8 +72,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
 
        /* Record DHCPACK, if present */
        if ( mode->DhcpAckReceived &&
-            ( ( rc = cachedhcp_record ( &cached_dhcpack, vlan,
-                                        virt_to_user ( &mode->DhcpAck ),
+            ( ( rc = cachedhcp_record ( &cached_dhcpack, vlan, &mode->DhcpAck,
                                         sizeof ( mode->DhcpAck ) ) ) != 0 ) ) {
                DBGC ( device, "EFI %s could not record DHCPACK: %s\n",
                       efi_handle_name ( device ), strerror ( rc ) );
@@ -83,7 +82,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
        /* Record ProxyDHCPOFFER, if present */
        if ( mode->ProxyOfferReceived &&
             ( ( rc = cachedhcp_record ( &cached_proxydhcp, vlan,
-                                        virt_to_user ( &mode->ProxyOffer ),
+                                        &mode->ProxyOffer,
                                         sizeof ( mode->ProxyOffer ) ) ) != 0)){
                DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n",
                       efi_handle_name ( device ), strerror ( rc ) );
@@ -92,9 +91,8 @@ int efi_cachedhcp_record ( EFI_HANDLE device,
 
        /* Record PxeBSACK, if present */
        if ( mode->PxeReplyReceived &&
-            ( ( rc = cachedhcp_record ( &cached_pxebs, vlan,
-                                        virt_to_user ( &mode->PxeReply ),
-                                        sizeof ( mode->PxeReply ) ) ) != 0)){
+            ( ( rc = cachedhcp_record ( &cached_pxebs, vlan, &mode->PxeReply,
+                                        sizeof ( mode->PxeReply ) ) ) != 0 )){
                DBGC ( device, "EFI %s could not record PXEBSACK: %s\n",
                       efi_handle_name ( device ), strerror ( rc ) );
                return rc;
index b7b97aee7cce0824a7f501c4713a9642581c11ac..79330641d5cd3dfc848a6e410d74050c5e5b22e8 100644 (file)
@@ -177,12 +177,12 @@ static size_t efi_file_len ( struct efi_file *file ) {
  * Read chunk of EFI file
  *
  * @v reader           EFI file reader
- * @v data             Input data, or UNULL to zero-fill
+ * @v data             Input data, or NULL to zero-fill
  * @v len              Length of input data
  * @ret len            Length of output data
  */
 static size_t efi_file_read_chunk ( struct efi_file_reader *reader,
-                                   userptr_t data, size_t len ) {
+                                   const void *data, size_t len ) {
        struct efi_file *file = reader->file;
        size_t offset;
 
@@ -203,7 +203,7 @@ static size_t efi_file_read_chunk ( struct efi_file_reader *reader,
 
        /* Copy or zero output data */
        if ( data ) {
-               copy_from_user ( reader->data, data, offset, len );
+               memcpy ( reader->data, ( data + offset ), len );
        } else {
                memset ( reader->data, 0, len );
        }
@@ -262,7 +262,7 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) {
                               efi_file_name ( file ), reader->pos,
                               ( reader->pos + pad_len ) );
                }
-               len += efi_file_read_chunk ( reader, UNULL, pad_len );
+               len += efi_file_read_chunk ( reader, NULL, pad_len );
 
                /* Read CPIO header(s), if applicable */
                name = cpio_name ( image );
@@ -274,13 +274,10 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) {
                               efi_file_name ( file ), reader->pos,
                               ( reader->pos + cpio_len + pad_len ),
                               image->name );
-                       len += efi_file_read_chunk ( reader,
-                                                    virt_to_user ( &cpio ),
+                       len += efi_file_read_chunk ( reader, &cpio,
                                                     sizeof ( cpio ) );
-                       len += efi_file_read_chunk ( reader,
-                                                    virt_to_user ( name ),
-                                                    name_len );
-                       len += efi_file_read_chunk ( reader, UNULL, pad_len );
+                       len += efi_file_read_chunk ( reader, name, name_len );
+                       len += efi_file_read_chunk ( reader, NULL, pad_len );
                }
 
                /* Read file data */
index 49ccf69c8b9f8896b692e4869773ed0872ad0920..1c44cab5ee5dd9d2d09e1c539dc75b20ee3b4026 100644 (file)
@@ -273,7 +273,7 @@ static int vmbus_negotiate_version ( struct hv_hypervisor *hv ) {
  * @v len              Length of data buffer
  * @ret gpadl          GPADL ID, or negative error
  */
-int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data,
+int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data,
                            size_t len ) {
        struct hv_hypervisor *hv = vmdev->hv;
        struct vmbus *vmbus = hv->vmbus;
@@ -442,7 +442,7 @@ int vmbus_open ( struct vmbus_device *vmdev,
        memset ( ring, 0, len );
 
        /* Establish GPADL for ring buffer */
-       gpadl = vmbus_establish_gpadl ( vmdev, virt_to_user ( ring ), len );
+       gpadl = vmbus_establish_gpadl ( vmdev, ring, len );
        if ( gpadl < 0 ) {
                rc = gpadl;
                goto err_establish;
index a2a8bf12e2b9f50157c2e4ec6169b03d59059012..21a2e27ccae6d33e06add05d3e52536306e71b12 100644 (file)
@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <errno.h>
 #include <ipxe/linux_api.h>
 #include <ipxe/linux_sysfs.h>
index a12c936edf87e48ecc35ffc466b42d4b37aaf4b8..1450fcf1b8573cd970feac3cd688c9358cd1362e 100644 (file)
@@ -19,6 +19,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER );
 
+#include <string.h>
 #include <errno.h>
 #include <ipxe/linux_api.h>
 #include <ipxe/linux_sysfs.h>
index cbb23d81d26413da684428c825f349732f538fc6..321824ba900f4ced24ce196952c4c9ef23da69de 100644 (file)
@@ -42,8 +42,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
  * @v data             Data to fill in
  * @ret len            Length read, or negative error
  */
-int linux_sysfs_read ( const char *filename, userptr_t *data ) {
-       userptr_t tmp;
+int linux_sysfs_read ( const char *filename, void **data ) {
+       void *tmp;
        ssize_t read;
        size_t len;
        int fd;
@@ -59,7 +59,7 @@ int linux_sysfs_read ( const char *filename, userptr_t *data ) {
        }
 
        /* Read file */
-       for ( *data = UNULL, len = 0 ; ; len += read ) {
+       for ( *data = NULL, len = 0 ; ; len += read ) {
 
                /* (Re)allocate space */
                tmp = urealloc ( *data, ( len + LINUX_SYSFS_BLKSIZE ) );
index 829924887bfa61b5e159d57dfde483aed21fdf27..dbef1eb9071313817d32886643123485c0a1c505 100644 (file)
@@ -26,7 +26,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-#include <ipxe/uaccess.h>
 #include <ipxe/init.h>
 #include <ipxe/pci.h>
 #include <ipxe/ethernet.h>
@@ -111,7 +110,7 @@ void bofm_test ( struct pci_device *pci ) {
        printf ( "BOFMTEST performing harvest\n" );
        bofmtab_harvest.en.busdevfn = pci->busdevfn;
        DBG_HDA ( 0, &bofmtab_harvest, sizeof ( bofmtab_harvest ) );
-       bofmrc = bofm ( virt_to_user ( &bofmtab_harvest ), pci );
+       bofmrc = bofm ( &bofmtab_harvest, pci );
        printf ( "BOFMTEST harvest result %08x\n", bofmrc );
        if ( bofmtab_harvest.en.options & BOFM_EN_HVST ) {
                printf ( "BOFMTEST harvested MAC address %s\n",
@@ -125,7 +124,7 @@ void bofm_test ( struct pci_device *pci ) {
        printf ( "BOFMTEST performing update\n" );
        bofmtab_update.en.busdevfn = pci->busdevfn;
        DBG_HDA ( 0, &bofmtab_update, sizeof ( bofmtab_update ) );
-       bofmrc = bofm ( virt_to_user ( &bofmtab_update ), pci );
+       bofmrc = bofm ( &bofmtab_update, pci );
        printf ( "BOFMTEST update result %08x\n", bofmrc );
        if ( bofmtab_update.en.options & BOFM_EN_CSM_SUCCESS ) {
                printf ( "BOFMTEST updated MAC address to %s\n",