Skip to contentSkip to conversation

multiboot2: set min address for mbi allocation to 0x1000

PATCH Superseded Lukasz Hawrylko 2 participants 2 messages Dec 13, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multiboot2: set min address for mbi allocation to 0x1000

In some cases GRUB2 allocates multiboot2 structure at 0 address, that is a confusing behavior, so define min address for mbi allocation in x86 and x86_64 platforms

---
 grub-core/loader/multiboot_mbi2.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
grub-core/loader/multiboot_mbi2.c +7 -1
index 53da78615..18e766c7b 100644
@@ -48,6 +48,12 @@
 #define HAS_VGA_TEXT 0
 #endif
 
+#if defined (__i386__) || defined (__x86_64__)
+#define MBI_MIN_ADDR 0x1000
+#else
+#define MBI_MIN_ADDR 0
+#endif
+
 struct module
 {
   struct module *next;
@@ -708,7 +714,7 @@ grub_multiboot2_make_mbi (grub_uint32_t *target)
   COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0);
 
   err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch,
-					  0, 0xffffffff - bufsize,
+					  MBI_MIN_ADDR, 0xffffffff - bufsize,
 					  bufsize, MULTIBOOT_TAG_ALIGN,
 					  GRUB_RELOCATOR_PREFERENCE_NONE, 1);
   if (err)
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Lukasz Hawrylko

In some cases GRUB2 allocates multiboot2 structure at 0 address, that is a confusing behavior, so define min address for mbi allocation in x86

Could you explain why this behavior is confusing?

Quoted 3 lines

and x86_64 platforms

Otherwise LGTM. If you add what I am asking for above then you can add

of patch.

Daniel