Skip to contentSkip to conversation

fix linuxboot.bin and multiboot.bin to not hijack int19

PATCH Superseded Gleb Natapov 3 participants 6 messages Jan 31, 2011 – Feb 2, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix linuxboot.bin and multiboot.bin to not hijack int19

Currently linuxboot.bin and multiboot.bin option roms override int19 vector to intercept boot process. No sane option rom should do that. Provide bev entry instead that will be called by BIOS if option rom is selected for booting.

---

Note that this patch should be applied after qemu will upgrade to Seabios that supports boot order. Otherwise there will be change in behavior since option rom will not be selected for booting by default.

pc-bios/optionrom/linuxboot.S +2 -0
index c109363..79b3ae8 100644
@@ -22,6 +22,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "Linux loader"
+
 BOOT_ROM_START
 
 run_linuxboot:
pc-bios/optionrom/multiboot.S +2 -0
index 9131837..069c4e8 100644
@@ -20,6 +20,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "multiboot loader"
+
 #define MULTIBOOT_MAGIC		0x2badb002
 
 #define GS_PROT_JUMP		0
pc-bios/optionrom/optionrom.h +27 -17

58 lines not on this page · raw message

--
Gleb.

#1 lore raw
Quoted 44 lines · Gleb Natapov

Currently linuxboot.bin and multiboot.bin option roms override int19 vector to intercept boot process. No sane option rom should do that. Provide bev entry instead that will be called by BIOS if option rom is selected for booting.

---

Note that this patch should be applied after qemu will upgrade to Seabios that supports boot order. Otherwise there will be change in behavior since option rom will not be selected for booting by default.

pc-bios/optionrom/linuxboot.S +2 -0
index c109363..79b3ae8 100644
@@ -22,6 +22,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "Linux loader"
+

BOOT_ROM_START

run_linuxboot:

pc-bios/optionrom/multiboot.S +2 -0
index 9131837..069c4e8 100644
@@ -20,6 +20,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "multiboot loader"
+
 #define MULTIBOOT_MAGIC		0x2badb002
 
 #define GS_PROT_JUMP		0
pc-bios/optionrom/optionrom.h +0 -0
index fbdd48a..95dbdda 100644
@@ -93,31 +93,41 @@
 	.global 	_start;				\

pc-bios/optionrom/optionrom.h line 102

Quoted 10 lines
pc-bios/optionrom/optionrom.h +7 -1
    _start:;						\
 	.short		0xaa55;				\
-	.byte		(_end - _start) / 512;
+	.byte		(_end - _start) / 512;		\
+	lret;						\
+	.org 		0x18;				\
+	.short		0;				\
+	.short		_pnph;				\
+    _pnph:						\
+	.ascii		"$PnP";				\

The idea behind the OPTION_ROM and BOOT_ROM split was to have a generic header that can be used as template for random option roms or boot roms alike. Your patch munges those two use-cases together by providing bev logic in the generic option rom part.

Please split it out into the BOOT_ROM macro, or - if necessary - create a new macro.

Alex

#2 lore raw
Quoted 6 lines · Alexander Graf
Quoted 1 line

The idea behind the OPTION_ROM and BOOT_ROM split was to have a generic header that can be used as template for random option roms or boot roms alike. Your patch munges those two use-cases together by providing bev logic in the generic option rom part.

Please split it out into the BOOT_ROM macro, or - if necessary - create a new macro.

Like this?

pc-bios/optionrom/linuxboot.S +2 -0
index c109363..79b3ae8 100644
@@ -22,6 +22,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "Linux loader"
+
 BOOT_ROM_START
 
 run_linuxboot:
pc-bios/optionrom/multiboot.S +2 -0
index 9131837..069c4e8 100644
@@ -20,6 +20,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "multiboot loader"
+
 #define MULTIBOOT_MAGIC		0x2badb002
 
 #define GS_PROT_JUMP		0
pc-bios/optionrom/optionrom.h +25 -15
index fbdd48a..2d4f40e 100644
@@ -97,27 +97,37 @@
 
 #define BOOT_ROM_START					\
 	OPTION_ROM_START				\
-	push		%eax;				\
-	push		%ds;				\
-							\
-	/* setup ds so we can access the IVT */		\
-	xor		%ax, %ax;			\
-	mov		%ax, %ds;			\
-							\
-	/* install our int 19 handler */		\
-	movw		$int19_handler, (0x19*4);	\
-	mov		%cs, (0x19*4+2);		\
-							\
-	pop		%ds;				\
-	pop		%eax;				\
 	lret;						\
