12e0eb483SAtish Patra // SPDX-License-Identifier: GPL-2.0-only 22e0eb483SAtish Patra /* 32e0eb483SAtish Patra * EFI stub implementation that is shared by arm and arm64 architectures. 42e0eb483SAtish Patra * This should be #included by the EFI stub implementation files. 52e0eb483SAtish Patra * 62e0eb483SAtish Patra * Copyright (C) 2013,2014 Linaro Limited 72e0eb483SAtish Patra * Roy Franz <roy.franz@linaro.org 82e0eb483SAtish Patra * Copyright (C) 2013 Red Hat, Inc. 92e0eb483SAtish Patra * Mark Salter <msalter@redhat.com> 102e0eb483SAtish Patra */ 112e0eb483SAtish Patra 122e0eb483SAtish Patra #include <linux/efi.h> 132e0eb483SAtish Patra #include <linux/libfdt.h> 142e0eb483SAtish Patra #include <asm/efi.h> 152e0eb483SAtish Patra 162e0eb483SAtish Patra #include "efistub.h" 172e0eb483SAtish Patra 182e0eb483SAtish Patra /* 192e0eb483SAtish Patra * This is the base address at which to start allocating virtual memory ranges 20b91540d5SAtish Patra * for UEFI Runtime Services. 21b91540d5SAtish Patra * 22b91540d5SAtish Patra * For ARM/ARM64: 23b91540d5SAtish Patra * This is in the low TTBR0 range so that we can use 242e0eb483SAtish Patra * any allocation we choose, and eliminate the risk of a conflict after kexec. 252e0eb483SAtish Patra * The value chosen is the largest non-zero power of 2 suitable for this purpose 262e0eb483SAtish Patra * both on 32-bit and 64-bit ARM CPUs, to maximize the likelihood that it can 272e0eb483SAtish Patra * be mapped efficiently. 282e0eb483SAtish Patra * Since 32-bit ARM could potentially execute with a 1G/3G user/kernel split, 292e0eb483SAtish Patra * map everything below 1 GB. (512 MB is a reasonable upper bound for the 302e0eb483SAtish Patra * entire footprint of the UEFI runtime services memory regions) 31b91540d5SAtish Patra * 32b91540d5SAtish Patra * For RISC-V: 33b91540d5SAtish Patra * There is no specific reason for which, this address (512MB) can't be used 34b91540d5SAtish Patra * EFI runtime virtual address for RISC-V. It also helps to use EFI runtime 35b91540d5SAtish Patra * services on both RV32/RV64. Keep the same runtime virtual address for RISC-V 36b91540d5SAtish Patra * as well to minimize the code churn. 372e0eb483SAtish Patra */ 382e0eb483SAtish Patra #define EFI_RT_VIRTUAL_BASE SZ_512M 392e0eb483SAtish Patra #define EFI_RT_VIRTUAL_SIZE SZ_512M 402e0eb483SAtish Patra 412e0eb483SAtish Patra #ifdef CONFIG_ARM64 422e0eb483SAtish Patra # define EFI_RT_VIRTUAL_LIMIT DEFAULT_MAP_WINDOW_64 432e0eb483SAtish Patra #else 442e0eb483SAtish Patra # define EFI_RT_VIRTUAL_LIMIT TASK_SIZE 452e0eb483SAtish Patra #endif 462e0eb483SAtish Patra 472e0eb483SAtish Patra static u64 virtmap_base = EFI_RT_VIRTUAL_BASE; 4854439370SArvind Sankar static bool flat_va_mapping; 492e0eb483SAtish Patra 50ccc27ae7SArd Biesheuvel const efi_system_table_t *efi_system_table; 512e0eb483SAtish Patra 522e0eb483SAtish Patra static struct screen_info *setup_graphics(void) 532e0eb483SAtish Patra { 542e0eb483SAtish Patra efi_guid_t gop_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; 552e0eb483SAtish Patra efi_status_t status; 562e0eb483SAtish Patra unsigned long size; 572e0eb483SAtish Patra void **gop_handle = NULL; 582e0eb483SAtish Patra struct screen_info *si = NULL; 592e0eb483SAtish Patra 602e0eb483SAtish Patra size = 0; 612e0eb483SAtish Patra status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, 622e0eb483SAtish Patra &gop_proto, NULL, &size, gop_handle); 632e0eb483SAtish Patra if (status == EFI_BUFFER_TOO_SMALL) { 642e0eb483SAtish Patra si = alloc_screen_info(); 652e0eb483SAtish Patra if (!si) 662e0eb483SAtish Patra return NULL; 67a5d8e55bSIngo Molnar status = efi_setup_gop(si, &gop_proto, size); 68a5d8e55bSIngo Molnar if (status != EFI_SUCCESS) { 69a5d8e55bSIngo Molnar free_screen_info(si); 70a5d8e55bSIngo Molnar return NULL; 71a5d8e55bSIngo Molnar } 722e0eb483SAtish Patra } 732e0eb483SAtish Patra return si; 742e0eb483SAtish Patra } 752e0eb483SAtish Patra 7687cd6378SZou Wei static void install_memreserve_table(void) 772e0eb483SAtish Patra { 782e0eb483SAtish Patra struct linux_efi_memreserve *rsv; 792e0eb483SAtish Patra efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; 802e0eb483SAtish Patra efi_status_t status; 812e0eb483SAtish Patra 822e0eb483SAtish Patra status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv), 832e0eb483SAtish Patra (void **)&rsv); 842e0eb483SAtish Patra if (status != EFI_SUCCESS) { 85793473c2SArvind Sankar efi_err("Failed to allocate memreserve entry!\n"); 862e0eb483SAtish Patra return; 872e0eb483SAtish Patra } 882e0eb483SAtish Patra 892e0eb483SAtish Patra rsv->next = 0; 902e0eb483SAtish Patra rsv->size = 0; 912e0eb483SAtish Patra atomic_set(&rsv->count, 0); 922e0eb483SAtish Patra 932e0eb483SAtish Patra status = efi_bs_call(install_configuration_table, 942e0eb483SAtish Patra &memreserve_table_guid, rsv); 952e0eb483SAtish Patra if (status != EFI_SUCCESS) 96793473c2SArvind Sankar efi_err("Failed to install memreserve config table!\n"); 972e0eb483SAtish Patra } 982e0eb483SAtish Patra 99*9e9888a0SArd Biesheuvel static u32 get_supported_rt_services(void) 100*9e9888a0SArd Biesheuvel { 101*9e9888a0SArd Biesheuvel const efi_rt_properties_table_t *rt_prop_table; 102*9e9888a0SArd Biesheuvel u32 supported = EFI_RT_SUPPORTED_ALL; 103*9e9888a0SArd Biesheuvel 104*9e9888a0SArd Biesheuvel rt_prop_table = get_efi_config_table(EFI_RT_PROPERTIES_TABLE_GUID); 105*9e9888a0SArd Biesheuvel if (rt_prop_table) 106*9e9888a0SArd Biesheuvel supported &= rt_prop_table->runtime_services_supported; 107*9e9888a0SArd Biesheuvel 108*9e9888a0SArd Biesheuvel return supported; 109*9e9888a0SArd Biesheuvel } 110*9e9888a0SArd Biesheuvel 1112e0eb483SAtish Patra /* 1122e0eb483SAtish Patra * EFI entry point for the arm/arm64 EFI stubs. This is the entrypoint 1132e0eb483SAtish Patra * that is described in the PE/COFF header. Most of the code is the same 1142e0eb483SAtish Patra * for both archictectures, with the arch-specific code provided in the 1152e0eb483SAtish Patra * handle_kernel_image() function. 1162e0eb483SAtish Patra */ 1176e99d321SArd Biesheuvel efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, 1186e99d321SArd Biesheuvel efi_system_table_t *sys_table_arg) 1192e0eb483SAtish Patra { 1202e0eb483SAtish Patra efi_loaded_image_t *image; 1212e0eb483SAtish Patra efi_status_t status; 1222e0eb483SAtish Patra unsigned long image_addr; 1232e0eb483SAtish Patra unsigned long image_size = 0; 1242e0eb483SAtish Patra /* addr/point and size pairs for memory management*/ 1252e0eb483SAtish Patra unsigned long initrd_addr = 0; 1262e0eb483SAtish Patra unsigned long initrd_size = 0; 1272e0eb483SAtish Patra unsigned long fdt_addr = 0; /* Original DTB */ 1282e0eb483SAtish Patra unsigned long fdt_size = 0; 1292e0eb483SAtish Patra char *cmdline_ptr = NULL; 1302e0eb483SAtish Patra int cmdline_size = 0; 1312e0eb483SAtish Patra efi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID; 1322e0eb483SAtish Patra unsigned long reserve_addr = 0; 1332e0eb483SAtish Patra unsigned long reserve_size = 0; 1342e0eb483SAtish Patra enum efi_secureboot_mode secure_boot; 1352e0eb483SAtish Patra struct screen_info *si; 1362e0eb483SAtish Patra efi_properties_table_t *prop_tbl; 1372e0eb483SAtish Patra unsigned long max_addr; 1382e0eb483SAtish Patra 139ccc27ae7SArd Biesheuvel efi_system_table = sys_table_arg; 1402e0eb483SAtish Patra 1412e0eb483SAtish Patra /* Check if we were booted by the EFI firmware */ 142ccc27ae7SArd Biesheuvel if (efi_system_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) { 1432e0eb483SAtish Patra status = EFI_INVALID_PARAMETER; 1442e0eb483SAtish Patra goto fail; 1452e0eb483SAtish Patra } 1462e0eb483SAtish Patra 1472e0eb483SAtish Patra status = check_platform_features(); 1482e0eb483SAtish Patra if (status != EFI_SUCCESS) 1492e0eb483SAtish Patra goto fail; 1502e0eb483SAtish Patra 1512e0eb483SAtish Patra /* 1522e0eb483SAtish Patra * Get a handle to the loaded image protocol. This is used to get 1532e0eb483SAtish Patra * information about the running image, such as size and the command 1542e0eb483SAtish Patra * line. 1552e0eb483SAtish Patra */ 156ccc27ae7SArd Biesheuvel status = efi_system_table->boottime->handle_protocol(handle, 1572e0eb483SAtish Patra &loaded_image_proto, (void *)&image); 1582e0eb483SAtish Patra if (status != EFI_SUCCESS) { 159793473c2SArvind Sankar efi_err("Failed to get loaded image protocol\n"); 1602e0eb483SAtish Patra goto fail; 1612e0eb483SAtish Patra } 1622e0eb483SAtish Patra 1632e0eb483SAtish Patra /* 1642e0eb483SAtish Patra * Get the command line from EFI, using the LOADED_IMAGE 1652e0eb483SAtish Patra * protocol. We are going to copy the command line into the 1662e0eb483SAtish Patra * device tree, so this can be allocated anywhere. 1672e0eb483SAtish Patra */ 16827cd5511SArd Biesheuvel cmdline_ptr = efi_convert_cmdline(image, &cmdline_size); 1692e0eb483SAtish Patra if (!cmdline_ptr) { 170793473c2SArvind Sankar efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n"); 1712e0eb483SAtish Patra status = EFI_OUT_OF_RESOURCES; 1722e0eb483SAtish Patra goto fail; 1732e0eb483SAtish Patra } 1742e0eb483SAtish Patra 1752e0eb483SAtish Patra if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || 1762e0eb483SAtish Patra IS_ENABLED(CONFIG_CMDLINE_FORCE) || 177055042beSArvind Sankar cmdline_size == 0) { 178055042beSArvind Sankar status = efi_parse_options(CONFIG_CMDLINE); 179055042beSArvind Sankar if (status != EFI_SUCCESS) { 180055042beSArvind Sankar efi_err("Failed to parse options\n"); 181055042beSArvind Sankar goto fail_free_cmdline; 182055042beSArvind Sankar } 183055042beSArvind Sankar } 1842e0eb483SAtish Patra 185055042beSArvind Sankar if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0) { 186055042beSArvind Sankar status = efi_parse_options(cmdline_ptr); 187055042beSArvind Sankar if (status != EFI_SUCCESS) { 188055042beSArvind Sankar efi_err("Failed to parse options\n"); 189055042beSArvind Sankar goto fail_free_cmdline; 190055042beSArvind Sankar } 191055042beSArvind Sankar } 1922e0eb483SAtish Patra 193793473c2SArvind Sankar efi_info("Booting Linux Kernel...\n"); 1942e0eb483SAtish Patra 1952e0eb483SAtish Patra si = setup_graphics(); 1962e0eb483SAtish Patra 1972e0eb483SAtish Patra status = handle_kernel_image(&image_addr, &image_size, 1982e0eb483SAtish Patra &reserve_addr, 1992e0eb483SAtish Patra &reserve_size, 200762cd288SArd Biesheuvel image); 2012e0eb483SAtish Patra if (status != EFI_SUCCESS) { 202793473c2SArvind Sankar efi_err("Failed to relocate kernel\n"); 203055042beSArvind Sankar goto fail_free_screeninfo; 2042e0eb483SAtish Patra } 2052e0eb483SAtish Patra 2062e0eb483SAtish Patra efi_retrieve_tpm2_eventlog(); 2072e0eb483SAtish Patra 2082e0eb483SAtish Patra /* Ask the firmware to clear memory on unclean shutdown */ 2092e0eb483SAtish Patra efi_enable_reset_attack_mitigation(); 2102e0eb483SAtish Patra 2112e0eb483SAtish Patra secure_boot = efi_get_secureboot(); 2122e0eb483SAtish Patra 2132e0eb483SAtish Patra /* 2142e0eb483SAtish Patra * Unauthenticated device tree data is a security hazard, so ignore 2152e0eb483SAtish Patra * 'dtb=' unless UEFI Secure Boot is disabled. We assume that secure 2162e0eb483SAtish Patra * boot is enabled if we can't determine its state. 2172e0eb483SAtish Patra */ 2182e0eb483SAtish Patra if (!IS_ENABLED(CONFIG_EFI_ARMSTUB_DTB_LOADER) || 2192e0eb483SAtish Patra secure_boot != efi_secureboot_mode_disabled) { 2202e0eb483SAtish Patra if (strstr(cmdline_ptr, "dtb=")) 2213839ab85SArvind Sankar efi_err("Ignoring DTB from command line.\n"); 2222e0eb483SAtish Patra } else { 2232e0eb483SAtish Patra status = efi_load_dtb(image, &fdt_addr, &fdt_size); 2242e0eb483SAtish Patra 2252e0eb483SAtish Patra if (status != EFI_SUCCESS) { 226793473c2SArvind Sankar efi_err("Failed to load device tree!\n"); 2272e0eb483SAtish Patra goto fail_free_image; 2282e0eb483SAtish Patra } 2292e0eb483SAtish Patra } 2302e0eb483SAtish Patra 2312e0eb483SAtish Patra if (fdt_addr) { 232793473c2SArvind Sankar efi_info("Using DTB from command line\n"); 2332e0eb483SAtish Patra } else { 2342e0eb483SAtish Patra /* Look for a device tree configuration table entry. */ 2352e0eb483SAtish Patra fdt_addr = (uintptr_t)get_fdt(&fdt_size); 2362e0eb483SAtish Patra if (fdt_addr) 237793473c2SArvind Sankar efi_info("Using DTB from configuration table\n"); 2382e0eb483SAtish Patra } 2392e0eb483SAtish Patra 2402e0eb483SAtish Patra if (!fdt_addr) 241793473c2SArvind Sankar efi_info("Generating empty DTB\n"); 2422e0eb483SAtish Patra 243980771f6SArd Biesheuvel if (!efi_noinitrd) { 2446208857bSArd Biesheuvel max_addr = efi_get_max_initrd_addr(image_addr); 2452e0eb483SAtish Patra status = efi_load_initrd(image, &initrd_addr, &initrd_size, 2462e0eb483SAtish Patra ULONG_MAX, max_addr); 2472e0eb483SAtish Patra if (status != EFI_SUCCESS) 248793473c2SArvind Sankar efi_err("Failed to load initrd!\n"); 2492e0eb483SAtish Patra } 2502e0eb483SAtish Patra 2512e0eb483SAtish Patra efi_random_get_seed(); 2522e0eb483SAtish Patra 2532e0eb483SAtish Patra /* 2542e0eb483SAtish Patra * If the NX PE data feature is enabled in the properties table, we 2552e0eb483SAtish Patra * should take care not to create a virtual mapping that changes the 2562e0eb483SAtish Patra * relative placement of runtime services code and data regions, as 2572e0eb483SAtish Patra * they may belong to the same PE/COFF executable image in memory. 2582e0eb483SAtish Patra * The easiest way to achieve that is to simply use a 1:1 mapping. 2592e0eb483SAtish Patra */ 2602e0eb483SAtish Patra prop_tbl = get_efi_config_table(EFI_PROPERTIES_TABLE_GUID); 2612e0eb483SAtish Patra flat_va_mapping = prop_tbl && 2622e0eb483SAtish Patra (prop_tbl->memory_protection_attribute & 2632e0eb483SAtish Patra EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA); 2642e0eb483SAtish Patra 265*9e9888a0SArd Biesheuvel /* force efi_novamap if SetVirtualAddressMap() is unsupported */ 266*9e9888a0SArd Biesheuvel efi_novamap |= !(get_supported_rt_services() & 267*9e9888a0SArd Biesheuvel EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP); 268*9e9888a0SArd Biesheuvel 2692e0eb483SAtish Patra /* hibernation expects the runtime regions to stay in the same place */ 270980771f6SArd Biesheuvel if (!IS_ENABLED(CONFIG_HIBERNATION) && !efi_nokaslr && !flat_va_mapping) { 2712e0eb483SAtish Patra /* 2722e0eb483SAtish Patra * Randomize the base of the UEFI runtime services region. 2732e0eb483SAtish Patra * Preserve the 2 MB alignment of the region by taking a 2742e0eb483SAtish Patra * shift of 21 bit positions into account when scaling 2752e0eb483SAtish Patra * the headroom value using a 32-bit random value. 2762e0eb483SAtish Patra */ 2772e0eb483SAtish Patra static const u64 headroom = EFI_RT_VIRTUAL_LIMIT - 2782e0eb483SAtish Patra EFI_RT_VIRTUAL_BASE - 2792e0eb483SAtish Patra EFI_RT_VIRTUAL_SIZE; 2802e0eb483SAtish Patra u32 rnd; 2812e0eb483SAtish Patra 2822e0eb483SAtish Patra status = efi_get_random_bytes(sizeof(rnd), (u8 *)&rnd); 2832e0eb483SAtish Patra if (status == EFI_SUCCESS) { 2842e0eb483SAtish Patra virtmap_base = EFI_RT_VIRTUAL_BASE + 2852e0eb483SAtish Patra (((headroom >> 21) * rnd) >> (32 - 21)); 2862e0eb483SAtish Patra } 2872e0eb483SAtish Patra } 2882e0eb483SAtish Patra 2892e0eb483SAtish Patra install_memreserve_table(); 2902e0eb483SAtish Patra 2912e0eb483SAtish Patra status = allocate_new_fdt_and_exit_boot(handle, &fdt_addr, 2922e0eb483SAtish Patra initrd_addr, initrd_size, 2932e0eb483SAtish Patra cmdline_ptr, fdt_addr, fdt_size); 2942e0eb483SAtish Patra if (status != EFI_SUCCESS) 2952e0eb483SAtish Patra goto fail_free_initrd; 2962e0eb483SAtish Patra 2972a55280aSArd Biesheuvel if (IS_ENABLED(CONFIG_ARM)) 2982a55280aSArd Biesheuvel efi_handle_post_ebs_state(); 2992a55280aSArd Biesheuvel 3002e0eb483SAtish Patra efi_enter_kernel(image_addr, fdt_addr, fdt_totalsize((void *)fdt_addr)); 3012e0eb483SAtish Patra /* not reached */ 3022e0eb483SAtish Patra 3032e0eb483SAtish Patra fail_free_initrd: 304793473c2SArvind Sankar efi_err("Failed to update FDT and exit boot services\n"); 3052e0eb483SAtish Patra 3062e0eb483SAtish Patra efi_free(initrd_size, initrd_addr); 3072e0eb483SAtish Patra efi_free(fdt_size, fdt_addr); 3082e0eb483SAtish Patra 3092e0eb483SAtish Patra fail_free_image: 3102e0eb483SAtish Patra efi_free(image_size, image_addr); 3112e0eb483SAtish Patra efi_free(reserve_size, reserve_addr); 312055042beSArvind Sankar fail_free_screeninfo: 3132e0eb483SAtish Patra free_screen_info(si); 314055042beSArvind Sankar fail_free_cmdline: 31527cd5511SArd Biesheuvel efi_bs_call(free_pool, cmdline_ptr); 3162e0eb483SAtish Patra fail: 3172e0eb483SAtish Patra return status; 3182e0eb483SAtish Patra } 3192e0eb483SAtish Patra 3202e0eb483SAtish Patra /* 3212e0eb483SAtish Patra * efi_get_virtmap() - create a virtual mapping for the EFI memory map 3222e0eb483SAtish Patra * 3232e0eb483SAtish Patra * This function populates the virt_addr fields of all memory region descriptors 3242e0eb483SAtish Patra * in @memory_map whose EFI_MEMORY_RUNTIME attribute is set. Those descriptors 3252e0eb483SAtish Patra * are also copied to @runtime_map, and their total count is returned in @count. 3262e0eb483SAtish Patra */ 3272e0eb483SAtish Patra void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size, 3282e0eb483SAtish Patra unsigned long desc_size, efi_memory_desc_t *runtime_map, 3292e0eb483SAtish Patra int *count) 3302e0eb483SAtish Patra { 3312e0eb483SAtish Patra u64 efi_virt_base = virtmap_base; 3322e0eb483SAtish Patra efi_memory_desc_t *in, *out = runtime_map; 3332e0eb483SAtish Patra int l; 3342e0eb483SAtish Patra 3352e0eb483SAtish Patra for (l = 0; l < map_size; l += desc_size) { 3362e0eb483SAtish Patra u64 paddr, size; 3372e0eb483SAtish Patra 3382e0eb483SAtish Patra in = (void *)memory_map + l; 3392e0eb483SAtish Patra if (!(in->attribute & EFI_MEMORY_RUNTIME)) 3402e0eb483SAtish Patra continue; 3412e0eb483SAtish Patra 3422e0eb483SAtish Patra paddr = in->phys_addr; 3432e0eb483SAtish Patra size = in->num_pages * EFI_PAGE_SIZE; 3442e0eb483SAtish Patra 3452e0eb483SAtish Patra in->virt_addr = in->phys_addr; 346980771f6SArd Biesheuvel if (efi_novamap) { 3472e0eb483SAtish Patra continue; 3482e0eb483SAtish Patra } 3492e0eb483SAtish Patra 3502e0eb483SAtish Patra /* 3512e0eb483SAtish Patra * Make the mapping compatible with 64k pages: this allows 3522e0eb483SAtish Patra * a 4k page size kernel to kexec a 64k page size kernel and 3532e0eb483SAtish Patra * vice versa. 3542e0eb483SAtish Patra */ 3552e0eb483SAtish Patra if (!flat_va_mapping) { 3562e0eb483SAtish Patra 3572e0eb483SAtish Patra paddr = round_down(in->phys_addr, SZ_64K); 3582e0eb483SAtish Patra size += in->phys_addr - paddr; 3592e0eb483SAtish Patra 3602e0eb483SAtish Patra /* 3612e0eb483SAtish Patra * Avoid wasting memory on PTEs by choosing a virtual 3622e0eb483SAtish Patra * base that is compatible with section mappings if this 3632e0eb483SAtish Patra * region has the appropriate size and physical 3642e0eb483SAtish Patra * alignment. (Sections are 2 MB on 4k granule kernels) 3652e0eb483SAtish Patra */ 3662e0eb483SAtish Patra if (IS_ALIGNED(in->phys_addr, SZ_2M) && size >= SZ_2M) 3672e0eb483SAtish Patra efi_virt_base = round_up(efi_virt_base, SZ_2M); 3682e0eb483SAtish Patra else 3692e0eb483SAtish Patra efi_virt_base = round_up(efi_virt_base, SZ_64K); 3702e0eb483SAtish Patra 3712e0eb483SAtish Patra in->virt_addr += efi_virt_base - paddr; 3722e0eb483SAtish Patra efi_virt_base += size; 3732e0eb483SAtish Patra } 3742e0eb483SAtish Patra 3752e0eb483SAtish Patra memcpy(out, in, desc_size); 3762e0eb483SAtish Patra out = (void *)out + desc_size; 3772e0eb483SAtish Patra ++*count; 3782e0eb483SAtish Patra } 3792e0eb483SAtish Patra } 380