Subject: port-i386/9676: can't boot from >8G partition
To: None <gnats-bugs@gnats.netbsd.org>
From: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
List: netbsd-bugs
Date: 03/26/2000 08:33:53
>Number:         9676
>Category:       port-i386
>Synopsis:       can't boot from >8G partition
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-i386-maintainer (NetBSD/i386 Portmaster)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 26 08:33:00 2000
>Last-Modified:
>Originator:     IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
>Organization:
	
>Release:        a week ago -current
>Environment:
System: NetBSD dolphin.my.domain 1.4V NetBSD 1.4V (NORIKA) #1: Wed Mar 22 13:40:51 JST 2000 toshii@norika.my.domain:/usr/src/syssrc/sys/arch/i386/compile/NORIKA i386


>Description:
	Bootloader hangs without an error message and cannot boot a kernel,
	if the NetBSD partition starts at >8G position.
	A bootloader residing in a floppy disk can boot the kernel just fine.
>How-To-Repeat:
	Install into a hard disk using the following partition table:

dolphin:~$ fdisk
NetBSD disklabel disk geometry:
cylinders: 16383 heads: 16 sectors/track: 63 (1008 sectors/cylinder)

BIOS disk geometry:
cylinders: 1023 heads: 255 sectors/track: 63 (16065 sectors/cylinder)

Partition table:
0: sysid 12 (Primary DOS with 32 bit FAT - LBA)
    start 63, size 12582912 (6144 MB), flag 0x80
        beg: cylinder    0, head   1, sector  1
        end: cylinder  783, head  64, sector 48
1: sysid 12 (Primary DOS with 32 bit FAT - LBA)
    start 12582975, size 11995119 (5856 MB), flag 0x0
        beg: cylinder  783, head  64, sector 49
        end: cylinder 1023, head 233, sector 30
2: <UNUSED>
3: sysid 169 (NetBSD)
    start 24578064, size 19407024 (9476 MB), flag 0x0
        beg: cylinder 1023, head 233, sector  1
        end: cylinder 1023, head 240, sector 63

	Use fdisk -B to install mbr_bootsel and try to boot NetBSD.
>Fix:
	Although I am not sure about differences in addressing
	modes, the following patch fixes the problem (for me).
	/usr/mdec/mbr may have the same problem (not really tested).

	The latter two diffs disables detection of LBA addressing
	call and are not correct fix, but it was necessary to make
	the code to fit into a sector.

	We must either
	(1) make room for extra few bytes required by the first patch,
	or
	(2) give up using dynamic check for necessity of LBA addressing
	    and make installboot write such a flag into bootcode,
	    which is already done with mbr_bootsel.
	
Index: start_bootsect.S
===================================================================
RCS file: /export/NetBSD-CVS/syssrc/sys/arch/i386/stand/lib/crt/bootsect/start_bootsect.S,v
retrieving revision 1.16
diff -u -r1.16 start_bootsect.S
--- start_bootsect.S    1999/08/23 08:24:37     1.16
+++ start_bootsect.S    2000/03/26 15:33:23
@@ -230,9 +230,11 @@
        mull    %ecx            /* eax = c * h * s */

        data32
+       movl    %esi, %ebx
        addr32
-       movl    8(%esi),%ebx
        data32
+       movl    %es:8(%ebx),%ebx
+       data32
        addl    $LOADSZ+1, %ebx /* ebx = maximum sector # we need */

        data32
@@ -259,6 +261,7 @@
  *                     %bx = 0xaa55
  *                     %cx = API subset bitmap, &1 -> extended disk access
  */
+/*
        pushl   %ebx
        pushl   %edx
        movb    $0x41, %ah
@@ -278,6 +281,7 @@
        testb   $1, %cl
        data32
        jz      tradint13
+*/

 /*
  * BIOS call "INT 0x13 Function 0x42", extended read
>Audit-Trail:
>Unformatted: