Hello all,

while reading through grub-core/boot/i386/pc/boot.S in the Bazaar version
of Grub 2, I noticed that the floppy probing code calls
int $0x13, %ah===$0x02  /* disk read sector */
without initializing the %es register, and with %bx holding a value
that was likely meant to go into %es. (boot.S:465)

My proposed change is included below. The two additional instructions have been
copied from further above in boot.S, where the same BIOS function is
used correctly. The resulting machine code is enlarged by 4 bytes, but
apparently still fits within the 512-byte limit.

Please note that I found this by inspection, not by observing undesired
behaviour.  The patch passes "make" and "make check", but I'm not sure if the
code will actually be exercised by "make check".
I hope you find it useful.

Mirko

=== modified file 'grub-core/boot/i386/pc/boot.S'
--- grub-core/boot/i386/pc/boot.S       2010-09-19 22:06:45 +0000
+++ grub-core/boot/i386/pc/boot.S       2010-10-26 09:51:29 +0000
@@ -459,6 +459,8 @@
 1:
        /* perform read */
        movw    $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
+       movw    %bx, %es
+       xorw    %bx, %bx
        movw    $0x201, %ax
        movb    $0, %ch
        movb    $0, %dh


_______________________________________________
Bug-grub mailing list
Bug-grub@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-grub

Reply via email to