seabios bug: fail to find etc/boot-fail-wait
./qemu-upstream-latest -boot reboot-timeout=1000 ... (after boot failed, VM waits for 1000 ms and try to reboot)
reboot-timeout parameter doesn't work now, I found this regression bug was introduced by commit 59d6ca52a7eba5b1f4f2becf70fd446dccaf0a2e
Quoted 11 lines
Author: Kevin O'Connor <[email protected]> Date: Thu May 31 00:20:55 2012 -0400Cache romfile entries.
Create a 'struct
romfile_s' and populate a list of all romfiles at start of init. Caching the romfiles both simplifies the code and makes it more efficient.Also, convert the ramdisk code to use romfile helpers instead of directly accessing cbfs.
romfile_add() is used to add rom files in the list. When seabios calls boot_fail(), the list becomes empty, romfile_find("etc/boot-fail-wait", ..) returns NULL. it seems the list items are released prematurely.
Thanks, Amos
Quoted 2 lines · Amos Kong
./qemu-upstream-latest -boot reboot-timeout=1000 ... (after boot failed, VM waits for 1000 ms and try to reboot)
[...]
Quoted 4 lines
romfile_add()is used to add rom files in the list. When seabios callsboot_fail(), the list becomes empty,romfile_find("etc/boot-fail-wait", ..)returns NULL. it seems the list items are released prematurely.
Yes - memory allocated with malloc_tmp() can't be used after the POST phase. The patch below should fix this.
It would be nice if we could compile-time check for this kind of thing. I'll have to give that some thought.
-Kevin
src/boot.c +8 -5
@@ -235,6 +235,7 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)* Boot setup ****************************************************************/ +static int BootRetryTime;static int CheckFloppySig =1 ;#define DEFAULT_PRIO 9999
@@ -271,6 +272,8 @@ boot_init(void) } } + BootRetryTime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); +loadBootOrder (); }
@@ -629,15 +632,15 @@ boot_rom(u32 vector)static void boot_fail (void ) { -u32 retrytime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); -if (retrytime == (u32)-1 ) +if (BootRetryTime == (u32)-1 )printf ("No bootable device.\n" );else -printf ("No bootable device. Retrying in %d seconds.\n" , retrytime/1000 ); +printf ("No bootable device. Retrying in %d seconds.\n" + , BootRetryTime/1000 );// Wait for 'retrytime' milliseconds and then reboot. -u32 end =calc_future_timer (retrytime); +u32 end =calc_future_timer (BootRetryTime);for (;;) { -if (retrytime != (u32)-1 &&check_timer (end)) +if (BootRetryTime != (u32)-1 &&check_timer (end))break ;yield_toirq (); }
PATCH 1/1 make reboot-timeout to static for using it after POST phase
In reply to Amos KongFrom: Kevin O'Connor <[email protected]>
Memory allocated with malloc_tmp() can't be used after the POST phase. The reboot-timeout inside romfile could not be loaded in boot_fail(). The patch saved reboot-timeout to a static variable, it fixed the regression bug introduced by commit 59d6ca52
I already tested this patch, reboot-timeout parameter of qemu works now.
@ qemu -boot reboot-timeout=1000 ...
--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
src/boot.c +8 -5
@@ -235,6 +235,7 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)* Boot setup ****************************************************************/ +static int BootRetryTime;static int CheckFloppySig =1 ;#define DEFAULT_PRIO 9999
@@ -271,6 +272,8 @@ boot_init(void) } } + BootRetryTime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); +loadBootOrder (); }
@@ -629,15 +632,15 @@ boot_rom(u32 vector)static void boot_fail (void ) { -u32 retrytime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); -if (retrytime == (u32)-1 ) +if (BootRetryTime == (u32)-1 )printf ("No bootable device.\n" );else -printf ("No bootable device. Retrying in %d seconds.\n" , retrytime/1000 ); +printf ("No bootable device. Retrying in %d seconds.\n" + , BootRetryTime/1000 );// Wait for 'retrytime' milliseconds and then reboot. -u32 end =calc_future_timer (retrytime); +u32 end =calc_future_timer (BootRetryTime);for (;;) { -if (retrytime != (u32)-1 &&check_timer (end)) +if (BootRetryTime != (u32)-1 &&check_timer (end))break ;yield_toirq (); }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [SeaBIOS] [Seabios PATCH] make reboot-timeout to static for using it after POST phase
Quoted 41 lines · 在 2013-03-05二的 10:06 +0800,Amos Kong写道:
From: Kevin O'Connor <[email protected]>
Memory allocated with
malloc_tmp()can't be used after the POST phase. The reboot-timeout inside romfile could not be loaded inboot_fail(). The patch saved reboot-timeout to a static variable, it fixed the regression bug introduced by commit59d6ca52I already tested this patch, reboot-timeout parameter of qemu works now.
@ qemu -boot reboot-timeout=1000 ...Signed-off-by Kevin O'Connor <[email protected]>Signed-off-by Amos Kong <[email protected]>--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)src/boot.c +3
-0@@ -235,6 +235,7 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)* Boot setup ****************************************************************/ +static int BootRetryTime;static int CheckFloppySig =1 ;#define DEFAULT_PRIO 9999@@ -271,6 +272,8 @@ boot_init(void) } } + BootRetryTime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); +loadBootOrder (); }@@ -629,15 +632,15 @@ boot_rom(u32 vector)static void boot_fail (void )
src/boot.c boot_rom(u32 vector) · line 640
Quoted 10 lines
src/boot.c +3
-3{ -u32 retrytime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); -if (retrytime == (u32)-1 ) +if (BootRetryTime == (u32)-1 )printf ("No bootable device.\n" );else -printf ("No bootable device. Retrying in %d seconds.\n" , retrytime/1000 ); +printf ("No bootable device. Retrying in %d seconds.\n" + , BootRetryTime/1000 );// Wait for 'retrytime' milliseconds and then reboot.
s/retrytime/BootRetryTime
Quoted 8 lines
src/boot.c +2
-2-u32 end =calc_future_timer (retrytime); +u32 end =calc_future_timer (BootRetryTime);for (;;) { -if (retrytime != (u32)-1 &&check_timer (end)) +if (BootRetryTime != (u32)-1 &&check_timer (end))break ;yield_toirq (); }
PATCH v2 1/1 make reboot-timeout to static for using it after POST phase
In reply to Amos KongFrom: Kevin O'Connor <[email protected]>
Memory allocated with malloc_tmp() can't be used after the POST phase. The reboot-timeout inside romfile could not be loaded in boot_fail(). The patch saved reboot-timeout to a static variable, it fixed the regression bug introduced by commit 59d6ca52
I already tested this patch, reboot-timeout parameter of qemu works now.
@ qemu -boot reboot-timeout=1000 ...
--
V2: trivial fix in comment (li guang)
--- src/boot.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
src/boot.c +9 -6
@@ -235,6 +235,7 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)* Boot setup ****************************************************************/ +static int BootRetryTime;static int CheckFloppySig =1 ;#define DEFAULT_PRIO 9999
@@ -271,6 +272,8 @@ boot_init(void) } } + BootRetryTime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); +loadBootOrder (); }
@@ -629,15 +632,15 @@ boot_rom(u32 vector)static void boot_fail (void ) { -u32 retrytime =romfile_loadint ("etc/boot-fail-wait" ,60 *1000 ); -if (retrytime == (u32)-1 ) +if (BootRetryTime == (u32)-1 )printf ("No bootable device.\n" );else -printf ("No bootable device. Retrying in %d seconds.\n" , retrytime/1000 ); -// Wait for 'retrytime' milliseconds and then reboot. -u32 end =calc_future_timer (retrytime); +printf ("No bootable device. Retrying in %d seconds.\n" + , BootRetryTime/1000 ); +// Wait for 'BootRetryTime' milliseconds and then reboot. +u32 end =calc_future_timer (BootRetryTime);for (;;) { -if (retrytime != (u32)-1 &&check_timer (end)) +if (BootRetryTime != (u32)-1 &&check_timer (end))break ;yield_toirq (); }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [Seabios PATCH v2] make reboot-timeout to static for using it after POST phase
Quoted 6 lines · Amos Kong
From: Kevin O'Connor <[email protected]>
Memory allocated with
malloc_tmp()can't be used after the POST phase. The reboot-timeout inside romfile could not be loaded inboot_fail(). The patch saved reboot-timeout to a static variable, it fixed the regression bug introduced by commit59d6ca52
FYI, this fix was committed.
-Kevin