diff mbox

[v3,05/16] pc: Make -no-fd-bootchk stick across boot order changes

Message ID 1371208516-7857-6-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster June 14, 2013, 11:15 a.m. UTC
Option -no-fd-bootchk asks the BIOS to attempt booting from a floppy
even when the boot sector signature isn't there, by setting a bit in
RTC CMOS.  It was added back in 2006 (commit 52ca8d6a).

Two years later, commit 0ecdffbb added monitor command boot_set.
Implemented by new function pc_boot_set().  It unconditionally clears
the floppy signature bit in CMOS.

Commit e0f084bf added -boot option once to automatically change the
boot order on first reset.  Reuses pc_boot_set(), thus also clears the
floppy signature bit.  Commit d9346e81 took care to preserve this
behavior.

Thus, -no-fd-bootchk applies to any number of boots.  Except it
applies just to the first boot with -boot once, and never after
boot_set.  Weird.  Make it stick instead: set the bit according to
-no-fd-bootchk in pc_boot_set().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/i386/pc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Anthony Liguori June 14, 2013, 1:40 p.m. UTC | #1
Markus Armbruster <armbru@redhat.com> writes:

> Option -no-fd-bootchk asks the BIOS to attempt booting from a floppy
> even when the boot sector signature isn't there, by setting a bit in
> RTC CMOS.  It was added back in 2006 (commit 52ca8d6a).
>
> Two years later, commit 0ecdffbb added monitor command boot_set.
> Implemented by new function pc_boot_set().  It unconditionally clears
> the floppy signature bit in CMOS.
>
> Commit e0f084bf added -boot option once to automatically change the
> boot order on first reset.  Reuses pc_boot_set(), thus also clears the
> floppy signature bit.  Commit d9346e81 took care to preserve this
> behavior.

Quite a history there :-)

Does anyone still use no-fd-bootchk?  Do you know what the original
use-case was?