-							\
-    int19_handler:;					\
+	.org 		0x18;				\
+	.short		0;				\
+	.short		_pnph;				\
+    _pnph:						\
+	.ascii		"$PnP";				\
+	.byte		0x01;				\
+	.byte		( _pnph_len / 16 );		\
+	.short		0x0000;				\
+	.byte		0x00;				\
+	.byte		0x00;				\
+	.long		0x00000000;			\
+	.short		_manufacturer;			\
+	.short		_product;			\
+	.long		0x00000000;			\
+	.short		0x0000;				\
+	.short		0x0000;				\
+	.short		_bev;				\
+	.short		0x0000;				\
+	.short		0x0000;				\
+	.equ		_pnph_len, . - _pnph;
+    _bev:;						\
 	/* DS = CS */					\
 	movw		%cs, %ax;			\
 	movw		%ax, %ds;
 
 #define OPTION_ROM_END					\
+    _manufacturer:;					\
+        .asciz "QEMU";					\
+    _product:;						\
+        .asciz PRODUCT;					\
     .align 512, 0;					\
     _end:
 

--
Gleb.

#3 lore raw
Quoted 14 lines · Gleb Natapov
Quoted 6 lines · Alexander Graf
Quoted 1 line

The idea behind the OPTION_ROM and BOOT_ROM split was to have a generic header that can be used as template for random option roms or boot roms alike. Your patch munges those two use-cases together by providing bev logic in the generic option rom part.

Please split it out into the BOOT_ROM macro, or - if necessary - create a new macro.

Like this?

pc-bios/optionrom/linuxboot.S +0 -0
index c109363..79b3ae8 100644

pc-bios/optionrom/linuxboot.S line 25

Quoted 4 lines
pc-bios/optionrom/linuxboot.S +1 -0
@@ -22,6 +22,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "Linux loader"

Please make this BOOT_ROM_PRODUCT

Otherwise, yes, a lot better :)

Alex

#4 lore raw
In reply to Gleb Natapov
Quoted 5 lines · Gleb Natapov

Currently linuxboot.bin and multiboot.bin option roms override int19 vector to intercept boot process. No sane option rom should do that. Provide bev entry instead that will be called by BIOS if option rom is selected for booting.

Quoted 7 lines

---

Note that this patch should be applied after qemu will upgrade to Seabios that supports boot order. Otherwise there will be change in behavior since option rom will not be selected for booting by default.

I don't think there's a SeaBIOS release yet that includes the boot order support.

Regards,

Anthony Liguori

Quoted 93 lines
pc-bios/optionrom/linuxboot.S +2 -0
index c109363..79b3ae8 100644
@@ -22,6 +22,8 @@
 
  #include "optionrom.h"
 
+#define PRODUCT "Linux loader"
+
  BOOT_ROM_START
 
  run_linuxboot:
pc-bios/optionrom/multiboot.S +2 -0
index 9131837..069c4e8 100644
@@ -20,6 +20,8 @@
 
  #include "optionrom.h"
 
+#define PRODUCT "multiboot loader"
+
  #define MULTIBOOT_MAGIC		0x2badb002
 
  #define GS_PROT_JUMP		0
pc-bios/optionrom/optionrom.h +27 -18
index fbdd48a..95dbdda 100644
@@ -93,31 +93,41 @@
  	.global 	_start;				\
      _start:;						\
  	.short		0xaa55;				\
-	.byte		(_end - _start) / 512;
+	.byte		(_end - _start) / 512;		\
+	lret;						\
+	.org 		0x18;				\
+	.short		0;				\
+	.short		_pnph;				\
+    _pnph:						\
+	.ascii		"$PnP";				\
+	.byte		0x01;				\
+	.byte		( _pnph_len / 16 );		\
+	.short		0x0000;				\
+	.byte		0x00;				\
+	.byte		0x00;				\
+	.long		0x00000000;			\
+	.short		_manufacturer;			\
+	.short		_product;			\
+	.long		0x00000000;			\
+	.short		0x0000;				\
+	.short		0x0000;				\
+	.short		_bev;				\
+	.short		0x0000;				\
+	.short		0x0000;				\
+	.equ		_pnph_len, . - _pnph;
 
  #define BOOT_ROM_START					\
  	OPTION_ROM_START				\
