Bug#323397: marked as done (grub: Does not fall back to source drive if BIOS fails to pass boot drive)

Debian Bug Tracking System owner at bugs.debian.org
Wed Dec 14 01:33:19 UTC 2005


Your message dated Tue, 13 Dec 2005 23:10:25 -0200
with message-id <87wti8lbzy.fsf at nurf.casa>
and subject line Fixed by upstream in 0.97
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 16 Aug 2005 13:20:58 +0000
>From mjg59 at srcf.ucam.org Tue Aug 16 06:20:58 2005
Return-path: <mjg59 at srcf.ucam.org>
Received: from cavan.codon.org.uk [217.147.81.22] 
	by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
	id 1E51NB-0008DY-00; Tue, 16 Aug 2005 06:20:57 -0700
Received: from mjg59 by cavan.codon.org.uk with local (Exim 4.43)
	id 1E51MU-0005aw-5A; Tue, 16 Aug 2005 14:20:14 +0100
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Matthew Garrett <mjg59 at srcf.ucam.org>
To: Debian Bug Tracking System <submit at bugs.debian.org>
Subject: grub: Does not fall back to source drive if BIOS fails to pass boot drive
X-Mailer: reportbug 3.5
Date: Tue, 16 Aug 2005 14:20:14 +0100
Message-Id: <E1E51MU-0005aw-5A at cavan.codon.org.uk>
X-SA-Exim-Connect-IP: <locally generated>
X-SA-Exim-Mail-From: mjg59 at srcf.ucam.org
X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false
Delivered-To: submit at bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-6.8 required=4.0 tests=BAYES_00,FROM_ENDS_IN_NUMS,
	HAS_PACKAGE autolearn=no version=2.60-bugs.debian.org_2005_01_02

Package: grub
Version: 0.95+cvs20040624-12
Severity: normal
Tags: patch

On boot, the BIOS is supposed to pass the boot drive to the bootloader 
in register dx. Not all BIOSes do this. The included patch causes grub 
to attempt to boot off the boot drive passed by the BIOS. If this fails, 
it then reverts to the drive that grub was originally installed to. It 
should only trigger in cases that currently fail.

diff -ur -x 'Makefile*' -x 'config.*' grub-0.95+cvs20040624/stage1/stage1.h grubme/stage1/stage1.h
--- grub-0.95+cvs20040624/stage1/stage1.h	2004-03-27 17:02:53 +0000
+++ grubme/stage1/stage1.h	2005-08-16 13:54:01 +0100
@@ -54,6 +54,9 @@
 /* The offset of BOOT_DRIVE_MASK.  */
 #define STAGE1_BOOT_DRIVE_MASK	0x4d
 
+/* The offset of STAGE1_SOURCE_DRIVE. */
+#define STAGE1_SOURCE_DRIVE     0x4e
+
 /* The offset of a magic number used by Windows NT.  */
 #define STAGE1_WINDOWS_NT_MAGIC	0x1b8
 
diff -ur -x 'Makefile*' -x 'config.*' grub-0.95+cvs20040624/stage1/stage1.S grubme/stage1/stage1.S
--- grub-0.95+cvs20040624/stage1/stage1.S	2004-03-27 17:02:53 +0000
+++ grubme/stage1/stage1.S	2005-08-16 13:55:34 +0100
@@ -115,12 +115,16 @@
 boot_drive_mask:
 	.byte	0x00
 
+
+source_drive:
+	.byte	GRUB_INVALID_DRIVE
+
 	/*
 	 * ljmp to the next instruction because some bogus BIOSes
 	 * jump to 07C0:0000 instead of 0000:7C00.
 	 */
 	ljmp	$0, $ABS(real_start)
-
+	
 real_start:	
 
 	/* set up %ds and %ss as offset from 0 */
@@ -236,7 +240,18 @@
 	testb	$STAGE1_BIOS_HD_FLAG, %dl
 	jz	floppy_probe
 
