Received: by 10.223.185.116 with SMTP id b49csp6025419wrg; Thu, 8 Mar 2018 00:06:11 -0800 (PST) X-Google-Smtp-Source: AG47ELu1IOfmxCM8jCZHiKIJ4WR1BW8HFN+GspgqkbMG6lWDuuSh1qA6GKeRePovvtkcLl0dPpop X-Received: by 2002:a17:902:4103:: with SMTP id e3-v6mr19625900pld.172.1520496370987; Thu, 08 Mar 2018 00:06:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520496370; cv=none; d=google.com; s=arc-20160816; b=tSAHEIzm9wigvoZP9O+hQcPesiJJWGCToBwJvNIxvGH3vPRvtWkzKdyT0FR24mfWj8 JzhISvUpiueYp+sC0RFdpOw1xaIxwoO99sYFl4vIxxxYMOjLMj/HigVkg5r+pjCkn5M4 kNvD51uGBYGaHa2Kp8U0UqDGNFPDnfL+YmuV9trg+6nlf2vR1GPyxnICtDYHhbXEzSyc teoczyFYUV7DGALDKx0bVujqHQ54ShGQhaR7wZhFOuXVnz3o5pJ0Z+qSPdP9LLotnFrM sX/RPTsfIssLqldT3z0JCdSKs4GCRIFHYk1yXzraXmUDvHVezaOVyNrCtpnL7H1egydX IB0g== 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=uR6XAAs54Wk1jRattopsy687p4Chn7HkmmTWEvFKXUo=; b=zgkWDdcP2sr6A6LSrSNcpiLexy1skq+SmYnmNf3kEdxmGQjuVb/Aen9XQhHQtcw0c2 zaDLKRU1r/kL3d2FkBeAzkwzYpAIaOn+m0JfIH/lRTK5kWEwDoz9GBat0GB2Vn/rb26L k826Xifn2bpwnzTGBmylVTmaz5Ms5CQdGRM+h7l/S4ZPw/tqUVMf/WFDM8/Gfh1mRNcY cW+ZPGMQ5Xc+D9cFRh1escS+4hlSuQ1FHsgmuQ4hRw7Kj0v61oo+OzUXV3uUstJkcrOL ZVYi6Due/QCFAvyJGn8p0Bu54Y39v1Bd3IXSuNI0UnMmagTXjR8no8+YAJjhMAanNNIR gHSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GvnE/6yi; 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 o6-v6si14339992plh.287.2018.03.08.00.05.56; Thu, 08 Mar 2018 00:06:10 -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=GvnE/6yi; 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 S965298AbeCHICN (ORCPT + 99 others); Thu, 8 Mar 2018 03:02:13 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53987 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965106AbeCHICJ (ORCPT ); Thu, 8 Mar 2018 03:02:09 -0500 Received: by mail-wm0-f65.google.com with SMTP id e194so9454827wmd.3 for ; Thu, 08 Mar 2018 00:02:09 -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=uR6XAAs54Wk1jRattopsy687p4Chn7HkmmTWEvFKXUo=; b=GvnE/6yi6gbrMxvtvtoeEYP7FtnRP6I+Z2E/RirBcrkJ7JHxTWOC93nHS5TvtJZIGf 28erTdKg00zTH72uYrbIGVu4lnkiL6JQ9j5LHpYD7HNqNWsCdUaR4Dd1xC0fn7sTs0DR W8GfW22RrnCVzOfDET1k5PJNgIf+TeVSY1pVY= 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=uR6XAAs54Wk1jRattopsy687p4Chn7HkmmTWEvFKXUo=; b=p4a2IuzLrJqneGFAsAFsv7gCu+8P5tlxvwaHWZMsm7Q/QKUFJv7gs7+KWn2aqtNWnD bcE0YOCeZgatKbxPwB1cKrid+ybEO83Bhqa9QrMfU5kdyLa531uFMx/ock0UfjpIR/IC +FlAhPmHvSS/+KktfOfvgB/9drLOSXPTV4r2n1Oy8gw7G12fGCkzSMyxQN4qhbToRVq4 37aBm9Heuo7a10S+W5w5V3fzBcxEufXr5iHneMsv6qMpuwiNUWrk78u1378UWs2FYf5y YGu8N6ghj34193tDzdh7H82FP22PUeAqLiHyClpLA59we/I6YqBwdp5XLDZS78zPUHTV jgLA== X-Gm-Message-State: AElRT7EP1mQB9ltEzMGhIgJdfkCvZCiEN374KESfx+8bOvBucwFWKb5Q Lt+T6D5v+o9syyaer5u9gRCQhw== X-Received: by 10.28.139.142 with SMTP id n136mr15737343wmd.101.1520496128605; Thu, 08 Mar 2018 00:02:08 -0800 (PST) Received: from localhost.localdomain ([160.89.73.46]) by smtp.gmail.com with ESMTPSA id e191sm11223361wmg.12.2018.03.08.00.02.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 00:02:07 -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" , Ricardo Neri , Ravi Shankar Subject: [PATCH 07/12] efi: Use efi_mm in x86 as well as ARM Date: Thu, 8 Mar 2018 08:00:15 +0000 Message-Id: <20180308080020.22828-8-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 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: Ravi Shankar Tested-by: Bhupesh Sharma Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- 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 c310a8284358..0045efe9947b 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -231,6 +231,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 13561aeb7396..5889cbea60b8 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 cd42f66a7c85..c0dda400d22a 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -75,6 +75,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 f5083aa72eae..f1b7d68ac460 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -966,6 +966,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.15.1