> Thus, -no-fd-bootchk applies to any number of boots.  Except it
> applies just to the first boot with -boot once, and never after
> boot_set.  Weird.  Make it stick instead: set the bit according to
> -no-fd-bootchk in pc_boot_set().
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>  hw/i386/pc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 4844a6b..7e524fc 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -266,7 +266,7 @@ static int boot_device2nibble(char boot_device)
>      return 0;
>  }
>  
> -static int set_boot_dev(ISADevice *s, const char *boot_device, int fd_bootchk)
> +static int set_boot_dev(ISADevice *s, const char *boot_device)
>  {
>  #define PC_MAX_BOOT_DEVICES 3
>      int nbds, bds[3] = { 0, };
> @@ -292,7 +292,7 @@ static int set_boot_dev(ISADevice *s, const char *boot_device, int fd_bootchk)
>  
>  static int pc_boot_set(void *opaque, const char *boot_device)
>  {
> -    return set_boot_dev(opaque, boot_device, 0);
> +    return set_boot_dev(opaque, boot_device);
>  }
>  
>  typedef struct pc_cmos_init_late_arg {
> @@ -407,8 +407,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
>      cpu_hotplug_cb.cpu_added_notifier.notify = rtc_notify_cpu_added;
>      qemu_register_cpu_added_notifier(&cpu_hotplug_cb.cpu_added_notifier);
>  
> -    /* set boot devices, and disable floppy signature check if requested */
> -    if (set_boot_dev(s, boot_device, fd_bootchk)) {
> +    if (set_boot_dev(s, boot_device)) {
>          exit(1);
>      }
>  
> -- 
> 1.7.11.7
Markus Armbruster June 18, 2013, 11:39 a.m. UTC | #2
Anthony Liguori <aliguori@us.ibm.com> writes:

> Markus Armbruster <armbru@redhat.com> writes:
>
>> Option -no-fd-bootchk asks the BIOS to attempt booting from a floppy
>> even when the boot sector signature isn't there, by setting a bit in
>> RTC CMOS.  It was added back in 2006 (commit 52ca8d6a).
>>
>> Two years later, commit 0ecdffbb added monitor command boot_set.
>> Implemented by new function pc_boot_set().  It unconditionally clears
>> the floppy signature bit in CMOS.
>>
>> Commit e0f084bf added -boot option once to automatically change the
>> boot order on first reset.  Reuses pc_boot_set(), thus also clears the
>> floppy signature bit.  Commit d9346e81 took care to preserve this
>> behavior.
>
> Quite a history there :-)
>
> Does anyone still use no-fd-bootchk?

No idea.

>                                       Do you know what the original
> use-case was?

Its commit message is of no help.  Best we got is the option
documentation:

    Disable boot signature checking for floppy disks in Bochs BIOS.  It
    may be needed to boot from old floppy disks.

As far as I can tell, SeaBIOS implements this, too.

>> Thus, -no-fd-bootchk applies to any number of boots.  Except it
>> applies just to the first boot with -boot once, and never after
>> boot_set.  Weird.  Make it stick instead: set the bit according to
>> -no-fd-bootchk in pc_boot_set().
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Thanks!
Kevin O'Connor July 8, 2013, 1:24 a.m. UTC | #3
On Tue, Jun 18, 2013 at 01:39:25PM +0200, Markus Armbruster wrote:
> Anthony Liguori <aliguori@us.ibm.com> writes:
> > Markus Armbruster <armbru@redhat.com> writes:
> >
> >> Option -no-fd-bootchk asks the BIOS to attempt booting from a floppy
> >> even when the boot sector signature isn't there, by setting a bit in
> >> RTC CMOS.  It was added back in 2006 (commit 52ca8d6a).
> >>
> >> Two years later, commit 0ecdffbb added monitor command boot_set.
> >> Implemented by new function pc_boot_set().  It unconditionally clears
> >> the floppy signature bit in CMOS.
> >>
> >> Commit e0f084bf added -boot option once to automatically change the
> >> boot order on first reset.  Reuses pc_boot_set(), thus also clears the
> >> floppy signature bit.  Commit d9346e81 took care to preserve this
> >> behavior.
> >
> > Quite a history there :-)
> >
> > Does anyone still use no-fd-bootchk?
> 
> No idea.

I've used it to test really old floppies.

> > use-case was?
> 
> Its commit message is of no help.  Best we got is the option
> documentation:
> 
>     Disable boot signature checking for floppy disks in Bochs BIOS.  It
>     may be needed to boot from old floppy disks.
> 
> As far as I can tell, SeaBIOS implements this, too.

The SeaBIOS and Bochs code check that there is a FAT partition
signature (0xaa55) on the first sector of the floppy drive.  This way,
if the disk doesn't look like it is valid, we wont try to execute the
first sector if it is just random junk.  However, really old floppies
didn't put this signature in the first sector and were still bootable.
So, no-fd-bootchk could be used to disable this check and still boot
really old floppies.

-Kevin
diff mbox

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4844a6b..7e524fc 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -266,7 +266,7 @@  static int boot_device2nibble(char boot_device)
     return 0;
 }
 
-static int set_boot_dev(ISADevice *s, const char *boot_device, int fd_bootchk)
+static int set_boot_dev(ISADevice *s, const char *boot_device)
 {
 #define PC_MAX_BOOT_DEVICES 3
     int nbds, bds[3] = { 0, };
@@ -292,7 +292,7 @@  static int set_boot_dev(ISADevice *s, const char *boot_device, int fd_bootchk)
 
 static int pc_boot_set(void *opaque, const char *boot_device)
 {
-    return set_boot_dev(opaque, boot_device, 0);
+    return set_boot_dev(opaque, boot_device);
 }
 
 typedef struct pc_cmos_init_late_arg {
@@ -407,8 +407,7 @@  void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
     cpu_hotplug_cb.cpu_added_notifier.notify = rtc_notify_cpu_added;
     qemu_register_cpu_added_notifier(&cpu_hotplug_cb.cpu_added_notifier);
 
-    /* set boot devices, and disable floppy signature check if requested */
-    if (set_boot_dev(s, boot_device, fd_bootchk)) {
+    if (set_boot_dev(s, boot_device)) {
         exit(1);
     }