Received: by 10.223.185.116 with SMTP id b49csp6024255wrg; Thu, 8 Mar 2018 00:04:53 -0800 (PST) X-Google-Smtp-Source: AG47ELtPngM3TA2fcvmCTT09Dwmw/Xxh3dMEIiLKVYQ716YGHkzMTADNLd9786HKTcNpNl76dfEb X-Received: by 2002:a17:902:3a1:: with SMTP id d30-v6mr22827885pld.409.1520496293441; Thu, 08 Mar 2018 00:04:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520496293; cv=none; d=google.com; s=arc-20160816; b=VHXnRemjhBfeOBzJRGDWsSdPHTq97YlUy0+CLtQvLxpuPKcFVDRpba86NAQOANAloa IoF/ynVvz3uMNAHgx2IXh3bp5fjEILOhVdcC29sJ6bHv6VRExzSvoJ+jsqEkPIcjL8B5 qWzVdHPRyi8MilM/HelODLNydZkuj54VoqBLENDsdrfdvZI29IU8Y96pTh71A2feKvbg HnsgGl9f3VPFcJ917aGvIF6THQpY6+dsWoewl9aJGs2kuDfXu1917de1zu4NTwOOHP44 CJw//sqiHkq848PWtvzt2a3Z2+y01vKwQQ/AIUaoqQl3tKR0IqhHFZspWw+YUdyxW0pF NVAw== 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=FsGL2UN03rY/SFjoYK6O3R2gchi1rSfwLQrQv4evXYE=; b=mMFWoUzG1b0jPMiV6yUn7ZI97knJxOXRT0/d2rxesh4Y7wc2an/OcAuwK3olsc6i+k AMf4dZfNkIeuxMBb43SUJrX2TjofyR3PB/EsdS4LztOtivWyOysbmk3SHLUep2zQi2Mv NOd6xx0AsQzhSqRhWszJCFzkvptmO9uLe0vHuQWHqngCpGaKQhxN9mVVrT7n6rZR7FV0 waWbwDj5btIAkRiw+uhdpUGDt1DDAYzw9+8Z8Qdgd0FvVYPGEhBmeaiWndGd1LXhDa8U yD0IpTvlRoYE+sIBcHqGqtdd0EQZNfInT3XWeAsnRQ8e4osMsOBsN+3eAtNcsTXulXcU wb4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q/+XPkpi; 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=pass (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 f89-v6si14443087plb.344.2018.03.08.00.04.38; Thu, 08 Mar 2018 00:04:53 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Q/+XPkpi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965787AbeCHIDO (ORCPT + 99 others); Thu, 8 Mar 2018 03:03:14 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:50462 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965346AbeCHICN (ORCPT ); Thu, 8 Mar 2018 03:02:13 -0500 Received: by mail-wm0-f66.google.com with SMTP id w128so9558085wmw.0 for ; Thu, 08 Mar 2018 00:02:12 -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=NPyyo0BaxERmlhPSs6JQ+Mbi4VczvyLr9MrpDT8A7LGrNe/bCzZmiXZyLU2YM8SzhS LEWBL5LiTMer8Fr7hr0V50ICrDBxJh8+T+3xbgaOiZIxhGd/lPshzQy2aLMkHiDQUyTq makqoGslky9mtUarGIaPKLJ3GU++bXYaUCt2GOvB2F+ATtFqKClyCRTIHHAonG9xHxJl 2SWQP7ZIWNostHTOI8Gng58E4ItWsv0GSIdIPH+i0Kz9QukFuRSGZq3CgDAIczDgVI9i 0S+S+B6n2qSKT8oZZlnoU+DpTJHmpn0nvQj9pMqnA7qdJeyv/A3tyIZa6qzKh2uhZXuG LNxQ== X-Gm-Message-State: AElRT7EsgkUsvQaBuu5g/rFLBw3JWh1ee9UEKTm21FxjXp/4y+p5O2X3 Hcvnr7ddPI/pE5Dl7bSmNZgGcw== 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-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: 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(-) 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 } -- 2.15.1