Skip to contentSkip to conversation

efi: stub out __grub_efi_api when GRUB_UTIL is defined

PATCH In review Mike Gilbert 2 participants 5 messages Nov 30, 2024 – Mar 31, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: stub out __grub_efi_api when GRUB_UTIL is defined

ms_abi is not a valid attribute on x32 (__x86_64__ && __ILP32__). This ABI should be unnecessary for utils anyway.

---
 include/grub/efi/api.h | 4 ++++
 1 file changed, 4 insertions(+)
include/grub/efi/api.h +4 -0
index b686e8afe..8b70be5e7 100644
@@ -590,6 +590,7 @@ typedef grub_efi_uintn_t grub_efi_status_t;
  * annotation. (This includes protocols implemented by GRUB that are installed
  * into the EFI protocol database.)
  */
+#if !defined(GRUB_UTIL)
 #if defined(__i386__)
 #define __grub_efi_api			__attribute__((regparm(0)))
 #elif defined(__x86_64__)
@@ -597,6 +598,9 @@ typedef grub_efi_uintn_t grub_efi_status_t;
 #else
 #define __grub_efi_api
 #endif
+#else /* defined(GRUB_UTIL) */
+#define __grub_efi_api
+#endif
 
 #define GRUB_EFI_ERROR_CODE(value)	\
   ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))
Signature · 7 lines
2.47.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw
Quoted 4 lines · Mike Gilbert

ms_abi is not a valid attribute on x32 (__x86_64__ && __ILP32__). This ABI should be unnecessary for utils anyway.

These utils are host tools, right? E.g., grub-install, update-grub, etc running under the OS?

Why are those using headers that define EFI APIs?

Quoted 29 lines
---
 include/grub/efi/api.h | 4 ++++
 1 file changed, 4 insertions(+)
include/grub/efi/api.h +4 -1
index b686e8afe..8b70be5e7 100644
@@ -590,6 +590,7 @@ typedef grub_efi_uintn_t grub_efi_status_t;
  * annotation. (This includes protocols implemented by GRUB that are installed
  * into the EFI protocol database.)
  */
+#if !defined(GRUB_UTIL)
 #if defined(__i386__)
 #define __grub_efi_api                 __attribute__((regparm(0)))
 #elif defined(__x86_64__)
@@ -597,6 +598,9 @@ typedef grub_efi_uintn_t grub_efi_status_t;
 #else
 #define __grub_efi_api
 #endif
+#else /* defined(GRUB_UTIL) */
+#define __grub_efi_api
+#endif
 
 #define GRUB_EFI_ERROR_CODE(value)     \
   ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))
--
Quoted 2 lines

2.47.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 9 lines · Ard Biesheuvel
Quoted 4 lines · Mike Gilbert

ms_abi is not a valid attribute on x32 (__x86_64__ && __ILP32__). This ABI should be unnecessary for utils anyway.

These utils are host tools, right? E.g., grub-install, update-grub, etc running under the OS?

Yes, these are the host tools.

Quoted 1 line

Why are those using headers that define EFI APIs?

The "grub-file" program has grub-core/commands/file.c listed as one of its sources in Makefile.util.def.

grub-core/commands/file.c includes grub/efi/efi.h, which pulls in grub/efi/api.h.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 14 lines · Mike Gilbert
Quoted 9 lines · Ard Biesheuvel
Quoted 4 lines · Mike Gilbert

ms_abi is not a valid attribute on x32 (__x86_64__ && __ILP32__). This ABI should be unnecessary for utils anyway.

These utils are host tools, right? E.g., grub-install, update-grub, etc running under the OS?

Yes, these are the host tools.

Quoted 7 lines
Quoted 1 line

Why are those using headers that define EFI APIs?

The "grub-file" program has grub-core/commands/file.c listed as one of its sources in Makefile.util.def.

grub-core/commands/file.c includes grub/efi/efi.h, which pulls in grub/efi/api.h.

If I remove #include <grub/efi/efi.h> from grub-core/commands/file.c, it causes a couple of errors:

grub-core/commands/file.c: In function ‘grub_cmd_file’:
grub-core/commands/file.c:392:41: error: storage size of ‘lh’ isn’t known
392 | struct linux_arch_kernel_header lh;
| ^~
In file included from ./include/grub/dl.h:26,
from grub-core/commands/file.c:19:
grub-core/commands/file.c:404:44: error:
‘GRUB_LINUX_ARM_MAGIC_SIGNATURE’ undeclared (first use in this function); did you mean ‘GRUB_LINUX_I386_MAGIC_SIGNATURE’?
404 | grub_cpu_to_le32_compile_time
(GRUB_LINUX_ARM_MAGIC_SIGNATURE))

     |                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
In reply to Mike Gilbert
Quoted 9 lines · Mike Gilbert

ms_abi is not a valid attribute on x32 (__x86_64__ && __ILP32__). This ABI should be unnecessary for utils anyway.

---
 include/grub/efi/api.h | 4 ++++
 1 file changed, 4 insertions(+)

Could we please get this patch merged before the next release?

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel