Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2472942imm; Mon, 24 Sep 2018 05:06:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV610hEBpzYxxg32BHDRwV7L5iG4dIHnn2eLJEKO8zNn1F9sERs1g7xUqk9qoOA51GAZfV94S X-Received: by 2002:a63:ff1f:: with SMTP id k31-v6mr9046151pgi.20.1537790792322; Mon, 24 Sep 2018 05:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790792; cv=none; d=google.com; s=arc-20160816; b=EA9XhhKVtvMCjCAv7YIpiHEPTyk4WPdm0iyiNayyzdDgisDxUu2j5oaDeLba75SDVc 4NunGH25f6FTr+lM/KnT+wrEm7dsEJvZxifDO8sRmzLGwPrCciir5p0wTW00dluywCII chJU5ALzl8aPA98bLHW23kyiya0Bt4kqh3cepDk3/toabl6Fa4F4/LrwCwu+8fKMcr9H EfGoIKF0rofmV4d60G5A6tkc+ztjpWzQf2oyU38ULs2VaoaW6vo97yApKSO/jeT5aaN1 nC2hEAI2xFw4DG8Lu9UnKG4Rwo2DaMkfUdGOHJsUR8KigQ3h+Ur0UDPvEyxLyOjENaSG bXQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=wiIlpg1iNGUQqw66rA2RxvfXaKkkbcnfC60SZnGq2nc=; b=ze29cxG1YJOSCOZJtQSMOZP+Lsq/ogy8NbHPeE1OKW9pN3pFKeKruy1B3ag9nvq2Gk G/TSGLTtj8vtevCR1WONROGb5x5QAe7+TiJ/6OGIyKGEVFO8M/sxb+D9QIPDOmTwdBb0 t5nAwxfNFQaUF4cNvwnvBSurZxcCzQDgTALJTxBauy5ohjNueMSOza33DGiey8ZmWaNG +Z27iiQg05GQ9Es/Ir2eBHBD31gDrXvSczmB3JXQ7F/Url9huoUQAjLko2a2G/tUI3ha JZOiVBdIlEefNgFelaou0pwwyOXPauiT2UxVZMevMR2fFnwq+pMBDBlrVwxPmQibwVwC uYlg== 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 1-v6si33989387plv.28.2018.09.24.05.06.16; Mon, 24 Sep 2018 05:06:32 -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 S1730996AbeIXSHD (ORCPT + 99 others); Mon, 24 Sep 2018 14:07:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53904 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728563AbeIXSHC (ORCPT ); Mon, 24 Sep 2018 14:07:02 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 73D131084; Mon, 24 Sep 2018 12:05:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Will Deacon , Sasha Levin Subject: [PATCH 4.9 034/111] efi/arm: preserve early mapping of UEFI memory map longer for BGRT Date: Mon, 24 Sep 2018 13:52:01 +0200 Message-Id: <20180924113108.066301972@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.337261320@linuxfoundation.org> References: <20180924113103.337261320@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Ard Biesheuvel [ Upstream commit 3ea86495aef2f6de26b7cb1599ba350dd6a0c521 ] The BGRT code validates the contents of the table against the UEFI memory map, and so it expects it to be mapped when the code runs. On ARM, this is currently not the case, since we tear down the early mapping after efi_init() completes, and only create the permanent mapping in arm_enable_runtime_services(), which executes as an early initcall, but still leaves a window where the UEFI memory map is not mapped. So move the call to efi_memmap_unmap() from efi_init() to arm_enable_runtime_services(). Signed-off-by: Ard Biesheuvel [will: fold in EFI_MEMMAP attribute check from Ard] Signed-off-by: Will Deacon Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/arm-init.c | 1 - drivers/firmware/efi/arm-runtime.c | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -250,7 +250,6 @@ void __init efi_init(void) reserve_regions(); efi_memattr_init(); efi_esrt_init(); - efi_memmap_unmap(); memblock_reserve(params.mmap & PAGE_MASK, PAGE_ALIGN(params.mmap_size + --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -118,11 +118,13 @@ static int __init arm_enable_runtime_ser { u64 mapsize; - if (!efi_enabled(EFI_BOOT)) { + if (!efi_enabled(EFI_BOOT) || !efi_enabled(EFI_MEMMAP)) { pr_info("EFI services will not be available.\n"); return 0; } + efi_memmap_unmap(); + if (efi_runtime_disabled()) { pr_info("EFI runtime services will be disabled.\n"); return 0;