Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2531384imu; Sun, 23 Dec 2018 01:46:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7wqelYBH9S8++XqXtPXYqVe+k1yVK+w6rOEMRtB3pMgVJ2Hh6meVzV3ZeWzyEcKyDcMcyB X-Received: by 2002:a17:902:9345:: with SMTP id g5mr8993944plp.148.1545558419290; Sun, 23 Dec 2018 01:46:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545558419; cv=none; d=google.com; s=arc-20160816; b=YdIGPIVapqDVJN3zdzIE44pHWzRAL1b8cmCycNrXJn9OWr5S+MlKHRp5YXr2YerVpu lmGlzf55pjL58S+nkGAovKTT1SgP6QyN1EJ0lXYILyUmAp8NuO8SwvKw7WF3yXuGkQzD ZKoQW+qeNgI5fu+JM21487ROnfj3BmIuWuyT5wY7fEkYj0+9u+0TIZOLoppUa9LXRUvB Gkx8ug2JeWtJLcYYZERKMFbsHfobulxl7Sqe6iPLr5r9JIfj3xPle369kwmzPt2o2KGv VvVp96xPavccou4HAmiRrrOjOmTVGi/12pRRG05M/iLUqgGZ0Cwtv9yBulxERSAODPa7 qKIw== 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 :message-id:date:subject:cc:to:from; bh=z6v6GFegDoJcoif8//G8HYubbwg6JV3Kz9eeldzrxMI=; b=sa8IntgmgwiXaET7r/itNlTeZNgIgGUWdGcrNa5ivkQCtCmPfKhrxKFACn/gIUR/vh jcrWig6OayuJiBoCv3A8ObcZZFe4s4AmaGG+3s8AJu4/8hKpFdMebh5qJyLxc/CqzxUS x9s+YiYxWwEoJWIG+XYFBWBc77WLKSkgk5zcBOxY2uwPdk4iUMm7oyDqwuhuYRXHb6TR 8NlrwW+3qPFFiqkwdAGZtbxUGgKnQflsCUnJASPTsoTV5foUCT32LJ3j6wm0lpMcLTjV iV8Wt3z0jq1uL7fWKDDo7oQvmYuZDYuxIMHGAwljM55AY1/LZ2TeoUa2XHXfXvWFUAf7 hsjg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si25472585pgl.153.2018.12.23.01.46.43; Sun, 23 Dec 2018 01:46:59 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731065AbeLVCYr (ORCPT + 99 others); Fri, 21 Dec 2018 21:24:47 -0500 Received: from mga12.intel.com ([192.55.52.136]:11627 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbeLVCYr (ORCPT ); Fri, 21 Dec 2018 21:24:47 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Dec 2018 18:24:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,383,1539673200"; d="scan'208";a="305869617" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by fmsmga005.fm.intel.com with ESMTP; 21 Dec 2018 18:24:46 -0800 From: Sai Praneeth Prakhya To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: Sai Praneeth Prakhya , Borislav Petkov , Ingo Molnar , Andy Lutomirski , Dave Hansen , Bhupesh Sharma , Peter Zijlstra , Thomas Gleixner , Ard Biesheuvel Subject: [PATCH] x86/efi: Don't unmap EFI boot services code/data regions for EFI_OLD_MEMMAP and EFI_MIXED_MODE Date: Fri, 21 Dec 2018 18:22:34 -0800 Message-Id: <20181222022234.7573-1-sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Borislav Petkov Cc: Ingo Molnar Cc: Andy Lutomirski Cc: Dave Hansen Cc: Bhupesh Sharma Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ard Biesheuvel --- 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..9c34230aaeae 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() && IS_ENABLED(CONFIG_EFI_MIXED)) + 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); -- 2.19.1