From patchwork Thu Mar 8 08:00:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 130971 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6175035lja; Thu, 8 Mar 2018 00:02:20 -0800 (PST) X-Google-Smtp-Source: AG47ELurlnyZ6/HMkPc+3aqsDuMMT332RD4yPmxcMgLXbuZ+djFt3zXcR3RbihKNgcQ7eQkF+dso X-Received: by 10.101.102.21 with SMTP id w21mr21106344pgv.247.1520496140150; Thu, 08 Mar 2018 00:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520496140; cv=none; d=google.com; s=arc-20160816; b=Ctr5cUz1is1ag7PuNueDPMtGP0809BrE8z0sw7OZPIOUJscwcRHbyPibAtWR0709dQ k4lxb75uSjwEVQlh/YUA3ofz6z7vZVq2tsCoGt7m0S/SFUTWt2H+aiLWerveWvZWk7ty lwL9EyJW2BD027rL36CF0svmNqEDq7RPRhIzw3Y6m6Sujwpeo6U3jo79ej+t2EbinkMJ 3K0UgtE9k4/WBNwB+BDp43kHNBXmOAjssVTy7i5/4EJpl7SS3ANzyxmD0LQ7JX9c0kje 71mlppoysfiLZim0PeBYhbrC5pyi6fcvxOR3FOTtLAsVMPmJzvoWXjw3wLOG2J7jsWIt jMiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Z5noG1Pz8bHSORdqMFYJR7ecnbEzJGGDdzA2OMLi/EI=; b=cfP8q+MeAV0mfURXmFiGZKGUwmI0WjyK1FjdOzsxwb4YMvqpdexSW0YONp6qqKVKiO s+18BAfIp30UCrtbHdd62VHnBngoB2zZpz/VrfxWNPVLzn3Omf8iqHWWvI+9t/thuRWM m+4CEdGkYMCzaJe1NcOsT89OdQoVdpfJKdJZA8vBLhjstVV6nzdNzuxIOBiLXP9P1YRZ tPrEDVnIyBnYx3ljjJNR6hrEp+XosTtBToCoCrA10H1M+AImp5IURhMGs+Xrp/u4YqWd 2GMpNrixTVmW27WO3CjHw+TXbBmrCxJSg1mzFkmpJdEtC9i6hmF0bxVYPuEV2IO1EYH2 LKNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Q/+XPkpi; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23si12462852pgv.121.2018.03.08.00.02.19; Thu, 08 Mar 2018 00:02:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Q/+XPkpi; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965513AbeCHICQ (ORCPT + 2 others); Thu, 8 Mar 2018 03:02:16 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:56214 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965379AbeCHICN (ORCPT ); Thu, 8 Mar 2018 03:02:13 -0500 Received: by mail-wm0-f65.google.com with SMTP id q83so9504578wme.5 for ; Thu, 08 Mar 2018 00:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FsGL2UN03rY/SFjoYK6O3R2gchi1rSfwLQrQv4evXYE=; b=Q/+XPkpilVwdFZ1Vdhfx4LIKdxwrzfD7yLvBknwXbFud8HSXsrMqk1o0Xe9ijzNlTs RZ6BXbYL9qB9BUxtiG+wjBSjDWaa8LKRF4x5Go+W7SzemaLhDnOCooQG+sk3x7M1r0CR U9uWv17aCtxK9cFgvHLZTacceP2aTv++sJPtg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FsGL2UN03rY/SFjoYK6O3R2gchi1rSfwLQrQv4evXYE=; b=b9ORDC9LzjYJm2Ecaxyh+qXxTft7n3Xp5QGlknY921SK3TaBcJcHldTb2byQarQH6/ zkzpNa/+oEXlXtbWJBcLrlw2VMgU1HkXhf+HfcVN4y8qHeNocghsL3JjrFIjfMvKh9nt +gRx0THuHW2/oS0aE7aW//Jydl8a/4nvEg4YdcblmLjKWAPCUhIPHLQaxJ8T4NqnqTey HTHzotJHU3cwVvWm7LpAyKMB3wkIn1RyxJbZpUzwYiPUK5ucfTpLCaxCp4FawkfWrx0V 48lOO0IfJoYUxs67zgDow0d2eFjLGK063sx9NK0IuZRoQJ8N4jQoL65x/DydXMC9JzJv JSKw== X-Gm-Message-State: AElRT7HIUPhvhQtvAIDJSIjGfLKNpkIH5mhiC9fGB7asqCxxUWctUdu9 MF5VDF6gofXu3pnS/rT2B4eoWFlG4ZM= X-Received: by 10.28.118.20 with SMTP id r20mr7109451wmc.145.1520496131916; Thu, 08 Mar 2018 00:02:11 -0800 (PST) Received: from localhost.localdomain ([160.89.73.46]) by smtp.gmail.com with ESMTPSA id e191sm11223361wmg.12.2018.03.08.00.02.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 00:02:11 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Sai Praneeth , Ard Biesheuvel , linux-kernel@vger.kernel.org, "Lee, Chun-Yi" , Borislav Petkov , Tony Luck , Andy Lutomirski , "Michael S . Tsirkin" , Bhupesh Sharma , Ricardo Neri , Ravi Shankar Subject: [PATCH 08/12] x86/efi: Replace efi_pgd with efi_mm.pgd Date: Thu, 8 Mar 2018 08:00:16 +0000 Message-Id: <20180308080020.22828-9-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180308080020.22828-1-ard.biesheuvel@linaro.org> References: <20180308080020.22828-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Sai Praneeth Since the previous patch added support for efi_mm, let's handle efi_pgd through efi_mm and remove global variable efi_pgd. Signed-off-by: Sai Praneeth Prakhya Cc: "Lee, Chun-Yi" Cc: Borislav Petkov Cc: Tony Luck Cc: Andy Lutomirski Cc: Michael S. Tsirkin Cc: Bhupesh Sharma Cc: Ricardo Neri Cc: Ravi Shankar Tested-by: Bhupesh Sharma Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/efi_64.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 0045efe9947b..8881e601c32d 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -190,8 +190,6 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd) early_code_mapping_set_exec(0); } -static pgd_t *efi_pgd; - /* * We need our own copy of the higher levels of the page tables * because we want to avoid inserting EFI region mappings (EFI_VA_END @@ -203,7 +201,7 @@ static pgd_t *efi_pgd; */ int __init efi_alloc_page_tables(void) { - pgd_t *pgd; + pgd_t *pgd, *efi_pgd; p4d_t *p4d; pud_t *pud; gfp_t gfp_mask; @@ -231,6 +229,7 @@ int __init efi_alloc_page_tables(void) return -ENOMEM; } + efi_mm.pgd = efi_pgd; mm_init_cpumask(&efi_mm); init_new_context(NULL, &efi_mm); @@ -246,6 +245,7 @@ void efi_sync_low_kernel_mappings(void) pgd_t *pgd_k, *pgd_efi; p4d_t *p4d_k, *p4d_efi; pud_t *pud_k, *pud_efi; + pgd_t *efi_pgd = efi_mm.pgd; if (efi_enabled(EFI_OLD_MEMMAP)) return; @@ -339,7 +339,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) unsigned long pfn, text, pf; struct page *page; unsigned npages; - pgd_t *pgd; + pgd_t *pgd = efi_mm.pgd; if (efi_enabled(EFI_OLD_MEMMAP)) return 0; @@ -349,8 +349,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) * this value is loaded into cr3 the PGD will be decrypted during * the pagetable walk. */ - efi_scratch.efi_pgt = (pgd_t *)__sme_pa(efi_pgd); - pgd = efi_pgd; + efi_scratch.efi_pgt = (pgd_t *)__sme_pa(pgd); /* * It can happen that the physical address of new_memmap lands in memory @@ -420,7 +419,7 @@ static void __init __map_region(efi_memory_desc_t *md, u64 va) { unsigned long flags = _PAGE_RW; unsigned long pfn; - pgd_t *pgd = efi_pgd; + pgd_t *pgd = efi_mm.pgd; if (!(md->attribute & EFI_MEMORY_WB)) flags |= _PAGE_PCD; @@ -524,7 +523,7 @@ void __init parse_efi_setup(u64 phys_addr, u32 data_len) static int __init efi_update_mappings(efi_memory_desc_t *md, unsigned long pf) { unsigned long pfn; - pgd_t *pgd = efi_pgd; + pgd_t *pgd = efi_mm.pgd; int err1, err2; /* Update the 1:1 mapping */ @@ -621,7 +620,7 @@ void __init efi_dump_pagetable(void) if (efi_enabled(EFI_OLD_MEMMAP)) ptdump_walk_pgd_level(NULL, swapper_pg_dir); else - ptdump_walk_pgd_level(NULL, efi_pgd); + ptdump_walk_pgd_level(NULL, efi_mm.pgd); #endif }