]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
efi: Convert efi_call_virt() to efi_call_virt_pointer()
authorAlex Thorlton <athorlton@sgi.com>
Sat, 25 Jun 2016 07:20:27 +0000 (08:20 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 27 Jun 2016 11:06:56 +0000 (13:06 +0200)
This commit makes a few slight modifications to the efi_call_virt() macro
to get it to work with function pointers that are stored in locations
other than efi.systab->runtime, and renames the macro to
efi_call_virt_pointer().  The majority of the changes here are to pull
these macros up into header files so that they can be accessed from
outside of drivers/firmware/efi/runtime-wrappers.c.

The most significant change not directly related to the code move is to
add an extra "p" argument into the appropriate efi_call macros, and use
that new argument in place of the, formerly hard-coded,
efi.systab->runtime pointer.

The last piece of the puzzle was to add an efi_call_virt() macro back into
drivers/firmware/efi/runtime-wrappers.c to wrap around the new
efi_call_virt_pointer() macro - this was mainly to keep the code from
looking too cluttered by adding a bunch of extra references to
efi.systab->runtime everywhere.

Note that I also broke up the code in the efi_call_virt_pointer() macro a
bit in the process of moving it.

Signed-off-by: Alex Thorlton <athorlton@sgi.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dimitri Sivanich <sivanich@sgi.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roy Franz <roy.franz@linaro.org>
Cc: Russ Anderson <rja@sgi.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1466839230-12781-5-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/arm/include/asm/efi.h
arch/arm64/include/asm/efi.h
arch/x86/include/asm/efi.h
drivers/firmware/efi/runtime-wrappers.c
include/linux/efi.h

index a708fa1f090579228363f8a5f0427db16d31b3a1..766bf9b781601f285bd648788ee53202ebcb4550 100644 (file)
@@ -28,10 +28,10 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
 #define arch_efi_call_virt_setup()     efi_virtmap_load()
 #define arch_efi_call_virt_teardown()  efi_virtmap_unload()
 
-#define arch_efi_call_virt(f, args...)                                 \
+#define arch_efi_call_virt(p, f, args...)                              \
 ({                                                                     \
        efi_##f##_t *__f;                                               \
-       __f = efi.systab->runtime->f;                                   \
+       __f = p->f;                                                     \
        __f(args);                                                      \
 })
 
index 622db3c6474e2d5c51b3a1689869534cf16019ee..bd887663689bd4fdc5b6e9f1f144be4d5eb8fdc3 100644 (file)
@@ -23,10 +23,10 @@ int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
        efi_virtmap_load();                                             \
 })
 
-#define arch_efi_call_virt(f, args...)                                 \
+#define arch_efi_call_virt(p, f, args...)                              \
 ({                                                                     \
        efi_##f##_t *__f;                                               \
-       __f = efi.systab->runtime->f;                                   \
+       __f = p->f;                                                     \
        __f(args);                                                      \
 })
 
index 78d1e7467eae9fb9bd200cb04205c22322b01b4f..55b4596ef6889d239129cac22c8189fe8bcf4980 100644 (file)
@@ -41,10 +41,9 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...);
 /*
  * Wrap all the virtual calls in a way that forces the parameters on the stack.
  */
