summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2025-04-21 01:15:52 +0200
committerMichael Brown2025-04-21 01:15:52 +0200
commit4535548cba255c220719a55d02535e06da82ba47 (patch)
treecc889e117fe18ab14ca45033321e5518b550bf7b /src
parent[uaccess] Remove redundant memcpy_user() and related string functions (diff)
downloadipxe-4535548cba255c220719a55d02535e06da82ba47.tar.gz
ipxe-4535548cba255c220719a55d02535e06da82ba47.tar.xz
ipxe-4535548cba255c220719a55d02535e06da82ba47.zip
[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>
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/image/bzimage.c4
-rw-r--r--src/arch/x86/image/initrd.c2
-rw-r--r--src/arch/x86/include/librm.h5
-rw-r--r--src/arch/x86/transitions/librm_mgmt.c1
-rw-r--r--src/core/fdt.c7
-rw-r--r--src/core/uaccess.c1
-rw-r--r--src/image/efi_image.c8
-rw-r--r--src/include/ipxe/linux/linux_uaccess.h5
-rw-r--r--src/include/ipxe/uaccess.h32
-rw-r--r--src/interface/efi/efi_pci.c2
-rw-r--r--src/interface/linux/linux_acpi.c2
-rw-r--r--src/interface/linux/linux_smbios.c2
-rw-r--r--src/interface/linux/linux_sysfs.c3
-rw-r--r--src/interface/linux/linux_uaccess.c1
14 files changed, 15 insertions, 60 deletions
diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c
index 29ebeb507..32598525f 100644
--- a/src/arch/x86/image/bzimage.c
+++ b/src/arch/x86/image/bzimage.c
@@ -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 */
diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c
index 95f12d804..bcf95deef 100644
--- a/src/arch/x86/image/initrd.c
+++ b/src/arch/x86/image/initrd.c
@@ -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 );
}
}
diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h
index c117a8b5c..9ed91022e 100644
--- a/src/arch/x86/include/librm.h
+++ b/src/arch/x86/include/librm.h
@@ -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 ) {
diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c
index 7ebf62137..82e8eab39 100644
--- a/src/arch/x86/transitions/librm_mgmt.c
+++ b/src/arch/x86/transitions/librm_mgmt.c
@@ -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 );
diff --git a/src/core/fdt.c b/src/core/fdt.c
index 54f930286..4c709b342 100644
--- a/src/core/fdt.c
+++ b/src/core/fdt.c
@@ -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;
diff --git a/src/core/uaccess.c b/src/core/uaccess.c
index 01089e6fa..1c33c10b8 100644
--- a/src/core/uaccess.c
+++ b/src/core/uaccess.c
@@ -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 );
diff --git a/src/image/efi_image.c b/src/image/efi_image.c
index c87196487..2b0ff567a 100644
--- a/src/image/efi_image.c
+++ b/src/image/efi_image.c
@@ -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",
diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h
index 0c680c08f..4b1257b1e 100644
--- a/src/include/ipxe/linux/linux_uaccess.h
+++ b/src/include/ipxe/linux/linux_uaccess.h
@@ -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 ) {
diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h
index e84ca3eae..4b3524bab 100644
--- a/src/include/ipxe/uaccess.h
+++ b/src/include/ipxe/uaccess.h
@@ -52,20 +52,6 @@ trivial_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.
- */
-static inline __always_inline void *
-trivial_user_to_virt ( userptr_t userptr, off_t offset ) {
- return ( ( void * ) userptr + offset );
-}
-
-/**
* Find character in user buffer
*
* @v buffer 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 ) {
@@ -171,17 +152,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
*
* @v addr Virtual 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 ) );
}
/**
diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c
index dd11dd342..01351df51 100644
--- a/src/interface/efi/efi_pci.c
+++ b/src/interface/efi/efi_pci.c
@@ -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 );
}
/**
diff --git a/src/interface/linux/linux_acpi.c b/src/interface/linux/linux_acpi.c
index e658936f2..846db2f1f 100644
--- a/src/interface/linux/linux_acpi.c
+++ b/src/interface/linux/linux_acpi.c
@@ -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;
diff --git a/src/interface/linux/linux_smbios.c b/src/interface/linux/linux_smbios.c
index 981873943..abe1b19d7 100644
--- a/src/interface/linux/linux_smbios.c
+++ b/src/interface/linux/linux_smbios.c
@@ -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 ) ) ) &&
diff --git a/src/interface/linux/linux_sysfs.c b/src/interface/linux/linux_sysfs.c
index 4f0027cd4..cbb23d81d 100644
--- a/src/interface/linux/linux_sysfs.c
+++ b/src/interface/linux/linux_sysfs.c
@@ -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 ) {
diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c
index d777bf3dd..e5c394365 100644
--- a/src/interface/linux/linux_uaccess.c
+++ b/src/interface/linux/linux_uaccess.c
@@ -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);