summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2025-04-20 19:29:48 +0200
committerMichael Brown2025-04-21 00:00:13 +0200
commit89fe7886897be76ed902317e311d60ae654057aa (patch)
treeeddd42226c8336226d0a9649d705ccc9f02c88f4 /src
parent[uaccess] Remove redundant userptr_add() and userptr_diff() (diff)
downloadipxe-89fe7886897be76ed902317e311d60ae654057aa.tar.gz
ipxe-89fe7886897be76ed902317e311d60ae654057aa.tar.xz
ipxe-89fe7886897be76ed902317e311d60ae654057aa.zip
[uaccess] Remove redundant memcpy_user() and related string functions
The memcpy_user(), memmove_user(), memcmp_user(), memset_user(), and strlen_user() functions are now just straightforward wrappers around the corresponding standard library functions. Remove these redundant wrappers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/core/runtime.c2
-rw-r--r--src/arch/x86/image/bzimage.c13
-rw-r--r--src/arch/x86/image/com32.c2
-rw-r--r--src/arch/x86/image/comboot.c4
-rw-r--r--src/arch/x86/image/initrd.c12
-rw-r--r--src/arch/x86/image/multiboot.c6
-rw-r--r--src/arch/x86/image/nbi.c2
-rw-r--r--src/arch/x86/image/pxe_image.c2
-rw-r--r--src/arch/x86/image/sdi.c4
-rw-r--r--src/arch/x86/image/ucode.c2
-rw-r--r--src/arch/x86/include/librm.h32
-rw-r--r--src/arch/x86/interface/pcbios/memtop_umalloc.c4
-rw-r--r--src/arch/x86/interface/pxe/pxe_file.c6
-rw-r--r--src/arch/x86/interface/syslinux/com32_call.c20
-rw-r--r--src/arch/x86/interface/syslinux/comboot_call.c20
-rw-r--r--src/arch/x86/transitions/librm_mgmt.c8
-rw-r--r--src/core/fbcon.c24
-rw-r--r--src/core/image.c2
-rw-r--r--src/core/uaccess.c4
-rw-r--r--src/crypto/deflate.c4
-rw-r--r--src/drivers/net/exanic.c2
-rw-r--r--src/drivers/net/gve.c2
-rw-r--r--src/drivers/usb/xhci.c2
-rw-r--r--src/image/elf.c2
-rw-r--r--src/image/segment.c2
-rw-r--r--src/include/ipxe/linux/linux_uaccess.h32
-rw-r--r--src/include/ipxe/uaccess.h166
-rw-r--r--src/interface/efi/efi_fbcon.c4
-rw-r--r--src/interface/efi/efi_umalloc.c4
-rw-r--r--src/interface/linux/linux_uaccess.c4
-rw-r--r--src/interface/smbios/smbios.c2
-rw-r--r--src/tests/cms_test.c4
-rw-r--r--src/tests/gzip_test.c5
-rw-r--r--src/tests/pixbuf_test.c5
-rw-r--r--src/tests/zlib_test.c5
35 files changed, 83 insertions, 331 deletions
diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c
index 02072b5bf..2b803f772 100644
--- a/src/arch/x86/core/runtime.c
+++ b/src/arch/x86/core/runtime.c
@@ -125,7 +125,7 @@ static int cmdline_init ( void ) {
return 0;
}
cmdline_user = phys_to_user ( cmdline_phys );
- len = ( strlen_user ( cmdline_user, 0 ) + 1 /* NUL */ );
+ len = ( strlen ( cmdline_user ) + 1 /* NUL */ );
/* Allocate and copy command line */
cmdline_copy = malloc ( len );
diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c
index d00b9f155..29ebeb507 100644
--- a/src/arch/x86/image/bzimage.c
+++ b/src/arch/x86/image/bzimage.c
@@ -369,8 +369,8 @@ static size_t bzimage_load_initrd ( struct image *image,
/* Copy in initrd image body and construct any cpio headers */
if ( address ) {
- memmove_user ( address, len, initrd->data, 0, initrd->len );
- memset_user ( address, 0, 0, len );
+ memmove ( ( address + len ), initrd->data, initrd->len );
+ memset ( address, 0, len );
offset = 0;
for ( i = 0 ; ( cpio_len = cpio_header ( initrd, i, &cpio ) ) ;
i++ ) {
@@ -395,7 +395,7 @@ static size_t bzimage_load_initrd ( struct image *image,
/* Zero-pad to next INITRD_ALIGN boundary */
pad_len = ( ( -len ) & ( INITRD_ALIGN - 1 ) );
if ( address )
- memset_user ( address, len, 0, pad_len );
+ memset ( ( address + len ), 0, pad_len );
return len;
}
@@ -562,10 +562,9 @@ static int bzimage_exec ( struct image *image ) {
unregister_image ( image_get ( image ) );
/* Load segments */
- memcpy_user ( bzimg.rm_kernel, 0, image->data,
- 0, bzimg.rm_filesz );
- memcpy_user ( bzimg.pm_kernel, 0, image->data,
- bzimg.rm_filesz, bzimg.pm_sz );
+ memcpy ( bzimg.rm_kernel, image->data, bzimg.rm_filesz );
+ memcpy ( bzimg.pm_kernel, ( image->data + bzimg.rm_filesz ),
+ bzimg.pm_sz );
/* Store command line */
bzimage_set_cmdline ( image, &bzimg );
diff --git a/src/arch/x86/image/com32.c b/src/arch/x86/image/com32.c
index 6f0e66041..3e38215cb 100644
--- a/src/arch/x86/image/com32.c
+++ b/src/arch/x86/image/com32.c
@@ -219,7 +219,7 @@ static int com32_load_image ( struct image *image ) {
}
/* Copy image to segment */
- memcpy_user ( buffer, 0, image->data, 0, filesz );
+ memcpy ( buffer, image->data, filesz );
return 0;
}
diff --git a/src/arch/x86/image/comboot.c b/src/arch/x86/image/comboot.c
index 9a847f0ff..8609eb0f7 100644
--- a/src/arch/x86/image/comboot.c
+++ b/src/arch/x86/image/comboot.c
@@ -267,10 +267,10 @@ static int comboot_prepare_segment ( struct image *image )
}
/* Zero PSP */
- memset_user ( seg_userptr, 0, 0, 0x100 );
+ memset ( seg_userptr, 0, 0x100 );
/* Copy image to segment:0100 */
- memcpy_user ( seg_userptr, 0x100, image->data, 0, image->len );
+ memcpy ( ( seg_userptr + 0x100 ), image->data, image->len );
return 0;
}
diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c
index e32e40341..95f12d804 100644
--- a/src/arch/x86/image/initrd.c
+++ b/src/arch/x86/image/initrd.c
@@ -80,7 +80,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) {
user_to_phys ( highest->data, highest->len ),
user_to_phys ( current, 0 ),
user_to_phys ( current, highest->len ) );
- memmove_user ( current, 0, highest->data, 0, highest->len );
+ memmove ( current, highest->data, highest->len );
highest->data = current;
}
@@ -96,8 +96,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) {
user_to_phys ( initrd->data, initrd->len ),
user_to_phys ( current, 0 ),
user_to_phys ( current, initrd->len ) );
- memcpy_user ( current, 0, initrd->data, 0,
- initrd->len );
+ memcpy ( current, initrd->data, initrd->len );
initrd->data = current;
}
}
@@ -140,9 +139,10 @@ static void initrd_swap ( struct image *low, struct image *high,
~( INITRD_ALIGN - 1 ) );
/* Swap fragments */
- memcpy_user ( free, 0, high->data, len, frag_len );
- memmove_user ( low->data, new_len, low->data, len, low->len );
- memcpy_user ( low->data, len, free, 0, frag_len );
+ memcpy ( free, ( high->data + len ), frag_len );
+ memmove ( ( low->data + new_len ), ( low->data + len ),
+ low->len );
+ memcpy ( ( low->data + len ), free, frag_len );
len = new_len;
}
diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c
index cada021ab..fe21f1f1a 100644
--- a/src/arch/x86/image/multiboot.c
+++ b/src/arch/x86/image/multiboot.c
@@ -222,8 +222,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
}
/* Copy module */
- memcpy_user ( phys_to_user ( start ), 0,
- module_image->data, 0, module_image->len );
+ memcpy ( phys_to_user ( start ), module_image->data,
+ module_image->len );
/* Add module to list */
module = &modules[mbinfo->mods_count++];
@@ -350,7 +350,7 @@ static int multiboot_load_raw ( struct image *image,
}
/* Copy image to segment */
- memcpy_user ( buffer, 0, image->data, offset, filesz );
+ memcpy ( buffer, ( image->data + offset ), filesz );
/* Record execution entry point and maximum used address */
*entry = hdr->mb.entry_addr;
diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c
index 2f0d3164a..0b02a8985 100644
--- a/src/arch/x86/image/nbi.c
+++ b/src/arch/x86/image/nbi.c
@@ -131,7 +131,7 @@ static int nbi_prepare_segment ( struct image *image, size_t offset __unused,
static int nbi_load_segment ( struct image *image, size_t offset,
userptr_t dest, size_t filesz,
size_t memsz __unused ) {
- memcpy_user ( dest, 0, image->data, offset, filesz );
+ memcpy ( dest, ( image->data + offset ), filesz );
return 0;
}
diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c
index b6bcb18b4..bdce165ca 100644
--- a/src/arch/x86/image/pxe_image.c
+++ b/src/arch/x86/image/pxe_image.c
@@ -66,7 +66,7 @@ static int pxe_exec ( struct image *image ) {
}
/* Copy image to segment */
- memcpy_user ( buffer, 0, image->data, 0, image->len );
+ memcpy ( buffer, image->data, image->len );
/* Arbitrarily pick the most recently opened network device */
if ( ( netdev = last_opened_netdev() ) == NULL ) {
diff --git a/src/arch/x86/image/sdi.c b/src/arch/x86/image/sdi.c
index fa2d0b73f..5bb5a7569 100644
--- a/src/arch/x86/image/sdi.c
+++ b/src/arch/x86/image/sdi.c
@@ -97,8 +97,8 @@ static int sdi_exec ( struct image *image ) {
user_to_phys ( image->data, sdi.boot_offset ), sdi.boot_size );
/* Copy boot code */
- memcpy_user ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), 0,
- image->data, sdi.boot_offset, sdi.boot_size );
+ memcpy ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ),
+ ( image->data + sdi.boot_offset ), sdi.boot_size );
/* Jump to boot code */
sdiptr = ( user_to_phys ( image->data, 0 ) | SDI_WTF );
diff --git a/src/arch/x86/image/ucode.c b/src/arch/x86/image/ucode.c
index 499c0a940..9b6b5067a 100644
--- a/src/arch/x86/image/ucode.c
+++ b/src/arch/x86/image/ucode.c
@@ -256,7 +256,7 @@ static int ucode_update_all ( struct image *image,
rc = -ENOMEM;
goto err_alloc;
}
- memset_user ( status, 0, 0, len );
+ memset ( status, 0, len );
/* Construct control structure */
memset ( &control, 0, sizeof ( control ) );
diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h
index c0d910287..c117a8b5c 100644
--- a/src/arch/x86/include/librm.h
+++ b/src/arch/x86/include/librm.h
@@ -137,38 +137,6 @@ UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) {
return trivial_user_to_virt ( userptr, offset );
}
-static inline __always_inline void
-UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off,
- size_t len ) {
- trivial_memcpy_user ( dest, dest_off, src, src_off, len );
-}
-
-static inline __always_inline void
-UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off,
- size_t len ) {
- trivial_memmove_user ( dest, dest_off, src, src_off, len );
-}
-
-static inline __always_inline int
-UACCESS_INLINE ( librm, memcmp_user ) ( userptr_t first, off_t first_off,
- userptr_t second, off_t second_off,
- size_t len ) {
- return trivial_memcmp_user ( first, first_off, second, second_off, len);
-}
-
-static inline __always_inline void
-UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
- int c, size_t len ) {
- trivial_memset_user ( buffer, offset, c, len );
-}
-
-static inline __always_inline size_t
-UACCESS_INLINE ( librm, strlen_user ) ( userptr_t buffer, off_t offset ) {
- return trivial_strlen_user ( buffer, offset );
-}
-
static inline __always_inline off_t
UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset,
int c, size_t len ) {
diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c
index e76b3df93..8239b23b8 100644
--- a/src/arch/x86/interface/pcbios/memtop_umalloc.c
+++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c
@@ -203,8 +203,8 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
user_to_phys ( ptr, extmem.size ),
user_to_phys ( new, 0 ),
user_to_phys ( new, new_size ));
- memmove_user ( new, 0, ptr, 0, ( ( extmem.size < new_size ) ?
- extmem.size : new_size ) );
+ memmove ( new, ptr, ( ( extmem.size < new_size ) ?
+ extmem.size : new_size ) );
bottom = new;
heap_size -= ( new_size - extmem.size );
extmem.size = new_size;
diff --git a/src/arch/x86/interface/pxe/pxe_file.c b/src/arch/x86/interface/pxe/pxe_file.c
index 456ffb5fd..1235520de 100644
--- a/src/arch/x86/interface/pxe/pxe_file.c
+++ b/src/arch/x86/interface/pxe/pxe_file.c
@@ -61,8 +61,8 @@ static PXENV_EXIT_t pxenv_file_open ( struct s_PXENV_FILE_OPEN *file_open ) {
/* Copy name from external program, and open it */
filename = real_to_user ( file_open->FileName.segment,
- file_open->FileName.offset );
- filename_len = strlen_user ( filename, 0 );
+ file_open->FileName.offset );
+ filename_len = strlen ( filename );
{
char uri_string[ filename_len + 1 ];
@@ -219,7 +219,7 @@ static PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) {
/* Copy name from external program, and exec it */
command = real_to_user ( file_exec->Command.segment,
file_exec->Command.offset );
- command_len = strlen_user ( command, 0 );
+ command_len = strlen ( command );
{
char command_string[ command_len + 1 ];
diff --git a/src/arch/x86/interface/syslinux/com32_call.c b/src/arch/x86/interface/syslinux/com32_call.c
index 19fdbaff9..da9d6491a 100644
--- a/src/arch/x86/interface/syslinux/com32_call.c
+++ b/src/arch/x86/interface/syslinux/com32_call.c
@@ -49,9 +49,8 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad
DBGC ( &com32_regs, "COM32 INT%x in %#08lx out %#08lx\n",
interrupt, inregs_phys, outregs_phys );
- memcpy_user ( virt_to_user( &com32_regs ), 0,
- phys_to_user ( inregs_phys ), 0,
- sizeof(com32sys_t) );
+ memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ),
+ sizeof ( com32sys_t ) );
com32_int_vector = interrupt;
@@ -108,9 +107,8 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad
: : );
if ( outregs_phys ) {
- memcpy_user ( phys_to_user ( outregs_phys ), 0,
- virt_to_user( &com32_regs ), 0,
- sizeof(com32sys_t) );
+ memcpy ( phys_to_user ( outregs_phys ),
+ virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) );
}
}
@@ -122,9 +120,8 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t
DBGC ( &com32_regs, "COM32 farcall %04x:%04x in %#08lx out %#08lx\n",
( proc >> 16 ), ( proc & 0xffff ), inregs_phys, outregs_phys );
- memcpy_user ( virt_to_user( &com32_regs ), 0,
- phys_to_user ( inregs_phys ), 0,
- sizeof(com32sys_t) );
+ memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ),
+ sizeof ( com32sys_t ) );
com32_farcall_proc = proc;
@@ -170,9 +167,8 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t
: : );
if ( outregs_phys ) {
- memcpy_user ( phys_to_user ( outregs_phys ), 0,
- virt_to_user( &com32_regs ), 0,
- sizeof(com32sys_t) );
+ memcpy ( phys_to_user ( outregs_phys ),
+ virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) );
}
}
diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c
index b75e8ef7c..f26fcad0a 100644
--- a/src/arch/x86/interface/syslinux/comboot_call.c
+++ b/src/arch/x86/interface/syslinux/comboot_call.c
@@ -119,7 +119,7 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig
if ( shuf[ i ].src == 0xFFFFFFFF ) {
/* Fill with 0 instead of copying */
- memset_user ( dest_u, 0, 0, shuf[ i ].len );
+ memset ( dest_u, 0, shuf[ i ].len );
} else if ( shuf[ i ].dest == 0xFFFFFFFF ) {
/* Copy new list of descriptors */
count = shuf[ i ].len / sizeof( comboot_shuffle_descriptor );
@@ -128,7 +128,7 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig
i = -1;
} else {
/* Regular copy */
- memmove_user ( dest_u, 0, src_u, 0, shuf[ i ].len );
+ memmove ( dest_u, src_u, shuf[ i ].len );
}
}
}
@@ -347,7 +347,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
case 0x0003: /* Run command */
{
userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx );
- int len = strlen_user ( cmd_u, 0 );
+ int len = strlen ( cmd_u );
char cmd[len + 1];
copy_from_user ( cmd, cmd_u, 0, len + 1 );
DBG ( "COMBOOT: executing command '%s'\n", cmd );
@@ -371,7 +371,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
{
int fd;
userptr_t file_u = real_to_user ( ix86->segs.es, ix86->regs.si );
- int len = strlen_user ( file_u, 0 );
+ int len = strlen ( file_u );
char file[len + 1];
copy_from_user ( file, file_u, 0, len + 1 );
@@ -484,7 +484,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
case 0x0010: /* Resolve hostname */
{
userptr_t hostname_u = real_to_user ( ix86->segs.es, ix86->regs.bx );
- int len = strlen_user ( hostname_u, 0 );
+ int len = strlen ( hostname_u );
char hostname[len];
struct in_addr addr;
@@ -551,8 +551,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
{
userptr_t file_u = real_to_user ( ix86->segs.ds, ix86->regs.si );
userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx );
- int file_len = strlen_user ( file_u, 0 );
- int cmd_len = strlen_user ( cmd_u, 0 );
+ int file_len = strlen ( file_u );
+ int cmd_len = strlen ( cmd_u );
char file[file_len + 1];
char cmd[cmd_len + 1];
@@ -595,9 +595,9 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );
/* Copy initial register values to .text16 */
- memcpy_user ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ), 0,
- real_to_user ( ix86->segs.ds, ix86->regs.si ), 0,
- sizeof(syslinux_rm_regs) );
+ memcpy ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ),
+ real_to_user ( ix86->segs.ds, ix86->regs.si ),
+ sizeof(syslinux_rm_regs) );
/* Load initial register values */
__asm__ __volatile__ (
diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c
index ec31fceb1..7ebf62137 100644
--- a/src/arch/x86/transitions/librm_mgmt.c
+++ b/src/arch/x86/transitions/librm_mgmt.c
@@ -69,7 +69,7 @@ uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) {
userptr_t rm_stack;
rm_sp -= size;
rm_stack = real_to_user ( rm_ss, rm_sp );
- memcpy_user ( rm_stack, 0, data, 0, size );
+ memcpy ( rm_stack, data, size );
return rm_sp;
};
@@ -83,7 +83,7 @@ uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) {
void remove_user_from_rm_stack ( userptr_t data, size_t size ) {
if ( data ) {
userptr_t rm_stack = real_to_user ( rm_ss, rm_sp );
- memcpy_user ( rm_stack, 0, data, 0, size );
+ memcpy ( rm_stack, data, size );
}
rm_sp += size;
};
@@ -432,10 +432,6 @@ PROVIDE_UACCESS_INLINE ( librm, phys_to_user );
PROVIDE_UACCESS_INLINE ( librm, user_to_phys );
PROVIDE_UACCESS_INLINE ( librm, virt_to_user );
PROVIDE_UACCESS_INLINE ( librm, user_to_virt );
-PROVIDE_UACCESS_INLINE ( librm, memcpy_user );
-PROVIDE_UACCESS_INLINE ( librm, memmove_user );
-PROVIDE_UACCESS_INLINE ( librm, memset_user );
-PROVIDE_UACCESS_INLINE ( librm, strlen_user );
PROVIDE_UACCESS_INLINE ( librm, memchr_user );
PROVIDE_IOMAP_INLINE ( pages, io_to_bus );
PROVIDE_IOMAP ( pages, ioremap, ioremap_pages );
diff --git a/src/core/fbcon.c b/src/core/fbcon.c
index ff3132ac7..8d05484e2 100644
--- a/src/core/fbcon.c
+++ b/src/core/fbcon.c
@@ -185,12 +185,12 @@ static void fbcon_draw ( struct fbcon *fbcon, struct fbcon_text_cell *cell,
/* Draw background picture, if applicable */
if ( transparent ) {
if ( fbcon->picture.start ) {
- memcpy_user ( fbcon->start, offset,
- fbcon->picture.start, offset,
- fbcon->character.len );
+ memcpy ( ( fbcon->start + offset ),
+ ( fbcon->picture.start + offset ),
+ fbcon->character.len );
} else {
- memset_user ( fbcon->start, offset, 0,
- fbcon->character.len );
+ memset ( ( fbcon->start + offset ), 0,
+ fbcon->character.len );
}
}
@@ -247,8 +247,8 @@ static void fbcon_scroll ( struct fbcon *fbcon ) {
/* Scroll up character array */
row_len = ( fbcon->character.width * sizeof ( struct fbcon_text_cell ));
- memmove_user ( fbcon->text.start, 0, fbcon->text.start, row_len,
- ( row_len * ( fbcon->character.height - 1 ) ) );
+ memmove ( fbcon->text.start, ( fbcon->text.start + row_len ),
+ ( row_len * ( fbcon->character.height - 1 ) ) );
fbcon_clear ( fbcon, ( fbcon->character.height - 1 ) );
/* Update cursor position */
@@ -552,7 +552,7 @@ static int fbcon_picture_init ( struct fbcon *fbcon,
( ygap + pixbuf->height ) );
/* Convert to frame buffer raw format */
- memset_user ( picture->start, 0, 0, len );
+ memset ( picture->start, 0, len );
for ( y = 0 ; y < height ; y++ ) {
offset = ( indent + ( y * pixel->stride ) );
pixbuf_offset = ( pixbuf_indent + ( y * pixbuf_stride ) );
@@ -684,7 +684,7 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start,
fbcon_clear ( fbcon, 0 );
/* Set framebuffer to all black (including margins) */
- memset_user ( fbcon->start, 0, 0, fbcon->len );
+ memset ( fbcon->start, 0, fbcon->len );
/* Generate pixel buffer from background image, if applicable */
if ( config->pixbuf &&
@@ -692,10 +692,8 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start,
goto err_picture;
/* Draw background picture (including margins), if applicable */
- if ( fbcon->picture.start ) {
- memcpy_user ( fbcon->start, 0, fbcon->picture.start, 0,
- fbcon->len );
- }
+ if ( fbcon->picture.start )
+ memcpy ( fbcon->start, fbcon->picture.start, fbcon->len );
/* Update console width and height */
console_set_size ( fbcon->character.width, fbcon->character.height );
diff --git a/src/core/image.c b/src/core/image.c
index c69c05c93..709d0da9c 100644
--- a/src/core/image.c
+++ b/src/core/image.c
@@ -246,7 +246,7 @@ int image_set_data ( struct image *image, userptr_t data, size_t len ) {
return rc;
/* Copy in new image data */
- memcpy_user ( image->data, 0, data, 0, len );
+ memcpy ( image->data, data, len );
return 0;
}
diff --git a/src/core/uaccess.c b/src/core/uaccess.c
index ad17a58ab..01089e6fa 100644
--- a/src/core/uaccess.c
+++ b/src/core/uaccess.c
@@ -36,8 +36,4 @@ PROVIDE_UACCESS_INLINE ( flat, phys_to_user );
PROVIDE_UACCESS_INLINE ( flat, user_to_phys );
PROVIDE_UACCESS_INLINE ( flat, virt_to_user );
PROVIDE_UACCESS_INLINE ( flat, user_to_virt );
-PROVIDE_UACCESS_INLINE ( flat, memcpy_user );
-PROVIDE_UACCESS_INLINE ( flat, memmove_user );
-PROVIDE_UACCESS_INLINE ( flat, memset_user );
-PROVIDE_UACCESS_INLINE ( flat, strlen_user );
PROVIDE_UACCESS_INLINE ( flat, memchr_user );
diff --git a/src/crypto/deflate.c b/src/crypto/deflate.c
index 7ad39ec1b..c6cce7516 100644
--- a/src/crypto/deflate.c
+++ b/src/crypto/deflate.c
@@ -464,8 +464,8 @@ static void deflate_copy ( struct deflate_chunk *out,
if ( copy_len > len )
copy_len = len;
while ( copy_len-- ) {
- memcpy_user ( out->data, out_offset++,
- start, offset++, 1 );
+ memcpy ( ( out->data + out_offset++ ),
+ ( start + offset++ ), 1 );
}
}
out->offset += len;
diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c
index aaa6a28a1..14a17df47 100644
--- a/src/drivers/net/exanic.c
+++ b/src/drivers/net/exanic.c
@@ -395,7 +395,7 @@ static int exanic_open ( struct net_device *netdev ) {
}
/* Reset receive region contents */
- memset_user ( port->rx, 0, 0xff, EXANIC_RX_LEN );
+ memset ( port->rx, 0xff, EXANIC_RX_LEN );
/* Reset transmit feedback region */
*(port->txf) = 0;
diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c
index 805feee3d..2cbc401f5 100644
--- a/src/drivers/net/gve.c
+++ b/src/drivers/net/gve.c
@@ -980,7 +980,7 @@ static int gve_start ( struct gve_nic *gve ) {
}
/* Invalidate receive completions */
- memset_user ( rx->cmplt, 0, 0, ( rx->count * rx->type->cmplt_len ) );
+ memset ( rx->cmplt, 0, ( rx->count * rx->type->cmplt_len ) );
/* Reset receive sequence */
gve->seq = gve_next ( 0 );
diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c
index 3247ee69c..f244086ce 100644
--- a/src/drivers/usb/xhci.c
+++ b/src/drivers/usb/xhci.c
@@ -1000,7 +1000,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) {
rc = -ENOMEM;
goto err_alloc;
}
- memset_user ( scratch->buffer, 0, 0, buffer_len );
+ memset ( scratch->buffer, 0, buffer_len );
/* Allocate scratchpad array */
array_len = ( scratch->count * sizeof ( scratch->array[0] ) );
diff --git a/src/image/elf.c b/src/image/elf.c
index 5c2f9db25..46c9fe8eb 100644
--- a/src/image/elf.c
+++ b/src/image/elf.c
@@ -66,7 +66,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr,
}
/* Copy image to segment */
- memcpy_user ( buffer, 0, image->data, phdr->p_offset, phdr->p_filesz );
+ memcpy ( buffer, ( image->data + phdr->p_offset ), phdr->p_filesz );
return 0;
}
diff --git a/src/image/segment.c b/src/image/segment.c
index 2d0f2f0fc..b7f8ef56c 100644
--- a/src/image/segment.c
+++ b/src/image/segment.c
@@ -83,7 +83,7 @@ int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) {
if ( ( start >= memmap.regions[i].start ) &&
( end <= memmap.regions[i].end ) ) {
/* Found valid region: zero bss and return */
- memset_user ( segment, filesz, 0, ( memsz - filesz ) );
+ memset ( ( segment + filesz ), 0, ( memsz - filesz ) );
return 0;
}
}
diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h
index 790c75123..0c680c08f 100644
--- a/src/include/ipxe/linux/linux_uaccess.h
+++ b/src/include/ipxe/linux/linux_uaccess.h
@@ -69,38 +69,6 @@ UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) {
return trivial_user_to_virt ( userptr, offset );
}
-static inline __always_inline void
-UACCESS_INLINE ( linux, memcpy_user ) ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off,
- size_t len ) {
- trivial_memcpy_user ( dest, dest_off, src, src_off, len );
-}
-
-static inline __always_inline void
-UACCESS_INLINE ( linux, memmove_user ) ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off,
- size_t len ) {
- trivial_memmove_user ( dest, dest_off, src, src_off, len );
-}
-
-static inline __always_inline int
-UACCESS_INLINE ( linux, memcmp_user ) ( userptr_t first, off_t first_off,
- userptr_t second, off_t second_off,
- size_t len ) {
- return trivial_memcmp_user ( first, first_off, second, second_off, len);
-}
-
-static inline __always_inline void
-UACCESS_INLINE ( linux, memset_user ) ( userptr_t buffer, off_t offset,
- int c, size_t len ) {
- trivial_memset_user ( buffer, offset, c, len );
-}
-
-static inline __always_inline size_t
-UACCESS_INLINE ( linux, strlen_user ) ( userptr_t buffer, off_t offset ) {
- return trivial_strlen_user ( buffer, offset );
-}
-
static inline __always_inline off_t
UACCESS_INLINE ( linux, memchr_user ) ( userptr_t buffer, off_t offset,
int c, size_t len ) {
diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h
index 93dc60d62..e84ca3eae 100644
--- a/src/include/ipxe/uaccess.h
+++ b/src/include/ipxe/uaccess.h
@@ -66,80 +66,6 @@ trivial_user_to_virt ( userptr_t userptr, off_t offset ) {
}
/**
- * Copy data between user buffers
- *
- * @v dest Destination
- * @v dest_off Destination offset
- * @v src Source
- * @v src_off Source offset
- * @v len Length
- */
-static inline __always_inline void
-trivial_memcpy_user ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off, size_t len ) {
- memcpy ( ( ( void * ) dest + dest_off ),
- ( ( void * ) src + src_off ), len );
-}
-
-/**
- * Copy data between user buffers, allowing for overlap
- *
- * @v dest Destination
- * @v dest_off Destination offset
- * @v src Source
- * @v src_off Source offset
- * @v len Length
- */
-static inline __always_inline void
-trivial_memmove_user ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off, size_t len ) {
- memmove ( ( ( void * ) dest + dest_off ),
- ( ( void * ) src + src_off ), len );
-}
-
-/**
- * Compare data between user buffers
- *
- * @v first First buffer
- * @v first_off First buffer offset
- * @v second Second buffer
- * @v second_off Second buffer offset
- * @v len Length
- * @ret diff Difference
- */
-static inline __always_inline int
-trivial_memcmp_user ( userptr_t first, off_t first_off,
- userptr_t second, off_t second_off, size_t len ) {
- return memcmp ( ( ( void * ) first + first_off ),
- ( ( void * ) second + second_off ), len );
-}
-
-/**
- * Fill user buffer with a constant byte
- *
- * @v buffer User buffer
- * @v offset Offset within buffer
- * @v c Constant byte with which to fill
- * @v len Length
- */
-static inline __always_inline void
-trivial_memset_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
- memset ( ( ( void * ) buffer + offset ), c, len );
-}
-
-/**
- * Find length of NUL-terminated string in user buffer
- *
- * @v buffer User buffer
- * @v offset Offset within buffer
- * @ret len Length of string (excluding NUL)
- */
-static inline __always_inline size_t
-trivial_strlen_user ( userptr_t buffer, off_t offset ) {
- return strlen ( ( void * ) buffer + offset );
-}
-
-/**
* Find character in user buffer
*
* @v buffer User buffer
@@ -207,38 +133,6 @@ UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) {
return trivial_user_to_virt ( userptr, offset );
}
-static inline __always_inline void
-UACCESS_INLINE ( flat, memcpy_user ) ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off,
- size_t len ) {
- trivial_memcpy_user ( dest, dest_off, src, src_off, len );
-}
-
-static inline __always_inline void
-UACCESS_INLINE ( flat, memmove_user ) ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off,
- size_t len ) {
- trivial_memmove_user ( dest, dest_off, src, src_off, len );
-}
-
-static inline __always_inline int
-UACCESS_INLINE ( flat, memcmp_user ) ( userptr_t first, off_t first_off,
- userptr_t second, off_t second_off,
- size_t len ) {
- return trivial_memcmp_user ( first, first_off, second, second_off, len);
-}
-
-static inline __always_inline void
-UACCESS_INLINE ( flat, memset_user ) ( userptr_t buffer, off_t offset,
- int c, size_t len ) {
- trivial_memset_user ( buffer, offset, c, len );
-}
-
-static inline __always_inline size_t
-UACCESS_INLINE ( flat, strlen_user ) ( userptr_t buffer, off_t offset ) {
- return trivial_strlen_user ( buffer, offset );
-}
-
static inline __always_inline off_t
UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset,
int c, size_t len ) {
@@ -311,18 +205,6 @@ static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) {
}
/**
- * Copy data between user buffers
- *
- * @v dest Destination
- * @v dest_off Destination offset
- * @v src Source
- * @v src_off Source offset
- * @v len Length
- */
-void memcpy_user ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off, size_t len );
-
-/**
* Copy data to user buffer
*
* @v dest Destination
@@ -332,7 +214,7 @@ void memcpy_user ( userptr_t dest, off_t dest_off,
*/
static inline __always_inline void
copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) {
- memcpy_user ( dest, dest_off, virt_to_user ( src ), 0, len );
+ memcpy ( ( dest + dest_off ), src, len );
}
/**
@@ -345,54 +227,10 @@ copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) {
*/
static inline __always_inline void
copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) {
- memcpy_user ( virt_to_user ( dest ), 0, src, src_off, len );
+ memcpy ( dest, ( src + src_off ), len );
}
/**
- * Copy data between user buffers, allowing for overlap
- *
- * @v dest Destination
- * @v dest_off Destination offset
- * @v src Source
- * @v src_off Source offset
- * @v len Length
- */
-void memmove_user ( userptr_t dest, off_t dest_off,
- userptr_t src, off_t src_off, size_t len );
-
-/**
- * Compare data between user buffers
- *
- * @v first First buffer
- * @v first_off First buffer offset
- * @v second Second buffer
- * @v second_off Second buffer offset
- * @v len Length
- * @ret diff Difference
- */
-int memcmp_user ( userptr_t first, off_t first_off,
- userptr_t second, off_t second_off, size_t len );
-
-/**
- * Fill user buffer with a constant byte
- *
- * @v userptr User buffer
- * @v offset Offset within buffer
- * @v c Constant byte with which to fill
- * @v len Length
- */
-void memset_user ( userptr_t userptr, off_t offset, int c, size_t len );
-
-/**
- * Find length of NUL-terminated string in user buffer
- *
- * @v userptr User buffer
- * @v offset Offset within buffer
- * @ret len Length of string (excluding NUL)
- */
-size_t strlen_user ( userptr_t userptr, off_t offset );
-
-/**
* Find character in user buffer
*
* @v userptr User buffer
diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c
index d388e0317..659ebd37e 100644
--- a/src/interface/efi/efi_fbcon.c
+++ b/src/interface/efi/efi_fbcon.c
@@ -124,7 +124,7 @@ static int efifb_draw ( unsigned int character, unsigned int index,
/* Clear existing glyph */
offset = ( index * efifb.font.height );
- memset_user ( efifb.glyphs, offset, 0, efifb.font.height );
+ memset ( ( efifb.glyphs + offset ), 0, efifb.font.height );
/* Get glyph */
blt = NULL;
@@ -296,7 +296,7 @@ static int efifb_glyphs ( void ) {
rc = -ENOMEM;
goto err_alloc;
}
- memset_user ( efifb.glyphs, 0, 0, len );
+ memset ( efifb.glyphs, 0, len );
/* Get font data */
for ( character = 0 ; character < EFIFB_ASCII ; character++ ) {
diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c
index 175ae367e..488c53f3d 100644
--- a/src/interface/efi/efi_umalloc.c
+++ b/src/interface/efi/efi_umalloc.c
@@ -87,8 +87,8 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) {
if ( old_ptr && ( old_ptr != UNOWHERE ) ) {
copy_from_user ( &old_size, old_ptr, -EFI_PAGE_SIZE,
sizeof ( old_size ) );
- memcpy_user ( new_ptr, 0, old_ptr, 0,
- ( (old_size < new_size) ? old_size : new_size ));
+ memcpy ( new_ptr, old_ptr,
+ ( (old_size < new_size) ? old_size : new_size ) );
old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 );
phys_addr = user_to_phys ( old_ptr, -EFI_PAGE_SIZE );
if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){
diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c
index 9fc99c5e2..d777bf3dd 100644
--- a/src/interface/linux/linux_uaccess.c
+++ b/src/interface/linux/linux_uaccess.c
@@ -30,8 +30,4 @@ FILE_LICENCE(GPL2_OR_LATER);
PROVIDE_UACCESS_INLINE(linux, user_to_phys);
PROVIDE_UACCESS_INLINE(linux, virt_to_user);
PROVIDE_UACCESS_INLINE(linux, user_to_virt);
-PROVIDE_UACCESS_INLINE(linux, memcpy_user);
-PROVIDE_UACCESS_INLINE(linux, memmove_user);
-PROVIDE_UACCESS_INLINE(linux, memset_user);
-PROVIDE_UACCESS_INLINE(linux, strlen_user);
PROVIDE_UACCESS_INLINE(linux, memchr_user);
diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c
index fdd14499f..3e69a0c15 100644
--- a/src/interface/smbios/smbios.c
+++ b/src/interface/smbios/smbios.c
@@ -277,7 +277,7 @@ int read_smbios_string ( struct smbios_structure *structure,
* smbios_strings struct is constructed so as to
* always end on a string boundary.
*/
- string_len = strlen_user ( smbios.address, offset );
+ string_len = strlen ( smbios.address + offset );
if ( --index == 0 ) {
/* Copy string, truncating as necessary. */
if ( len > string_len )
diff --git a/src/tests/cms_test.c b/src/tests/cms_test.c
index fc4f6bd19..debbfeee7 100644
--- a/src/tests/cms_test.c
+++ b/src/tests/cms_test.c
@@ -1773,8 +1773,8 @@ static void cms_decrypt_okx ( struct cms_test_image *img,
/* Check decrypted image matches expected plaintext */
okx ( img->image.len == expected->image.len, file, line );
- okx ( memcmp_user ( img->image.data, 0, expected->image.data, 0,
- expected->image.len ) == 0, file, line );
+ okx ( memcmp ( img->image.data, expected->image.data,
+ expected->image.len ) == 0, file, line );
}
#define cms_decrypt_ok( data, envelope, keypair, expected ) \
cms_decrypt_okx ( data, envelope, keypair, expected, \
diff --git a/src/tests/gzip_test.c b/src/tests/gzip_test.c
index fa76edc53..9226b4c26 100644
--- a/src/tests/gzip_test.c
+++ b/src/tests/gzip_test.c
@@ -128,9 +128,8 @@ static void gzip_okx ( struct gzip_test *test, const char *file,
/* Verify extracted image content */
okx ( extracted->len == test->expected_len, file, line );
- okx ( memcmp_user ( extracted->data, 0,
- virt_to_user ( test->expected ), 0,
- test->expected_len ) == 0, file, line );
+ okx ( memcmp ( extracted->data, virt_to_user ( test->expected ),
+ test->expected_len ) == 0, file, line );
/* Verify extracted image name */
okx ( strcmp ( extracted->name, test->expected_name ) == 0,
diff --git a/src/tests/pixbuf_test.c b/src/tests/pixbuf_test.c
index aaa516bb2..1f82e0018 100644
--- a/src/tests/pixbuf_test.c
+++ b/src/tests/pixbuf_test.c
@@ -71,9 +71,8 @@ void pixbuf_okx ( struct pixel_buffer_test *test, const char *file,
/* Check pixel buffer data */
okx ( pixbuf->len == test->len, file, line );
- okx ( memcmp_user ( pixbuf->data, 0,
- virt_to_user ( test->data ), 0,
- test->len ) == 0, file, line );
+ okx ( memcmp ( pixbuf->data, virt_to_user ( test->data ),
+ test->len ) == 0, file, line );
pixbuf_put ( pixbuf );
}
diff --git a/src/tests/zlib_test.c b/src/tests/zlib_test.c
index df52d09ac..2efdcbad8 100644
--- a/src/tests/zlib_test.c
+++ b/src/tests/zlib_test.c
@@ -103,9 +103,8 @@ static void zlib_okx ( struct zlib_test *test, const char *file,
/* Verify extracted image content */
okx ( extracted->len == test->expected_len, file, line );
- okx ( memcmp_user ( extracted->data, 0,
- virt_to_user ( test->expected ), 0,
- test->expected_len ) == 0, file, line );
+ okx ( memcmp ( extracted->data, virt_to_user ( test->expected ),
+ test->expected_len ) == 0, file, line );
/* Verify extracted image name */
okx ( strcmp ( extracted->name, test->expected_name ) == 0,