Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

two bootloader fixes



Here are two changes to the i386 bootloader that I hope someone will
review before I commit them:

The first change makes
sys/arch/i386/stand/lib/biosdisk.c:add_biosdisk_bootinfo() stateless.
Prior to this change, if the bootloader had to try one or more kernels
before finding one (e.g., try netbsd -> ENOENT, try netbsd.gz), it would
not try to pass BTINFO_BOOTWEDGE- and BTINFO_BOOTDISK-type bootinfo
to the second and subsequent kernels.  So while the bootloader may
automatically boot netbsd.gz from wd0e, the kernel would use root on
wd0a instead of on wd0e.

The second change measures, with sizeof(), the size of a struct instead
of a pointer to struct, so that the bootloader computes the correct
size of the userconf bootinfo.  I found this bug by groveling through a
hexdump of bootinfo using the kernel debugger and finding a very strange
bootinfo with length 4.  The kernel should probably sneeze when it sees
such a thing, but I haven't any patch for that.

Dave

-- 
David Young
dyoung%pobox.com@localhost    Urbana, IL    (217) 721-9981
--- sys/arch/i386/stand/lib/biosdisk.c  2012/09/05 20:48:18
+++ sys/arch/i386/stand/lib/biosdisk.c  2012/10/02 19:55:45
@@ -694,22 +694,8 @@
 static void
 add_biosdisk_bootinfo(void)
 {
-       static bool done;
-
-       if (bootinfo == NULL) {
-               done = false;
-               return;
-       }
-       
-       if (done)
-               return;
-
        BI_ADD(&bi_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
        BI_ADD(&bi_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
-
-       done = true;
-
-       return;
 }
 
 #endif
--- sys/arch/i386/stand/lib/exec.c      2012/09/05 20:48:18
+++ sys/arch/i386/stand/lib/exec.c      2012/10/02 19:57:41
@@ -627,7 +627,7 @@
        count = 0;
        for (uc = userconf_commands; uc != NULL; uc = uc->uc_next)
                count++;
-       len = sizeof(btinfo_userconfcommands) +
+       len = sizeof(*btinfo_userconfcommands) +
              count * sizeof(struct bi_userconfcommand);
 
        /* Allocate the userconf commands list */


Home | Main Index | Thread Index | Old Index