* [PATCH] x86/efi: Setup separate EFI page tables in kexec paths
@ 2016-01-21 14:11 Matt Fleming
2016-01-21 19:33 ` Srikar Dronamraju
2016-01-22 12:54 ` [tip:efi/core] " tip-bot for Matt Fleming
0 siblings, 2 replies; 5+ messages in thread
From: Matt Fleming @ 2016-01-21 14:11 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin
Cc: linux-kernel, linux-efi, Matt Fleming, Raghavendra K T,
Dave Young, Linus Torvalds, Borislav Petkov, Srikar Dronamraju
The switch to using a new dedicated page table for EFI runtime calls
in commit commit 67a9108ed431 ("x86/efi: Build our own page table
structures") failed to take into account changes required for the
kexec code paths, which are unfortunately duplicated in the EFI code.
Call the allocation and setup functions in kexec_enter_virtual_mode()
just like we do for __efi_enter_virtual_mode() to avoid hitting
NULL-pointer dereferences when making EFI runtime calls.
At the very least, the call to efi_setup_page_tables() should have
existed for kexec before commit 67a9108ed431. Things just magically
worked because we were actually using the kernel's page tables that
contained the required mappings.
Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
arch/x86/platform/efi/efi.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
Folks, please apply this to the queue of EFI patches sitting in
tip/x86/efi.
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 3c1f3cd7b2ba..2aedee71f965 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -815,6 +815,7 @@ static void __init kexec_enter_virtual_mode(void)
{
#ifdef CONFIG_KEXEC_CORE
efi_memory_desc_t *md;
+ unsigned num_pages;
void *p;
efi.systab = NULL;
@@ -829,6 +830,12 @@ static void __init kexec_enter_virtual_mode(void)
return;
}
+ if (efi_alloc_page_tables()) {
+ pr_err("Failed to allocate EFI page tables\n");
+ clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+ return;
+ }
+
/*
* Map efi regions which were passed via setup_data. The virt_addr is a
* fixed addr which was used in first kernel of a kexec boot.
@@ -843,6 +850,14 @@ static void __init kexec_enter_virtual_mode(void)
BUG_ON(!efi.systab);
+ num_pages = ALIGN(memmap.nr_map * memmap.desc_size, PAGE_SIZE);
+ num_pages >>= PAGE_SHIFT;
+
+ if (efi_setup_page_tables(memmap.phys_map, num_pages)) {
+ clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+ return;
+ }
+
efi_sync_low_kernel_mappings();
/*
--
2.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] x86/efi: Setup separate EFI page tables in kexec paths
2016-01-21 14:11 [PATCH] x86/efi: Setup separate EFI page tables in kexec paths Matt Fleming
@ 2016-01-21 19:33 ` Srikar Dronamraju
2016-01-21 20:58 ` Matt Fleming
2016-01-22 12:54 ` [tip:efi/core] " tip-bot for Matt Fleming
1 sibling, 1 reply; 5+ messages in thread
From: Srikar Dronamraju @ 2016-01-21 19:33 UTC (permalink / raw)
To: Matt Fleming
Cc: Ingo Molnar, Thomas Gleixner, H . Peter Anvin, linux-kernel,
linux-efi, Raghavendra K T, Dave Young, Linus Torvalds,
Borislav Petkov
* Matt Fleming <matt@codeblueprint.co.uk> [2016-01-21 14:11:59]:
> The switch to using a new dedicated page table for EFI runtime calls
> in commit commit 67a9108ed431 ("x86/efi: Build our own page table
> structures") failed to take into account changes required for the
> kexec code paths, which are unfortunately duplicated in the EFI code.
>
> Call the allocation and setup functions in kexec_enter_virtual_mode()
> just like we do for __efi_enter_virtual_mode() to avoid hitting
> NULL-pointer dereferences when making EFI runtime calls.
>
> At the very least, the call to efi_setup_page_tables() should have
> existed for kexec before commit 67a9108ed431. Things just magically
> worked because we were actually using the kernel's page tables that
> contained the required mappings.
>
> Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Applied this patch on top of tip/x86/efi and was able to build and boot
the kernel.
--
Thanks and Regards
Srikar Dronamraju
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] x86/efi: Setup separate EFI page tables in kexec paths
2016-01-21 19:33 ` Srikar Dronamraju
@ 2016-01-21 20:58 ` Matt Fleming
2016-01-25 9:42 ` Matt Fleming
0 siblings, 1 reply; 5+ messages in thread
From: Matt Fleming @ 2016-01-21 20:58 UTC (permalink / raw)
To: Srikar Dronamraju
Cc: Ingo Molnar, Thomas Gleixner, H . Peter Anvin, linux-kernel,
linux-efi, Raghavendra K T, Dave Young, Linus Torvalds,
Borislav Petkov
On Fri, 22 Jan, at 01:03:32AM, Srikar Dronamraju wrote:
> * Matt Fleming <matt@codeblueprint.co.uk> [2016-01-21 14:11:59]:
>
> > The switch to using a new dedicated page table for EFI runtime calls
> > in commit commit 67a9108ed431 ("x86/efi: Build our own page table
> > structures") failed to take into account changes required for the
> > kexec code paths, which are unfortunately duplicated in the EFI code.
> >
> > Call the allocation and setup functions in kexec_enter_virtual_mode()
> > just like we do for __efi_enter_virtual_mode() to avoid hitting
> > NULL-pointer dereferences when making EFI runtime calls.
> >
> > At the very least, the call to efi_setup_page_tables() should have
> > existed for kexec before commit 67a9108ed431. Things just magically
> > worked because we were actually using the kernel's page tables that
> > contained the required mappings.
> >
> > Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> > Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
> > Cc: Dave Young <dyoung@redhat.com>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
>
> Applied this patch on top of tip/x86/efi and was able to build and boot
> the kernel.
Fantastic, thanks for testing!
Ingo, this commit should unblock the EFI changes for v4.5.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] x86/efi: Setup separate EFI page tables in kexec paths
2016-01-21 20:58 ` Matt Fleming
@ 2016-01-25 9:42 ` Matt Fleming
0 siblings, 0 replies; 5+ messages in thread
From: Matt Fleming @ 2016-01-25 9:42 UTC (permalink / raw)
Cc: Thomas Gleixner, H . Peter Anvin, linux-kernel, linux-efi,
Raghavendra K T, Dave Young, Linus Torvalds, Borislav Petkov,
Srikar Dronamraju
On Thu, 21 Jan, at 08:58:15PM, Matt Fleming wrote:
>
> Ingo, this commit should unblock the EFI changes for v4.5.
Looks like all this material missed v4.5. Was that intentional?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:efi/core] x86/efi: Setup separate EFI page tables in kexec paths
2016-01-21 14:11 [PATCH] x86/efi: Setup separate EFI page tables in kexec paths Matt Fleming
2016-01-21 19:33 ` Srikar Dronamraju
@ 2016-01-22 12:54 ` tip-bot for Matt Fleming
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Matt Fleming @ 2016-01-22 12:54 UTC (permalink / raw)
To: linux-tip-commits
Cc: luto, mingo, dvlasenk, linux-kernel, hpa, tglx, peterz,
raghavendra.kt, bp, brgerst, torvalds, matt, srikar, dyoung
Commit-ID: 753b11ef8e92a1c1bbe97f2a5ec14bdd1ef2e6fe
Gitweb: http://git.kernel.org/tip/753b11ef8e92a1c1bbe97f2a5ec14bdd1ef2e6fe
Author: Matt Fleming <matt@codeblueprint.co.uk>
AuthorDate: Thu, 21 Jan 2016 14:11:59 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 21 Jan 2016 21:01:34 +0100
x86/efi: Setup separate EFI page tables in kexec paths
The switch to using a new dedicated page table for EFI runtime
calls in commit commit 67a9108ed431 ("x86/efi: Build our own
page table structures") failed to take into account changes
required for the kexec code paths, which are unfortunately
duplicated in the EFI code.
Call the allocation and setup functions in
kexec_enter_virtual_mode() just like we do for
__efi_enter_virtual_mode() to avoid hitting NULL-pointer
dereferences when making EFI runtime calls.
At the very least, the call to efi_setup_page_tables() should
have existed for kexec before the following commit:
67a9108ed431 ("x86/efi: Build our own page table structures")
Things just magically worked because we were actually using
the kernel's page tables that contained the required mappings.
Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1453385519-11477-1-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/platform/efi/efi.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 3c1f3cd..bdd9477 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -815,6 +815,7 @@ static void __init kexec_enter_virtual_mode(void)
{
#ifdef CONFIG_KEXEC_CORE
efi_memory_desc_t *md;
+ unsigned int num_pages;
void *p;
efi.systab = NULL;
@@ -829,6 +830,12 @@ static void __init kexec_enter_virtual_mode(void)
return;
}
+ if (efi_alloc_page_tables()) {
+ pr_err("Failed to allocate EFI page tables\n");
+ clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+ return;
+ }
+
/*
* Map efi regions which were passed via setup_data. The virt_addr is a
* fixed addr which was used in first kernel of a kexec boot.
@@ -843,6 +850,14 @@ static void __init kexec_enter_virtual_mode(void)
BUG_ON(!efi.systab);
+ num_pages = ALIGN(memmap.nr_map * memmap.desc_size, PAGE_SIZE);
+ num_pages >>= PAGE_SHIFT;
+
+ if (efi_setup_page_tables(memmap.phys_map, num_pages)) {
+ clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+ return;
+ }
+
efi_sync_low_kernel_mappings();
/*
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-25 9:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-21 14:11 [PATCH] x86/efi: Setup separate EFI page tables in kexec paths Matt Fleming
2016-01-21 19:33 ` Srikar Dronamraju
2016-01-21 20:58 ` Matt Fleming
2016-01-25 9:42 ` Matt Fleming
2016-01-22 12:54 ` [tip:efi/core] " tip-bot for Matt Fleming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).