[uaccess] Remove trivial uses of userptr_t

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-24 01:30:50 +01:00
parent 945df9b429
commit e8ffe2cd64
34 changed files with 69 additions and 86 deletions

View 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;
}

View 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;

View 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 );
}
/**

View 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;
}

View 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 */

View 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 */