From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753828AbcAVM4O (ORCPT ); Fri, 22 Jan 2016 07:56:14 -0500 Received: from terminus.zytor.com ([198.137.202.10]:44218 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753778AbcAVM4A (ORCPT ); Fri, 22 Jan 2016 07:56:00 -0500 Date: Fri, 22 Jan 2016 04:54:42 -0800 From: tip-bot for Matt Fleming Message-ID: Cc: luto@amacapital.net, mingo@kernel.org, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, peterz@infradead.org, raghavendra.kt@linux.vnet.ibm.com, bp@alien8.de, brgerst@gmail.com, torvalds@linux-foundation.org, matt@codeblueprint.co.uk, srikar@linux.vnet.ibm.com, dyoung@redhat.com Reply-To: linux-kernel@vger.kernel.org, luto@amacapital.net, mingo@kernel.org, dvlasenk@redhat.com, tglx@linutronix.de, peterz@infradead.org, hpa@zytor.com, bp@alien8.de, brgerst@gmail.com, raghavendra.kt@linux.vnet.ibm.com, dyoung@redhat.com, torvalds@linux-foundation.org, srikar@linux.vnet.ibm.com, matt@codeblueprint.co.uk In-Reply-To: <1453385519-11477-1-git-send-email-matt@codeblueprint.co.uk> References: <1453385519-11477-1-git-send-email-matt@codeblueprint.co.uk> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] x86/efi: Setup separate EFI page tables in kexec paths Git-Commit-ID: 753b11ef8e92a1c1bbe97f2a5ec14bdd1ef2e6fe X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 753b11ef8e92a1c1bbe97f2a5ec14bdd1ef2e6fe Gitweb: http://git.kernel.org/tip/753b11ef8e92a1c1bbe97f2a5ec14bdd1ef2e6fe Author: Matt Fleming AuthorDate: Thu, 21 Jan 2016 14:11:59 +0000 Committer: Ingo Molnar 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 Tested-by: Srikar Dronamraju Signed-off-by: Matt Fleming Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Young Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Raghavendra K T Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1453385519-11477-1-git-send-email-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar --- 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(); /*