From patchwork Mon Mar 12 08:44:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 131372 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp477347ljb; Mon, 12 Mar 2018 01:45:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELssqL0QTPl44GlgjGThjHi7G2fPewgQHcEBh8Tg3qZd/Cut0S3FqqRFkz3wmJBrNcPXnNuX X-Received: by 2002:a17:902:a614:: with SMTP id u20-v6mr7433609plq.249.1520844338886; Mon, 12 Mar 2018 01:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520844338; cv=none; d=google.com; s=arc-20160816; b=SS0hVyLhaQb/+r0YjNWpJh5x3mS8sHvnnZXcSCmb29slMMMnpXPyowAQMYcLA7Souo Do+xAbhxWLFFT8/OyXb2bdJ6ddG/kcDNGssJfr1SZZxei5szWEnd4FGHe9ial0aHQN3O smNmUEXfGK8o4hBLoEq2jNEy2f782JcBFtqxZY6il9iaXsYHyULkW5i7XpmhEFMSlzKE AjMhPZ72zzhq9DEKJRZnVUpTWubI6KNtgJhZTOD3XrYWBwmXFyAElPaCOYwsRIbm4E+g 0rll1PoQO1aPURFDIyZHIYat7xnVcqK6xkdTzuunso+Jm3jPYvD+KAwmetSypyEiPAT1 hawA== 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=SAQZ34QViO4u9Pzo+YkzwEZXHTsMDudUXjW7+tiTEeTYSXYW1aZ9dKRNB6UFdkMBeO b0APymZO+KDS6bZ7mF219/O+JU+ts4e7U8dliOnziC5EOf8YUzZ05pd/PNVfK/KGLQRG 8azeRoyJCPl6B0wSc0cCk42PqAEtAL9UHHLSmWJaU/NEjc9p0u60R9/yADKu8eH+lv8Z rgPZsyULstgkqJqrNik9sTutYJXgCPgA+455wlklL6dt2qekGP1ovqM4slounIOYCGLR ItTgGDyhFk9el2Mk+3RPRXcVeVeWq7rpLQtV+tIQsyuX1tSH1l8YyW+UpE+1vg6RWn+U p0TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ds0oAn8C; 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 e16si5503678pfd.6.2018.03.12.01.45.38; Mon, 12 Mar 2018 01:45:38 -0700 (PDT) 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=ds0oAn8C; 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 S1752518AbeCLIpg (ORCPT + 2 others); Mon, 12 Mar 2018 04:45:36 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39899 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbeCLIpd (ORCPT ); Mon, 12 Mar 2018 04:45:33 -0400 Received: by mail-wm0-f68.google.com with SMTP id i3so14363423wmi.4 for ; Mon, 12 Mar 2018 01:45:32 -0700 (PDT) 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=ds0oAn8C1UZLmFp3C77GbZtAR1W032Foy3D7mLa6m8QS2q5RM4qAlqAy7cqu/+O3FL tOEp9Ezmdq9T7mCqjZKyodrt3kv891lLOsuHGfUEzuuQ0mvGidrgHYiLWnhRKBdHjayG bjgTBvOmy7LMLo1B47jWL5+GXr8dSveqVDjyk= 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=jsibYwi0LxWYh4V21/ha8uYbE1R21T3YigP3e47IvZCE7bnhDEjfFwjQc77MWDGGvg EeKJ3uOnsiE+iubtmLjcVNx5+O7aNZfq4mmVMMlQkF8+H2/Z3r+hsAXE3xrgavqUGF+M dcl6ZFd/vjkAMG4t6EdQsD83Nnxc0x9hB404Y+Cj5QXulC3VS4FAxB2tZ1bJPL089l41 pThZmRUmBEl8/iUK0sU+HJZUTdzH/r0ehlNtNZYXIMYidmCkAq3WimPnATfZFVQKTN4G WFJco/KSFt94shPZiCNQ7XsL4EsfVrhSFXvr6dBGmL0K2JUzniRjMTEts3iBo+8lzex9 fujw== X-Gm-Message-State: AElRT7FOpzEUcIIVtmKQB87tbUFng9pi3j9bPf51pReoRojOO4n7XpPV VGE3re4gGoLsvt1g3QM1uX13xSE4Hcw= X-Received: by 10.28.116.17 with SMTP id p17mr5203840wmc.137.1520844331749; Mon, 12 Mar 2018 01:45:31 -0700 (PDT) Received: from localhost.localdomain ([105.148.128.186]) by smtp.gmail.com with ESMTPSA id c1sm6544788wre.27.2018.03.12.01.45.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 01:45:30 -0700 (PDT) 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 2/5] x86/efi: Replace efi_pgd with efi_mm.pgd Date: Mon, 12 Mar 2018 08:44:57 +0000 Message-Id: <20180312084500.10764-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180312084500.10764-1-ard.biesheuvel@linaro.org> References: <20180312084500.10764-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 }