Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2821018imu; Sun, 23 Dec 2018 08:31:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN7wizHyttjhpmX54l/DCpTFEIB2c7OkCQt4goPB3jkz/8JnXSsinSOTtrErDGx0tTRGbA68 X-Received: by 2002:a63:2141:: with SMTP id s1mr9676293pgm.148.1545582717012; Sun, 23 Dec 2018 08:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545582716; cv=none; d=google.com; s=arc-20160816; b=ieAXU9Cb8oVsgT+tjJBIVYxtSuF2utoRVdy1XOqGIfNY9AyoyCv2gBKJLt+5I8072d fhny8eMAfQJc38X2xnYn1uo/7EN4D5wek0hx9HNhxRmJZcx5OMN6VIluw8a7YKAG+Tzq +4SAamILmpLfRv3nKCW0jYzfHk7CdTvduzqsVJpiVNiCNDC5KyQzpix90l25llt4+wMU y4QP0U0iB+Ihl87CUt/JzXZ0EEBgRyuKEjTDE8I89YNpCLuj9kRELePVBrDPnAPBihwM bGcMGjqiQ3YSVMAMzd1kSHHHLMeLc6rVycfB+nDvwQMWHCdEVNlPazYqWOItZxHtmCvz I75A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=6J5227Eny8Yhm+NmVSuF4Xw5dOkch0fGnvYTnfxAtMA=; b=FTHpPjANdDpxw5RGsJgOWFbRkgs1pk3RRa7zdKDu6BXZmnngAZaBmIyFv+9fZ8xKAz nyS6WnQn76cC8o3FVwKgoHI0S0/N0zWyifnxwLwvZD7R/Ujl8cNgl4v63Ob3/5FKZN1t g9eQEoc1ncp83lwNJg4BTRfuYnnVAdS1tS7u7zx1bL6D4ApslcO/NDe8CedxJqv2CHv3 7eSVBidqq9m2DddrJrRSxjtPTUox1TdLKFNzH5UAw5lGXYvWR8Iv98fY0iUNti/+vzwf ssldzrTrG1D4Uq/xWUvxwgpBcOiDAVOa/JdNrND7YcZBKM6h3bdTSK5gW58En/kvJqZf DNlQ== 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 r34si26263462pga.242.2018.12.23.08.31.41; Sun, 23 Dec 2018 08:31:56 -0800 (PST) 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 S2390043AbeLVVFL (ORCPT + 99 others); Sat, 22 Dec 2018 16:05:11 -0500 Received: from terminus.zytor.com ([198.137.202.136]:51843 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387605AbeLVVFK (ORCPT ); Sat, 22 Dec 2018 16:05:10 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id wBML41RJ283665 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 22 Dec 2018 13:04:01 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id wBML3w4C283662; Sat, 22 Dec 2018 13:03:58 -0800 Date: Sat, 22 Dec 2018 13:03:58 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Sai Praneeth Prakhya Message-ID: Cc: dave.hansen@linux.intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, ard.biesheuvel@linaro.org, luto@kernel.org, sai.praneeth.prakhya@intel.com, mingo@kernel.org, peterz@infradead.org, bp@alien8.de, bhsharma@redhat.com, dave.hansen@intel.com, torvalds@linux-foundation.org, riel@surriel.com Reply-To: bhsharma@redhat.com, bp@alien8.de, riel@surriel.com, torvalds@linux-foundation.org, dave.hansen@intel.com, tglx@linutronix.de, ard.biesheuvel@linaro.org, hpa@zytor.com, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, peterz@infradead.org, mingo@kernel.org, sai.praneeth.prakhya@intel.com, luto@kernel.org In-Reply-To: <20181222022234.7573-1-sai.praneeth.prakhya@intel.com> References: <20181222022234.7573-1-sai.praneeth.prakhya@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] x86/efi: Don't unmap EFI boot services code/data regions for EFI_OLD_MEMMAP and EFI_MIXED_MODE Git-Commit-ID: 1debf0958fa27b7c469dbf22754929ec59a7c0e7 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 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1debf0958fa27b7c469dbf22754929ec59a7c0e7 Gitweb: https://git.kernel.org/tip/1debf0958fa27b7c469dbf22754929ec59a7c0e7 Author: Sai Praneeth Prakhya AuthorDate: Fri, 21 Dec 2018 18:22:34 -0800 Committer: Ingo Molnar CommitDate: Sat, 22 Dec 2018 20:58:30 +0100 x86/efi: Don't unmap EFI boot services code/data regions for EFI_OLD_MEMMAP and EFI_MIXED_MODE The following commit: d5052a7130a6 ("x86/efi: Unmap EFI boot services code/data regions from efi_pgd") forgets to take two EFI modes into consideration, namely EFI_OLD_MEMMAP and EFI_MIXED_MODE: - EFI_OLD_MEMMAP is a legacy way of mapping EFI regions into swapper_pg_dir using ioremap() and init_memory_mapping(). This feature can be enabled by passing "efi=old_map" as kernel command line argument. But, efi_unmap_pages() unmaps EFI boot services code/data regions *only* from efi_pgd and hence cannot be used for unmapping EFI boot services code/data regions from swapper_pg_dir. Introduce a temporary fix to not unmap EFI boot services code/data regions when EFI_OLD_MEMMAP is enabled while working on a real fix. - EFI_MIXED_MODE is another feature where a 64-bit kernel runs on a 64-bit platform crippled by a 32-bit firmware. To support EFI_MIXED_MODE, all RAM (i.e. namely EFI regions like EFI_CONVENTIONAL_MEMORY, EFI_LOADER_, EFI_BOOT_SERVICES_ and EFI_RUNTIME_CODE/DATA regions) is mapped into efi_pgd all the time to facilitate EFI runtime calls access it's arguments in 1:1 mode. Hence, don't unmap EFI boot services code/data regions when booted in mixed mode. Signed-off-by: Sai Praneeth Prakhya Acked-by: Ard Biesheuvel Cc: Andy Lutomirski Cc: Bhupesh Sharma Cc: Borislav Petkov Cc: Dave Hansen Cc: Dave Hansen Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20181222022234.7573-1-sai.praneeth.prakhya@intel.com Signed-off-by: Ingo Molnar --- arch/x86/platform/efi/quirks.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 09e811b9da26..17456a1d3f04 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -380,6 +380,22 @@ static void __init efi_unmap_pages(efi_memory_desc_t *md) u64 pa = md->phys_addr; u64 va = md->virt_addr; + /* + * To Do: Remove this check after adding functionality to unmap EFI boot + * services code/data regions from direct mapping area because + * "efi=old_map" maps EFI regions in swapper_pg_dir. + */ + if (efi_enabled(EFI_OLD_MEMMAP)) + return; + + /* + * EFI mixed mode has all RAM mapped to access arguments while making + * EFI runtime calls, hence don't unmap EFI boot services code/data + * regions. + */ + if (!efi_is_native()) + return; + if (kernel_unmap_pages_in_pgd(pgd, pa, md->num_pages)) pr_err("Failed to unmap 1:1 mapping for 0x%llx\n", pa);