Subject: port-alpha/12225: dec_6600 can select the wrong root drive
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kre@munnari.OZ.AU>
List: netbsd-bugs
Date: 02/16/2001 21:56:30
>Number:         12225
>Category:       port-alpha
>Synopsis:       dec_6600 (alpha) can select the wrong boot device
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-alpha-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 16 03:02:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Robert Elz
>Release:        NetBSD 1.5 RELEASE and everything after that (maybe before)
>Organization:
	University of Melbourne
>Environment:
	
System: NetBSD munnnari.cs.mu.OZ.AU 1.5 NetBSD 1.5 (MUNNNARI) #0: Fri Feb 16 20:41:00 EST 2001     kre@munnnari.cs.mu.OZ.AU:/usr/src/sys/arch/alpha/compile/MUNNNARI alpha

Also happens in NetBSD-current as of today (Feb 16, 2001)

>Description:
	The ATAPI channel number is ignored when matching atapi devices
	for boot purposes.  That can lead to the wrong device being selected
	as the boot device.
>How-To-Repeat:
	Build a DS10 with an IDE (atapi) cdrom on channel 0 (pciide0:0:0)
	and a wd drive on channel 1 (pciide0:1:0).   Boot from the wd drive
	(which will be dqb0 to SRM).  Watch a kernel configired as "root on ?"
	(as in  GENERIC kernel) select cd0 as the root device, then panic
	"can't find init" (assuming the cd doesn't have sbin/init in its root).
>Fix:
	Apply the following patch (expect some line number slippage perhaps,
	the diff was generated from 1.5 RELEASE against 1.5-current ...)

--- dec_6600.c.WAS	Mon Jun 26 05:17:39 2000
+++ dec_6600.c	Fri Feb 16 21:40:15 2001
@@ -248,13 +248,16 @@
 			return;
 
 		if (sa->sa_sc_link->type == BUS_SCSI
 		    && b->unit / 100 != sa->sa_sc_link->scsipi_scsi.target)
 			return;
-		if (sa->sa_sc_link->type == BUS_ATAPI
-		    && b->unit / 100 != sa->sa_sc_link->scsipi_atapi.drive)
+		if (sa->sa_sc_link->type == BUS_ATAPI) {
+		    if (b->unit / 100 != sa->sa_sc_link->scsipi_atapi.drive)
 			return;
+		    if (b->channel != sa->sa_sc_link->scsipi_atapi.channel)
+			return;
+		}
 
 		/* XXX LUN! */
 
 		switch (b->boot_dev_type) {
 		case 0:


	If b->unit % 100 is where the scsi LUN would be placed by SRM,
	(and the boot blocks) then a pretty similar little fix in the earlier
	(BUS_SCSI) case should get rid of the XXX LUN! comment...
	However, I have no way to test that at the minute, so ...
>Release-Note:
>Audit-Trail:
>Unformatted: