From c0ac23fc56e5f46b8101cb2be7e96b277dd8f51d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 11 Nov 2025 14:45:01 +0000 Subject: [PATCH] [efi] Switch back to VA_START() etc macros for EFIAPI functions Commit 670810b ("[efi] Use standard va_args macros instead of VA_START() etc") fixed a 32-bit RISC-V build error, but broke the functionality of the InstallMultipleProtocolInterfaces() and UninstallMultipleProtocolInterfaces() wrapper functions. GCC does not automatically check the ABI of the current function when using the __builtin_va_start() and related macros, and it is therefore necessary for code to use __builtin_ms_va_start() etc from within functions marked as EFIAPI. Since commit 9016f2e ("[efi] Skip including the EDK2 ProcessorBind.h header for 32-bit RISC-V") has now fixed the original 32-bit RISC-V build error, we can switch back to using the EDK2 VA_START() etc macros to obtain the correct behaviour. Signed-off-by: Michael Brown --- src/interface/efi/efi_wrap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 8c3f41e3b..936074f2a 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -1082,7 +1082,7 @@ efi_install_multiple_protocol_interfaces_wrapper ( EFI_HANDLE *handle, ... ) { void *retaddr = __builtin_return_address ( 0 ); EFI_GUID *protocol[ MAX_WRAP_MULTI + 1 ]; VOID *interface[MAX_WRAP_MULTI]; - va_list ap; + VA_LIST ap; unsigned int i; EFI_STATUS efirc; @@ -1090,20 +1090,20 @@ efi_install_multiple_protocol_interfaces_wrapper ( EFI_HANDLE *handle, ... ) { efi_handle_name ( *handle ) ); memset ( protocol, 0, sizeof ( protocol ) ); memset ( interface, 0, sizeof ( interface ) ); - va_start ( ap, handle ); - for ( i = 0 ; ( protocol[i] = va_arg ( ap, EFI_GUID * ) ) ; i++ ) { + VA_START ( ap, handle ); + for ( i = 0 ; ( protocol[i] = VA_ARG ( ap, EFI_GUID * ) ) ; i++ ) { if ( i == MAX_WRAP_MULTI ) { - va_end ( ap ); + VA_END ( ap ); efirc = EFI_OUT_OF_RESOURCES; DBGC ( colour, " ) = %s " "-> %p\n", efi_status ( efirc ), retaddr ); return efirc; } - interface[i] = va_arg ( ap, VOID * ); + interface[i] = VA_ARG ( ap, VOID * ); DBGC ( colour, ", %s, %p", efi_guid_ntoa ( protocol[i] ), interface[i] ); } - va_end ( ap ); + VA_END ( ap ); DBGC ( colour, " ) " ); efirc = bs->InstallMultipleProtocolInterfaces ( handle, protocol[0], interface[0], protocol[1], interface[1], @@ -1132,7 +1132,7 @@ efi_uninstall_multiple_protocol_interfaces_wrapper ( EFI_HANDLE handle, ... ) { void *retaddr = __builtin_return_address ( 0 ); EFI_GUID *protocol[ MAX_WRAP_MULTI + 1 ]; VOID *interface[MAX_WRAP_MULTI]; - va_list ap; + VA_LIST ap; unsigned int i; EFI_STATUS efirc; @@ -1140,20 +1140,20 @@ efi_uninstall_multiple_protocol_interfaces_wrapper ( EFI_HANDLE handle, ... ) { efi_handle_name ( handle ) ); memset ( protocol, 0, sizeof ( protocol ) ); memset ( interface, 0, sizeof ( interface ) ); - va_start ( ap, handle ); - for ( i = 0 ; ( protocol[i] = va_arg ( ap, EFI_GUID * ) ) ; i++ ) { + VA_START ( ap, handle ); + for ( i = 0 ; ( protocol[i] = VA_ARG ( ap, EFI_GUID * ) ) ; i++ ) { if ( i == MAX_WRAP_MULTI ) { - va_end ( ap ); + VA_END ( ap ); efirc = EFI_OUT_OF_RESOURCES; DBGC ( colour, " ) = %s " "-> %p\n", efi_status ( efirc ), retaddr ); return efirc; } - interface[i] = va_arg ( ap, VOID * ); + interface[i] = VA_ARG ( ap, VOID * ); DBGC ( colour, ", %s, %p", efi_guid_ntoa ( protocol[i] ), interface[i] ); } - va_end ( ap ); + VA_END ( ap ); DBGC ( colour, " ) " ); efirc = bs->UninstallMultipleProtocolInterfaces ( handle, protocol[0], interface[0], protocol[1], interface[1],