]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uaccess] Remove user_to_phys() and phys_to_user()
authorMichael Brown <mcb30@ipxe.org>
Mon, 21 Apr 2025 15:16:01 +0000 (16:16 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 21 Apr 2025 15:17:19 +0000 (16:17 +0100)
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>
48 files changed:
src/arch/x86/core/runtime.c
src/arch/x86/core/vram_settings.c
src/arch/x86/image/bzimage.c
src/arch/x86/image/com32.c
src/arch/x86/image/initrd.c
src/arch/x86/image/multiboot.c
src/arch/x86/image/nbi.c
src/arch/x86/image/sdi.c
src/arch/x86/image/ucode.c
src/arch/x86/include/librm.h
src/arch/x86/include/realmode.h
src/arch/x86/interface/pcbios/bios_cachedhcp.c
src/arch/x86/interface/pcbios/bios_smbios.c
src/arch/x86/interface/pcbios/int13.c
src/arch/x86/interface/pcbios/memtop_umalloc.c
src/arch/x86/interface/pcbios/rsdp.c
src/arch/x86/interface/pcbios/vesafb.c
src/arch/x86/interface/pxe/pxe_tftp.c
src/arch/x86/interface/syslinux/com32_call.c
src/arch/x86/interface/syslinux/comboot_call.c
src/arch/x86/transitions/librm_mgmt.c
src/core/acpi.c
src/core/blocktrans.c
src/core/cachedhcp.c
src/core/fbcon.c
src/core/image.c
src/core/uaccess.c
src/drivers/block/srp.c
src/drivers/infiniband/arbel.c
src/drivers/infiniband/golan.c
src/drivers/infiniband/golan.h
src/drivers/infiniband/hermon.c
src/drivers/net/exanic.c
src/drivers/net/gve.c
src/drivers/net/thunderx.c
src/drivers/usb/xhci.c
src/hci/commands/image_mem_cmd.c
src/image/elf.c
src/image/segment.c
src/include/ipxe/linux/linux_uaccess.h
src/include/ipxe/uaccess.h
src/interface/efi/efi_acpi.c
src/interface/efi/efi_fbcon.c
src/interface/efi/efi_smbios.c
src/interface/efi/efi_umalloc.c
src/interface/hyperv/vmbus.c
src/interface/linux/linux_uaccess.c
src/interface/smbios/smbios.c

index 2b803f772d9cb05d82f7b6f63867c32405295399..2d2a1067457b40682bbc0420ddb462ff8bb9e342 100644 (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" );
index 9c169b40c865f0902e153c5972e1420ee40e975e..ceeada46733d36c6a400aa7e29dc01c54ec43292 100644 (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 )
index 32598525f028e4fdeb40f3b30e478ab066ea1879..0f373c1c8c8d8857d68ce0f2ba2ece965d5d0092 100644 (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",
index 3e38215cb664c3ed4e553eff011777f57623b819..a2b60987d445ae3000e3b5305f538b8cc9712691 100644 (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 ) );
index bcf95deeffdba2029efab6fa7a8553c84063d573..fff40dd140f0e3143a3211356e22a8a081348104 100644 (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 */
index fe21f1f1ac1d4e30a70e9e800470cb58094c1f0a..24f67e02fef615384353a28e0b0456f808490b46 100644 (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 ) );
index 0b02a89855f91dcb7b5f02e5c19ad873ddab2372..1f72c12877a25bf1e48929ac7716c6097f7907a0 100644 (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:
index 5bb5a75695d306dde48b7d72b3ae4ee7f6a55551..5e22daeb38e3275796e44b4e0482b55bb0c4a8dd 100644 (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 ),
index 9b6b5067a3709666a5f0aa5166eee109f7ebdaca..a9fa8b8c4c0fb48eca76daef73d5801205cf0051 100644 (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 */
index 9ed91022e9e0ab939a6331d23f3812b9568c5262..7755abdcfd4657b376f06eebc17d0511e3b62a0f 100644 (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
index 4defd3b9743675ba5e056205b8b419a1c3d8cb82..616db5eb961948f08663e1e7afaa4f848507403d 100644 (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 ) );
 }
 
 /**
index bea803d6e86594f1b4d41ddfa2d82b7956083b13..05d89b3b7c3ae9bab1a87ac9a35ad1d698e56558 100644 (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 ) );
index 366679d3674a1986635045a92ff0d033ceaf668c..ab53d424b369416c044cd88abf184b1c770e7064 100644 (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 );
index 372d40ba3c0a76fe3afe72df24378685538d024d..d60f7c7cccfa2a5c241796e6eabdf1ecdc4ea136 100644 (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 */
index 8239b23b827ee36984ac63c6d63eb47977684436..b87d22516aeb7642c91b0fc45981f89db10a8491 100644 (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 );
 }
index 3c67b7525e1c3b63da0b36ab7855679bfb453f8b..02c58c7804ca62f21b9e129f493f7ae01a2f828b 100644 (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;
index 86edbda42e84cdca77e710dd85148b6d93dddec7..61609fa8c428420e41b1a15d7252d35ae2645a50 100644 (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;
index 3b4c6d847861eb0a2176d0a1c3b6f5d1ead9271f..2c2eccca4118ecac8c6a1b8e10da892e993ca93e 100644 (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();
index da9d6491a937f62d1dabc109af401898e3bb53e8..47be69f9fa0a5e7d87367d913fae555c4c4361b1 100644 (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__ (
index f26fcad0ab107b1a5446d1b0f679b67760b252f6..d7e923b7044e3ee66970337ebb887754fc80a946 100644 (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 */
index 82e8eab394e74a2e2589ec141dbf9b96fdf7d94c..fbc6539691f3409920c5ca617dfeffefbafe0a2b 100644 (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 );
index 526bf855582e5896eb960d9f5b355980b2f6359a..d7da0ccc12e43171bda6ce612bf39063bb1a3ca2 100644 (file)
@@ -128,16 +128,16 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) {
        copy_from_user ( &acpi, rsdt, 0, sizeof ( acpi ) );
        if ( acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) {
                DBGC ( colour, "RSDT %#08lx has invalid signature:\n",
-                      user_to_phys ( rsdt, 0 ) );
-               DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi,
+                      virt_to_phys ( rsdt ) );
+               DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi,
                           sizeof ( acpi ) );
                return UNULL;
        }
        len = le32_to_cpu ( acpi.length );
        if ( len < sizeof ( rsdtab->acpi ) ) {
                DBGC ( colour, "RSDT %#08lx has invalid length:\n",
-                      user_to_phys ( rsdt, 0 ) );
-               DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi,
+                      virt_to_phys ( rsdt ) );
+               DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi,
                           sizeof ( acpi ) );
                return UNULL;
        }
@@ -154,7 +154,7 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) {
                                 sizeof ( entry ) );
 
                /* Read table header */
-               table = phys_to_user ( entry );
+               table = phys_to_virt ( entry );
                copy_from_user ( &acpi.signature, table, 0,
                                 sizeof ( acpi.signature ) );
 
@@ -169,20 +169,20 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) {
                /* Check table integrity */
                if ( acpi_checksum ( table ) != 0 ) {
                        DBGC ( colour, "RSDT %#08lx found %s with bad "
-                              "checksum at %08lx\n", user_to_phys ( rsdt, 0 ),
+                              "checksum at %08lx\n", virt_to_phys ( rsdt ),
                               acpi_name ( signature ),
-                              user_to_phys ( table, 0 ) );
+                              virt_to_phys ( table ) );
                        break;
                }
 
                DBGC ( colour, "RSDT %#08lx found %s at %08lx\n",
-                      user_to_phys ( rsdt, 0 ), acpi_name ( signature ),
-                      user_to_phys ( table, 0 ) );
+                      virt_to_phys ( rsdt ), acpi_name ( signature ),
+                      virt_to_phys ( table ) );
                return table;
        }
 
        DBGC ( colour, "RSDT %#08lx could not find %s\n",
-              user_to_phys ( rsdt, 0 ), acpi_name ( signature ) );
+              virt_to_phys ( rsdt ), acpi_name ( signature ) );
        return UNULL;
 }
 
