[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

@@ -48,7 +48,7 @@ static userptr_t efi_find_rsdt ( void ) {
/* Locate RSDT via ACPI configuration table, if available */
if ( rsdp )
return phys_to_user ( rsdp->RsdtAddress );
return phys_to_virt ( rsdp->RsdtAddress );
return UNULL;
}

View File

@@ -583,7 +583,7 @@ static int efifb_init ( struct console_configuration *config ) {
mode, efifb.pixel.width, efifb.pixel.height, bpp, efifb.start );
/* Initialise frame buffer console */
if ( ( rc = fbcon_init ( &efifb.fbcon, phys_to_user ( efifb.start ),
if ( ( rc = fbcon_init ( &efifb.fbcon, phys_to_virt ( efifb.start ),
&efifb.pixel, &efifb.map, &efifb.font,
config ) ) != 0 )
goto err_fbcon_init;

View File

@@ -48,27 +48,27 @@ static int efi_find_smbios ( struct smbios *smbios ) {
/* Use 64-bit table if present */
if ( smbios3_entry && ( smbios3_entry->signature == SMBIOS3_SIGNATURE ) ) {
smbios->address = phys_to_user ( smbios3_entry->smbios_address );
smbios->address = phys_to_virt ( smbios3_entry->smbios_address );
smbios->len = smbios3_entry->smbios_len;
smbios->count = 0;
smbios->version =
SMBIOS_VERSION ( smbios3_entry->major, smbios3_entry->minor );
DBG ( "Found 64-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n",
smbios3_entry->major, smbios3_entry->minor, smbios3_entry,
user_to_phys ( smbios->address, 0 ), smbios->len );
virt_to_phys ( smbios->address ), smbios->len );
return 0;
}
/* Otherwise, use 32-bit table if present */
if ( smbios_entry && ( smbios_entry->signature == SMBIOS_SIGNATURE ) ) {
smbios->address = phys_to_user ( smbios_entry->smbios_address );
smbios->address = phys_to_virt ( smbios_entry->smbios_address );
smbios->len = smbios_entry->smbios_len;
smbios->count = smbios_entry->smbios_count;
smbios->version =
SMBIOS_VERSION ( smbios_entry->major, smbios_entry->minor );
DBG ( "Found 32-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n",
smbios_entry->major, smbios_entry->minor, smbios_entry,
user_to_phys ( smbios->address, 0 ), smbios->len );
virt_to_phys ( smbios->address ), smbios->len );
return 0;
}

View File

@@ -72,7 +72,7 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) {
return UNULL;
}
assert ( phys_addr != 0 );
new_ptr = phys_to_user ( phys_addr + EFI_PAGE_SIZE );
new_ptr = phys_to_virt ( phys_addr + EFI_PAGE_SIZE );
copy_to_user ( new_ptr, -EFI_PAGE_SIZE,
&new_size, sizeof ( new_size ) );
DBG ( "EFI allocated %d pages at %llx\n",
@@ -90,7 +90,7 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t 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 );
phys_addr = virt_to_phys ( old_ptr - EFI_PAGE_SIZE );
if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){
rc = -EEFI ( efirc );
DBG ( "EFI could not free %d pages at %llx: %s\n",