From f209e9b8b5838e61a4df3d2380d3114009dae73e Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 28 Sep 2012 17:56:08 -0700 Subject: [PATCH] --- yaml --- r: 323989 b: refs/heads/master c: 7bc90e01c3f66c137e7e761f574bbf883087d590 h: refs/heads/master i: 323987: c04451402401c5edcdb5dec0aa4acf827c591e8b v: v3 --- [refs] | 2 +- trunk/arch/x86/platform/efi/efi.c | 28 ++++++++++++++++++++++++++++ trunk/include/linux/efi.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4245fafe72a0..4e9a3e94fcee 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 785107923a83d8456bbd8564e288a24d84109a46 +refs/heads/master: 7bc90e01c3f66c137e7e761f574bbf883087d590 diff --git a/trunk/arch/x86/platform/efi/efi.c b/trunk/arch/x86/platform/efi/efi.c index b3dbbdbd2a42..f7f928c315da 100644 --- a/trunk/arch/x86/platform/efi/efi.c +++ b/trunk/arch/x86/platform/efi/efi.c @@ -776,6 +776,34 @@ static void __init runtime_code_page_mkexec(void) } } +/* + * We can't ioremap data in EFI boot services RAM, because we've already mapped + * it as RAM. So, look it up in the existing EFI memory map instead. Only + * callable after efi_enter_virtual_mode and before efi_free_boot_services. + */ +void __iomem *efi_lookup_mapped_addr(u64 phys_addr) +{ + void *p; + if (WARN_ON(!memmap.map)) + return NULL; + for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { + efi_memory_desc_t *md = p; + u64 size = md->num_pages << EFI_PAGE_SHIFT; + u64 end = md->phys_addr + size; + if (!(md->attribute & EFI_MEMORY_RUNTIME) && + md->type != EFI_BOOT_SERVICES_CODE && + md->type != EFI_BOOT_SERVICES_DATA) + continue; + if (!md->virt_addr) + continue; + if (phys_addr >= md->phys_addr && phys_addr < end) { + phys_addr += md->virt_addr - md->phys_addr; + return (__force void __iomem *)(unsigned long)phys_addr; + } + } + return NULL; +} + /* * This function will switch the EFI runtime services to virtual mode. * Essentially, look through the EFI memmap and map every region that diff --git a/trunk/include/linux/efi.h b/trunk/include/linux/efi.h index 5782114f4838..fff135d9375e 100644 --- a/trunk/include/linux/efi.h +++ b/trunk/include/linux/efi.h @@ -501,6 +501,7 @@ extern void efi_free_boot_services(void); #else static inline void efi_free_boot_services(void) {} #endif +extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); extern u64 efi_get_iobase (void); extern u32 efi_mem_type (unsigned long phys_addr); extern u64 efi_mem_attributes (unsigned long phys_addr);