-	/* Nope, we definitely have a hard disk, and we're screwed. */
+	/* Nope, we definitely have a hard disk, and we're screwed. 
+	   Try as hard as we can to recover. */
+
+	MOV_MEM_TO_AL(ABS(source_drive))	/* movb	ABS(source_drive), %al */
+	cmpb	$GRUB_INVALID_DRIVE, %al
+	je	1f
+	cmpb	%al, %dl /* We've been here before */
+	je	1f
+	movb	%al, %dl
+	jmp	1b
+	
+1:	
 	jmp	hd_probe_error
 
 final_init:
diff -ur -x 'Makefile*' -x 'config.*' grub-0.95+cvs20040624/stage2/builtins.c grubme/stage2/builtins.c
--- grub-0.95+cvs20040624/stage2/builtins.c	2005-08-16 13:34:13 +0100
+++ grubme/stage2/builtins.c	2005-08-16 13:57:44 +0100
@@ -2063,12 +2063,19 @@
   src_part_start = part_start;
   src_geom = buf_geom;
   
-  if (! new_drive)
+  if (! new_drive) {
     new_drive = src_drive;
-  else if (src_drive != dest_drive)
-    grub_printf ("Warning: the option `d' was not used, but the Stage 1 will"
-		 " be installed on a\ndifferent drive than the drive where"
-		 " the Stage 2 resides.\n");
+    *((unsigned char *) (stage1_buffer + STAGE1_SOURCE_DRIVE)) = 
+	    GRUB_INVALID_DRIVE;
+  } else {
+	  if (src_drive != dest_drive)
+		  grub_printf ("Warning: the option `d' was not used, but the" 
+			       " Stage 1 will be installed on a\ndifferent"
+			       " drive than the drive where the Stage 2"
+			       " resides.\n");
+	  *((unsigned char *) (stage1_buffer + STAGE1_SOURCE_DRIVE)) = 
+		  src_drive;
+  }
 
   /* Set the boot drive.  */
   *((unsigned char *) (stage1_buffer + STAGE1_BOOT_DRIVE)) = new_drive;


-- System Information:
Debian Release: 3.1
Architecture: i386 (i586)
Kernel: Linux 2.6.8-2-386
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)

Versions of packages grub depends on:
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
ii  libncurses5                 5.4-4        Shared libraries for terminal hand

-- debconf information:
* grub/install_boot_loader: true
  grub/replace_other_boot_loader: false

---------------------------------------
Received: (at 323397-done) by bugs.debian.org; 14 Dec 2005 01:09:39 +0000
>From otavio at debian.org Tue Dec 13 17:09:38 2005
Return-path: <otavio at debian.org>
Received: from aveiro.procergs.com.br ([200.198.128.42])
	by spohr.debian.org with esmtp (Exim 4.50)
	id 1EmL9G-0002D0-MB
	for 323397-done at bugs.debian.org; Tue, 13 Dec 2005 17:09:38 -0800
Received: from localhost (unknown [201.10.58.28])
	by aveiro.procergs.com.br (Postfix) with ESMTP id B07ED5010ABE
	for <323397-done at bugs.debian.org>; Tue, 13 Dec 2005 23:09:07 -0200 (BRDT)
Received: by localhost (Postfix, from userid 1000)
	id B78741C0B6AE; Tue, 13 Dec 2005 23:10:25 -0200 (BRST)
From: Otavio Salvador <otavio at debian.org>
To: 323397-done at bugs.debian.org
Subject: Fixed by upstream in 0.97
Organization: O.S. Systems Ltda.
X-URL: http://www.debian.org/~otavio/
X-Attribution: O.S.
Date: Tue, 13 Dec 2005 23:10:25 -0200
Message-ID: <87wti8lbzy.fsf at nurf.casa>
User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
	autolearn=no version=2.60-bugs.debian.org_2005_01_02

Package: grub
Version: 0.97-1

Hello,

Current version has a better code for doing it. It also handle the
cases when bug BIOS do not provide the need information.

Try it out and if you feel it continue to be important, please reopen
the bug.

-- 
        O T A V I O    S A L V A D O R
---------------------------------------------
 E-mail: otavio at debian.org      UIN: 5906116
 GNU/Linux User: 239058     GPG ID: 49A5F855
 Home Page: http://www.freedom.ind.br/otavio
---------------------------------------------
"Microsoft gives you Windows ... Linux gives
 you the whole house."



More information about the Pkg-grub-devel mailing list