lkml.org 
[lkml]   [2019]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 10/10] efi/libstub/x86: avoid thunking for native firmware calls
On Sat, Dec 14, 2019 at 06:57:35PM +0100, Ard Biesheuvel wrote:
>
> @@ -232,7 +232,7 @@ static inline bool efi_is_native(void)
> #define efi_table_attr(table, attr, instance) ({ \
> __typeof__(((table##_t *)0)->attr) __ret; \
> if (efi_is_native()) { \
> - __ret = ((table##_t *)instance)->attr; \
> + __ret = instance->attr; \
> } else { \
> __typeof__(((table##_32_t *)0)->attr) at; \
> at = (((table##_32_t *)(unsigned long)instance)->attr); \

Is there a reason we didn't remove this cast for native-mode earlier in
the series?

> @@ -242,19 +242,25 @@ static inline bool efi_is_native(void)
> })
>
> #define efi_call_proto(protocol, f, instance, ...) \
> - __efi_early()->call((unsigned long) \
> + efi_is_native() \
> + ? instance->f(instance, ##__VA_ARGS__) \
> + : efi64_thunk((unsigned long) \
> efi_table_attr(protocol, f, instance), \
> - instance, ##__VA_ARGS__)
> + instance, ##__VA_ARGS__)
>
> #define efi_call_early(f, ...) \
> - __efi_early()->call((unsigned long) \
> + efi_is_native() \
> + ? __efi_early()->boot_services->f(__VA_ARGS__) \
> + : efi64_thunk((unsigned long) \
> efi_table_attr(efi_boot_services, f, \
> - __efi_early()->boot_services), __VA_ARGS__)
> + __efi_early()->boot_services), __VA_ARGS__)
>
> #define efi_call_runtime(f, ...) \
> - __efi_early()->call((unsigned long) \
> + efi_is_native() \
> + ? __efi_early()->runtime_services->f(__VA_ARGS__) \
> + : efi64_thunk((unsigned long) \
> efi_table_attr(efi_runtime_services, f, \
> - __efi_early()->runtime_services), __VA_ARGS__)
> + __efi_early()->runtime_services), __VA_ARGS__)
>
> extern bool efi_reboot_required(void);
> extern bool efi_is_table_address(unsigned long phys_addr);

For the efi_call macros, their definition should be enclosed in
parentheses now that it's a ternary operator.

\
 
 \ /
  Last update: 2019-12-15 20:32    [W:0.101 / U:1.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site