Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2501021imm; Mon, 24 Sep 2018 05:32:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV63N/ebzhyabyiUXej8JzeVHaupmtGTt8gB5bpbF2ht5fn7ubtvlMk+J5Wvbbbl/9t5rutGU X-Received: by 2002:a17:902:a58b:: with SMTP id az11-v6mr4349187plb.93.1537792355752; Mon, 24 Sep 2018 05:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792355; cv=none; d=google.com; s=arc-20160816; b=vjbOF4KWzFBs7RbhdnsndwHEo8283cN2XRLdHXGISqOQlctMVJLUu2DJgx4qfBurXH U/KDRQZBS+ICsnheuXeIJDwInrvK9l8OgUXCfOwT1aCHJY7zp6UIfbQxNbjKgBb7Aluf 7H72bHKM7g3K2tcb2aII1+L3SoxNGDGrZOCIlR3tQT3Gdsmd07JPKj8D2vkF5UW+oQXN 6BU6kGvQZ176HhjmrtJSLhuH85gjYekaWpYD8TT4q2Gci6aBJ4Vs2Nc7oIKvazT4UUKq T4LpM7Qq7Ik1vFOfQ1yAV3eKzghH5NPwp+FqtqsoTrasVkxX802gibubE4XFvduEC8NK 4Mqg== 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=M+rcQErHVh4sffh9d9/R8ip8n1HmJegCb86VvLcvkAc=; b=bPZWTo0HP3qveHvl4O4vdCyRr8nNCAHrUyPWqYBIiTw40xjrGjkhEz7zmEd1lvZYmf mNHDGIK7u3GUdzurnAyylTEow7Jurm5IvsQMSvGO11V8bTg3OAIQOZ8KRkh5I06Ksrpe 9E3YXBuCNtXYOon+S8nlr7mRLj5jij4b4fRpZQeakr9pvXFs6nreo5KfVcL5qun4s8wG UlErrgXjj9dSaZrkRRWHAOZEw88UKqg0uZr0DhnhTxOL1CR0GxGIIZyzAQM5KSIGr67j pmwovgImN6YWGBa2oJdT9QICNL+jjAnKFbqEa1tN6tjIyswi2GXeNrzAasPLOHJoW/VJ kDzw== 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 31-v6si36422249pld.145.2018.09.24.05.32.20; Mon, 24 Sep 2018 05:32:35 -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 S2388023AbeIXSdQ (ORCPT + 99 others); Mon, 24 Sep 2018 14:33:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57954 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388008AbeIXSdP (ORCPT ); Mon, 24 Sep 2018 14:33:15 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6B3631099; Mon, 24 Sep 2018 12:31:20 +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.18 075/235] efi/arm: preserve early mapping of UEFI memory map longer for BGRT Date: Mon, 24 Sep 2018 13:51:01 +0200 Message-Id: <20180924113112.670780213@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@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.18-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 @@ -259,7 +259,6 @@ void __init efi_init(void) reserve_regions(); 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 @@ -110,11 +110,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;