Skip to contentSkip to conversation

Memory Map information: GRUB2 vs. Legacy GRUB (GRUB1)

DISCUSSION Francis Shim 2 participants 4 messages Aug 12, 2009 – Aug 14, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

I am developing an eductional/hobby OS that is multiboot-compliant that has been booted by Legacy GRUB successfully. In this particular instance, I am examining the Memory Map information that I obtain from the Multiboot Information structure that Legacy GRUB returns successfully. Available and reserved areas appear to be collated correctly.

However, when I boot using GRUB2, the Memory Map seems to have been written over.

Some observations:
1) Legacy GRUB seems to use a combination of ELF and Multiboot header
information to boot the OS image; however, GRUB2 using the "multiboot" kernel type will use strictly Multiboot protocol.
2) The Memory Map information under GRUB2 seems to be "zeroed" which
leads me to believe that there must be something different in the way Legacy GRUB and GRUB2 handle Data and BSS segments (ie: initializing data by zeroing out).

I am using GRUB2 version 1.96 from the Fedora RPM repository; hence, I wanted to know if a later SVN version has a fix or is there a change in the specifications.

Peace,
Frank

#1 lore raw
Quoted 7 lines

However, when I boot using GRUB2, the Memory Map seems to have been written over.

Some observations:
 1) Legacy GRUB seems to use a combination of ELF and Multiboot header information to boot the OS image; however, GRUB2 using the "multiboot" kernel type will use strictly Multiboot protocol.

Both booters behave the same way about this. Loading ELF is a part of multiboot

Quoted 4 lines

 2) The Memory Map information under GRUB2 seems to be "zeroed" which leads me to believe that there must be something different in the way Legacy GRUB and GRUB2 handle Data and BSS segments (ie: initializing data by zeroing out).

The most common reason is the OS zeroing it out. Legacy put the memory map in lowmem. GRUB2 puts it just after the kernel image. Some kernels may overwrite it during an initialisation phase.

Quoted 4 lines

I am using GRUB2 version 1.96 from the Fedora RPM repository; hence, I wanted to know if a later SVN version has a fix or is there a change in the specifications.

Specifications are the same but we fixed a lot of bugs.

Quoted 12 lines

Peace,
Frank

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

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#2 lore raw

Hi Vlad (phcoder),

Quoted 8 lines · Vladimir 'phcoder' Serbinenko
Quoted 7 lines

However, when I boot using GRUB2, the Memory Map seems to have been written over.

Some observations:
1) Legacy GRUB seems to use a combination of ELF and Multiboot header
information to boot the OS image; however, GRUB2 using the "multiboot" kernel type will use strictly Multiboot protocol.

Both booters behave the same way about this. Loading ELF is a part of multiboot

Understood. I was not sure if there was some ELF/A.OUT/Multiboot file format that I might be missing out; hence, my query.

Quoted 7 lines
Quoted 4 lines

2) The Memory Map information under GRUB2 seems to be "zeroed" which
leads me to believe that there must be something different in the way Legacy GRUB and GRUB2 handle Data and BSS segments (ie: initializing data by zeroing out).

The most common reason is the OS zeroing it out. Legacy put the memory map in lowmem. GRUB2 puts it just after the kernel image. Some kernels may overwrite it during an initialisation phase.

That will explain it. If GRUB2 puts the memory map just after the kernel image then it means that the OS cannot assume that the memory range immediately after the kernel image is free. In fact, the multiboot OS "must" use the provided memory map to decide what ranges of memory are available for "dynamic memory" and which of it is free. I mistakenly thought that the memory map will always be in low memory and only assume that the first 1 MB of physical memory should be left alone at boot time to preserve the information.

BTW, why the difference? Was putting multiboot information (eg: memory map) in low memory clobbering BIOS information or the VGA/EGA/CGA memory mapped areas? Just curious.

Thanks for clearing that up!

Peace,
Frank

Quoted 8 lines
Quoted 4 lines

I am using GRUB2 version 1.96 from the Fedora RPM repository; hence, I wanted to know if a later SVN version has a fix or is there a change in the specifications.

Specifications are the same but we fixed a lot of bugs.

Quoted 3 lines

Peace,
Frank

#3 lore raw
Quoted 17 lines
Quoted 7 lines
Quoted 4 lines

 2) The Memory Map information under GRUB2 seems to be "zeroed" which leads me to believe that there must be something different in the way Legacy GRUB and GRUB2 handle Data and BSS segments (ie: initializing data by zeroing out).

The most common reason is the OS zeroing it out. Legacy put the memory map in lowmem. GRUB2 puts it just after the kernel image. Some kernels may overwrite it during an initialisation phase.

That will explain it.  If GRUB2 puts the memory map just after the kernel image then it means that the OS cannot assume that the memory range immediately after the kernel image is free.  In fact, the multiboot OS "must" use the provided memory map to decide what ranges of memory are available for "dynamic memory" and which of it is free.  I mistakenly thought that the memory map will always be in low memory and only assume that the first 1 MB of physical memory should be left alone at boot time to preserve the information.

Quoted 3 lines

BTW, why the difference?  Was putting multiboot information (eg: memory map) in low memory clobbering BIOS information or the VGA/EGA/CGA memory mapped areas?  Just curious.

Multiboot specification never promised anything about where mbi is stored. Read it here:
http://www.gnu.org/software/grub/manual/multiboot/. Don't assume anythin not explicitly stated in this document

Quoted 23 lines

Thanks for clearing that up!

Peace,
Frank

Quoted 8 lines
Quoted 4 lines

I am using GRUB2 version 1.96 from the Fedora RPM repository; hence, I wanted to know if a later SVN version has a fix or is there a change in the specifications.

Specifications are the same but we fixed a lot of bugs.

Quoted 3 lines

Peace,
Frank

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

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git