Re: [PATCH v4 5/5] efi: Use generic EFI loader for x86_64 and i386

2023-05-23 Thread Ard Biesheuvel
On Tue, 23 May 2023 at 17:32, Ard Biesheuvel wrote: > > Switch the x86 based EFI platform builds to the generic EFI loader, > which exposes the initrd via the LoadFile2 protocol instead of the > x86-specific setup header. This will launch the Linux kernel via its EFI > stub, which performs its own

[PATCH v4 2/5] efi: Add calling convention annotation to all prototypes

2023-05-23 Thread Ard Biesheuvel
UEFI mandates MS calling convention on x86_64, which was not supported on GCC when UEFI support was first introduced into GRUB. However, now we can use the ms_abi function type attribute to annotate functions and function pointers as adhering to the MS calling convention, and the compiler will gene

[PATCH v4 4/5] efi: Remove x86_64 call wrappers

2023-05-23 Thread Ard Biesheuvel
The call wrappers are no longer needed now that GCC can generate function calls using MS calling convention, so let's get rid of them. Signed-off-by: Ard Biesheuvel --- grub-core/Makefile.core.def | 1 - grub-core/kern/x86_64/efi/callwrap.S | 129 include/grub/efi

[PATCH v4 3/5] efi: Drop all uses of efi_call_XX wrappers

2023-05-23 Thread Ard Biesheuvel
Now that GCC can generate function calls using the correct calling convention for us, we can stop using the efi_call_XX () wrappers, and just dereference the function pointers directly. This avoids the untyped variadic wrapper routines, which means better type checking for the method calls. Signe

[PATCH v4 1/5] efi: Make EFI PXE protocol methods non-callable

2023-05-23 Thread Ard Biesheuvel
The grub_efi_pxe_t struct definition has placeholders for the various protocol method pointers, given that they are never called in the code, and the prototypes have been omitted, and therefore do not comply with the UEFI spec. So let's convert them into void* pointers, so they cannot be called in

[PATCH v4 0/5] efi: Implement generic EFI boot for x86

2023-05-23 Thread Ard Biesheuvel
Switch the i386-efi and x86_64-efi builds to the generic EFI loader, which enters the Linux kernel via the EFI stub and provides the initrd via the LoadFile2 protocol. This unifies x86 with other EFI architectures, and removes the dependency on the setup header and struct bootparams. Do some prepa

[PATCH v4 5/5] efi: Use generic EFI loader for x86_64 and i386

2023-05-23 Thread Ard Biesheuvel
Switch the x86 based EFI platform builds to the generic EFI loader, which exposes the initrd via the LoadFile2 protocol instead of the x86-specific setup header. This will launch the Linux kernel via its EFI stub, which performs its own initialization in the EFI boot services context before calling

Re: [PATCH v3 0/5] efi: Implement generic EFI boot for x86

2023-05-23 Thread Daniel Kiper
On Tue, May 23, 2023 at 10:23:50AM +0200, Ard Biesheuvel wrote: > Switch the i386-efi and x86_64-efi builds to the generic EFI loader, > which enters the Linux kernel via the EFI stub and provides the initrd > via the LoadFile2 protocol. This unifies x86 with other EFI > architectures, and removes

Re: [PATCH 0/4] Address coverity untrusted loop bound bugs in multiboot_elfxx.c

2023-05-23 Thread Daniel Kiper
On Mon, May 22, 2023 at 04:52:45PM -0400, Alec Brown wrote: > Coverity has listed two untrusted loop bound bugs in > grub-core/loader/multiboot_elfxx.c. They are CID 314029 and CID 314038. After > testing the first patch, the CID changed to an untrusted loop bound for line > 244: shdr = grub_calloc

[PATCH v3 1/5] efi: Make EFI PXE protocol methods non-callable

2023-05-23 Thread Ard Biesheuvel
The grub_efi_pxe_t struct definition has placeholders for the various protocol method pointers, given that they are never called in the code, and the prototypes have been omitted, and therefore do not comply with the UEFI spec. So let's convert them into void* pointers, so they cannot be called in

[PATCH v3 5/5] efi: Use generic EFI loader for x86_64 and i386

2023-05-23 Thread Ard Biesheuvel
Switch the x86 based EFI platform builds to the generic EFI loader, which exposes the initrd via the LoadFile2 protocol instead of the x86-specific setup header. This will launch the Linux kernel via its EFI stub, which performs its own initialization in the EFI boot services context before calling

[PATCH v3 2/5] efi: Add calling convention annotation to all prototypes

2023-05-23 Thread Ard Biesheuvel
UEFI mandates MS calling convention on x86_64, which was not supported on GCC when UEFI support was first introduced into GRUB. However, now we can use the ms_abi function type attribute to annotate functions and function pointers as adhering to the MS calling convention, and the compiler will gene

[PATCH v3 0/5] efi: Implement generic EFI boot for x86

2023-05-23 Thread Ard Biesheuvel
Switch the i386-efi and x86_64-efi builds to the generic EFI loader, which enters the Linux kernel via the EFI stub and provides the initrd via the LoadFile2 protocol. This unifies x86 with other EFI architectures, and removes the dependency on the setup header and struct bootparams. Do some prepa

[PATCH v3 3/5] efi: Drop all uses of efi_call_XX wrappers

2023-05-23 Thread Ard Biesheuvel
Now that GCC can generate function calls using the correct calling convention for us, we can stop using the efi_call_XX () wrappers, and just dereference the function pointers directly. This avoids the untyped variadic wrapper routines, which means better type checking for the method calls. Signe

[PATCH v3 4/5] efi: Remove x86_64 call wrappers

2023-05-23 Thread Ard Biesheuvel
The call wrappers are no longer needed now that GCC can generate function calls using MS calling convention, so let's get rid of them. Signed-off-by: Ard Biesheuvel --- grub-core/Makefile.core.def | 1 - grub-core/kern/x86_64/efi/callwrap.S | 129 include/grub/efi