-	push		%eax;				\
-	push		%ds;				\
-							\
-	/* setup ds so we can access the IVT */		\
-	xor		%ax, %ax;			\
-	mov		%ax, %ds;			\
-							\
-	/* install our int 19 handler */		\
-	movw		$int19_handler, (0x19*4);	\
-	mov		%cs, (0x19*4+2);		\
-							\
-	pop		%ds;				\
-	pop		%eax;				\
-	lret;						\
-							\
-    int19_handler:;					\
+    _bev:;						\
  	/* DS = CS */					\
  	movw		%cs, %ax;			\
  	movw		%ax, %ds;
 
  #define OPTION_ROM_END					\
+    _manufacturer:;					\
+        .asciz "QEMU";					\
+    _product:;						\
+        .asciz PRODUCT;					\
      .align 512, 0;					\
      _end:
 
--

Gleb.

#5 lore raw
Quoted 9 lines · Anthony Liguori
Quoted 8 lines · Gleb Natapov

Currently linuxboot.bin and multiboot.bin option roms override int19 vector to intercept boot process. No sane option rom should do that. Provide bev entry instead that will be called by BIOS if option rom is selected for booting.

---

Quoted 7 lines
Quoted 3 lines

Note that this patch should be applied after qemu will upgrade to Seabios that supports boot order. Otherwise there will be change in behavior since option rom will not be selected for booting by default.

I don't think there's a SeaBIOS release yet that includes the boot order support.

I thought for AHCI support you are going to move to latest Seabios HEAD. If this is not the case the patch should wait.

Quoted 93 lines

Regards,

Anthony Liguori

Quoted 89 lines
pc-bios/optionrom/linuxboot.S +2 -0
index c109363..79b3ae8 100644
@@ -22,6 +22,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "Linux loader"
+
 BOOT_ROM_START
 
 run_linuxboot:
pc-bios/optionrom/multiboot.S +2 -0
index 9131837..069c4e8 100644
@@ -20,6 +20,8 @@
 
 #include "optionrom.h"
 
+#define PRODUCT "multiboot loader"
+
 #define MULTIBOOT_MAGIC		0x2badb002
 
 #define GS_PROT_JUMP		0
pc-bios/optionrom/optionrom.h +27 -17
index fbdd48a..95dbdda 100644
@@ -93,31 +93,41 @@
 	.global 	_start;				\
     _start:;						\
 	.short		0xaa55;				\
-	.byte		(_end - _start) / 512;
+	.byte		(_end - _start) / 512;		\
+	lret;						\
+	.org 		0x18;				\
+	.short		0;				\
+	.short		_pnph;				\
+    _pnph:						\
+	.ascii		"$PnP";				\
+	.byte		0x01;				\
+	.byte		( _pnph_len / 16 );		\
+	.short		0x0000;				\
+	.byte		0x00;				\
+	.byte		0x00;				\
+	.long		0x00000000;			\
+	.short		_manufacturer;			\
+	.short		_product;			\
+	.long		0x00000000;			\
+	.short		0x0000;				\
+	.short		0x0000;				\
+	.short		_bev;				\
+	.short		0x0000;				\
+	.short		0x0000;				\
+	.equ		_pnph_len, . - _pnph;
 
 #define BOOT_ROM_START					\
 	OPTION_ROM_START				\
-	push		%eax;				\
-	push		%ds;				\
-							\
-	/* setup ds so we can access the IVT */		\
-	xor		%ax, %ax;			\
-	mov		%ax, %ds;			\
-							\
-	/* install our int 19 handler */		\
-	movw		$int19_handler, (0x19*4);	\
-	mov		%cs, (0x19*4+2);		\
-							\
-	pop		%ds;				\
-	pop		%eax;				\
-	lret;						\
-							\
-    int19_handler:;					\
+    _bev:;						\
 	/* DS = CS */					\
 	movw		%cs, %ax;			\
 	movw		%ax, %ds;
 
 #define OPTION_ROM_END					\
+    _manufacturer:;					\
+        .asciz "QEMU";					\
+    _product:;						\
+        .asciz PRODUCT;					\
     .align 512, 0;					\
     _end:
 
Quoted 3 lines
Quoted 3 lines

--
Gleb.

--
Gleb.