From: tip-bot for Matthew Garrett <mjg@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, mjg@redhat.com, hpa@zytor.com,
mingo@redhat.com, tglx@linutronix.de, hpa@linux.intel.com
Subject: [tip:x86/efi] x86, efi: Pass a minimal map to SetVirtualAddressMap()
Date: Mon, 9 May 2011 23:17:39 GMT [thread overview]
Message-ID: <tip-7cb00b72876ea2451eb79d468da0e8fb9134aa8a@git.kernel.org> (raw)
In-Reply-To: <1304623186-18261-4-git-send-email-mjg@redhat.com>
Commit-ID: 7cb00b72876ea2451eb79d468da0e8fb9134aa8a
Gitweb: http://git.kernel.org/tip/7cb00b72876ea2451eb79d468da0e8fb9134aa8a
Author: Matthew Garrett <mjg@redhat.com>
AuthorDate: Thu, 5 May 2011 15:19:45 -0400
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 9 May 2011 12:14:39 -0700
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>
---
arch/x86/platform/efi/efi.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index a46a73e..b30aa26 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)
efi_status_t status;
unsigned long size;
u64 end, systab, addr, npages, end_pfn;
- void *p, *va;
+ void *p, *va, *new_memmap = NULL;
+ int count = 0;
efi.systab = NULL;
@@ -569,15 +570,21 @@ void __init efi_enter_virtual_mode(void)
systab += md->virt_addr - md->phys_addr;
efi.systab = (efi_system_table_t *) (unsigned long) systab;
}
+ new_memmap = krealloc(new_memmap,
+ (count + 1) * memmap.desc_size,
+ GFP_KERNEL);
+ memcpy(new_memmap + (count * memmap.desc_size), md,
+ memmap.desc_size);
+ count++;
}
BUG_ON(!efi.systab);
status = phys_efi_set_virtual_address_map(
- memmap.desc_size * memmap.nr_map,
+ memmap.desc_size * count,
memmap.desc_size,
memmap.desc_version,
- memmap.phys_map);
+ (efi_memory_desc_t *)__pa(new_memmap));
if (status != EFI_SUCCESS) {
printk(KERN_ALERT "Unable to switch EFI into virtual mode "
@@ -605,6 +612,7 @@ void __init efi_enter_virtual_mode(void)
runtime_code_page_mkexec();
early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
memmap.map = NULL;
+ kfree(new_memmap);
}
/*
next prev parent reply other threads:[~2011-05-09 23:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 19:19 [PATCH 1/5] efi: Remove virtual-mode SetVirtualAddressMap call Matthew Garrett
2011-05-05 19:19 ` [PATCH 2/5] efi: Consolidate EFI nx control Matthew Garrett
2011-05-09 23:16 ` [tip:x86/efi] x86, " tip-bot for Matthew Garrett
2011-05-05 19:19 ` [PATCH 3/5] efi: Merge contiguous memory regions of the same type and attribute Matthew Garrett
2011-05-09 23:17 ` [tip:x86/efi] x86, " tip-bot for Matthew Garrett
2011-05-05 19:19 ` [PATCH 4/5] efi: Pass a minimal map to SetVirtualAddressMap() Matthew Garrett
2011-05-09 23:17 ` tip-bot for Matthew Garrett [this message]
2011-05-05 19:19 ` [PATCH 5/5] efi: Ensure that the entirity of a region is mapped Matthew Garrett
2011-05-09 23:18 ` [tip:x86/efi] x86, " tip-bot for Matthew Garrett
2011-05-09 23:16 ` [tip:x86/efi] x86, efi: Remove virtual-mode SetVirtualAddressMap call tip-bot for Matthew Garrett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-7cb00b72876ea2451eb79d468da0e8fb9134aa8a@git.kernel.org \
--to=mjg@redhat.com \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox