]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
efi: Use efi_mm in x86 as well as ARM
authorSai Praneeth <sai.praneeth.prakhya@intel.com>
Mon, 12 Mar 2018 08:44:56 +0000 (08:44 +0000)
committerIngo Molnar <mingo@kernel.org>
Mon, 12 Mar 2018 09:05:01 +0000 (10:05 +0100)
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>
arch/x86/include/asm/efi.h
arch/x86/platform/efi/efi_64.c
drivers/firmware/efi/arm-runtime.c
drivers/firmware/efi/efi.c
include/linux/efi.h

index a399c1ebf6f0e6d974da0b773248b9c0cfe811a9..c62443fa7d0a6cd43f07231d9c55af68559ce6d5 100644 (file)
@@ -7,6 +7,7 @@
 #include <asm/processor-flags.h>
 #include <asm/tlb.h>
 #include <asm/nospec-branch.h>
+#include <asm/mmu_context.h>
 
 /*
  * We map the EFI regions needed for runtime services non-contiguously,
index 780460aa5ea5e5a18283c559d14457977c51c13d..29425b6c98a7943c48b6ead2bf580e94c7c09e83 100644 (file)
@@ -233,6 +233,9 @@ int __init efi_alloc_page_tables(void)
                return -ENOMEM;
        }
 
+       mm_init_cpumask(&efi_mm);
+       init_new_context(NULL, &efi_mm);
+
        return 0;
 }
 
index 13561aeb73969c8075c649490e9e1c7c3360d1bd..5889cbea60b84d5ffbb6e09a62e73a0f98be3852 100644 (file)
 
 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 <asm/ptdump.h>
 
index 92b9e79e5da9ca85da602f03b6dd877731729308..232f4915223b519b3ee6580cb08354ac9b0a7016 100644 (file)
@@ -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)
 {
index f5083aa72eaee51278d9e173525a15039c0f2056..f1b7d68ac4600a3df4ec3280ef2c25086dfc6670 100644 (file)
@@ -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)
 {