Ghost EDD devices in /sys again
H. Peter Anvin
reviewerI think this is closer to what we really want; after all, memory being written is the "first principles" test that applies here.
Signature · 1 line
Sent from my mobile phone (pardon any lack of formatting)
-----Original Message-----
From: Andrey Borzenkov <[email protected]>
Sent: Saturday, September 06, 2008 10:46
To: H. Peter Anvin <[email protected]>
Cc: Andrew Morton <[email protected]>; Rafael J. Wysocki <[email protected]>; Linux Kernel Mailing List <[email protected]>; Ingo Molnar <[email protected]>
Subject: Re: [PATCH] Ghost EDD devices in /sys again
Quoted 8 lines · H. Peter Anvin
Quoted 6 lines · Andrey Borzenkov
Was it really that simple?
Subject: [PATCH] Fix ghost devices under
/sys/firmware/edd
From: Andrey Borzenkov <[email protected]>
Quoted 8 lines
Quoted 3 lines
Some BIOSes do not always set CF on error before return from int13. The patch adds additional check for status being zero (AH == 0).
Do you have any evidence that there aren't any BIOSes which leave AH != 0 on legitimate success? If so, you have turned a nuisance bug into something that could cause install failures.
Hmm ... if install depends on having valid MBR, it will break right now as well, because it will have duplicated signatures. So at least something like following is needed.
arch/x86/boot/edd.c +1 -0
@@ -58,6 +58,7 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)if (mbrbuf_end > (char *)(size_t )boot_params.hdr.heap_end_ptr)return -1 ; +memset (mbrbuf_ptr,0 , sector_size);if (read_mbr (devno, mbrbuf_ptr))return -1 ;
Quoted 3 lines · H. Peter Anvin
I think this is closer to what we really want; after all, memory being written is the "first principles" test that applies here.
OK I have been using this for some time. I do not actually insist on returning "failure" for zero signature; my main concern was duplicated signature resulted from not clearing read buffer. Still I assume that zero signature is the same as no signature; i.e. even if disk is physically present but zeroed out there is no point in presenting mbr_signature in sysfs either.
Subject: [PATCH] Fix ghost entries under /sys/firmware/edd take 2
From: Andrey Borzenkov < [email protected]>
Some BIOSes do not indicate error when trying to read from non- existing device. Zero buffer before reading and check that we actually got some data.
This was fixed in different way for edd.S in
http://marc.info/?l=linux-kernel&m=114087765422490&w=2, but lost again when edd.S was rewritten in C.
---
arch/x86/boot/edd.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/boot/edd.c +2 -1
@@ -58,11 +58,12 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)if (mbrbuf_end > (char *)(size_t )boot_params.hdr.heap_end_ptr)return -1 ; +memset (mbrbuf_ptr,0 , sector_size);if (read_mbr (devno, mbrbuf_ptr))return -1 ; *mbrsig = *(u32 *)&mbrbuf_ptr[EDD_MBR_SIG_OFFSET ]; -return 0 ; +return -!*mbrsig;/* treat zero signature as no sig */ }static int get_edd_info (u8 devno,struct edd_info *ei)
H. Peter Anvin
reviewerQuoted 11 lines · Andrey Borzenkov
Quoted 2 lines · H. Peter Anvin
I think this is closer to what we really want; after all, memory being written is the "first principles" test that applies here.
OK I have been using this for some time. I do not actually insist on returning "failure" for zero signature; my main concern was duplicated signature resulted from not clearing read buffer. Still I assume that zero signature is the same as no signature; i.e. even if disk is physically present but zeroed out there is no point in presenting
mbr_signaturein sysfs either.
Right, I think that's a much better patch.
The really Right Thing[TM] to do is probably to pre-clear the buffer and then look for the 0xaa55 signature at offset 510; it is required for sector 0 to be a valid MBR-format partition table and hence for the MBR *signature* to be valid.
I'll write that up tomorrow (I'm travelling today), or you can send me a patch.
-hpa