@@ -218,7 +218,7 @@ static int acpi_zsdt ( userptr_t zsdt, uint32_t signature, void *data,
                if ( buf != cpu_to_le32 ( signature ) )
                        continue;
                DBGC ( zsdt, "DSDT/SSDT %#08lx found %s at offset %#zx\n",
-                      user_to_phys ( zsdt, 0 ), acpi_name ( signature ),
+                      virt_to_phys ( zsdt ), acpi_name ( signature ),
                       offset );
 
                /* Attempt to extract data */
@@ -251,7 +251,7 @@ int acpi_extract ( uint32_t signature, void *data,
        fadt = acpi_table ( FADT_SIGNATURE, 0 );
        if ( fadt ) {
                copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) );
-               dsdt = phys_to_user ( fadtab.dsdt );
+               dsdt = phys_to_virt ( fadtab.dsdt );
                if ( ( rc = acpi_zsdt ( dsdt, signature, data,
                                        extract ) ) == 0 )
                        return 0;
index f9dcb95d2517693af618704963a5ff6087ca3a7e..f3be2ba2be8668067f2826ffc064dc50beb30e3e 100644 (file)
@@ -248,7 +248,7 @@ int block_translate ( struct interface *block, userptr_t buffer, size_t size ) {
        DBGC2 ( blktrans, "BLKTRANS %p created", blktrans );
        if ( buffer ) {
                DBGC2 ( blktrans, " for %#lx+%#zx",
-                       user_to_phys ( buffer, 0 ), size );
+                       virt_to_phys ( buffer ), size );
        }
        DBGC2 ( blktrans, "\n" );
        return 0;
index 04945e6463add77fd02282a29a4314229b370c2a..07589f0b84329050beb53a56c7def334f5e107da 100644 (file)
@@ -251,7 +251,7 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan,
 
        /* Store as cached packet */
        DBGC ( colour, "CACHEDHCP %s at %#08lx+%#zx/%#zx\n", cache->name,
-              user_to_phys ( data, 0 ), len, max_len );
+              virt_to_phys ( data ), len, max_len );
        cache->dhcppkt = dhcppkt;
        cache->vlan = vlan;
 
