aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2011-05-05 15:19:45 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2011-05-09 15:14:39 -0400
commit7cb00b72876ea2451eb79d468da0e8fb9134aa8a (patch)
tree403d22d33c4e050d6d30749e7a7be9a1393368a6
parent202f9d0a41809e3424af5f61489b48b622824aed (diff)
x86, efi: Pass a minimal map to SetVirtualAddressMap()
Experimentation with various EFI implementations has shown that functions outside runtime services will still update their pointers if SetVirtualAddressMap() is called with memory descriptors outside the runtime area. This is obviously insane, and therefore is unsurprising. Evidence from instrumenting another EFI implementation suggests that it only passes the set of descriptors covering runtime regions, so let's avoid any problems by doing the same. Runtime descriptors are copied to a separate memory map, and only that map is passed back to the firmware. Signed-off-by: Matthew Garrett <mjg@redhat.com> Link: http://lkml.kernel.org/r/1304623186-18261-4-git-send-email-mjg@redhat.com Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/platform/efi/efi.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index a46a73ecc5f3..b30aa26a8df2 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -502,7 +502,8 @@ void __init efi_enter_virtual_mode(void)
502 efi_status_t status; 502 efi_status_t status;
503 unsigned long size; 503 unsigned long size;
504 u64 end, systab, addr, npages, end_pfn; 504 u64 end, systab, addr, npages, end_pfn;
505 void *p, *va; 505 void *p, *va, *new_memmap = NULL;
506 int count = 0;
506 507
507 efi.systab = NULL; 508 efi.systab = NULL;
508 509
@@ -569,15 +570,21 @@ void __init efi_enter_virtual_mode(void)
569 systab += md->virt_addr - md->phys_addr; 570 systab += md->virt_addr - md->phys_addr;
570 efi.systab = (efi_system_table_t *) (unsigned long) systab; 571 efi.systab = (efi_system_table_t *) (unsigned long) systab;
571 } 572 }
573 new_memmap = krealloc(new_memmap,
574 (count + 1) * memmap.desc_size,
575 GFP_KERNEL);
576 memcpy(new_memmap + (count * memmap.desc_size), md,
577 memmap.desc_size);
578 count++;
572 } 579 }
573 580
574 BUG_ON(!efi.systab); 581 BUG_ON(!efi.systab);
575 582
576 status = phys_efi_set_virtual_address_map( 583 status = phys_efi_set_virtual_address_map(
577 memmap.desc_size * memmap.nr_map, 584 memmap.desc_size * count,
578 memmap.desc_size, 585 memmap.desc_size,
579 memmap.desc_version, 586 memmap.desc_version,
580 memmap.phys_map); 587 (efi_memory_desc_t *)__pa(new_memmap));
581 588
582 if (status != EFI_SUCCESS) { 589 if (status != EFI_SUCCESS) {
583 printk(KERN_ALERT "Unable to switch EFI into virtual mode " 590 printk(KERN_ALERT "Unable to switch EFI into virtual mode "
@@ -605,6 +612,7 @@ void __init efi_enter_virtual_mode(void)
605 runtime_code_page_mkexec(); 612 runtime_code_page_mkexec();
606 early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); 613 early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
607 memmap.map = NULL; 614 memmap.map = NULL;
615 kfree(new_memmap);
608} 616}
609 617
610/* 618/*