Received: by 10.223.176.46 with SMTP id f43csp12711wra; Thu, 18 Jan 2018 13:08:48 -0800 (PST) X-Google-Smtp-Source: ACJfBotejzeVYuC1n9sSsoNcqtGmrAligwtiBuNarF7Rao4TmgWUoMXd/qejIue9kGfZlcrB7OsT X-Received: by 10.98.156.71 with SMTP id f68mr24780538pfe.29.1516309728189; Thu, 18 Jan 2018 13:08:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516309728; cv=none; d=google.com; s=arc-20160816; b=pbpgEE5N8jqUAN4Oj4ThyDsJ5ydmTD/0Zqvae5AUAa3h6XP/Hv5pSiUHGTd/xW6wv8 tiZI8A+sRAUATGigDuF1b7eX1B1p3RPTHmTx0xwSIi7KW3nq8CozEpBQ2ZVjDjqMm68O bOYx9sPz3xAenWepXyRmsUCYae0tRsSVrlNzhghA5Rq7CfNSoyEvTG2pvn63c+hZ2Cky W6SXTbhIv6JDFsPu1/PlxsIBmFKDYUaqpUKPSKcTPxPkpzhLNq2OHtPsQBBVRB7K/WiR 2uu+v9lNK0Gn6GBqZHhvvy2xz6ewvC+gPcyXPGJvQr2YExRvKwURMTe/9nKQBVtaWmK9 7QLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EfoS7yj7V25h3ustpiTI4Gx1fRJWWovH2T2UAa0n+L4=; b=RsU7XJPs4urXxPoWRewP4QJY9kzJlhOcAZQmTrpn6B/xsNlxNOBlWGNd7Hm2cYIGKn SlWey4Gvu4VAqg/I/qRLYy0sUIVclhwFGPj/cYdf5r/dOorgVwaZKEmm6KbXcGBsCw/d dr/4ACV/mkuEgmm5a27HTk9SDD6FODtzGxTSMA1K1ba0OHrieDIazejipahef1fLPvZP 6kGx+GIagIi0Q+e77LmuOyRlornY7qw7iswLjpEOZaByChEzgCMb9Jhjgl+Rcl1TTQPj XagHGtav2ooYWPcbdfk++45TA7x9eAXWOIedGDfpiVuYpjjLbr0whknl3bYFf5UUC173 R1Ug== 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 y28si1260349pgc.742.2018.01.18.13.08.34; Thu, 18 Jan 2018 13:08:48 -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 S932838AbeARVHm (ORCPT + 99 others); Thu, 18 Jan 2018 16:07:42 -0500 Received: from mga04.intel.com ([192.55.52.120]:46120 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932761AbeARVH3 (ORCPT ); Thu, 18 Jan 2018 16:07:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 13:07:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,378,1511856000"; d="scan'208";a="20878811" Received: from saipraneeth.sc.intel.com ([143.183.140.145]) by FMSMGA003.fm.intel.com with ESMTP; 18 Jan 2018 13:07:28 -0800 From: Sai Praneeth Prakhya To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sai Praneeth , "Lee, Chun-Yi" , Borislav Petkov , Tony Luck , Andy Lutomirski , "Michael S. Tsirkin" , Bhupesh Sharma , Ricardo Neri , Matt Fleming , Ard Biesheuvel , Ravi Shankar Subject: [PATCH V4 2/3] x86/efi: Replace efi_pgd with efi_mm.pgd Date: Thu, 18 Jan 2018 13:01:31 -0800 Message-Id: <1516309291-24021-1-git-send-email-sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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: Matt Fleming Cc: Ard Biesheuvel Cc: Ravi Shankar Tested-by: Bhupesh Sharma --- arch/x86/platform/efi/efi_64.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index c9f8e6924df7..c93f59731608 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -191,8 +191,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 @@ -204,7 +202,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; @@ -232,6 +230,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); @@ -247,6 +246,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; @@ -340,7 +340,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; @@ -350,8 +350,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 @@ -421,7 +420,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; @@ -525,7 +524,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 */ @@ -622,7 +621,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 } -- 2.1.4