index 8d05484e260685ab4c8b38b0ece70470172bba2e..6d08ac419ef14bac8523c10e298090b1bafaa003 100644 (file)
@@ -613,8 +613,8 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start,
        /* Derive overall length */
        fbcon->len = ( pixel->height * pixel->stride );
        DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon,
-              user_to_phys ( fbcon->start, 0 ),
-              user_to_phys ( fbcon->start, fbcon->len ) );
+              virt_to_phys ( fbcon->start ),
+              ( virt_to_phys ( fbcon->start ) + fbcon->len ) );
 
        /* Calculate margin.  If the actual screen size is larger than
         * the requested screen size, then update the margins so that
index 709d0da9c898f47d502a01d7c3de543a801e05f6..e90d82ffbe9fa86d249a162236072dc050d1f1e4 100644 (file)
@@ -300,8 +300,8 @@ int register_image ( struct image *image ) {
        image->flags |= IMAGE_REGISTERED;
        list_add_tail ( &image->list, &images );
        DBGC ( image, "IMAGE %s at [%lx,%lx) registered\n",
-              image->name, user_to_phys ( image->data, 0 ),
-              user_to_phys ( image->data, image->len ) );
+              image->name, virt_to_phys ( image->data ),
+              ( virt_to_phys ( image->data ) + image->len ) );
 
        /* Try to detect image type, if applicable.  Ignore failures,
         * since we expect to handle some unrecognised images
index 1c33c10b8eafe356c0b67a2f4ff94749b2eb1c21..32bd1ac38561717d2cdc6302d0f673e013080f24 100644 (file)
@@ -32,7 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  */
 
 /* Flat address space user access API */
-PROVIDE_UACCESS_INLINE ( flat, phys_to_user );
-PROVIDE_UACCESS_INLINE ( flat, user_to_phys );
+PROVIDE_UACCESS_INLINE ( flat, phys_to_virt );
+PROVIDE_UACCESS_INLINE ( flat, virt_to_phys );
 PROVIDE_UACCESS_INLINE ( flat, virt_to_user );
 PROVIDE_UACCESS_INLINE ( flat, memchr_user );
index ab48125199f9b7a9a50e6b2b026b5d88f81b4611..c12f230f79a2729840587e5d45175f366e6b2617 100644 (file)
@@ -428,7 +428,7 @@ static int srp_cmd ( struct srp_device *srpdev,
                cmd->data_buffer_formats |= SRP_CMD_DO_FMT_DIRECT;
                data_out = iob_put ( iobuf, sizeof ( *data_out ) );
                data_out->address =
-                   cpu_to_be64 ( user_to_phys ( command->data_out, 0 ) );
+                   cpu_to_be64 ( virt_to_phys ( command->data_out ) );
                data_out->handle = ntohl ( srpdev->memory_handle );
                data_out->len = ntohl ( command->data_out_len );
        }
@@ -438,7 +438,7 @@ static int srp_cmd ( struct srp_device *srpdev,
                cmd->data_buffer_formats |= SRP_CMD_DI_FMT_DIRECT;
                data_in = iob_put ( iobuf, sizeof ( *data_in ) );
                data_in->address =
-                    cpu_to_be64 ( user_to_phys ( command->data_in, 0 ) );
+                    cpu_to_be64 ( virt_to_phys ( command->data_in ) );
                data_in->handle = ntohl ( srpdev->memory_handle );
                data_in->len = ntohl ( command->data_in_len );
        }
index 8be06d93d384de34be9ad86971c1699a8828afb7..4cb4167e06d72a48576cb89d92e955db25e51cf7 100644 (file)
@@ -2079,7 +2079,7 @@ static int arbel_start_firmware ( struct arbel *arbel ) {
        } else {
                assert ( arbel->firmware_len == fw_len );
        }
