mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 10:01:03 +03:00
[uaccess] Remove redundant user_to_virt()
The user_to_virt() function is now a straightforward wrapper around addition, with the addend almost invariably being zero. Remove this redundant wrapper. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -388,7 +388,7 @@ static size_t bzimage_load_initrd ( struct image *image,
|
||||
user_to_phys ( address, ( offset + initrd->len ) ),
|
||||
( filename ? " " : "" ), ( filename ? filename : "" ) );
|
||||
DBGC2_MD5A ( image, user_to_phys ( address, offset ),
|
||||
user_to_virt ( address, offset ), initrd->len );
|
||||
( address + offset ), initrd->len );
|
||||
}
|
||||
len += initrd->len;
|
||||
|
||||
@@ -427,7 +427,7 @@ static int bzimage_check_initrds ( struct image *image,
|
||||
( initrd->cmdline ? " " : "" ),
|
||||
( initrd->cmdline ? initrd->cmdline : "" ) );
|
||||
DBGC2_MD5A ( image, user_to_phys ( initrd->data, 0 ),
|
||||
user_to_virt ( initrd->data, 0 ), initrd->len );
|
||||
initrd->data, initrd->len );
|
||||
}
|
||||
|
||||
/* Calculate lowest usable address */
|
||||
|
||||
@@ -211,7 +211,7 @@ static void initrd_dump ( void ) {
|
||||
initrd->name, user_to_phys ( initrd->data, 0 ),
|
||||
user_to_phys ( initrd->data, initrd->len ) );
|
||||
DBGC2_MD5A ( &images, user_to_phys ( initrd->data, 0 ),
|
||||
user_to_virt ( initrd->data, 0 ), initrd->len );
|
||||
initrd->data, initrd->len );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,11 +132,6 @@ UACCESS_INLINE ( librm, virt_to_user ) ( volatile const void *addr ) {
|
||||
return trivial_virt_to_user ( addr );
|
||||
}
|
||||
|
||||
static inline __always_inline void *
|
||||
UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) {
|
||||
return trivial_user_to_virt ( userptr, offset );
|
||||
}
|
||||
|
||||
static inline __always_inline off_t
|
||||
UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset,
|
||||
int c, size_t len ) {
|
||||
|
||||
@@ -431,7 +431,6 @@ void setup_sipi ( unsigned int vector, uint32_t handler,
|
||||
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, memchr_user );
|
||||
PROVIDE_IOMAP_INLINE ( pages, io_to_bus );
|
||||
PROVIDE_IOMAP ( pages, ioremap, ioremap_pages );
|
||||
|
||||
@@ -734,8 +734,7 @@ static int fdt_parse_image ( struct fdt *fdt, struct image *image ) {
|
||||
int rc;
|
||||
|
||||
/* Parse image */
|
||||
if ( ( rc = fdt_parse ( fdt, user_to_virt ( image->data, 0 ),
|
||||
image->len ) ) != 0 ) {
|
||||
if ( ( rc = fdt_parse ( fdt, image->data, image->len ) ) != 0 ) {
|
||||
DBGC ( fdt, "FDT image \"%s\" is invalid: %s\n",
|
||||
image->name, strerror ( rc ) );
|
||||
return rc;
|
||||
@@ -1038,7 +1037,7 @@ static int fdt_urealloc ( struct fdt *fdt, size_t len ) {
|
||||
assert ( len >= fdt->used );
|
||||
|
||||
/* Attempt reallocation */
|
||||
new = user_to_virt ( urealloc ( virt_to_user ( fdt->raw ), len ), 0 );
|
||||
new = urealloc ( virt_to_user ( fdt->raw ), len );
|
||||
if ( ! new ) {
|
||||
DBGC ( fdt, "FDT could not reallocate from +%#04zx to "
|
||||
"+%#04zx\n", fdt->len, len );
|
||||
@@ -1112,7 +1111,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) {
|
||||
}
|
||||
|
||||
/* Create modifiable copy */
|
||||
copy = user_to_virt ( umalloc ( fdt.len ), 0 );
|
||||
copy = umalloc ( fdt.len );
|
||||
if ( ! copy ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
|
||||
@@ -35,5 +35,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
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, memchr_user );
|
||||
|
||||
@@ -245,8 +245,8 @@ static int efi_image_exec ( struct image *image ) {
|
||||
/* Attempt loading image */
|
||||
handle = NULL;
|
||||
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, path,
|
||||
user_to_virt ( exec->data, 0 ),
|
||||
exec->len, &handle ) ) != 0 ) {
|
||||
exec->data, exec->len,
|
||||
&handle ) ) != 0 ) {
|
||||
/* Not an EFI image */
|
||||
rc = -EEFI_LOAD ( efirc );
|
||||
DBGC ( image, "EFIIMAGE %s could not load: %s\n",
|
||||
@@ -379,8 +379,8 @@ static int efi_image_probe ( struct image *image ) {
|
||||
/* Attempt loading image */
|
||||
handle = NULL;
|
||||
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, &empty_path,
|
||||
user_to_virt ( image->data, 0 ),
|
||||
image->len, &handle ) ) != 0 ) {
|
||||
image->data, image->len,
|
||||
&handle ) ) != 0 ) {
|
||||
/* Not an EFI image */
|
||||
rc = -EEFI_LOAD ( efirc );
|
||||
DBGC ( image, "EFIIMAGE %s could not load: %s\n",
|
||||
|
||||
@@ -64,11 +64,6 @@ UACCESS_INLINE ( linux, virt_to_user ) ( volatile const void *addr ) {
|
||||
return trivial_virt_to_user ( addr );
|
||||
}
|
||||
|
||||
static inline __always_inline void *
|
||||
UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) {
|
||||
return trivial_user_to_virt ( userptr, offset );
|
||||
}
|
||||
|
||||
static inline __always_inline off_t
|
||||
UACCESS_INLINE ( linux, memchr_user ) ( userptr_t buffer, off_t offset,
|
||||
int c, size_t len ) {
|
||||
|
||||
@@ -51,20 +51,6 @@ trivial_virt_to_user ( volatile const void *addr ) {
|
||||
return ( ( userptr_t ) addr );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert user pointer to virtual address
|
||||
*
|
||||
* @v userptr User pointer
|
||||
* @v offset Offset from user pointer
|
||||
* @ret addr Virtual address
|
||||
*
|
||||
* This operation is not available under all memory models.
|
||||
*/
|
||||
static inline __always_inline void *
|
||||
trivial_user_to_virt ( userptr_t userptr, off_t offset ) {
|
||||
return ( ( void * ) userptr + offset );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find character in user buffer
|
||||
*
|
||||
@@ -128,11 +114,6 @@ UACCESS_INLINE ( flat, virt_to_user ) ( volatile const void *addr ) {
|
||||
return trivial_virt_to_user ( addr );
|
||||
}
|
||||
|
||||
static inline __always_inline void *
|
||||
UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) {
|
||||
return trivial_user_to_virt ( userptr, offset );
|
||||
}
|
||||
|
||||
static inline __always_inline off_t
|
||||
UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset,
|
||||
int c, size_t len ) {
|
||||
@@ -170,17 +151,6 @@ unsigned long user_to_phys ( userptr_t userptr, off_t offset );
|
||||
*/
|
||||
userptr_t virt_to_user ( volatile const void *addr );
|
||||
|
||||
/**
|
||||
* Convert user pointer to virtual address
|
||||
*
|
||||
* @v userptr User pointer
|
||||
* @v offset Offset from user pointer
|
||||
* @ret addr Virtual address
|
||||
*
|
||||
* This operation is not available under all memory models.
|
||||
*/
|
||||
void * user_to_virt ( userptr_t userptr, off_t offset );
|
||||
|
||||
/**
|
||||
* Convert virtual address to a physical address
|
||||
*
|
||||
@@ -201,7 +171,7 @@ virt_to_phys ( volatile const void *addr ) {
|
||||
* This operation is not available under all memory models.
|
||||
*/
|
||||
static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) {
|
||||
return user_to_virt ( phys_to_user ( phys_addr ), 0 );
|
||||
return ( phys_to_user ( phys_addr ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -669,7 +669,7 @@ static userptr_t efipci_dma_umalloc ( struct dma_device *dma,
|
||||
static void efipci_dma_ufree ( struct dma_device *dma, struct dma_mapping *map,
|
||||
userptr_t addr, size_t len ) {
|
||||
|
||||
efipci_dma_free ( dma, map, user_to_virt ( addr, 0 ), len );
|
||||
efipci_dma_free ( dma, map, addr, len );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,7 +101,7 @@ static userptr_t linux_acpi_find ( uint32_t signature, unsigned int index ) {
|
||||
filename, strerror ( rc ) );
|
||||
goto err_read;
|
||||
}
|
||||
header = user_to_virt ( table->data, 0 );
|
||||
header = table->data;
|
||||
if ( ( ( ( size_t ) len ) < sizeof ( *header ) ) ||
|
||||
( ( ( size_t ) len ) < le32_to_cpu ( header->length ) ) ) {
|
||||
rc = -ENOENT;
|
||||
|
||||
@@ -59,7 +59,7 @@ static int linux_find_smbios ( struct smbios *smbios ) {
|
||||
smbios_entry_filename, strerror ( rc ) );
|
||||
goto err_entry;
|
||||
}
|
||||
data = user_to_virt ( entry, 0 );
|
||||
data = entry;
|
||||
smbios3_entry = data;
|
||||
smbios_entry = data;
|
||||
if ( ( len >= ( ( int ) sizeof ( *smbios3_entry ) ) ) &&
|
||||
|
||||
@@ -70,8 +70,7 @@ int linux_sysfs_read ( const char *filename, userptr_t *data ) {
|
||||
*data = tmp;
|
||||
|
||||
/* Read from file */
|
||||
read = linux_read ( fd, user_to_virt ( *data, len ),
|
||||
LINUX_SYSFS_BLKSIZE );
|
||||
read = linux_read ( fd, ( *data + len ), LINUX_SYSFS_BLKSIZE );
|
||||
if ( read == 0 )
|
||||
break;
|
||||
if ( read < 0 ) {
|
||||
|
||||
@@ -29,5 +29,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, memchr_user);
|
||||
|
||||
Reference in New Issue
Block a user