Received: by 10.223.176.46 with SMTP id f43csp12243wra; Thu, 18 Jan 2018 13:08:24 -0800 (PST) X-Google-Smtp-Source: ACJfBovuu5OFhooD9DtvWjjmFMZmRjqIT3GMhA3za4uYQOTymg6Ufj3cG+jQpocZGFqHLOMHGvb1 X-Received: by 10.98.155.8 with SMTP id r8mr33354541pfd.94.1516309704329; Thu, 18 Jan 2018 13:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516309704; cv=none; d=google.com; s=arc-20160816; b=CzItog43Rr9p+i+tZNpbb4WnjimkFh3DBI4WsCldo3iQp6o8amuhaQ/eGTtM479Vvz uxJQRs+GO70HZiRQdn/z3WNhUv+92mN2crwPXDvlwl73oNdMnLwuwVvxhSuCkWqgdmNA 6GxD+H358JfGv7voHDGN7yL4KeOOHeC0evzwolQpCmRTN5dkGnGu2kbfI3T3m178CgGP +7M1wW2uN9PZpcOc5n0OCIgTJYahuBXr/qXrtjRsNn6qxGKmbn9xpNi9DhzWI7zUWntT 9udIhYZEvyt/O6q7/OgFthIOjeSL7zwBmDt4/N0W8AT92wnplhKMPSpIYKEfBh1UAELF 4ymg== 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=Vt+tuqcCXH7P1j8oWDNx4rHvLiNqOI/jSgMCr40PRmA=; b=SJBbhJ5MMpXno3gX5gCpvzMxZtbcVd72sIrRP2kOxQKA32AVuEUzJn7ir8YdSEk97w 0on/G4D/cG+HbDeldaUEbUxTllm9PO+MfABGa9e+wMTGwBfQdN7msLBfMs3tX0JUlNFT nAcSkLiee+wpMGtkW7M4WQIPMdaD6aWRo3hAR3nD3EiDAdjw+0ja6fiomvzWV8w6KtKH eBTebF9RxwIYdDEFJbeQxgVNdNYM11XhSUje5re9sjT6mjoLWZckCqDEQzmmIai221af wRu6zL7N2skrWL455Ji6+fRr81Q040Lbtdb7M37jKYVD/94oj5dslW9NtYmyN8nqoFTS 8Q1Q== 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 x25si7852934pfj.295.2018.01.18.13.08.08; Thu, 18 Jan 2018 13:08:24 -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 S932778AbeARVH3 (ORCPT + 99 others); Thu, 18 Jan 2018 16:07:29 -0500 Received: from mga01.intel.com ([192.55.52.88]:32728 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932738AbeARVHR (ORCPT ); Thu, 18 Jan 2018 16:07:17 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 13:07:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,378,1511856000"; d="scan'208";a="196860697" Received: from saipraneeth.sc.intel.com ([143.183.140.145]) by fmsmga006.fm.intel.com with ESMTP; 18 Jan 2018 13:07:16 -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" , Ricardo Neri , Matt Fleming , Ard Biesheuvel , Ravi Shankar Subject: [PATCH V4 1/3] efi: Use efi_mm in x86 as well as ARM Date: Thu, 18 Jan 2018 13:01:19 -0800 Message-Id: <1516309279-23977-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 Presently, only ARM uses mm_struct to manage efi page tables and efi runtime region mappings. As this is the preferred approach, let's make this data structure common across architectures. Specially, for x86, using this data structure improves code maintainability and readability. Signed-off-by: Sai Praneeth Prakhya Cc: Lee, Chun-Yi Cc: Borislav Petkov Cc: Tony Luck Cc: Andy Lutomirski Cc: Michael S. Tsirkin Cc: Ricardo Neri Cc: Matt Fleming Cc: Ard Biesheuvel Cc: Ravi Shankar Tested-by: Bhupesh Sharma --- arch/x86/include/asm/efi.h | 4 ++++ arch/x86/platform/efi/efi_64.c | 3 +++ drivers/firmware/efi/arm-runtime.c | 9 --------- drivers/firmware/efi/efi.c | 9 +++++++++ include/linux/efi.h | 2 ++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 85f6ccb80b91..00f977ddd718 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -2,10 +2,14 @@ #ifndef _ASM_X86_EFI_H #define _ASM_X86_EFI_H +#include +#include + #include #include #include #include +#include /* * We map the EFI regions needed for runtime services non-contiguously, diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 2dd15e967c3f..c9f8e6924df7 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -232,6 +232,9 @@ int __init efi_alloc_page_tables(void) return -ENOMEM; } + mm_init_cpumask(&efi_mm); + init_new_context(NULL, &efi_mm); + return 0; } diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 1cc41c3d6315..d6b26534812b 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -31,15 +31,6 @@ extern u64 efi_system_table; -static struct mm_struct efi_mm = { - .mm_rb = RB_ROOT, - .mm_users = ATOMIC_INIT(2), - .mm_count = ATOMIC_INIT(1), - .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem), - .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock), - .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), -}; - #ifdef CONFIG_ARM64_PTDUMP_DEBUGFS #include diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 557a47829d03..760260b933b6 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -74,6 +74,15 @@ static unsigned long *efi_tables[] = { &efi.mem_attr_table, }; +struct mm_struct efi_mm = { + .mm_rb = RB_ROOT, + .mm_users = ATOMIC_INIT(2), + .mm_count = ATOMIC_INIT(1), + .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem), + .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock), + .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), +}; + static bool disable_runtime; static int __init setup_noefi(char *arg) { diff --git a/include/linux/efi.h b/include/linux/efi.h index 29fdf8029cf6..d79f1cc4c8bb 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -930,6 +930,8 @@ extern struct efi { unsigned long flags; } efi; +extern struct mm_struct efi_mm; + static inline int efi_guidcmp (efi_guid_t left, efi_guid_t right) { -- 2.1.4