-       fw_base = user_to_phys ( arbel->firmware_area, 0 );
+       fw_base = virt_to_phys ( arbel->firmware_area );
        DBGC ( arbel, "Arbel %p firmware area at [%08lx,%08lx)\n",
               arbel, fw_base, ( fw_base + fw_len ) );
        if ( ( rc = arbel_map_vpm ( arbel, arbel_cmd_map_fa,
@@ -2452,7 +2452,7 @@ static int arbel_alloc_icm ( struct arbel *arbel,
                assert ( arbel->icm_len == icm_len );
                assert ( arbel->icm_aux_len == icm_aux_len );
        }
-       icm_phys = user_to_phys ( arbel->icm, 0 );
+       icm_phys = virt_to_phys ( arbel->icm );
 
        /* Allocate doorbell UAR */
        arbel->db_rec = malloc_phys ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE );
index 81fc6c0f08ce4dd0938b946e3ef011c707430aa1..a33bad9ff84246218a4cfdc903fd0cce9de81cd4 100755 (executable)
@@ -486,8 +486,8 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages
                for ( i = 0 , j = MANAGE_PAGES_PSA_OFFSET; i < pas_num; ++i ,++j,
                                next_page_addr += GOLAN_PAGE_SIZE ) {
                        addr = next_page_addr;
-                       if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) {
-                               DBGC (golan ,"Addr not Page alligned [%lx]\n", user_to_phys(addr, 0));
+                       if (GOLAN_PAGE_MASK & virt_to_phys(addr)) {
+                               DBGC (golan ,"Addr not Page alligned [%lx]\n", virt_to_phys(addr));
                        }
                        mailbox->mblock.data[j] = USR_2_BE64_BUS(addr);
                }
index 2fd06ecf0cb7dfa143dd1c1c53b07c0e8a6791c8..f7da1e96070425f3e6041c4dbf8e266327020925 100755 (executable)
@@ -69,8 +69,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 #define VIRT_2_BE64_BUS( addr )                cpu_to_be64(((unsigned long long )virt_to_bus(addr)))
 #define BE64_BUS_2_VIRT( addr )                bus_to_virt(be64_to_cpu(addr))
-#define USR_2_BE64_BUS( addr )         cpu_to_be64(((unsigned long long )user_to_phys(addr, 0)))
-#define BE64_BUS_2_USR( addr )         be64_to_cpu(phys_to_user(addr))
+#define USR_2_BE64_BUS( addr )         cpu_to_be64(((unsigned long long )virt_to_phys(addr)))
+#define BE64_BUS_2_USR( addr )         be64_to_cpu(phys_to_virt(addr))
 
 #define GET_INBOX(golan, idx)          (&(((struct mbox *)(golan->mboxes.inbox))[idx]))
 #define GET_OUTBOX(golan, idx)         (&(((struct mbox *)(golan->mboxes.outbox))[idx]))
index e5c3544fa8cfbfbda1a6099f61d13d6c6f0262c4..3138d8bfb1d5c239653fb0350fcecaf349e07021 100644 (file)
@@ -2382,7 +2382,7 @@ static int hermon_start_firmware ( struct hermon *hermon ) {
        } else {
                assert ( hermon->firmware_len == fw_len );
        }
-       fw_base = user_to_phys ( hermon->firmware_area, 0 );
+       fw_base = virt_to_phys ( hermon->firmware_area );
        DBGC ( hermon, "Hermon %p firmware area at physical [%08lx,%08lx)\n",
               hermon, fw_base, ( fw_base + fw_len ) );
        if ( ( rc = hermon_map_vpm ( hermon, hermon_cmd_map_fa,
@@ -2752,7 +2752,7 @@ static int hermon_map_icm ( struct hermon *hermon,
                assert ( hermon->icm_len == icm_len );
                assert ( hermon->icm_aux_len == icm_aux_len );
        }
-       icm_phys = user_to_phys ( hermon->icm, 0 );
+       icm_phys = virt_to_phys ( hermon->icm );
 
        /* Map ICM auxiliary area */
        DBGC ( hermon, "Hermon %p mapping ICM AUX => %08lx\n",
index 14a17df47b3076daecf9a6bdce1f47d973644072..b3148e090ebf5de6ea8455385e95dadb41687f65 100644 (file)
@@ -406,7 +406,7 @@ static int exanic_open ( struct net_device *netdev ) {
        port->rx_cons = 0;
 
        /* Map receive region */
-       exanic_write_base ( phys_to_bus ( user_to_phys ( port->rx, 0 ) ),
+       exanic_write_base ( phys_to_bus ( virt_to_phys ( port->rx ) ),
                            ( port->regs + EXANIC_PORT_RX_BASE ) );
 
        /* Enable promiscuous mode */
@@ -729,8 +729,8 @@ static int exanic_probe_port ( struct exanic *exanic, struct device *dev,
        DBGC ( port, "EXANIC %s port %d TX [%#05zx,%#05zx) TXF %#02x RX "
               "[%#lx,%#lx)\n", netdev->name, index, port->tx_offset,
               ( port->tx_offset + tx_len ), port->txf_slot,
-              user_to_phys ( port->rx, 0 ),
-              user_to_phys ( port->rx, EXANIC_RX_LEN ) );
+              virt_to_phys ( port->rx ),
+              ( virt_to_phys ( port->rx ) + EXANIC_RX_LEN ) );
 
        /* Set initial link state */
        exanic_check_link ( netdev );
index 2cbc401f56de3e2ce6a26fd26babb8d0535e5506..f9ec388a49d5ba4bce248ca1406e3886a30a61f6 100644 (file)
@@ -521,14 +521,14 @@ static int gve_deconfigure ( struct gve_nic *gve ) {
 static int gve_register ( struct gve_nic *gve, struct gve_qpl *qpl ) {
        struct gve_pages *pages = &gve->scratch.buf->pages;
        union gve_admin_command *cmd;
-       physaddr_t addr;
+       void *addr;
        unsigned int i;
        int rc;
 
        /* Build page address list */
        for ( i = 0 ; i < qpl->count ; i++ ) {
-               addr = user_to_phys ( qpl->data, ( i * GVE_PAGE_SIZE ) );
-               pages->addr[i] = cpu_to_be64 ( dma_phys ( &qpl->map, addr ) );
+               addr = ( qpl->data + ( i * GVE_PAGE_SIZE ) );
+               pages->addr[i] = cpu_to_be64 ( dma ( &qpl->map, addr ) );
        }
 
        /* Construct request */
@@ -575,11 +575,10 @@ static void gve_create_tx_param ( struct gve_queue *queue,
                                  union gve_admin_command *cmd ) {
        struct gve_admin_create_tx *create = &cmd->create_tx;
        const struct gve_queue_type *type = queue->type;
-       physaddr_t desc = user_to_phys ( queue->desc, 0 );
 
        /* Construct request parameters */
        create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) );
-       create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) );
+       create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) );
        create->qpl_id = cpu_to_be32 ( type->qpl );
        create->notify_id = cpu_to_be32 ( type->irq );
 }
@@ -594,14 +593,12 @@ static void gve_create_rx_param ( struct gve_queue *queue,
                                  union gve_admin_command *cmd ) {
        struct gve_admin_create_rx *create = &cmd->create_rx;
        const struct gve_queue_type *type = queue->type;
-       physaddr_t desc = user_to_phys ( queue->desc, 0 );
-       physaddr_t cmplt = user_to_phys ( queue->cmplt, 0 );
 
        /* Construct request parameters */
        create->notify_id = cpu_to_be32 ( type->irq );
        create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) );
-       create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) );
-       create->cmplt = cpu_to_be64 ( dma_phys ( &queue->cmplt_map, cmplt ) );
+       create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) );
+       create->cmplt = cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt ));
        create->qpl_id = cpu_to_be32 ( type->qpl );
        create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE );
 }
