]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Switch back to VA_START() etc macros for EFIAPI functions
authorMichael Brown <mcb30@ipxe.org>
Tue, 11 Nov 2025 14:45:01 +0000 (14:45 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 11 Nov 2025 15:41:42 +0000 (15:41 +0000)
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 <mcb30@ipxe.org>
src/interface/efi/efi_wrap.c

index 8c3f41e3b1660653d9caabb8e4ed0fbae208ce57..936074f2a5769e7844ba12fa68a3a164e3f7c20c 100644 (file)
@@ -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, "<FATAL: too many arguments> ) = %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, "<FATAL: too many arguments> ) = %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],