mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 18:11:49 +03:00
[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>
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 ) );
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 ];
|
||||
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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__ (
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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] ) );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -65,80 +65,6 @@ trivial_user_to_virt ( userptr_t userptr, off_t offset ) {
|
||||
return ( ( void * ) userptr + 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
|
||||
*
|
||||
@@ -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 ) {
|
||||
@@ -310,18 +204,6 @@ static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) {
|
||||
return user_to_virt ( phys_to_user ( phys_addr ), 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -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,53 +227,9 @@ 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
|
||||
*
|
||||
|
||||
@@ -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++ ) {
|
||||
|
||||
@@ -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 ){
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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, \
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user