bug-grub
[Top][All Lists]
Advanced

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

[bug #29464] util/i386/pc/grub-setup: fails to write Buggy BIOS boot-sec


From: TJ
Subject: [bug #29464] util/i386/pc/grub-setup: fails to write Buggy BIOS boot-sector drive-number detection in boot.img
Date: Wed, 07 Apr 2010 21:38:11 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100404 Ubuntu/10.04 (lucid) Firefox/3.6.3

URL:
  <http://savannah.gnu.org/bugs/?29464>

                 Summary: util/i386/pc/grub-setup: fails to write Buggy BIOS
boot-sector drive-number detection in boot.img
                 Project: GNU GRUB
            Submitted by: intuitivenipple
            Submitted on: Wed 07 Apr 2010 09:38:10 PM GMT
                Category: Installation
                Severity: Major
                Priority: 5 - Normal
              Item Group: Software Error
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 
                 Release: 1.98
         Reproducibility: Every Time
         Planned Release: None

    _______________________________________________________

Details:

I've been investigating why, on Acer Travelmate C100 tablet PCs, grub2 fails
to boot, reporting:

"Geom Error"

It turns out the MBR boot sector does not have the two NOP instructions
written into offset 0x66 which allows drive 0x80 to be forced as the boot
device when the BIOS reports a different device - in this case 0x5F.

I traced the code in util/i386/pc/grub-setup.c and discovered that the test
for the drive number fails and therefore the jmp instruction isn't
over-written.

The reason is dest_dev->disk->id is never set prior to the test.

So far as I can determine this is the code-path:

utils/i386/pc/grub-setup.c::setup()
   dest_dev = grub_device_open (dest);
   kern/device.c::grub_device_open(const char *dest name)
    disk = grub_disk_open(name);
    kern/disk.c::grub_disk_open(const char *name)
      disk = (grub_disk_t) grub_zalloc(sizeof(*disk));
      disk->name = grub_strdup (name);
      ...
      disk->dev = dev;
      ...
      return disk;
   dev->disk = disk;
   return dev;
 ...
 /* If DEST_DRIVE is a hard disk, enable the workaround, which is
    for buggy BIOSes which don't pass boot drive correctly. Instead,
    they pass 0x00 or 0x01 even when booted from 0x80. */
 if (dest_dev->disk->id & 0x80)
 /* Replace the jmp (2 bytes) with double nop's. */
 *boot_drive_check = 0x9090;

To test this I added a small patch to report the value of disk->id and built
the binary. When run on the target system it reveals:

./grub-setup: info: the size of hd0 is 78140160
./grub-setup: info: setting the root device to 'hd0,1'.
./grub-setup: info: disk->id = 0.

and the resulting boot sector contained the jmp instruction.

I've got a manual workaround until a fix can be created.

1. Boot from a LiveCD image from CD or network (via PXE).
2. Open a terminal (there are two ways)
 a. press Ctrl+Alt+F1 *twice* to get to virtual console #1
 b. Applications > Accessories > Terminal
3. Create a file containing the nops:
 echo -e -n "\0220\0220" >/tmp/nop.bin
4. Write the nops into the boot sector (replace /dev/sda if necessary with
the boot device name on *your* system):
 sudo dd if=/tmp/nop.bin of=/dev/sda bs=2 count=1 seek=102
5. Restart and test.

This issue was originally reported in Ubuntu Forums and has a bug report
against it at:

https://bugs.launchpad.net/ubuntu/+bug/555500




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?29464>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]