* [PATCH][RFC] Add boot sector checksums to EDD
@ 2004-11-10 4:43 Carl-Daniel Hailfinger
0 siblings, 0 replies; 2+ messages in thread
From: Carl-Daniel Hailfinger @ 2004-11-10 4:43 UTC (permalink / raw)
To: Matt Domsch; +Cc: Linux Kernel Mailing List
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 <c-d.hailfinger.kernel.2004@gmx.net>
--- ./linux-2.6.9/arch/i386/boot/edd.S~ 2004-11-05 14:27:08.000000000 +0100
+++ ./linux-2.6.9/arch/i386/boot/edd.S 2004-11-06 23:55:23.000000000 +0100
@@ -5,7 +5,9 @@
* projects 1572D, 1484D, 1386D, 1226DT
* disk signature read by Matt Domsch <Matt_Domsch@dell.com>
* and Andrew Wilks <Andrew_Wilks@dell.com> September 2003, June 2004
- * legacy CHS retreival by Patrick J. LoPresti <patl@users.sourceforge.net>
+ * disk checksum computation by Carl-Daniel Hailfinger
+ * <c-d.hailfinger.kernel.2004@gmx.net> November 2004
+ * legacy CHS retrieval by Patrick J. LoPresti <patl@users.sourceforge.net>
* 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~ 2004-11-05 14:27:47.000000000 +0100
+++ ./linux-2.6.9/include/linux/edd.h 2004-11-06 23:43:20.000000000 +0100
@@ -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 */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][RFC] Add boot sector checksums to EDD
[not found] ` <4191ABE8.1060703@gmx.net>
@ 2004-11-10 15:35 ` Matt Domsch
0 siblings, 0 replies; 2+ messages in thread
From: Matt Domsch @ 2004-11-10 15:35 UTC (permalink / raw)
To: Carl-Daniel Hailfinger; +Cc: Michael E Brown, linux-kernel
On Wed, Nov 10, 2004 at 06:49:28AM +0100, Carl-Daniel Hailfinger wrote:
> Michael E Brown schrieb:
(copying lkml again)
> > I'm curious, do you have a tool that uses the boot sector checksum? I
> > can think of a couple of places it could be useful, but all of my
> > use-cases are adequately covered by simple signature.
>
> The tool is SUSE hwinfo. Currently its author does the checksumming
> in the bootloader which kills some BIOSes (1st EDD request in the
> bootloader is ok, second request by kernel EDD startup code hangs
> the machine).
I'd be curious to understand this better. i.e. failure mode, why it
fails, for what systems, etc.
> I have some drives with identical mbr_signature (drives were wiped
> with dd before I got them). Using a checksum gives me at least some
> chance to identify them better because one has a bootloader, the
> other hasn't, they have different partition tables etc.
What wrote the bootloader to the first disk? Can *that* write a
unique signature into the disk? Red Hat's build of parted includes a
patch I wrote (not yet included in parted upstream IIRC) which has
parted write a unique signature to each disk, so that's how we solve
it there...
Thanks,
Matt
--
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-11-10 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-10 4:43 [PATCH][RFC] Add boot sector checksums to EDD Carl-Daniel Hailfinger
[not found] <4191A8D7.1030300@michaels-house.net>
[not found] ` <4191ABE8.1060703@gmx.net>
2004-11-10 15:35 ` Matt Domsch
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.