Re: [PATCH 10/10] efi/libstub/x86: avoid thunking for native firmware calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux