Skip to contentSkip to conversation

multiboot: fix e801 memory map

PATCH Applied Paolo Bonzini 3 participants 9 messages Nov 29, 2012 – Nov 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multiboot: fix e801 memory map

The e801 memory sizes in the multiboot structures hard-code the available low memory to 640. However, the value should not include the size of the EBDA. Fill the value in the option ROM, getting the size of low memory from the BIOS.

---
Alex, can you ack this patch for 1.3?

 pc-bios/multiboot.bin         | Bin 1024 -> 1024 bytes
 pc-bios/optionrom/multiboot.S |   7 +++++++
 2 files changed, 7 insertions(+)
pc-bios/multiboot.bin binary +0 -0
index f74a6e142fddc054d7f40ab346a108532afac40f..7b3c1745a430ea5e0e15b9aa817d1cbbaa40db14 100644
GIT binary patch
pc-bios/optionrom/multiboot.S +7 -0
index f08222a..003bcfb 100644
@@ -75,6 +75,13 @@ run_multiboot:
 	shr		$4, %eax
 	mov		%ax, %fs
 
+	/* Account for the EBDA in the multiboot structure's e801
+	 * map.
+	 */
+	int		$0x12
+	cwtl
+	movl		%eax, %fs:4
+
 	/* ES = mmap_addr */
 	mov 		%fs:48, %eax
 	shr		$4, %eax
Signature · 1 line
1.8.0
#1 lore raw

PATCH 1/1 multiboot: fix e801 memory map

The e801 memory sizes in the multiboot structures hard-code the available low memory to 640. However, the value should not include the size of the EBDA. Fill the value in the option ROM, getting the size of low memory from the BIOS.

---
 pc-bios/multiboot.bin         | Bin 1024 -> 1024 bytes
 pc-bios/optionrom/multiboot.S |   7 +++++++
 2 files changed, 7 insertions(+)
pc-bios/multiboot.bin binary +0 -0
index f74a6e142fddc054d7f40ab346a108532afac40f..7b3c1745a430ea5e0e15b9aa817d1cbbaa40db14 100644
GIT binary patch
pc-bios/optionrom/multiboot.S +7 -0
index f08222a..003bcfb 100644
@@ -75,6 +75,13 @@ run_multiboot:
 	shr		$4, %eax
 	mov		%ax, %fs
 
+	/* Account for the EBDA in the multiboot structure's e801
+	 * map.
+	 */
+	int		$0x12
+	cwtl
+	movl		%eax, %fs:4
+
 	/* ES = mmap_addr */
 	mov 		%fs:48, %eax
 	shr		$4, %eax
Signature · 1 line
1.8.0
#2 lore raw
In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini

The e801 memory sizes in the multiboot structures hard-code the available low memory to 640. However, the value should not include the size of the EBDA. Fill the value in the option ROM, getting the size of low memory from the BIOS.

---
Alex, can you ack this patch for 1.3?

Do you have a test case (OS that fails for example)?

Alex

Quoted 37 lines

pc-bios/multiboot.bin | Bin 1024 -> 1024 bytes
pc-bios/optionrom/multiboot.S | 7 +++++++

2 files changed, 7 insertions(+)
pc-bios/multiboot.bin binary +0 -0
index f74a6e142fddc054d7f40ab346a108532afac40f..7b3c1745a430ea5e0e15b9aa817d1cbbaa40db14 100644
GIT binary patch
pc-bios/optionrom/multiboot.S +7 -0
index f08222a..003bcfb 100644
@@ -75,6 +75,13 @@ run_multiboot:
 	shr		$4, %eax
 	mov		%ax, %fs
 
+	/* Account for the EBDA in the multiboot structure's e801
+	 * map.
+	 */
+	int		$0x12
+	cwtl
+	movl		%eax, %fs:4
+
 	/* ES = mmap_addr */
 	mov 		%fs:48, %eax
 	shr		$4, %eax
Signature · 1 line
1.8.0
#3 lore raw
In reply to Paolo Bonzini
Quoted 4 lines · Paolo Bonzini

The e801 memory sizes in the multiboot structures hard-code the available low memory to 640. However, the value should not include the size of the EBDA. Fill the value in the option ROM, getting the size of low memory from the BIOS.

The description mentions that instead of hard coding, you fetch the value dynamically via a BIOS call. However, I don't see the code that hard codes it changed. Where is that one?

Alex

Quoted 42 lines

---
Alex, can you ack this patch for 1.3?

pc-bios/multiboot.bin | Bin 1024 -> 1024 bytes
pc-bios/optionrom/multiboot.S | 7 +++++++

2 files changed, 7 insertions(+)
pc-bios/multiboot.bin binary +0 -0
index f74a6e142fddc054d7f40ab346a108532afac40f..7b3c1745a430ea5e0e15b9aa817d1cbbaa40db14 100644
GIT binary patch
pc-bios/optionrom/multiboot.S +7 -0
index f08222a..003bcfb 100644
@@ -75,6 +75,13 @@ run_multiboot:
 	shr		$4, %eax
 	mov		%ax, %fs
 
+	/* Account for the EBDA in the multiboot structure's e801
+	 * map.
+	 */
+	int		$0x12
+	cwtl
+	movl		%eax, %fs:4
+
 	/* ES = mmap_addr */
 	mov 		%fs:48, %eax
 	shr		$4, %eax
Signature · 1 line
1.8.0
#4 lore raw

----- Messaggio originale -----

Quoted 9 lines

