[uaccess] Remove user_to_phys() and phys_to_user()

Remove the intermediate concept of a user pointer from physical
address conversions, leaving virt_to_phys() and phys_to_virt() as the
directly implemented functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-21 16:16:01 +01:00
parent 4535548cba
commit 8c31270a21
48 changed files with 211 additions and 235 deletions

View File

@@ -60,7 +60,7 @@ static void cachedhcp_init ( void ) {
/* Record cached DHCPACK */
if ( ( rc = cachedhcp_record ( &cached_dhcpack, 0,
phys_to_user ( cached_dhcpack_phys ),
phys_to_virt ( cached_dhcpack_phys ),
sizeof ( BOOTPLAYER_t ) ) ) != 0 ) {
DBGC ( colour, "CACHEDHCP could not record DHCPACK: %s\n",
strerror ( rc ) );

View File

@@ -54,7 +54,7 @@ static int bios_find_smbios2 ( struct smbios *smbios ) {
return rc;
/* Fill in entry point descriptor structure */
smbios->address = phys_to_user ( entry.smbios_address );
smbios->address = phys_to_virt ( entry.smbios_address );
smbios->len = entry.smbios_len;
smbios->count = entry.smbios_count;
smbios->version = SMBIOS_VERSION ( entry.major, entry.minor );
@@ -85,7 +85,7 @@ static int bios_find_smbios3 ( struct smbios *smbios ) {
}
/* Fill in entry point descriptor structure */
smbios->address = phys_to_user ( entry.smbios_address );
smbios->address = phys_to_virt ( entry.smbios_address );
smbios->len = entry.smbios_len;
smbios->count = 0;
smbios->version = SMBIOS_VERSION ( entry.major, entry.minor );

View File

@@ -743,7 +743,7 @@ static int int13_extended_rw ( struct san_device *sandev,
if ( ( addr.count == 0xff ) ||
( ( addr.buffer.segment == 0xffff ) &&
( addr.buffer.offset == 0xffff ) ) ) {
buffer = phys_to_user ( addr.buffer_phys );
buffer = phys_to_virt ( addr.buffer_phys );
DBGC2 ( sandev->drive, "%08llx",
( ( unsigned long long ) addr.buffer_phys ) );
} else {
@@ -1058,7 +1058,7 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev,
/* Read from boot catalog */
if ( ( rc = sandev_read ( sandev, start, command.count,
phys_to_user ( command.buffer ) ) ) != 0 ) {
phys_to_virt ( command.buffer ) ) ) != 0 ) {
DBGC ( sandev->drive, "INT13 drive %02x could not read boot "
"catalog: %s\n", sandev->drive, strerror ( rc ) );
return -INT13_STATUS_READ_ERROR;
@@ -1455,7 +1455,7 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
"catalog (status %04x)\n", drive, status );
return -EIO;
}
copy_from_user ( &catalog, phys_to_user ( eltorito_cmd.buffer ), 0,
copy_from_user ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), 0,
sizeof ( catalog ) );
/* Sanity checks */

View File

@@ -106,7 +106,7 @@ size_t largest_memblock ( userptr_t *start ) {
/* Use largest block */
if ( region_len > len ) {
DBG ( "...new best block found\n" );
*start = phys_to_user ( region_start );
*start = phys_to_virt ( region_start );
len = region_len;
}
}
@@ -124,7 +124,7 @@ static void init_eheap ( void ) {
heap_size = largest_memblock ( &base );
bottom = top = ( base + heap_size );
DBG ( "External heap grows downwards from %lx (size %zx)\n",
user_to_phys ( top, 0 ), heap_size );
virt_to_phys ( top ), heap_size );
}
/**
@@ -141,8 +141,8 @@ static void ecollect_free ( void ) {
sizeof ( extmem ) );
if ( extmem.used )
break;
DBG ( "EXTMEM freeing [%lx,%lx)\n", user_to_phys ( bottom, 0 ),
user_to_phys ( bottom, extmem.size ) );
DBG ( "EXTMEM freeing [%lx,%lx)\n", virt_to_phys ( bottom ),
( virt_to_phys ( bottom ) + extmem.size ) );
len = ( extmem.size + sizeof ( extmem ) );
bottom += len;
heap_size += len;
@@ -182,7 +182,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
ptr = bottom = ( bottom - sizeof ( extmem ) );
heap_size -= sizeof ( extmem );
DBG ( "EXTMEM allocating [%lx,%lx)\n",
user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) );
virt_to_phys ( ptr ), virt_to_phys ( ptr ) );
extmem.size = 0;
}
extmem.used = ( new_size > 0 );
@@ -191,7 +191,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
if ( ptr == bottom ) {
/* Update block */
new = ( ptr - ( new_size - extmem.size ) );
align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) );
align = ( virt_to_phys ( new ) & ( EM_ALIGN - 1 ) );
new_size += align;
new -= align;
if ( new_size > ( heap_size + extmem.size ) ) {
@@ -199,10 +199,10 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
return UNULL;
}
DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n",
user_to_phys ( ptr, 0 ),
user_to_phys ( ptr, extmem.size ),
user_to_phys ( new, 0 ),
user_to_phys ( new, new_size ));
virt_to_phys ( ptr ),
( virt_to_phys ( ptr ) + extmem.size ),
virt_to_phys ( new ),
( virt_to_phys ( new ) + new_size ) );
memmove ( new, ptr, ( ( extmem.size < new_size ) ?
extmem.size : new_size ) );
bottom = new;
@@ -213,8 +213,8 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
if ( new_size > extmem.size ) {
/* Refuse to expand */
DBG ( "EXTMEM cannot expand [%lx,%lx)\n",
user_to_phys ( ptr, 0 ),
user_to_phys ( ptr, extmem.size ) );
virt_to_phys ( ptr ),
( virt_to_phys ( ptr ) + extmem.size ) );
return UNULL;
}
}
@@ -225,9 +225,9 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
/* Collect any free blocks and update hidden memory region */
ecollect_free();
hide_umalloc ( user_to_phys ( bottom, ( ( bottom == top ) ?
0 : -sizeof ( extmem ) ) ),
user_to_phys ( top, 0 ) );
hide_umalloc ( ( virt_to_phys ( bottom ) -
( ( bottom == top ) ? 0 : sizeof ( extmem ) ) ),
virt_to_phys ( top ) );
return ( new_size ? new : UNOWHERE );
}

