From: Dave Young <dyoung@redhat.com>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
x86@kernel.org, mjg59@srcf.ucam.org, hpa@zytor.com,
James.Bottomley@HansenPartnership.com, vgoyal@redhat.com,
ebiederm@xmission.com, horms@verge.net.au,
kexec@lists.fedoraproject.org, kexec@lists.infradead.org
Subject: Re: [patch 3/6] Cleanup efi_enter_virtual_mode function
Date: Mon, 28 Oct 2013 18:10:11 +0800 [thread overview]
Message-ID: <20131028101011.GF25527@dhcp-16-126.nay.redhat.com> (raw)
In-Reply-To: <20131028100402.GC4314@pd.tnic>
[-- Attachment #1: Type: text/plain, Size: 735 bytes --]
On 10/28/13 at 11:04am, Borislav Petkov wrote:
> On Mon, Oct 28, 2013 at 05:51:17PM +0800, Dave Young wrote:
> > It does have a warning, but it applied successfully, no idea though:
> > patches/02-efi-enter-virtual-mode-cleanup.patch
> > Applying: Cleanup efi_enter_virtual_mode function
> > /home/dave/git/efi/.git/rebase-apply/patch:42: space before tab in indent.
> > efi_memory_desc_t *md, *prev_md = NULL;
> > warning: 1 line adds whitespace errors.
>
> Hmm, ok, can you upload the patches somewhere so that I can pull them?
Sorry, I have not any public git account. Attached the patch I applied with git
>
> Thanks.
>
> --
> Regards/Gruss,
> Boris.
>
> Sent from a fat crate under my desk. Formatting is fine.
> --
[-- Attachment #2: 02-efi-enter-virtual-mode-cleanup-1.patch.new --]
[-- Type: text/plain, Size: 3675 bytes --]
From: Dave Young <dyoung@redhat.com>
Cleanup efi_enter_virtual_mode function
Add two small functions:
efi_merge_regions and efi_map_regions, efi_enter_virtual_mode
calls them instead of embedding two long for loop.
Signed-off-by: Dave Young <dyoung@redhat.com>
---
arch/x86/platform/efi/efi.c | 83 +++++++++++++++++++++++++++-----------------
1 file changed, 52 insertions(+), 31 deletions(-)
--- efi.orig/arch/x86/platform/efi/efi.c
+++ efi/arch/x86/platform/efi/efi.c
@@ -789,35 +789,13 @@ void __init old_map_region(efi_memory_de
pr_err("ioremap of 0x%llX failed!\n",
(unsigned long long)md->phys_addr);
}
-/*
- * This function will switch the EFI runtime services to virtual mode.
- * Essentially, look through the EFI memmap and map every region that
- * has the runtime attribute bit set in its memory descriptor and update
- * that memory descriptor with the virtual address obtained from ioremap().
- * This enables the runtime services to be called without having to
- * thunk back into physical mode for every invocation.
- */
-void __init efi_enter_virtual_mode(void)
-{
- efi_memory_desc_t *md, *prev_md = NULL;
- void *p, *new_memmap = NULL;
- unsigned long size;
- efi_status_t status;
- u64 end, systab;
- int count = 0;
- efi.systab = NULL;
-
- /*
- * We don't do virtual mode, since we don't do runtime services, on
- * non-native EFI
- */
- if (!efi_is_native()) {
- efi_unmap_memmap();
- return;
- }
+/* Merge contiguous regions of the same type and attribute */
+static void efi_merge_regions(void)
+{
+ void *p;
+ efi_memory_desc_t *md, *prev_md = NULL;
- /* Merge contiguous regions of the same type and attribute */
for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
u64 prev_size;
md = p;
@@ -844,6 +822,19 @@ void __init efi_enter_virtual_mode(void)
prev_md = md;
}
+}
+
+/*
+ * Map efi memory ranges for runtime serivce
+ * Return the new memmap with updated virtual addrresses.
+ */
+void efi_map_regions(void **new_memmap, int *count)
+{
+ efi_memory_desc_t *md, *prev_md = NULL;
+ void *p;
+ unsigned long size;
+ efi_status_t status;
+ u64 end, systab;
for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
md = p;
@@ -862,14 +853,44 @@ 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,
+ *new_memmap = krealloc(*new_memmap,
+ (*count + 1) * memmap.desc_size,
GFP_KERNEL);
- memcpy(new_memmap + (count * memmap.desc_size), md,
+ memcpy(*new_memmap + (*count * memmap.desc_size), md,
memmap.desc_size);
- count++;
+ (*count)++;
+ }
+}
+
+/*
+ * This function will switch the EFI runtime services to virtual mode.
+ * Essentially, look through the EFI memmap and map every region that
+ * has the runtime attribute bit set in its memory descriptor and update
+ * that memory descriptor with the virtual address obtained from ioremap().
+ * This enables the runtime services to be called without having to
+ * thunk back into physical mode for every invocation.
+ */
+void __init efi_enter_virtual_mode(void)
+{
+ efi_status_t status;
+ void *p, *new_memmap = NULL;
+ int count = 0;
+
+ efi.systab = NULL;
+
+ /*
+ * We don't do virtual mode, since we don't do runtime services, on
+ * non-native EFI
+ */
+ if (!efi_is_native()) {
+ efi_unmap_memmap();
+ return;
}
+ efi_merge_regions();
+
+ efi_map_regions(&new_memmap, &count);
+
#ifdef CONFIG_X86_64
efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
next prev parent reply other threads:[~2013-10-28 10:11 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-27 3:47 [patch 0/6] kexec kernel efi runtime support dyoung
2013-10-27 3:47 ` [patch 1/6] Add function efi_remap_region for remapping to saved virt address dyoung
2013-10-27 11:50 ` Borislav Petkov
2013-10-28 1:25 ` Dave Young
2013-10-27 3:47 ` [patch 3/6] Cleanup efi_enter_virtual_mode function dyoung
2013-10-28 9:32 ` Borislav Petkov
2013-10-28 9:40 ` Dave Young
2013-10-28 9:51 ` Dave Young
2013-10-28 10:04 ` Borislav Petkov
2013-10-28 10:10 ` Dave Young [this message]
2013-10-28 10:39 ` Dave Young
2013-10-28 11:20 ` Borislav Petkov
2013-10-28 11:24 ` Dave Young
2013-10-28 14:58 ` Borislav Petkov
2013-10-28 15:10 ` Dave Young
2013-10-29 2:32 ` Dave Young
2013-10-29 13:43 ` Borislav Petkov
2013-10-30 2:03 ` Dave Young
2013-10-30 10:47 ` Borislav Petkov
2013-10-31 2:04 ` Dave Young
2013-10-31 2:07 ` Dave Young
2013-10-31 3:07 ` H. Peter Anvin
2013-10-31 10:45 ` Borislav Petkov
2013-11-01 1:15 ` Dave Young
2013-10-31 10:44 ` Borislav Petkov
2013-11-01 1:18 ` Dave Young
2013-11-01 11:32 ` Borislav Petkov
2013-10-27 3:47 ` [patch 4/6] export more efi table variable to sysfs dyoung
2013-10-27 3:47 ` [patch 5/6] export efi runtime memory mapping " dyoung
2013-10-29 5:34 ` Dave Young
2013-10-27 3:47 ` [patch 6/6] passing kexec necessary efi data via setup_data dyoung
[not found] ` <20131027035922.924386710@dhcp-16-126.nay.redhat.com>
2013-10-27 10:50 ` [patch 2/6] x86 efi: reserve boot service fix Borislav Petkov
2013-10-27 20:30 ` Matt Fleming
2013-10-28 1:18 ` Dave Young
2013-10-28 8:44 ` Borislav Petkov
2013-10-28 10:27 ` Matt Fleming
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=20131028101011.GF25527@dhcp-16-126.nay.redhat.com \
--to=dyoung@redhat.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bp@alien8.de \
--cc=ebiederm@xmission.com \
--cc=horms@verge.net.au \
--cc=hpa@zytor.com \
--cc=kexec@lists.fedoraproject.org \
--cc=kexec@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=vgoyal@redhat.com \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®