Parcourir la source

From: Laszlo Ersek <lersek@redhat.com>
Date: Mon, 2 Jun 2014 23:26:48 +0200
Subject: [PATCH] always observe EFIAPI calling convention when calling
STO.SetAttribute

We have to consider the following cases wrt. the PRINT_STATE.Output and
PRINT_STATE.SetAttr EFIAPI function pointers, especially when building for
x86_64 with gcc:

(1) The compiler is new enough, and EFIAPI actually ensures the Microsoft
calling convention. In this case everything happens to work fine even
if we forget uefi_call_wrapper(), because the wrapper would expand to
a normal C function call anyway.

(2) Otherwise (ie. gcc is old), EFIAPI expands to nothing, and we must
take into account the called function's origin:

(2a) If the callee that is declared EFIAPI is *defined* inside gnu-efi,
then EFIAPI means nothing for the callee too, so caller and callee
only understand each other if the caller intentionally omits
uefi_call_wrapper().

(2b) If the callee that is declared EFIAPI is defined by the platform
UEFI implementation, then the caller *must* use
uefi_call_wrapper().

The PRINT_STATE.Output EFIAPI function pointer is dereferenced correctly:
the PFLUSH() distinguishes cases (2a) from (2b) by using IsLocalPrint().

However use of the PRINT_STATE.SetAttr EFIAPI function pointer is not
always correct:

- The PSETATTR() helper function always relies on the wrapper (case (2b)).
This is correct, because PRINT_STATE.SetAttr always points to a
platform-provided function.

- The DbgPrint() function contains two incorrect calls: they mistakenly
assume case (2a) (or case (1)), even though the pointer always points to
a platform function, implying (2b). (The error is masked in case (1).)
Fix them.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hp.com>

Nigel Croxon il y a 11 ans
Parent
commit
6caab22f23
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      gnu-efi-3.0/lib/print.c

+ 2 - 2
gnu-efi-3.0/lib/print.c

@@ -257,7 +257,7 @@ Returns:
 
     if (ps.SetAttr) {
         ps.Attr = attr;
-        ps.SetAttr (ps.Context, attr);
+        uefi_call_wrapper(ps.SetAttr, 2, ps.Context, attr);
     }
 
     _Print (&ps);
@@ -270,7 +270,7 @@ Returns:
     //
 
     if (ps.SetAttr) {
-        ps.SetAttr (ps.Context, SavedAttribute);
+        uefi_call_wrapper(ps.SetAttr, 2, ps.Context, SavedAttribute);
     }
     
     return 0;