-#define arch_efi_call_virt(f, args...)                                 \
+#define arch_efi_call_virt(p, f, args...)                              \
 ({                                                                     \
-       ((efi_##f##_t __attribute__((regparm(0)))*)                     \
-               efi.systab->runtime->f)(args);                          \
+       ((efi_##f##_t __attribute__((regparm(0)))*) p->f)(args);        \
 })
 
 #define efi_ioremap(addr, size, type, attr)    ioremap_cache(addr, size)
@@ -81,8 +80,8 @@ struct efi_scratch {
        }                                                               \
 })
 
-#define arch_efi_call_virt(f, args...)                                 \
-       efi_call((void *)efi.systab->runtime->f, args)                  \
+#define arch_efi_call_virt(p, f, args...)                              \
+       efi_call((void *)p->f, args)                                    \
 
 #define arch_efi_call_virt_teardown()                                  \
 ({                                                                     \
index 23bef6bb73ee58db932e7fd34100e4d850e73a4a..41958774cde301e5e1d1d5f3eef7be6e1eea0b59 100644 (file)
 #include <linux/stringify.h>
 #include <asm/efi.h>
 
-static void efi_call_virt_check_flags(unsigned long flags, const char *call)
+/*
+ * Wrap around the new efi_call_virt_generic() macros so that the
+ * code doesn't get too cluttered:
+ */
+#define efi_call_virt(f, args...)   \
+       efi_call_virt_pointer(efi.systab->runtime, f, args)
+#define __efi_call_virt(f, args...) \
+       __efi_call_virt_pointer(efi.systab->runtime, f, args)
+
+void efi_call_virt_check_flags(unsigned long flags, const char *call)
 {
        unsigned long cur_flags, mismatch;
 
@@ -38,48 +47,6 @@ static void efi_call_virt_check_flags(unsigned long flags, const char *call)
        local_irq_restore(flags);
 }
 
-/*
- * Arch code can implement the following three template macros, avoiding
- * reptition for the void/non-void return cases of {__,}efi_call_virt:
- *
- *  * arch_efi_call_virt_setup
- *
- *    Sets up the environment for the call (e.g. switching page tables,
- *    allowing kernel-mode use of floating point, if required).
- *
- *  * arch_efi_call_virt
- *
- *    Performs the call. The last expression in the macro must be the call
- *    itself, allowing the logic to be shared by the void and non-void
- *    cases.
- *
- *  * arch_efi_call_virt_teardown
- *
- *    Restores the usual kernel environment once the call has returned.
- */
-
-#define efi_call_virt(f, args...)                                      \
-({                                                                     \
-       efi_status_t __s;                                               \
-       unsigned long flags;                                            \
-       arch_efi_call_virt_setup();                                     \
-       local_save_flags(flags);                                        \
-       __s = arch_efi_call_virt(f, args);                              \
-       efi_call_virt_check_flags(flags, __stringify(f));               \
-       arch_efi_call_virt_teardown();                                  \
-       __s;                                                            \
-})
-
-#define __efi_call_virt(f, args...)                                    \
-({                                                                     \
-       unsigned long flags;                                            \
-       arch_efi_call_virt_setup();                                     \
-       local_save_flags(flags);                                        \
-       arch_efi_call_virt(f, args);                                    \
-       efi_call_virt_check_flags(flags, __stringify(f));               \
-       arch_efi_call_virt_teardown();                                  \
-})
-
 /*
  * According to section 7.1 of the UEFI spec, Runtime Services are not fully
  * reentrant, and there are particular combinations of calls that need to be
index 03009695760d91c90ad78201df2e10143c35f1a2..75d148dc9c3fb4b69d7adab3dac10029d44ac73b 100644 (file)
@@ -1480,4 +1480,55 @@ efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg,
                           unsigned long size);
 
 bool efi_runtime_disabled(void);
+extern void efi_call_virt_check_flags(unsigned long flags, const char *call);
+
+/*
+ * Arch code can implement the following three template macros, avoiding
+ * reptition for the void/non-void return cases of {__,}efi_call_virt():
+ *
+ *  * arch_efi_call_virt_setup()
+ *
+ *    Sets up the environment for the call (e.g. switching page tables,
+ *    allowing kernel-mode use of floating point, if required).
+ *
+ *  * arch_efi_call_virt()
+ *
+ *    Performs the call. The last expression in the macro must be the call
+ *    itself, allowing the logic to be shared by the void and non-void
+ *    cases.
+ *
+ *  * arch_efi_call_virt_teardown()
+ *
+ *    Restores the usual kernel environment once the call has returned.
+ */
+
+#define efi_call_virt_pointer(p, f, args...)                           \
+({                                                                     \
+       efi_status_t __s;                                               \
+       unsigned long __flags;                                          \
+                                                                       \
+       arch_efi_call_virt_setup();                                     \
+                                                                       \
+       local_save_flags(__flags);                                      \
+       __s = arch_efi_call_virt(p, f, args);                           \
+       efi_call_virt_check_flags(__flags, __stringify(f));             \
+                                                                       \
+       arch_efi_call_virt_teardown();                                  \
+                                                                       \
+       __s;                                                            \
+})
+
+#define __efi_call_virt_pointer(p, f, args...)                         \
+({                                                                     \
+       unsigned long __flags;                                          \
+                                                                       \
+       arch_efi_call_virt_setup();                                     \
+                                                                       \
+       local_save_flags(__flags);                                      \
+       arch_efi_call_virt(p, f, args);                                 \
+       efi_call_virt_check_flags(__flags, __stringify(f));             \
+                                                                       \
+       arch_efi_call_virt_teardown();                                  \
+})
+
 #endif /* _LINUX_EFI_H */