[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

@@ -124,7 +124,7 @@ static int cmdline_init ( void ) {
DBGC ( colour, "RUNTIME found no command line\n" );
return 0;
}
cmdline_user = phys_to_user ( cmdline_phys );
cmdline_user = phys_to_virt ( cmdline_phys );
len = ( strlen ( cmdline_user ) + 1 /* NUL */ );
/* Allocate and copy command line */
@@ -193,7 +193,7 @@ static int initrd_init ( void ) {
initrd_phys, ( initrd_phys + initrd_len ) );
/* Create initrd image */
image = image_memory ( "<INITRD>", phys_to_user ( initrd_phys ),
image = image_memory ( "<INITRD>", phys_to_virt ( initrd_phys ),
initrd_len );
if ( ! image ) {
DBGC ( colour, "RUNTIME could not create initrd image\n" );

View File

@@ -47,7 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
* @ret len Length of setting data, or negative error
*/
static int vram_fetch ( void *data, size_t len ) {
userptr_t vram = phys_to_user ( VRAM_BASE );
userptr_t vram = phys_to_virt ( VRAM_BASE );
/* Copy video RAM */
if ( len > VRAM_LEN )

View File

@@ -169,7 +169,7 @@ static int bzimage_parse_header ( struct image *image,
bzimg->rm_memsz += BZI_CMDLINE_SIZE;
/* Calculate load address of protected-mode portion */
bzimg->pm_kernel = phys_to_user ( is_bzimage ? BZI_LOAD_HIGH_ADDR
bzimg->pm_kernel = phys_to_virt ( is_bzimage ? BZI_LOAD_HIGH_ADDR
: BZI_LOAD_LOW_ADDR );
/* Extract video mode */
@@ -185,8 +185,8 @@ static int bzimage_parse_header ( struct image *image,
DBGC ( image, "bzImage %p version %04x RM %#lx+%#zx PM %#lx+%#zx "
"cmdlen %zd\n", image, bzimg->version,
user_to_phys ( bzimg->rm_kernel, 0 ), bzimg->rm_filesz,
user_to_phys ( bzimg->pm_kernel, 0 ), bzimg->pm_sz,
virt_to_phys ( bzimg->rm_kernel ), bzimg->rm_filesz,
virt_to_phys ( bzimg->pm_kernel ), bzimg->pm_sz,
bzimg->cmdline_size );
return 0;
@@ -215,8 +215,8 @@ static void bzimage_update_header ( struct image *image,
/* Set command line */
if ( bzimg->version >= 0x0202 ) {
bzimg->bzhdr.cmd_line_ptr = user_to_phys ( bzimg->rm_kernel,
bzimg->rm_cmdline );
bzimg->bzhdr.cmd_line_ptr = ( virt_to_phys ( bzimg->rm_kernel )
+ bzimg->rm_cmdline );
} else {
bzimg->cmdline_magic.magic = BZI_CMDLINE_MAGIC;
bzimg->cmdline_magic.offset = bzimg->rm_cmdline;
@@ -383,11 +383,11 @@ static size_t bzimage_load_initrd ( struct image *image,
}
assert ( offset == len );
DBGC ( image, "bzImage %p initrd %p [%#08lx,%#08lx,%#08lx)"
"%s%s\n", image, initrd, user_to_phys ( address, 0 ),
user_to_phys ( address, offset ),
user_to_phys ( address, ( offset + initrd->len ) ),
"%s%s\n", image, initrd, virt_to_phys ( address ),
( virt_to_phys ( address ) + offset ),
( virt_to_phys ( address ) + offset + initrd->len ),
( filename ? " " : "" ), ( filename ? filename : "" ) );
DBGC2_MD5A ( image, user_to_phys ( address, offset ),
DBGC2_MD5A ( image, ( virt_to_phys ( address ) + offset ),
( address + offset ), initrd->len );
}
len += initrd->len;
@@ -422,11 +422,11 @@ static int bzimage_check_initrds ( struct image *image,
len = bzimage_align ( len );
DBGC ( image, "bzImage %p initrd %p from [%#08lx,%#08lx)%s%s\n",
image, initrd, user_to_phys ( initrd->data, 0 ),
user_to_phys ( initrd->data, initrd->len ),
image, initrd, virt_to_phys ( initrd->data ),
( virt_to_phys ( initrd->data ) + initrd->len ),
( initrd->cmdline ? " " : "" ),
( initrd->cmdline ? initrd->cmdline : "" ) );
DBGC2_MD5A ( image, user_to_phys ( initrd->data, 0 ),
DBGC2_MD5A ( image, virt_to_phys ( initrd->data ),
initrd->data, initrd->len );
}
@@ -445,7 +445,7 @@ static int bzimage_check_initrds ( struct image *image,
}
/* Check that total length fits within kernel's memory limit */
if ( user_to_phys ( bottom, len ) > bzimg->mem_limit ) {
if ( ( virt_to_phys ( bottom ) + len ) > bzimg->mem_limit ) {
DBGC ( image, "bzImage %p not enough space for initrds\n",
image );
return -ENOBUFS;
@@ -485,12 +485,12 @@ static void bzimage_load_initrds ( struct image *image,
/* Find highest usable address */
top = ( highest->data + bzimage_align ( highest->len ) );
if ( user_to_phys ( top, -1 ) > bzimg->mem_limit ) {
top = phys_to_user ( ( bzimg->mem_limit + 1 ) &
if ( ( virt_to_phys ( top ) - 1UL ) > bzimg->mem_limit ) {
top = phys_to_virt ( ( bzimg->mem_limit + 1 ) &
~( INITRD_ALIGN - 1 ) );
}
DBGC ( image, "bzImage %p loading initrds from %#08lx downwards\n",
image, user_to_phys ( top, -1 ) );
image, ( virt_to_phys ( top ) - 1UL ) );
/* Load initrds in order */
for_each_image ( initrd ) {
@@ -512,8 +512,8 @@ static void bzimage_load_initrds ( struct image *image,
/* Record initrd location */
if ( ! bzimg->ramdisk_image )
bzimg->ramdisk_image = user_to_phys ( dest, 0 );
bzimg->ramdisk_size = ( user_to_phys ( dest, len ) -
bzimg->ramdisk_image = virt_to_phys ( dest );
bzimg->ramdisk_size = ( virt_to_phys ( dest ) + len -
bzimg->ramdisk_image );
}
DBGC ( image, "bzImage %p initrds at [%#08lx,%#08lx)\n",

View File

@@ -211,7 +211,7 @@ static int com32_load_image ( struct image *image ) {
filesz = image->len;
memsz = filesz;
buffer = phys_to_user ( COM32_START_PHYS );
buffer = phys_to_virt ( COM32_START_PHYS );
if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
DBGC ( image, "COM32 %p: could not prepare segment: %s\n",
image, strerror ( rc ) );

View File

@@ -76,10 +76,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) {
current -= len;
DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->"
"[%#08lx,%#08lx)\n", highest->name,
user_to_phys ( highest->data, 0 ),
user_to_phys ( highest->data, highest->len ),
user_to_phys ( current, 0 ),
user_to_phys ( current, highest->len ) );
virt_to_phys ( highest->data ),
( virt_to_phys ( highest->data ) + highest->len ),
virt_to_phys ( current ),
( virt_to_phys ( current ) + highest->len ) );
memmove ( current, highest->data, highest->len );
highest->data = current;
}
@@ -92,10 +92,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) {
current -= len;
DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->"
"[%#08lx,%#08lx)\n", initrd->name,
user_to_phys ( initrd->data, 0 ),
user_to_phys ( initrd->data, initrd->len ),
user_to_phys ( current, 0 ),
user_to_phys ( current, initrd->len ) );
virt_to_phys ( initrd->data ),
( virt_to_phys ( initrd->data ) + initrd->len ),
virt_to_phys ( current ),
( virt_to_phys ( current ) + initrd->len ) );
memcpy ( current, initrd->data, initrd->len );
initrd->data = current;
}
@@ -119,10 +119,10 @@ static void initrd_swap ( struct image *low, struct image *high,
size_t new_len;
DBGC ( &images, "INITRD swapping %s [%#08lx,%#08lx)<->[%#08lx,%#08lx) "
"%s\n", low->name, user_to_phys ( low->data, 0 ),
user_to_phys ( low->data, low->len ),
user_to_phys ( high->data, 0 ),
user_to_phys ( high->data, high->len ), high->name );
"%s\n", low->name, virt_to_phys ( low->data ),
( virt_to_phys ( low->data ) + low->len ),
virt_to_phys ( high->data ),
( virt_to_phys ( high->data ) + high->len ), high->name );
/* Round down length of free space */
free_len &= ~( INITRD_ALIGN - 1 );
@@ -208,9 +208,9 @@ static void initrd_dump ( void ) {
/* Dump initrd locations */
for_each_image ( initrd ) {
DBGC ( &images, "INITRD %s at [%#08lx,%#08lx)\n",
initrd->name, user_to_phys ( initrd->data, 0 ),
user_to_phys ( initrd->data, initrd->len ) );
DBGC2_MD5A ( &images, user_to_phys ( initrd->data, 0 ),
initrd->name, virt_to_phys ( initrd->data ),
( virt_to_phys ( initrd->data ) + initrd->len ) );
DBGC2_MD5A ( &images, virt_to_phys ( initrd->data ),
initrd->data, initrd->len );
}
}
@@ -239,7 +239,7 @@ void initrd_reshuffle ( userptr_t bottom ) {
/* Debug */
DBGC ( &images, "INITRD region [%#08lx,%#08lx)\n",
user_to_phys ( bottom, 0 ), user_to_phys ( top, 0 ) );
virt_to_phys ( bottom ), virt_to_phys ( top ) );
initrd_dump();
/* Squash initrds as high as possible in memory */

View File

@@ -212,7 +212,7 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
start = ( ( start + 0xfff ) & ~0xfff );
/* Prepare segment */
if ( ( rc = prep_segment ( phys_to_user ( start ),
if ( ( rc = prep_segment ( phys_to_virt ( start ),
module_image->len,
module_image->len ) ) != 0 ) {
DBGC ( image, "MULTIBOOT %p could not prepare module "
@@ -222,7 +222,7 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
}
/* Copy module */
memcpy ( phys_to_user ( start ), module_image->data,
memcpy ( phys_to_virt ( start ), module_image->data,
module_image->len );
/* Add module to list */
@@ -342,7 +342,7 @@ static int multiboot_load_raw ( struct image *image,
( image->len - offset ) );
memsz = ( hdr->mb.bss_end_addr ?
( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz );
buffer = phys_to_user ( hdr->mb.load_addr );
buffer = phys_to_virt ( hdr->mb.load_addr );
if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
DBGC ( image, "MULTIBOOT %p could not prepare segment: %s\n",
image, strerror ( rc ) );

View File

@@ -181,7 +181,7 @@ static int nbi_process_segments ( struct image *image,
/* Calculate segment load address */
switch ( NBI_LOADADDR_FLAGS ( sh.flags ) ) {
case NBI_LOADADDR_ABS:
dest = phys_to_user ( sh.loadaddr );
dest = phys_to_virt ( sh.loadaddr );
break;
case NBI_LOADADDR_AFTER:
dest = ( dest + memsz + sh.loadaddr );
@@ -194,7 +194,7 @@ static int nbi_process_segments ( struct image *image,
* maintains backwards compatibility with
* previous versions of Etherboot.
*/
dest = phys_to_user ( ( extmemsize() + 1024 ) * 1024
dest = phys_to_virt ( ( extmemsize() + 1024 ) * 1024
- sh.loadaddr );
break;
default:

View File

@@ -92,16 +92,17 @@ static int sdi_exec ( struct image *image ) {
return -ENOTTY;
}
DBGC ( image, "SDI %p image at %08lx+%08zx\n",
image, user_to_phys ( image->data, 0 ), image->len );
DBGC ( image, "SDI %p boot code at %08lx+%llx\n", image,
user_to_phys ( image->data, sdi.boot_offset ), sdi.boot_size );
image, virt_to_phys ( image->data ), image->len );
DBGC ( image, "SDI %p boot code at %08llx+%llx\n", image,
( virt_to_phys ( image->data ) + sdi.boot_offset ),
sdi.boot_size );
/* Copy boot code */
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 );
sdiptr = ( virt_to_phys ( image->data ) | SDI_WTF );
__asm__ __volatile__ ( REAL_CODE ( "ljmp %0, %1\n\t" )
: : "i" ( SDI_BOOT_SEG ),
"i" ( SDI_BOOT_OFF ),

View File

@@ -165,7 +165,7 @@ static int ucode_status ( struct ucode_update *update,
assert ( id <= control->apic_max );
/* Read status report */
copy_from_user ( &status, phys_to_user ( control->status ),
copy_from_user ( &status, phys_to_virt ( control->status ),
( id * sizeof ( status ) ), sizeof ( status ) );
/* Ignore empty optional status reports */
@@ -261,7 +261,7 @@ static int ucode_update_all ( struct image *image,
/* Construct control structure */
memset ( &control, 0, sizeof ( control ) );
control.desc = virt_to_phys ( update->desc );
control.status = user_to_phys ( status, 0 );
control.status = virt_to_phys ( status );
vendor = update->vendor;
if ( vendor ) {
control.ver_clear = vendor->ver_clear;
@@ -446,8 +446,8 @@ static int ucode_parse_intel ( struct image *image, size_t start,
/* Populate descriptor */
desc.signature = hdr.signature;
desc.version = hdr.version;
desc.address = user_to_phys ( image->data,
( start + sizeof ( hdr ) ) );
desc.address = ( virt_to_phys ( image->data ) +
start + sizeof ( hdr ) );
/* Add non-extended descriptor, if applicable */
ucode_describe ( image, start, &ucode_intel, &desc, hdr.platforms,
@@ -589,7 +589,8 @@ static int ucode_parse_amd ( struct image *image, size_t start,
copy_from_user ( &patch, image->data, ( start + offset ),
sizeof ( patch ) );
desc.version = patch.version;
desc.address = user_to_phys ( image->data, ( start + offset ) );
desc.address = ( virt_to_phys ( image->data ) +
start + offset );
offset += phdr.len;
/* Parse equivalence table to find matching signatures */

View File

@@ -85,33 +85,32 @@ extern const unsigned long virt_offset;
/**
* Convert physical address to user pointer
*
* @v phys_addr Physical address
* @ret userptr User pointer
* @v phys Physical address
* @ret virt Virtual address
*/
static inline __always_inline userptr_t
UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
static inline __always_inline void *
UACCESS_INLINE ( librm, phys_to_virt ) ( unsigned long phys ) {
/* In a 64-bit build, any valid physical address is directly
* usable as a virtual address, since the low 4GB is
* identity-mapped.
*/
if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) )
return ( ( userptr_t ) phys_addr );
return ( ( void * ) phys );
/* In a 32-bit build, subtract virt_offset */
return ( ( userptr_t ) ( phys_addr - virt_offset ) );
return ( ( void * ) ( phys - virt_offset ) );
}
/**
* Convert user buffer to physical address
* Convert virtual address to physical address
*
* @v userptr User pointer
* @v offset Offset from user pointer
* @ret phys_addr Physical address
* @v virt Virtual address
* @ret phys Physical address
*/
static inline __always_inline unsigned long
UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) {
unsigned long addr = ( ( unsigned long ) ( userptr + offset ) );
static inline __always_inline physaddr_t
UACCESS_INLINE ( librm, virt_to_phys ) ( volatile const void *virt ) {
physaddr_t addr = ( ( physaddr_t ) virt );
/* In a 64-bit build, any virtual address in the low 4GB is
* directly usable as a physical address, since the low 4GB is

View File

@@ -73,7 +73,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
static inline __always_inline userptr_t
real_to_user ( unsigned int segment, unsigned int offset ) {
return ( phys_to_user ( ( segment << 4 ) + offset ) );
return ( phys_to_virt ( ( segment << 4 ) + offset ) );
}
/**

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;

View File

@@ -492,7 +492,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
}
/* Read entire file */
pxe_tftp.buffer = phys_to_user ( tftp_read_file->Buffer );
pxe_tftp.buffer = phys_to_virt ( tftp_read_file->Buffer );
pxe_tftp.size = tftp_read_file->BufferSize;
while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS )
step();

View File

@@ -49,7 +49,7 @@ 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 ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ),
memcpy ( virt_to_user( &com32_regs ), phys_to_virt ( inregs_phys ),
sizeof ( com32sys_t ) );
com32_int_vector = interrupt;
@@ -107,7 +107,7 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad
: : );
if ( outregs_phys ) {
memcpy ( phys_to_user ( outregs_phys ),
memcpy ( phys_to_virt ( outregs_phys ),
virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) );
}
}
@@ -120,7 +120,7 @@ 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 ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ),
memcpy ( virt_to_user( &com32_regs ), phys_to_virt ( inregs_phys ),
sizeof ( com32sys_t ) );
com32_farcall_proc = proc;
@@ -167,7 +167,7 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t
: : );
if ( outregs_phys ) {
memcpy ( phys_to_user ( outregs_phys ),
memcpy ( phys_to_virt ( outregs_phys ),
virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) );
}
}
@@ -181,7 +181,7 @@ int __asmcall com32_cfarcall ( uint32_t proc, physaddr_t stack, size_t stacksz )
DBGC ( &com32_regs, "COM32 cfarcall %04x:%04x params %#08lx+%#zx\n",
( proc >> 16 ), ( proc & 0xffff ), stack, stacksz );
copy_user_to_rm_stack ( phys_to_user ( stack ), stacksz );
copy_user_to_rm_stack ( phys_to_virt ( stack ), stacksz );
com32_farcall_proc = proc;
__asm__ __volatile__ (

View File

@@ -114,8 +114,8 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig
/* Do the copies */
for ( i = 0; i < count; i++ ) {
userptr_t src_u = phys_to_user ( shuf[ i ].src );
userptr_t dest_u = phys_to_user ( shuf[ i ].dest );
userptr_t src_u = phys_to_virt ( shuf[ i ].src );
userptr_t dest_u = phys_to_virt ( shuf[ i ].dest );
if ( shuf[ i ].src == 0xFFFFFFFF ) {
/* Fill with 0 instead of copying */

View File

@@ -428,8 +428,8 @@ void setup_sipi ( unsigned int vector, uint32_t handler,
copy_to_real ( ( vector << 8 ), 0, sipi, ( ( size_t ) sipi_len ) );
}
PROVIDE_UACCESS_INLINE ( librm, phys_to_user );
PROVIDE_UACCESS_INLINE ( librm, user_to_phys );
PROVIDE_UACCESS_INLINE ( librm, phys_to_virt );
PROVIDE_UACCESS_INLINE ( librm, virt_to_phys );
PROVIDE_UACCESS_INLINE ( librm, virt_to_user );
PROVIDE_UACCESS_INLINE ( librm, memchr_user );
PROVIDE_IOMAP_INLINE ( pages, io_to_bus );