Received: by 10.192.165.156 with SMTP id m28csp1121482imm; Wed, 11 Apr 2018 12:51:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49gc4jHJhX/fSK/Bd2gSz8aOTAYeEEvFI5RPaM89oqllwghJEGNrnq1e2ckE/LLDlgc0gcR X-Received: by 10.99.97.11 with SMTP id v11mr4417067pgb.172.1523476270069; Wed, 11 Apr 2018 12:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523476270; cv=none; d=google.com; s=arc-20160816; b=aYl0hjB17C2TKRYm5zCoj+trutLrA9hifeWoood6l/pni2qcmGRxrQONDdSLO/3TX5 coIoBJOCr3v9wGvH5fRipTkSL5iswB+nG52V1b/hLRIAcrghGpYEmVtPBtRsB56RV+FS i88jZuV596CRb4dulZUbprwpj023+jZg8Lkljpuq0dmgJx1kEGpqt/xBnRO9p25ULgMj v9eDEmd0KVRtDxAq+m7FXMWkiDHnCebBm6/2Y+gusXoE2jn99+nQe9ixU2057ZQwxXD1 cGlT+oc2i2TMFfPHvBhO3Bibs8ZXzr3tYMZMcrGg4JAPHehl+4zxqgxzxlXd5n2qD7ND Ti7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UPIyYRXbW8ZV809j+cJP6PWKFBk0RwHoY1sW9/8RhU4=; b=xK5EOoNwTGkceU703slew5KPuAMdcyDAe/M80onunvzgBjZi1YbDrZxHwjx1cm8Drj +RKTO/A8qOoerMr1l8UE7DRYpRqc2OGbkdA4FkTpWKJHPdQOG9BkdLsji1/nFNMHJx9V 6GvUGZaK8P0NyUVkXirgKeQRZdMvn6jADJpvFqKCYDTyLPahMcSQSkX4+9NxdfP4Ocrc mzcuCvnKVyqmqQMQA/ka/q0w0QaRMN9vtjflqNPihb4a3GbXoaNIn66Nc4cmGkbZfKEM DjB1AZFXZxEDli3H9/I0DFptsnzbuCcFBosQtVX4MA2IycgybrQPoLilb448KGURsP6W gIFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si1607364plg.650.2018.04.11.12.50.33; Wed, 11 Apr 2018 12:51:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934084AbeDKS7W (ORCPT + 99 others); Wed, 11 Apr 2018 14:59:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37346 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934024AbeDKS7S (ORCPT ); Wed, 11 Apr 2018 14:59:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id ADE6E9C1; Wed, 11 Apr 2018 18:59:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Chun-Yi , Sai Praneeth Prakhya , Matt Fleming , Dave Young , Ard Biesheuvel , Borislav Petkov , Linus Torvalds , Peter Zijlstra , Ravi Shankar , Ricardo Neri , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.9 149/310] x86/efi: Disable runtime services on kexec kernel if booted with efi=old_map Date: Wed, 11 Apr 2018 20:34:48 +0200 Message-Id: <20180411183628.840963751@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sai Praneeth [ Upstream commit 4e52797d2efefac3271abdc54439a3435abd77b9 ] Booting kexec kernel with "efi=old_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=old_map was never intended to work with kexec. The problem with using efi=old_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=old_map, disable runtime services in kexec if booted with efi=old_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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/platform/efi/efi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -832,9 +832,11 @@ static void __init kexec_enter_virtual_m /* * We don't do virtual mode, since we don't do runtime services, on - * non-native EFI + * non-native EFI. With efi=old_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;