diff mbox series

[5/7] multiboot2: Add support for 64-bit entry addresses

Message ID 20240313150748.791236-6-ross.lagerwall@citrix.com (mailing list archive)
State New, archived
Headers show
Series GRUB: Supporting Secure Boot of xen.gz | expand

Commit Message

Ross Lagerwall March 13, 2024, 3:07 p.m. UTC
Add support for entry addresses that may be either 32 bits or 64 bits in
size. This may be necessary if the binary is built with an entry address
above 4G.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 grub-core/loader/multiboot_mbi2.c | 10 ++++++++--
 include/multiboot2.h              |  6 +++++-
 2 files changed, 13 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
index 3ec96e2f29b9..c268aa614284 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -205,13 +205,19 @@  grub_multiboot2_load (grub_file_t file, const char *filename)
 
       case MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS:
 	entry_specified = 1;
-	entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr;
+	if ((tag->size - sizeof(struct multiboot_header_tag)) == sizeof(multiboot_uint64_t))
+	  entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr64;
+	else
+	  entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr32;
 	break;
 
       case MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64:
 #if defined (GRUB_MACHINE_EFI) && defined (__x86_64__)
 	efi_entry_specified = 1;
-	efi_entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr;
+	if ((tag->size - sizeof(struct multiboot_header_tag)) == sizeof(multiboot_uint64_t))
+	  efi_entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr64;
+	else
+	  efi_entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr32;
 #endif
 	break;
 
diff --git a/include/multiboot2.h b/include/multiboot2.h
index f4377bf7b394..e4798bfef937 100644
--- a/include/multiboot2.h
+++ b/include/multiboot2.h
@@ -140,7 +140,11 @@  struct multiboot_header_tag_entry_address
   multiboot_uint16_t type;
   multiboot_uint16_t flags;
   multiboot_uint32_t size;
-  multiboot_uint32_t entry_addr;
+  union
+  {
+    multiboot_uint32_t entry_addr32;
+    multiboot_uint64_t entry_addr64;
+  };
 };
 
 struct multiboot_header_tag_console_flags