From: Sasha Levin Subject: [PATCH AUTOSEL for 4.9 153/281] x86/efi: Disable runtime services on kexec kernel if booted with efi=old_map Date: Mon, 19 Mar 2018 16:00:54 +0000 Message-ID: <20180319155742.13731-153-alexander.levin@microsoft.com> References: <20180319155742.13731-1-alexander.levin@microsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20180319155742.13731-1-alexander.levin@microsoft.com> Content-Language: en-US Sender: stable-owner@vger.kernel.org To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Cc: Sai Praneeth , Matt Fleming , Ard Biesheuvel , Borislav Petkov , Linus Torvalds , Peter Zijlstra , Ravi Shankar , Ricardo Neri , Thomas Gleixner , "linux-efi@vger.kernel.org" , Ingo Molnar , Sasha Levin List-Id: linux-efi@vger.kernel.org From: Sai Praneeth [ Upstream commit 4e52797d2efefac3271abdc54439a3435abd77b9 ] Booting kexec kernel with "efi=3Dold_map" in kernel command line hits kernel panic as shown below. BUG: unable to handle kernel paging request at ffff88007fe78070 IP: virt_efi_set_variable.part.7+0x63/0x1b0 PGD 7ea28067 PUD 7ea2b067 PMD 7ea2d067 PTE 0 [...] Call Trace: virt_efi_set_variable() efi_delete_dummy_variable() efi_enter_virtual_mode() start_kernel() x86_64_start_reservations() x86_64_start_kernel() start_cpu() [ efi=3Dold_map was never intended to work with kexec. The problem with using efi=3Dold_map is that the virtual addresses are assigned from the memory region used by other kernel mappings; vmalloc() space. Potentially there could be collisions when booting kexec if something else is mapped at the virtual address we allocated for runtime service regions in the initial boot - Matt Fleming ] Since kexec was never intended to work with efi=3Dold_map, disable runtime services in kexec if booted with efi=3Dold_map, so that we don't panic. Tested-by: Lee Chun-Yi Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Matt Fleming Acked-by: Dave Young Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Ravi Shankar Cc: Ricardo Neri Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20170526113652.21339-4-matt@codeblueprint.co= .uk Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/platform/efi/efi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 274dfc481849..a0e85f2aff7d 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -832,9 +832,11 @@ static void __init kexec_enter_virtual_mode(void) =20 /* * We don't do virtual mode, since we don't do runtime services, on - * non-native EFI + * non-native EFI. With efi=3Dold_map, we don't do runtime services in + * kexec kernel because in the initial boot something else might + * have been mapped at these virtual addresses. */ - if (!efi_is_native()) { + if (!efi_is_native() || efi_enabled(EFI_OLD_MEMMAP)) { efi_memmap_unmap(); clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); return; --=20 2.14.1