@@ -760,8 +757,8 @@ static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl,
                return -ENOMEM;
 
        DBGC ( gve, "GVE %p QPL %#08x at [%08lx,%08lx)\n",
-              gve, qpl->id, user_to_phys ( qpl->data, 0 ),
-              user_to_phys ( qpl->data, len ) );
+              gve, qpl->id, virt_to_phys ( qpl->data ),
+              ( virt_to_phys ( qpl->data ) + len ) );
        return 0;
 }
 
@@ -883,8 +880,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) {
                goto err_desc;
        }
        DBGC ( gve, "GVE %p %s descriptors at [%08lx,%08lx)\n",
-              gve, type->name, user_to_phys ( queue->desc, 0 ),
-              user_to_phys ( queue->desc, desc_len ) );
+              gve, type->name, virt_to_phys ( queue->desc ),
+              ( virt_to_phys ( queue->desc ) + desc_len ) );
 
        /* Allocate completions */
        if ( cmplt_len ) {
@@ -895,8 +892,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) {
                        goto err_cmplt;
                }
                DBGC ( gve, "GVE %p %s completions at [%08lx,%08lx)\n",
-                      gve, type->name, user_to_phys ( queue->cmplt, 0 ),
-                      user_to_phys ( queue->cmplt, cmplt_len ) );
+                      gve, type->name, virt_to_phys ( queue->cmplt ),
+                      ( virt_to_phys ( queue->cmplt ) + cmplt_len ) );
        }
 
        /* Allocate queue resources */
