aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Praneeth <sai.praneeth.prakhya@intel.com>2018-03-12 04:44:56 -0400
committerIngo Molnar <mingo@kernel.org>2018-03-12 05:05:01 -0400
commit7e904a91bf6049071ef9d605a52f863ae774081d (patch)
tree9068d922b617ccbb46314242ae0c88b745952046
parentb0599e2801df79d571c9e9a763b174b9f0edc558 (diff)
efi: Use efi_mm in x86 as well as ARM
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. Tested-by: Bhupesh Sharma <bhsharma@redhat.com> [ardb: don't #include the world to get a declaration of struct mm_struct] Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Lee, Chun-Yi <jlee@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Shankar <ravi.v.shankar@intel.com> Cc: Ricardo Neri <ricardo.neri@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180312084500.10764-2-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/efi.h1
-rw-r--r--arch/x86/platform/efi/efi_64.c3
-rw-r--r--drivers/firmware/efi/arm-runtime.c9
-rw-r--r--drivers/firmware/efi/efi.c9
-rw-r--r--include/linux/efi.h2
5 files changed, 15 insertions, 9 deletions
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index a399c1ebf6f0..c62443fa7d0a 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -7,6 +7,7 @@
7#include <asm/processor-flags.h> 7#include <asm/processor-flags.h>
8#include <asm/tlb.h> 8#include <asm/tlb.h>
9#include <asm/nospec-branch.h> 9#include <asm/nospec-branch.h>
10#include <asm/mmu_context.h>
10 11
11/* 12/*
12 * We map the EFI regions needed for runtime services non-contiguously, 13 * 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 780460aa5ea5..29425b6c98a7 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -233,6 +233,9 @@ int __init efi_alloc_page_tables(void)
233 return -ENOMEM; 233 return -ENOMEM;
234 } 234 }
235 235
236 mm_init_cpumask(&efi_mm);
237 init_new_context(NULL, &efi_mm);
238
236 return 0; 239 return 0;
237} 240}
238 241
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 @@
31 31
32extern u64 efi_system_table; 32extern u64 efi_system_table;
33 33
34static struct mm_struct efi_mm = {
35 .mm_rb = RB_ROOT,
36 .mm_users = ATOMIC_INIT(2),
37 .mm_count = ATOMIC_INIT(1),
38 .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem),
39 .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock),
40 .mmlist = LIST_HEAD_INIT(efi_mm.mmlist),
41};
42
43#ifdef CONFIG_ARM64_PTDUMP_DEBUGFS 34#ifdef CONFIG_ARM64_PTDUMP_DEBUGFS
44#include <asm/ptdump.h> 35#include <asm/ptdump.h>
45 36
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 92b9e79e5da9..232f4915223b 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -75,6 +75,15 @@ static unsigned long *efi_tables[] = {
75 &efi.mem_attr_table, 75 &efi.mem_attr_table,
76}; 76};
77 77
78struct mm_struct efi_mm = {
79 .mm_rb = RB_ROOT,
80 .mm_users = ATOMIC_INIT(2),
81 .mm_count = ATOMIC_INIT(1),
82 .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem),
83 .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock),
84 .mmlist = LIST_HEAD_INIT(efi_mm.mmlist),
85};
86
78static bool disable_runtime; 87static bool disable_runtime;
79static int __init setup_noefi(char *arg) 88static int __init setup_noefi(char *arg)
80{ 89{
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 {
966 unsigned long flags; 966 unsigned long flags;
967} efi; 967} efi;
968 968
969extern struct mm_struct efi_mm;
970
969static inline int 971static inline int
970efi_guidcmp (efi_guid_t left, efi_guid_t right) 972efi_guidcmp (efi_guid_t left, efi_guid_t right)
971{ 973{