Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1431081 > unrolled thread
| Started by | Matt Fleming <matt@codeblueprint.co.uk> |
|---|---|
| First post | 2016-06-25 09:30 +0200 |
| Last post | 2016-06-27 15:10 +0200 |
| Articles | 10 — 5 participants |
Back to article view | Back to linux.kernel
[GIT PULL 0/7] EFI changes for v4.8 Matt Fleming <matt@codeblueprint.co.uk> - 2016-06-25 09:30 +0200
[PATCH 6/7] x86/efi: Update efi_thunk to use the the arch_efi_call_virt* macros Matt Fleming <matt@codeblueprint.co.uk> - 2016-06-25 09:30 +0200
[tip:efi/core] x86/efi: Update efi_thunk() to use the the arch_efi_call_virt*() macros tip-bot for Alex Thorlton <tipbot@zytor.com> - 2016-06-27 15:10 +0200
[PATCH 1/7] efibc: Report more information in the error messages Matt Fleming <matt@codeblueprint.co.uk> - 2016-06-25 09:30 +0200
[tip:efi/core] efibc: Report more information in the error messages "tip-bot for Compostella, Jeremy" <tipbot@zytor.com> - 2016-06-27 15:10 +0200
[PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer Matt Fleming <matt@codeblueprint.co.uk> - 2016-06-25 09:30 +0200
Re: [PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer Ingo Molnar <mingo@kernel.org> - 2016-06-27 13:10 +0200
Re: [PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer Mark Rutland <mark.rutland@arm.com> - 2016-06-27 13:30 +0200
Re: [PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer Matt Fleming <matt@codeblueprint.co.uk> - 2016-07-04 15:20 +0200
[tip:efi/core] efi: Convert efi_call_virt() to efi_call_virt_pointer() tip-bot for Alex Thorlton <tipbot@zytor.com> - 2016-06-27 15:10 +0200
| From | Matt Fleming <matt@codeblueprint.co.uk> |
|---|---|
| Date | 2016-06-25 09:30 +0200 |
| Subject | [GIT PULL 0/7] EFI changes for v4.8 |
| Message-ID | <rNQcp-2yr-5@gated-at.bofh.it> |
Folks, please pull the v4.8 EFI queue. Included are some cleanups and
fixes for SGI/UV BIOS calls.
The following changes since commit 5edb56491d4812c42175980759da53388e5d86f5:
Linux 4.7-rc3 (2016-06-12 07:20:35 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git tags/efi-next
for you to fetch changes up to bc6e082f7a4bec4efde100b5b6528f5a2ea82106:
x86/efi: Remove unused efi_get_time function (2016-06-23 14:32:14 +0100)
----------------------------------------------------------------
* Improve error messages in the efibc driver by providing more
information about why the errors occurred - Jeremy Compostella
* Document the formatting of the EFI GUID constants - Peter Jones
* Remove an unused variable to fix a clang build warning - Colin King
* Refactor the EFI runtime services code so that it can be used for
function pointers outside of efi.systab->runtime, e.g. during
SGI/UV BIOS and EFI mixed mode calls - Alex Thorlton
* Remove the unused efi_get_time() function which also suffers from
the 32-bit time_t overflow in 2038 issue - Arnd Bergmann
----------------------------------------------------------------
Alex Thorlton (3):
efi: Convert efi_call_virt to efi_call_virt_pointer
x86/uv: Update uv_bios_call to use efi_call_virt_pointer
x86/efi: Update efi_thunk to use the the arch_efi_call_virt* macros
Arnd Bergmann (1):
x86/efi: Remove unused efi_get_time function
Colin Ian King (1):
x86/efi: Remove unused variable efi
Compostella, Jeremy (1):
efibc: Report more information in the error messages
Peter Jones (1):
efi: Document #define FOO_PROTOCOL_GUID layout
arch/arm/include/asm/efi.h | 4 +-
arch/arm64/include/asm/efi.h | 4 +-
arch/x86/boot/compressed/eboot.c | 2 -
arch/x86/include/asm/efi.h | 9 ++---
arch/x86/platform/efi/efi.c | 15 -------
arch/x86/platform/efi/efi_64.c | 11 ++----
arch/x86/platform/uv/bios_uv.c | 3 +-
drivers/firmware/efi/efibc.c | 6 ++-
drivers/firmware/efi/runtime-wrappers.c | 53 +++++--------------------
include/linux/efi.h | 69 ++++++++++++++++++++++++++++++++-
10 files changed, 93 insertions(+), 83 deletions(-)
[toc] | [next] | [standalone]
| From | Matt Fleming <matt@codeblueprint.co.uk> |
|---|---|
| Date | 2016-06-25 09:30 +0200 |
| Subject | [PATCH 6/7] x86/efi: Update efi_thunk to use the the arch_efi_call_virt* macros |
| Message-ID | <rNQcq-2yr-19@gated-at.bofh.it> |
| In reply to | #1431081 |
From: Alex Thorlton <athorlton@sgi.com> Currently, the efi_thunk macro has some semi-duplicated code in it that can be replaced with the arch_efi_call_virt_setup/teardown macros. This commit simply replaces the duplicated code with those macros. Signed-off-by: Alex Thorlton <athorlton@sgi.com> Suggested-by: Matt Fleming <matt@codeblueprint.co.uk> Cc: Russ Anderson <rja@sgi.com> Cc: Dimitri Sivanich <sivanich@sgi.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Roy Franz <roy.franz@linaro.org> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-efi@vger.kernel.org Cc: x86@kernel.org Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk> --- arch/x86/platform/efi/efi_64.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 6e7242be1c87..4cc2b9688dc2 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -469,18 +469,13 @@ extern efi_status_t efi64_thunk(u32, ...); unsigned long flags; \ u32 func; \ \ - efi_sync_low_kernel_mappings(); \ local_irq_save(flags); \ - \ - efi_scratch.prev_cr3 = read_cr3(); \ - write_cr3((unsigned long)efi_scratch.efi_pgt); \ - __flush_tlb_all(); \ + arch_efi_call_virt_setup(); \ \ func = runtime_service32(f); \ - __s = efi64_thunk(func, __VA_ARGS__); \ + __s = efi64_thunk(func, __VA_ARGS__); \ \ - write_cr3(efi_scratch.prev_cr3); \ - __flush_tlb_all(); \ + arch_efi_call_virt_teardown(); \ local_irq_restore(flags); \ \ __s; \ -- 2.7.3
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Alex Thorlton <tipbot@zytor.com> |
|---|---|
| Date | 2016-06-27 15:10 +0200 |
| Subject | [tip:efi/core] x86/efi: Update efi_thunk() to use the the arch_efi_call_virt*() macros |
| Message-ID | <rOEsy-DU-45@gated-at.bofh.it> |
| In reply to | #1431082 |
Commit-ID: 21f866257c7027f8f49bfde83f559f9e58f9ee93
Gitweb: http://git.kernel.org/tip/21f866257c7027f8f49bfde83f559f9e58f9ee93
Author: Alex Thorlton <athorlton@sgi.com>
AuthorDate: Sat, 25 Jun 2016 08:20:29 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 27 Jun 2016 13:06:57 +0200
x86/efi: Update efi_thunk() to use the the arch_efi_call_virt*() macros
Currently, the efi_thunk macro has some semi-duplicated code in it that
can be replaced with the arch_efi_call_virt_setup/teardown macros. This
commit simply replaces the duplicated code with those macros.
Suggested-by: Matt Fleming <matt@codeblueprint.co.uk>
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-7-git-send-email-matt@codeblueprint.co.uk
[ Renamed variables to the standard __ prefix. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/platform/efi/efi_64.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index b226b3f..5cb4301 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -466,22 +466,17 @@ extern efi_status_t efi64_thunk(u32, ...);
#define efi_thunk(f, ...) \
({ \
efi_status_t __s; \
- unsigned long flags; \
- u32 func; \
+ unsigned long __flags; \
+ u32 __func; \
\
- efi_sync_low_kernel_mappings(); \
- local_irq_save(flags); \
+ local_irq_save(__flags); \
+ arch_efi_call_virt_setup(); \
\
- efi_scratch.prev_cr3 = read_cr3(); \
- write_cr3((unsigned long)efi_scratch.efi_pgt); \
- __flush_tlb_all(); \
+ __func = runtime_service32(f); \
+ __s = efi64_thunk(__func, __VA_ARGS__); \
\
- func = runtime_service32(f); \
- __s = efi64_thunk(func, __VA_ARGS__); \
- \
- write_cr3(efi_scratch.prev_cr3); \
- __flush_tlb_all(); \
- local_irq_restore(flags); \
+ arch_efi_call_virt_teardown(); \
+ local_irq_restore(__flags); \
\
__s; \
})
[toc] | [prev] | [next] | [standalone]
| From | Matt Fleming <matt@codeblueprint.co.uk> |
|---|---|
| Date | 2016-06-25 09:30 +0200 |
| Subject | [PATCH 1/7] efibc: Report more information in the error messages |
| Message-ID | <rNQcq-2yr-23@gated-at.bofh.it> |
| In reply to | #1431081 |
From: "Compostella, Jeremy" <jeremy.compostella@intel.com>
Report the name of the EFI variable if the value size is too large or
if efibc_set_variable() fails to allocate the struct efivar_entry
object. If efibc_set_variable() fails because the value size is too
large, it also reports the value size in the error message.
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Reported-by: Robert Elliott <elliott@hpe.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
drivers/firmware/efi/efibc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c
index 8dd0c7085e59..568335d4239a 100644
--- a/drivers/firmware/efi/efibc.c
+++ b/drivers/firmware/efi/efibc.c
@@ -37,13 +37,15 @@ static int efibc_set_variable(const char *name, const char *value)
size_t size = (strlen(value) + 1) * sizeof(efi_char16_t);
if (size > sizeof(entry->var.Data)) {
- pr_err("value is too large");
+ pr_err("value is too large (%zu bytes) for %s EFI variable\n",
+ size, name);
return -EINVAL;
}
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (!entry) {
- pr_err("failed to allocate efivar entry");
+ pr_err("failed to allocate efivar entry for %s EFI variable\n",
+ name);
return -ENOMEM;
}
--
2.7.3
[toc] | [prev] | [next] | [standalone]
| From | "tip-bot for Compostella, Jeremy" <tipbot@zytor.com> |
|---|---|
| Date | 2016-06-27 15:10 +0200 |
| Subject | [tip:efi/core] efibc: Report more information in the error messages |
| Message-ID | <rOEsy-DU-33@gated-at.bofh.it> |
| In reply to | #1431083 |
Commit-ID: 5356c32742bd51c8c57065d2389a2c4bc036adcd
Gitweb: http://git.kernel.org/tip/5356c32742bd51c8c57065d2389a2c4bc036adcd
Author: Compostella, Jeremy <jeremy.compostella@intel.com>
AuthorDate: Sat, 25 Jun 2016 08:20:24 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 27 Jun 2016 13:06:54 +0200
efibc: Report more information in the error messages
Report the name of the EFI variable if the value size is too large,
or if efibc_set_variable() fails to allocate the 'struct efivar_entry'
object.
If efibc_set_variable() fails because the 'size' value is too
large, it also reports this value in the error message.
Reported-by: Robert Elliott <elliott@hpe.com>
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1466839230-12781-2-git-send-email-matt@codeblueprint.co.uk
[ Minor readability edits. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
drivers/firmware/efi/efibc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c
index 8dd0c70..503bbe2 100644
--- a/drivers/firmware/efi/efibc.c
+++ b/drivers/firmware/efi/efibc.c
@@ -37,13 +37,13 @@ static int efibc_set_variable(const char *name, const char *value)
size_t size = (strlen(value) + 1) * sizeof(efi_char16_t);
if (size > sizeof(entry->var.Data)) {
- pr_err("value is too large");
+ pr_err("value is too large (%zu bytes) for '%s' EFI variable\n", size, name);
return -EINVAL;
}
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (!entry) {
- pr_err("failed to allocate efivar entry");
+ pr_err("failed to allocate efivar entry for '%s' EFI variable\n", name);
return -ENOMEM;
}
[toc] | [prev] | [next] | [standalone]
| From | Matt Fleming <matt@codeblueprint.co.uk> |
|---|---|
| Date | 2016-06-25 09:30 +0200 |
| Subject | [PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer |
| Message-ID | <rNQcq-2yr-21@gated-at.bofh.it> |
| In reply to | #1431081 |
From: Alex Thorlton <athorlton@sgi.com>
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>
Cc: Russ Anderson <rja@sgi.com>
Cc: Dimitri Sivanich <sivanich@sgi.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Roy Franz <roy.franz@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-efi@vger.kernel.org
Cc: x86@kernel.org
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
arch/arm/include/asm/efi.h | 4 +--
arch/arm64/include/asm/efi.h | 4 +--
arch/x86/include/asm/efi.h | 9 +++---
drivers/firmware/efi/runtime-wrappers.c | 53 +++++++--------------------------
include/linux/efi.h | 51 +++++++++++++++++++++++++++++++
5 files changed, 69 insertions(+), 52 deletions(-)
diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h
index a708fa1f0905..766bf9b78160 100644
--- a/arch/arm/include/asm/efi.h
+++ b/arch/arm/include/asm/efi.h
@@ -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); \
})
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index 622db3c6474e..bd887663689b 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -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); \
})
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index 78d1e7467eae..55b4596ef688 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -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() \
({ \
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index 23bef6bb73ee..6a364f525a4f 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -22,7 +22,16 @@
#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;
@@ -39,48 +48,6 @@ static 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(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
* serialized. (source: UEFI Specification v2.4A)
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 03009695760d..a5f6f75936eb 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -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 */
--
2.7.3
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2016-06-27 13:10 +0200 |
| Subject | Re: [PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer |
| Message-ID | <rOCAq-7Tb-9@gated-at.bofh.it> |
| In reply to | #1431084 |
* Matt Fleming <matt@codeblueprint.co.uk> wrote:
> +#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(); \
> +})
Note that while at it I renamed 'flags' to '__flags' because 'flags' is
a commonly used variable name and the 'efi_status_t __s' variable was
macro-prefixed already.
Any objections?
Thanks,
Ingo
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2016-06-27 13:30 +0200 |
| Subject | Re: [PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer |
| Message-ID | <rOCTM-809-37@gated-at.bofh.it> |
| In reply to | #1431926 |
On Mon, Jun 27, 2016 at 01:00:50PM +0200, Ingo Molnar wrote:
>
> * Matt Fleming <matt@codeblueprint.co.uk> wrote:
>
> > +#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(); \
> > +})
>
> Note that while at it I renamed 'flags' to '__flags' because 'flags' is
> a commonly used variable name and the 'efi_status_t __s' variable was
> macro-prefixed already.
>
> Any objections?
FWIW, none from me. I probably should have done that when I wrote the
original {__,}efi_call_virt macros.
Thanks,
Mark.
[toc] | [prev] | [next] | [standalone]
| From | Matt Fleming <matt@codeblueprint.co.uk> |
|---|---|
| Date | 2016-07-04 15:20 +0200 |
| Subject | Re: [PATCH 4/7] efi: Convert efi_call_virt to efi_call_virt_pointer |
| Message-ID | <rRbX4-63R-27@gated-at.bofh.it> |
| In reply to | #1431926 |
On Mon, 27 Jun, at 01:00:50PM, Ingo Molnar wrote: > > Note that while at it I renamed 'flags' to '__flags' because 'flags' is > a commonly used variable name and the 'efi_status_t __s' variable was > macro-prefixed already. > > Any objections? Nope, that's fine.
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Alex Thorlton <tipbot@zytor.com> |
|---|---|
| Date | 2016-06-27 15:10 +0200 |
| Subject | [tip:efi/core] efi: Convert efi_call_virt() to efi_call_virt_pointer() |
| Message-ID | <rOEsy-DU-29@gated-at.bofh.it> |
| In reply to | #1431084 |
Commit-ID: 80e75596079f0a41f905836ad0ccaac68ba33612
Gitweb: http://git.kernel.org/tip/80e75596079f0a41f905836ad0ccaac68ba33612
Author: Alex Thorlton <athorlton@sgi.com>
AuthorDate: Sat, 25 Jun 2016 08:20:27 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 27 Jun 2016 13:06:56 +0200
efi: Convert efi_call_virt() to efi_call_virt_pointer()
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 | 4 +--
arch/arm64/include/asm/efi.h | 4 +--
arch/x86/include/asm/efi.h | 9 +++---
drivers/firmware/efi/runtime-wrappers.c | 53 +++++++--------------------------
include/linux/efi.h | 51 +++++++++++++++++++++++++++++++
5 files changed, 69 insertions(+), 52 deletions(-)
diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h
index a708fa1..766bf9b 100644
--- a/arch/arm/include/asm/efi.h
+++ b/arch/arm/include/asm/efi.h
@@ -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); \
})
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index 622db3c..bd88766 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -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); \
})
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index 78d1e74..55b4596 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -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() \
({ \
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index 23bef6b..4195877 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -22,7 +22,16 @@
#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;
@@ -39,48 +48,6 @@ static 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(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
* serialized. (source: UEFI Specification v2.4A)
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 0300969..75d148d 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -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 */
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web