Re: [PATCH 1/3] Convert efi_call_virt to efi_call_virt_generic
On Thu, Jun 02, 2016 at 04:41:14PM +0100, Matt Fleming wrote: > Oops, you're missing updates to the 32-bit version and ARM/arm64, > which results in this, > > drivers/firmware/efi/runtime-wrappers.c: In function ‘virt_efi_get_time’: > arch/x86/include/asm/efi.h:46:4: error: ‘efi_efi’ undeclared (first use in > this function) > ((efi_##f##_t __attribute__((regparm(0)))*) \ > ^ > > but that's easily fixed up. Oops! Sorry about that. I had done a pretty recent pull before I did my last build, but it was probably before these updates came in. I'll rebase my patches onto the latest tip kernel and fix this. > > +/* > > + * 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_generic(efi.systab->runtime, f, args) > > +#define __efi_call_virt(f, args...) \ > > + __efi_call_virt_generic(efi.systab->runtime, f, args) > > + > > +void efi_call_virt_check_flags(unsigned long flags, const char *call) > > { > > unsigned long cur_flags, mismatch; > > > > I'm not crazy about using "generic" in the name. How about > efi_call_virt_function() or efi_call_virt_pointer()? I'm not married to "generic." I'll change it to efi_call_virt_pointer. I think efi_call_virt_function is a little confusing/redundant, since a call is always to a function, right? I will fix this stuff up and send a v2. Thanks for looking this over, Matt! - Alex
Re: [PATCH 1/3] Convert efi_call_virt to efi_call_virt_generic
On Wed, 18 May, at 02:11:39PM, Alex Thorlton wrote: > 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_generic. 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_generic 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_generic macro a > bit in the process of moving it. > > Signed-off-by: Alex Thorlton > Cc: Matt Fleming > Cc: Borislav Petkov > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Mike Travis > Cc: Russ Anderson > Cc: Dimitri Sivanich > Cc: x...@kernel.org > Cc: linux-...@vger.kernel.org > --- > arch/x86/include/asm/efi.h | 4 +-- > drivers/firmware/efi/runtime-wrappers.c | 53 > +++-- > include/linux/efi.h | 51 +++ > 3 files changed, 63 insertions(+), 45 deletions(-) > > diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h > index 78d1e74..f310f0b 100644 > --- a/arch/x86/include/asm/efi.h > +++ b/arch/x86/include/asm/efi.h > @@ -81,8 +81,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() > \ > ({ \ Oops, you're missing updates to the 32-bit version and ARM/arm64, which results in this, drivers/firmware/efi/runtime-wrappers.c: In function ‘virt_efi_get_time’: arch/x86/include/asm/efi.h:46:4: error: ‘efi_efi’ undeclared (first use in this function) ((efi_##f##_t __attribute__((regparm(0)))*) \ ^ but that's easily fixed up. > diff --git a/drivers/firmware/efi/runtime-wrappers.c > b/drivers/firmware/efi/runtime-wrappers.c > index 23bef6b..e8bc493 100644 > --- a/drivers/firmware/efi/runtime-wrappers.c > +++ b/drivers/firmware/efi/runtime-wrappers.c > @@ -22,7 +22,16 @@ > #include > #include > > -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_generic(efi.systab->runtime, f, args) > +#define __efi_call_virt(f, args...) \ > + __efi_call_virt_generic(efi.systab->runtime, f, args) > + > +void efi_call_virt_check_flags(unsigned long flags, const char *call) > { > unsigned long cur_flags, mismatch; > I'm not crazy about using "generic" in the name. How about efi_call_virt_function() or efi_call_virt_pointer()?
[PATCH 1/3] Convert efi_call_virt to efi_call_virt_generic
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_generic. 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_generic 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_generic macro a bit in the process of moving it. Signed-off-by: Alex Thorlton Cc: Matt Fleming Cc: Borislav Petkov Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Mike Travis Cc: Russ Anderson Cc: Dimitri Sivanich Cc: x...@kernel.org Cc: linux-...@vger.kernel.org --- arch/x86/include/asm/efi.h | 4 +-- drivers/firmware/efi/runtime-wrappers.c | 53 +++-- include/linux/efi.h | 51 +++ 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 78d1e74..f310f0b 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -81,8 +81,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..e8bc493 100644 --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -22,7 +22,16 @@ #include #include -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_generic(efi.systab->runtime, f, args) +#define __efi_call_virt(f, args...) \ + __efi_call_virt_generic(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,