Add boot sector checksums to EDD
RFC PATCH 1/1 Add boot sector checksums to EDD
Hi Matt,
this first draft of a patch to implement boot sector checksums in EDD. Since the comments in edd.S and edd.h discourage changing some offsets, I made my code overwrite the /sys/firmware/edd/int13_dev*/mbr_signature file contents. For a later patch I would suggest to add a mbr_checksum file, so the two can coexist.
The patch is tested and didn't break anything on my machine so far. Please comment.
Regards,
Carl-Daniel
http://www.hailfinger.org/
Signed-off-by Carl-Daniel Hailfinger <[email protected]>
linux-2.6.9/arch/i386/boot/edd.S renamed from linux-2.6.9/arch/i386/boot/edd.S~ +14 -1
@@ -5,7 +5,9 @@ * projects 1572D, 1484D, 1386D, 1226DT * disk signature read by Matt Domsch <[email protected]> * and Andrew Wilks <[email protected]> September 2003, June 2004 - * legacy CHS retreival by Patrick J. LoPresti <[email protected]> + * disk checksum computation by Carl-Daniel Hailfinger + * <[email protected]> November 2004 + * legacy CHS retrieval by Patrick J. LoPresti <[email protected]> * March 2004 * Use EXTENDED READ calls if possible, Matt Domsch, October 2004 */
@@ -88,10 +90,21 @@ movb %dl, %bl # copy drive number to ebx sub $0x80, %bl # subtract 80h from drive number shlw $2, %bx # multiply by 4 + movw %bx, %cx # save bx addw $EDD_MBR_SIG_BUF, %bx # add to sig_buf # bx now points to the right sig slot movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR movl %eax, (%bx) # store success + movw %cx, %bx # restore bx + addw $EDD_MBR_CKSUM_BUF, %bx # add to cksum_buf + # bx now points to the right cksum slot + xorl %eax, %eax # clear eax + movl $0x7f, %ecx # loop counter +edd_mbr_compute_checksum: + xorl EDDBUF(,%ecx,4), %eax # compute checksum of mbr + decl %ecx + jns edd_mbr_compute_checksum # until the checksum in complete + movl %eax, (%bx) # store success incb (EDD_MBR_SIG_NR_BUF) # note that we stored something edd_mbr_sig_next: incb %dl # increment to next device
linux-2.6.9/include/linux/edd.h renamed from linux-2.6.9/include/linux/edd.h~ +1 -0
@@ -50,6 +50,7 @@#define EDD_MBR_SIG_OFFSET 0x1B8/* offset of signature in the MBR */ #define EDD_DEV_ADDR_PACKET_LEN 0x10/* for int13 fn42 */ #define EDD_MBR_SIG_BUF 0x290/* addr in boot params */ +#define EDD_MBR_CKSUM_BUF 0x290/* addr in boot params */ #define EDD_MBR_SIG_MAX 16/* max number of signatures to store */ #define EDD_MBR_SIG_NR_BUF 0x1ea/* addr of number of MBR signtaures at EDD_MBR_SIG_BUF in boot_params - treat this as 1 byte */