index 1865a9b9178835fe65845c90e68e733c21997aa5..3d213b1673014218df167332fac68ba4cbbf43f1 100644 (file)
@@ -118,14 +118,14 @@ static int txnic_create_sq ( struct txnic *vnic ) {
        writeq ( TXNIC_QS_SQ_CFG_RESET, ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
 
        /* Configure and enable send queue */
-       writeq ( user_to_phys ( vnic->sq.sqe, 0 ),
+       writeq ( virt_to_phys ( vnic->sq.sqe ),
                 ( vnic->regs + TXNIC_QS_SQ_BASE(0) ) );
        writeq ( ( TXNIC_QS_SQ_CFG_ENA | TXNIC_QS_SQ_CFG_QSIZE_1K ),
                 ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
 
        DBGC ( vnic, "TXNIC %s SQ at [%08lx,%08lx)\n",
-              vnic->name, user_to_phys ( vnic->sq.sqe, 0 ),
-              user_to_phys ( vnic->sq.sqe, TXNIC_SQ_SIZE ) );
+              vnic->name, virt_to_phys ( vnic->sq.sqe ),
+              ( virt_to_phys ( vnic->sq.sqe ) + TXNIC_SQ_SIZE ) );
        return 0;
 }
 
@@ -277,7 +277,7 @@ static int txnic_create_rq ( struct txnic *vnic ) {
                 ( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) );
 
        /* Configure and enable receive buffer descriptor ring */
-       writeq ( user_to_phys ( vnic->rq.rqe, 0 ),
+       writeq ( virt_to_phys ( vnic->rq.rqe ),
                 ( vnic->regs + TXNIC_QS_RBDR_BASE(0) ) );
        writeq ( ( TXNIC_QS_RBDR_CFG_ENA | TXNIC_QS_RBDR_CFG_QSIZE_8K |
                   TXNIC_QS_RBDR_CFG_LINES ( TXNIC_RQE_SIZE /
@@ -288,8 +288,8 @@ static int txnic_create_rq ( struct txnic *vnic ) {
        writeq ( TXNIC_QS_RQ_CFG_ENA, ( vnic->regs + TXNIC_QS_RQ_CFG(0) ) );
 
        DBGC ( vnic, "TXNIC %s RQ at [%08lx,%08lx)\n",
-              vnic->name, user_to_phys ( vnic->rq.rqe, 0 ),
-              user_to_phys ( vnic->rq.rqe, TXNIC_RQ_SIZE ) );
+              vnic->name, virt_to_phys ( vnic->rq.rqe ),
+              ( virt_to_phys ( vnic->rq.rqe ) + TXNIC_RQ_SIZE ) );
        return 0;
 }
 
@@ -463,14 +463,14 @@ static int txnic_create_cq ( struct txnic *vnic ) {
        writeq ( TXNIC_QS_CQ_CFG_RESET, ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
 
        /* Configure and enable completion queue */
-       writeq ( user_to_phys ( vnic->cq.cqe, 0 ),
+       writeq ( virt_to_phys ( vnic->cq.cqe ),
                 ( vnic->regs + TXNIC_QS_CQ_BASE(0) ) );
        writeq ( ( TXNIC_QS_CQ_CFG_ENA | TXNIC_QS_CQ_CFG_QSIZE_256 ),
                 ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
 
        DBGC ( vnic, "TXNIC %s CQ at [%08lx,%08lx)\n",
-              vnic->name, user_to_phys ( vnic->cq.cqe, 0 ),
-              user_to_phys ( vnic->cq.cqe, TXNIC_CQ_SIZE ) );
+              vnic->name, virt_to_phys ( vnic->cq.cqe ),
+              ( virt_to_phys ( vnic->cq.cqe ) + TXNIC_CQ_SIZE ) );
        return 0;
 }
 
@@ -559,7 +559,8 @@ static void txnic_poll_cq ( struct txnic *vnic ) {
                default:
                        DBGC ( vnic, "TXNIC %s unknown completion type %d\n",
                               vnic->name, cqe.common.cqe_type );
-                       DBGC_HDA ( vnic, user_to_phys ( vnic->cq.cqe, offset ),
+                       DBGC_HDA ( vnic,
+                                  ( virt_to_phys ( vnic->cq.cqe ) + offset ),
                                   &cqe, sizeof ( cqe ) );
                        break;
                }
index f244086ce08a77e6f7e396940a1bff3232783750..30ee09bbb1f46c75dc37490ccb8bb27a5ea5d3e1 100644 (file)
@@ -1014,8 +1014,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) {
        }
 
        /* Populate scratchpad array */
-       addr = dma_phys ( &scratch->buffer_map,
-                         user_to_phys ( scratch->buffer, 0 ) );
+       addr = dma ( &scratch->buffer_map, scratch->buffer );
        for ( i = 0 ; i < scratch->count ; i++ ) {
                scratch->array[i] = cpu_to_le64 ( addr );
                addr += xhci->pagesize;
@@ -1027,8 +1026,8 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) {
                                                     scratch->array ) );
 
        DBGC2 ( xhci, "XHCI %s scratchpad [%08lx,%08lx) array [%08lx,%08lx)\n",
-               xhci->name, user_to_phys ( scratch->buffer, 0 ),
-               user_to_phys ( scratch->buffer, buffer_len ),
+               xhci->name, virt_to_phys ( scratch->buffer ),
+               ( virt_to_phys ( scratch->buffer ) + buffer_len ),
                virt_to_phys ( scratch->array ),
                ( virt_to_phys ( scratch->array ) + array_len ) );
        return 0;
index c8bfab1ad67e3600f608ad0b5e609a5d44f32505..5f83634617914b4117b64e97852f8e4be11745a2 100644 (file)
@@ -81,7 +81,7 @@ static int imgmem_exec ( int argc, char **argv ) {
                return rc;
 
        /* Create image */
-       if ( ( rc = imgmem ( opts.name, phys_to_user ( data ), len ) ) != 0 )
+       if ( ( rc = imgmem ( opts.name, phys_to_virt ( data ), len ) ) != 0 )
                return rc;
 
        return 0;
index 46c9fe8eb5ae3172537b6f8d0c611b5f6e569852..fa714b15f882deaf33c0419ad9ea48fd4d78fdd6 100644 (file)
@@ -50,7 +50,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  */
 static int elf_load_segment ( struct image *image, Elf_Phdr *phdr,
                              physaddr_t dest ) {
-       userptr_t buffer = phys_to_user ( dest );
+       userptr_t buffer = phys_to_virt ( dest );
        int rc;
 
        DBGC ( image, "ELF %p loading segment [%x,%x) to [%lx,%lx,%lx)\n",
index b7f8ef56cfcf064aa21b62bb4028f5312fe77172..ebc2b703dd548772cfb491026528f8cddca698ad 100644 (file)
@@ -59,9 +59,9 @@ struct errortab segment_errors[] __errortab = {
  */
 int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) {
        struct memory_map memmap;
-       physaddr_t start = user_to_phys ( segment, 0 );
-       physaddr_t mid = user_to_phys ( segment, filesz );
-       physaddr_t end = user_to_phys ( segment, memsz );
+       physaddr_t start = virt_to_phys ( segment );
+       physaddr_t mid = ( start + filesz );
+       physaddr_t end = ( start + memsz );
        unsigned int i;
 
        DBG ( "Preparing segment [%lx,%lx,%lx)\n", start, mid, end );
index 4b1257b1e31502ed4b241eb4b95b861397a11dfd..b4f7e2fc69a78bf76a3632ad64fe8592c53af3f3 100644 (file)
  *
  * We have no concept of the underlying physical addresses, since
  * these are not exposed to userspace.  We provide a stub
- * implementation of user_to_phys() since this is required by
- * alloc_memblock().  We provide no implementation of phys_to_user();
- * any code attempting to access physical addresses will therefore
- * (correctly) fail to link.
+ * implementation of virt_to_phys() since this is required by
+ * alloc_memblock().  We provide a matching stub implementation of
+ * phys_to_virt().
  */
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
@@ -25,14 +24,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #endif
 
 /**
- * Convert user pointer 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 ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) {
+static inline __always_inline physaddr_t
+UACCESS_INLINE ( linux, virt_to_phys ) ( volatile const void *virt ) {
 
        /* We do not know the real underlying physical address.  We
         * provide this stub implementation only because it is
@@ -43,20 +41,20 @@ UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) {
         * virtual address will suffice for the purpose of determining
         * alignment.
         */
-       return ( ( unsigned long ) ( userptr + offset ) );
+       return ( ( physaddr_t ) virt );
 }
 
 /**
- * Convert physical address to user pointer
+ * Convert physical address to virtual address
  *
- * @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 ( linux, phys_to_user ) ( physaddr_t phys_addr ) {
+static inline __always_inline void *
+UACCESS_INLINE ( linux, phys_to_virt ) ( physaddr_t phys ) {
 
-       /* For symmetry with the stub user_to_phys() */
-       return ( ( userptr_t ) phys_addr );
+       /* For symmetry with the stub virt_to_phys() */
+       return ( ( void * ) phys );
 }
 
 static inline __always_inline userptr_t
index 4b3524babcab9059d5b7a3b8d3813c2f3cd473e3..62030dd8a4cb0e83aed4be02b4becedfd4289370 100644 (file)
@@ -99,14 +99,14 @@ trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
 #define PROVIDE_UACCESS_INLINE( _subsys, _api_func ) \
        PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func )
 
-static inline __always_inline userptr_t
-UACCESS_INLINE ( flat, phys_to_user ) ( unsigned long phys_addr ) {
-       return ( ( userptr_t ) phys_addr );
+static inline __always_inline void *
+UACCESS_INLINE ( flat, phys_to_virt ) ( physaddr_t phys ) {
+       return ( ( void * ) phys );
 }
 
-static inline __always_inline unsigned long
-UACCESS_INLINE ( flat, user_to_phys ) ( userptr_t userptr, off_t offset ) {
-       return ( ( unsigned long ) ( userptr + offset ) );
+static inline __always_inline physaddr_t
+UACCESS_INLINE ( flat, virt_to_phys ) ( volatile const void *virt ) {
+       return ( ( physaddr_t ) virt );
 }
 
 static inline __always_inline userptr_t
@@ -126,23 +126,6 @@ UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset,
 /* Include all architecture-dependent user access API headers */
 #include <bits/uaccess.h>
 
-/**
- * Convert physical address to user pointer
- *
- * @v phys_addr                Physical address
- * @ret userptr                User pointer
- */
-userptr_t phys_to_user ( unsigned long phys_addr );
-
-/**
- * Convert user pointer to physical address
- *
- * @v userptr          User pointer
- * @v offset           Offset from user pointer
- * @ret phys_addr      Physical address
- */
-unsigned long user_to_phys ( userptr_t userptr, off_t offset );
-
 /**
  * Convert virtual address to user pointer
  *
@@ -154,25 +137,21 @@ userptr_t virt_to_user ( volatile const void *addr );
 /**
  * Convert virtual address to a physical address
  *
- * @v addr             Virtual address
- * @ret phys_addr      Physical address
+ * @v virt             Virtual address
+ * @ret phys           Physical address
  */
-static inline __always_inline unsigned long
-virt_to_phys ( volatile const void *addr ) {
-       return user_to_phys ( virt_to_user ( addr ), 0 );
-}
+physaddr_t __attribute__ (( const ))
+virt_to_phys ( volatile const void *virt );
 
 /**
  * Convert physical address to a virtual address
  *
- * @v addr             Virtual address
- * @ret phys_addr      Physical address
+ * @v phys             Physical address
+ * @ret virt           Virtual address
  *
  * This operation is not available under all memory models.
  */
-static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) {
-       return ( phys_to_user ( phys_addr ) );
-}
+void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys );
 
 /**
  * Copy data to user buffer
index 07a2256329eace53c624e47d422b6bbcc0d227ff..c1046c01afacd5981ba004596aebe1a095a1302a 100644 (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;
 }
index 659ebd37e6f278c40ff4ae3ede5cc92a2a9bbb3b..09cfde4c2934a0fd186089d35833b61bab67ae8e 100644 (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;
index d7877b0aad61b5151b4dc70f708eb73bd80044a8..3c1b77bdc98d1fb6c55a47790e00e9949baf0eef 100644 (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;
        }
 
index 488c53f3d46a6dd9e74d8c99653491c6fa31a57a..0636cb7fdfff5ffaec3ca0a38a159737bdfe5ac1 100644 (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",
index 86d2a08d7ec357e8b0ba9fd2cb6cfe5b6ce303f6..49ccf69c8b9f8896b692e4869773ed0872ad0920 100644 (file)
@@ -277,7 +277,7 @@ int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data,
                            size_t len ) {
        struct hv_hypervisor *hv = vmdev->hv;
        struct vmbus *vmbus = hv->vmbus;
-       physaddr_t addr = user_to_phys ( data, 0 );
+       physaddr_t addr = virt_to_phys ( data );
        unsigned int pfn_count = hv_pfn_count ( addr, len );
        struct {
                struct vmbus_gpadl_header gpadlhdr;
index e5c3943654a8361202c9a9c75da91933e1ffaa07..4fdd8c03a5b3322741b50bc72e9f20bc657747bf 100644 (file)
@@ -27,6 +27,7 @@ FILE_LICENCE(GPL2_OR_LATER);
  *
  */
 
-PROVIDE_UACCESS_INLINE(linux, user_to_phys);
+PROVIDE_UACCESS_INLINE(linux, phys_to_virt);
+PROVIDE_UACCESS_INLINE(linux, virt_to_phys);
 PROVIDE_UACCESS_INLINE(linux, virt_to_user);
 PROVIDE_UACCESS_INLINE(linux, memchr_user);
index 3e69a0c153b0e1a677a756c125b85b812beaf657..89fa4d7ca1756fb46c777cedea6bf5cc6814572d 100644 (file)
@@ -86,14 +86,14 @@ int find_smbios_entry ( userptr_t start, size_t len,
                if ( ( sum = smbios_checksum ( start, offset,
                                               entry->len ) ) != 0 ) {
                        DBG ( "SMBIOS at %08lx has bad checksum %02x\n",
-                             user_to_phys ( start, offset ), sum );
+                             virt_to_phys ( start + offset ), sum );
                        continue;
                }
 
                /* Fill result structure */
                DBG ( "Found SMBIOS v%d.%d entry point at %08lx\n",
                      entry->major, entry->minor,
-                     user_to_phys ( start, offset ) );
+                     virt_to_phys ( start + offset ) );
                return 0;
        }
 
@@ -126,14 +126,14 @@ int find_smbios3_entry ( userptr_t start, size_t len,
                if ( ( sum = smbios_checksum ( start, offset,
                                               entry->len ) ) != 0 ) {
                        DBG ( "SMBIOS3 at %08lx has bad checksum %02x\n",
-                             user_to_phys ( start, offset ), sum );
+                             virt_to_phys ( start + offset ), sum );
                        continue;
                }
 
                /* Fill result structure */
                DBG ( "Found SMBIOS3 v%d.%d entry point at %08lx\n",
                      entry->major, entry->minor,
-                     user_to_phys ( start, offset ) );
+                     virt_to_phys ( start + offset ) );
                return 0;
        }