Da: "Alexander Graf" <[email protected]>
A: "Paolo Bonzini" <[email protected]>
Cc: [email protected]
Inviato: Giovedì, 29 novembre 2012 19:51:07
Oggetto: Re: [PATCH 1.3?] multiboot: fix e801 memory map

On 29.11.2012, at 18:11, Paolo Bonzini wrote:

Quoted 8 lines
Quoted 4 lines

The e801 memory sizes in the multiboot structures hard-code the available low memory to 640. However, the value should not include the size of the EBDA. Fill the value in the option ROM, getting the size of low memory from the BIOS.

The description mentions that instead of hard coding, you fetch the value dynamically via a BIOS call. However, I don't see the code that hard codes it changed. Where is that one?

It is in hw/multiboot.c:

    stl_p(bootinfo + MBI_MEM_LOWER,   640);

Regarding the testcase, Xen will touch the EBDA without this patch and with http://permalink.gmane.org/gmane.comp.emulators.xen.devel/144855.
However, SeaBIOS does not complain.

Paolo

#5 lore raw
Quoted 17 lines · Paolo Bonzini

----- Messaggio originale -----

Quoted 14 lines

Da: "Alexander Graf" <[email protected]>
A: "Paolo Bonzini" <[email protected]>
Cc: [email protected]
Inviato: Giovedì, 29 novembre 2012 19:51:07
Oggetto: Re: [PATCH 1.3?] multiboot: fix e801 memory map

Quoted 4 lines · Paolo Bonzini

The e801 memory sizes in the multiboot structures hard-code the available low memory to 640. However, the value should not include the size of the EBDA. Fill the value in the option ROM, getting the size of low memory from the BIOS.

Quoted 7 lines
Quoted 3 lines

The description mentions that instead of hard coding, you fetch the value dynamically via a BIOS call. However, I don't see the code that hard codes it changed. Where is that one?

It is in hw/multiboot.c:

   stl_p(bootinfo + MBI_MEM_LOWER,   640);

You want to remove that one then.

Quoted 3 lines

Regarding the testcase, Xen will touch the EBDA without this patch and with http://permalink.gmane.org/gmane.comp.emulators.xen.devel/144855.
However, SeaBIOS does not complain.

I see :). Well, the patch is unintrusive enough for be ok for 1.3 IMHO.

Alex

#6 lore raw

Il 29/11/2012 20:24, Alexander Graf ha scritto:

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

It is in hw/multiboot.c:

   stl_p(bootinfo + MBI_MEM_LOWER,   640);

You want to remove that one then.

I wasn't sure of what happens if the multiboot option ROM is old. Do we support that to any extent?

Quoted 5 lines
Quoted 3 lines

Regarding the testcase, Xen will touch the EBDA without this patch and with http://permalink.gmane.org/gmane.comp.emulators.xen.devel/144855.
However, SeaBIOS does not complain.

I see :). Well, the patch is unintrusive enough for be ok for 1.3 IMHO.

Actually it's relatively easy to see a failure with Xen and a need to PCI passthrough something with a bulky boot ROM; iSCSI or FC cards will do. You'll need both the Xen patch above, and this patch to boot successfully. Otherwise, it will fail to boot.

Paolo

#7 lore raw
Quoted 8 lines · Paolo Bonzini

Il 29/11/2012 20:24, Alexander Graf ha scritto:

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

It is in hw/multiboot.c:

   stl_p(bootinfo + MBI_MEM_LOWER,   640);

You want to remove that one then.

I wasn't sure of what happens if the multiboot option ROM is old. Do we support that to any extent?

Option ROMs are migrated but reset after reboot. I guess you could migrate before the option ROM is executed but that seems extraordinarily unlikely.

Regards,

Anthony Liguori

Quoted 13 lines
Quoted 6 lines
Quoted 4 lines

Regarding the testcase, Xen will touch the EBDA without this patch and with http://permalink.gmane.org/gmane.comp.emulators.xen.devel/144855.
However, SeaBIOS does not complain.

I see :). Well, the patch is unintrusive enough for be ok for 1.3 IMHO.

Actually it's relatively easy to see a failure with Xen and a need to PCI passthrough something with a bulky boot ROM; iSCSI or FC cards will do. You'll need both the Xen patch above, and this patch to boot successfully. Otherwise, it will fail to boot.

Paolo

#8 lore raw
In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini

The e801 memory sizes in the multiboot structures hard-code the available low memory to 640. However, the value should not include the size of the EBDA. Fill the value in the option ROM, getting the size of low memory from the BIOS.

---
Alex, can you ack this patch for 1.3?

Applied. Thanks.

Didn't see a clear ack from Alex but since this does fix a bug, I figured we should carry it for 1.3.

Regards,

Anthony Liguori

Quoted 36 lines
 pc-bios/multiboot.bin         | Bin 1024 -> 1024 bytes
 pc-bios/optionrom/multiboot.S |   7 +++++++
 2 files changed, 7 insertions(+)
pc-bios/multiboot.bin binary +0 -0
index f74a6e142fddc054d7f40ab346a108532afac40f..7b3c1745a430ea5e0e15b9aa817d1cbbaa40db14 100644
GIT binary patch
pc-bios/optionrom/multiboot.S +7 -0
index f08222a..003bcfb 100644
@@ -75,6 +75,13 @@ run_multiboot:
 	shr		$4, %eax
 	mov		%ax, %fs
 
+	/* Account for the EBDA in the multiboot structure's e801
+	 * map.
+	 */
+	int		$0x12
+	cwtl
+	movl		%eax, %fs:4
+
 	/* ES = mmap_addr */
 	mov 		%fs:48, %eax
 	shr		$4, %eax
Signature · 1 line
1.8.0