grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [EXTERNAL] Re: grub-2.06 fails to load 64bit Multiboot2 ELF with reg


From: Baksik, Fred [USA]
Subject: RE: [EXTERNAL] Re: grub-2.06 fails to load 64bit Multiboot2 ELF with regions above 4GiB
Date: Fri, 23 Jun 2023 15:10:36 +0000

That is only true when boot services is enabled.  Which is not always true.

The OS we are loading does not include the boot services tag.

 

Also it looks like the 4GiB limit was introduced with support of the 3.1.13 Relocatable header tag.

It appears that the extra restriction on non-relocatable images was interjected as a side effect.  Refer to multiboot2: Add support for relocatable images · rhboot/grub2@a620876 · GitHub

 

--

Fred Baksik

Senior Principal Software Engineer

Mercury Systems

Office: +1 (978) 967-3405

fred.baksik@mrcy.com | mrcy.com | Innovation That Matters

 

From: Daniel Kiper <dkiper@net-space.pl>
Sent: Friday, June 23, 2023 10:25 AM
To: Baksik, Fred [USA] <fred.baksik@mrcy.com>
Cc: grub-devel@gnu.org
Subject: [EXTERNAL] Re: grub-2.06 fails to load 64bit Multiboot2 ELF with regions above 4GiB

 

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Hi,

On Fri, Jun 16, 2023 at 10:50:14AM +0000, Baksik, Fred [USA] via Grub-devel wrote:
>
> I tried report this issue to the bug-grub mailing list but didn’t see the Bug
> Tracker get updated.
> I’d like to get this reported so anyone else using multiboot2 to boot and
> embedded RTOS knows of this problem.
>  
> I also supplied a patch that fixes the issue.
>  
> Regards,
> Fred Baksik
> Sr Prin Software Engineer
> Systems | Mission
> Mercury Systems
> 6675 Shiloh Road East, Alpharetta, GA 30005
> +1_978.967.3405 office
>
> fred.baksik@mrcy.com | mrcy.com
>  
> From: Baksik, Fred [USA]
> Sent: Wednesday, May 24, 2023 9:14 AM
> To: bug-grub@gnu.org
> Subject: grub-2.06 fails to load 64bit Multiboot2 ELF with regions above 4GiB
>  
> GRUB2 fails to load a Multiboot2 ELF with loadable regions above 4GiB.  The
> error seen is “segment crosses 4 GiB border”.
>  
> The 4 GiB border check was added as part of “multiboot2: Add support for
> relocatable images” commit a620876e3b32e4ea0c9a7b3541fcb9a4dd4fb9eb.
> I believe this check should only apply when the multiboot2 image supports
> relocation via the MULTIBOOT_HEADER_TAG_RELOCATABLE tag.
>  
> Subject: [PATCH] multiboot2: check 4GiB limit for relocatable images only
>  
> ---
> grub-core/loader/multiboot_elfxx.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>  
> diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/
> multiboot_elfxx.c
> index f2318e0..0ac11f0 100644
> --- a/grub-core/loader/multiboot_elfxx.c
> +++ b/grub-core/loader/multiboot_elfxx.c
> @@ -92,10 +92,6 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld)
>     highest_load = grub_max (highest_load, phdr(i)->p_paddr + phdr(i)-
> >p_memsz);
>        }
>  
> -#ifdef MULTIBOOT_LOAD_ELF64
> -  if (highest_load >= 0x100000000)
> -    return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border");
> -#endif
>  
>    if (mld->relocatable)
>      {
> @@ -106,6 +102,11 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld)
>               (long) mld->align, mld->preference, load_size,
>               mld->avoid_efi_boot_services);
>  
> +#ifdef MULTIBOOT_LOAD_ELF64
> +      if (highest_load >= 0x100000000)
> +        return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border");
> +#endif
> +
>        if (load_size > mld->max_addr || mld->min_addr > mld->max_addr -
> load_size)
>     return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load
> size");

Unfortunately your fix is incorrect. Here [1] is the explanation why.
The paragraph gives also some hints how to properly add 64-bit support
to the Multiboot2 protocol. I hope that helps.

Daniel

[1] https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#EFI-amd64-machine-state-with-boot-services-enabled


reply via email to

[Prev in Thread] Current Thread [Next in Thread]