View File

@@ -78,10 +78,10 @@ static userptr_t rsdp_find_rsdt_range ( userptr_t start, size_t len ) {
continue;
/* Extract RSDT */
rsdt = phys_to_user ( le32_to_cpu ( rsdp.rsdt ) );
rsdt = phys_to_virt ( le32_to_cpu ( rsdp.rsdt ) );
DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n",
user_to_phys ( rsdt, 0 ),
user_to_phys ( start, offset ) );
virt_to_phys ( rsdt ),
( virt_to_phys ( start ) + offset ) );
return rsdt;
}
@@ -114,7 +114,7 @@ static userptr_t rsdp_find_rsdt ( void ) {
}
/* Search fixed BIOS area */
rsdt = rsdp_find_rsdt_range ( phys_to_user ( RSDP_BIOS_START ),
rsdt = rsdp_find_rsdt_range ( phys_to_virt ( RSDP_BIOS_START ),
RSDP_BIOS_LEN );
if ( rsdt )
return rsdt;

View File

@@ -473,7 +473,7 @@ static int vesafb_init ( struct console_configuration *config ) {
vesafb_font();
/* Initialise frame buffer console */
if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_virt ( vesafb.start ),
&vesafb.pixel, &vesafb.map, &vesafb.font,
config ) ) != 0 )
goto err_fbcon_init;