[RFC PATCH 22/36] efi/runtime-wrappers: Permit architectures to override IRQ flags checks

Jinjie Ruan ruanjinjie at huawei.com
Mon Jul 13 01:27:02 PDT 2026



On 7/9/2026 8:13 PM, Vladimir Murzin wrote:
> Representation of IRQ flags on arm64 has recently changed. They now
> track both DAIF and PMR state while remaining compatible with the
> irqflags API by encoding the state in an unsigned long.
> 
> While the generic check can still detect corruption of the IRQ flags
> caused by EFI runtime services, the resulting error message is cryptic
> because it does not understand the arm64-specific representation.
> 
> Permit architectures to override the IRQ flags checks and associated
> error messages, while keeping the existing implementation as the
> default.

Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>

> 
> Signed-off-by: Vladimir Murzin <vladimir.murzin at arm.com>
> ---
>  drivers/firmware/efi/runtime-wrappers.c | 32 +++++++++++++++----------
>  1 file changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
> index da8d29621644..498fb3612643 100644
> --- a/drivers/firmware/efi/runtime-wrappers.c
> +++ b/drivers/firmware/efi/runtime-wrappers.c
> @@ -137,6 +137,25 @@ struct efi_runtime_work efi_rts_work;
>  #define arch_efi_restore_flags(state_flags)	local_irq_restore(state_flags)
>  #endif
>  
> +#ifndef arch_efi_check_flags
> +#define arch_efi_check_flags(state_flags, caller) 							\
> +do {													\
> +	unsigned long cur_flags, mismatch;								\
> +													\
> +	cur_flags = efi_call_virt_save_flags();								\
> +													\
> +	mismatch = state_flags ^ cur_flags;								\
> +	if (!WARN_ON_ONCE(mismatch & ARCH_EFI_IRQ_FLAGS_MASK))						\
> +		break;											\
> +													\
> +	add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_NOW_UNRELIABLE); 					\
> +	pr_err_ratelimited(FW_BUG "IRQ flags corrupted (0x%08lx=>0x%08lx) by EFI call from %pS\n",	\
> +			   state_flags, cur_flags,							\
> +			   caller ?: __builtin_return_address(0));					\
> +	arch_efi_restore_flags(state_flags);								\
> +} while(0);
> +#endif
> +
>  unsigned long efi_call_virt_save_flags(void)
>  {
>  	unsigned long flags;
> @@ -147,18 +166,7 @@ unsigned long efi_call_virt_save_flags(void)
>  
>  void efi_call_virt_check_flags(unsigned long flags, const void *caller)
>  {
> -	unsigned long cur_flags, mismatch;
> -
> -	cur_flags = efi_call_virt_save_flags();
> -
> -	mismatch = flags ^ cur_flags;
> -	if (!WARN_ON_ONCE(mismatch & ARCH_EFI_IRQ_FLAGS_MASK))
> -		return;
> -
> -	add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_NOW_UNRELIABLE);
> -	pr_err_ratelimited(FW_BUG "IRQ flags corrupted (0x%08lx=>0x%08lx) by EFI call from %pS\n",
> -			   flags, cur_flags, caller ?: __builtin_return_address(0));
> -	arch_efi_restore_flags(flags);
> +	arch_efi_check_flags(flags, caller);
>  }
>  
>  /*




More information about the linux-arm-kernel mailing list