From owner-freebsd-usb@FreeBSD.ORG Wed Jan 5 21:01:04 2005 Return-Path: Delivered-To: freebsd-usb@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 22CD016A4D1 for ; Wed, 5 Jan 2005 21:01:04 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE12843D45 for ; Wed, 5 Jan 2005 21:01:03 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id j05L13GU085804 for ; Wed, 5 Jan 2005 21:01:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id j05L139i085802; Wed, 5 Jan 2005 21:01:03 GMT (envelope-from gnats) Date: Wed, 5 Jan 2005 21:01:03 GMT Message-Id: <200501052101.j05L139i085802@freefall.freebsd.org> To: freebsd-usb@FreeBSD.org From: Peter Edwards Subject: Re: kern/66248: [panic] bootloader is confused by booting from USB flash, trashes main drives boot block X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Peter Edwards List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jan 2005 21:01:04 -0000 The following reply was made to PR kern/66248; it has been noted by GNATS. From: Peter Edwards To: freebsd-gnats-submit@FreeBSD.org, bremner@unb.ca Cc: julian@elischer.org, imp@bsdimp.org Subject: Re: kern/66248: [panic] bootloader is confused by booting from USB flash, trashes main drives boot block Date: Wed, 05 Jan 2005 20:53:02 +0000 This is a multi-part message in MIME format. --------------070200040205060401080901 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit The following patch, applied before the one above, shrinks boot0 enough to squeeze the previous patch in without undeffing the BEL stuff. FWIW: The patch to fix the bug looks good to me. I someone gives a go-ahead, I'll commit a combined patch: I certainly don't want to make a commit to boot0 and have half the FreeBSD community left without a bootable machine, unless I can pass the book :-) --------------070200040205060401080901 Content-Type: text/plain; name="boot0.smaller.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="boot0.smaller.patch" Index: boot0.S =================================================================== RCS file: /usr/cvs/FreeBSD-CVS/src/sys/boot/i386/boot0/boot0.S,v retrieving revision 1.12 diff -u -w -r1.12 boot0.S --- boot0.S 24 Nov 2004 15:39:04 -0000 1.12 +++ boot0.S 5 Jan 2005 20:44:32 -0000 @@ -29,7 +29,7 @@ .set PRT_OFF,0x1be # Partition table .set TBL0SZ,0x3 # Table 0 size - .set TBL1SZ,0xb # Table 1 size + .set TBL1SZ,0xc # Table 1 size .set MAGIC,0xaa55 # Magic: bootable .set B0MAGIC,0xbb66 # Identification @@ -148,13 +148,8 @@ movb $TBL1SZ,%cl # Number of entries repne # Known scasb # type? - jne main.4 # No -/* - * If it matches get the matching element in the next array. If it doesn't, - * we are already pointing at its first element which points to a "?". - */ - addw $TBL1SZ,%di # Adjust -main.4: movb (%di),%cl # Partition + addw $TBL1SZ - 1, %di # Adjust + movb (%di),%cl # Partition addw %cx,%di # description callw putx # Display it main.5: incw %dx # Next item @@ -314,8 +309,7 @@ cmpw $MAGIC,0x1fe(%bx) # Bootable? jne main.10 # No pushw %si # Save - movw $crlf,%si # Leave some - callw puts # space + callw putn # Leave some space popw %si # Restore jmp *%bx # Invoke bootstrap @@ -408,14 +402,14 @@ .byte 0x0, 0x5, 0xf /* * These values indicate bootable types we know the names of. + * The value of the last entry is unimportant: it indicates "everything else" */ .byte 0x1, 0x4, 0x6, 0xb, 0xc, 0xe, 0x83 - .byte 0x9f, 0xa5, 0xa6, 0xa9 + .byte 0x9f, 0xa5, 0xa6, 0xa9, 0xff /* * These are offsets that match the known names above and point to the strings * that will be printed. */ - .byte os_misc-. # Unknown .byte os_dos-. # DOS .byte os_dos-. # DOS .byte os_dos-. # DOS @@ -427,6 +421,7 @@ .byte os_freebsd-. # FreeBSD .byte os_bsd-. # OpenBSD .byte os_bsd-. # NetBSD + .byte os_misc-. # Unknown /* * And here are the strings themselves. 0x80 or'd into a byte indicates * the end of the string. (not so great for Russians but...) --------------070200040205060401080901--