Skip to contentSkip to conversation

Ghost EDD devices in /sys again

PATCH In review Andrey Borzenkov 3 participants 6 messages Sep 5, 2008 – Sep 6, 2008 x86

lore
Share & tools
lore
#0 lore raw

This is regression but old enough. Apparently I had for whatever reasons EDD turned off till recently. This is 2.6.27-rc5 just in case.

In 2006 I fixed ghost devices due to buggy BIOS:

http://marc.info/?l=linux-kernel&m=114087765422490&w=2

Later edd.S has been rewritten in C, and apparently this patch has been lost:

{pts/1}% ls /sys/firmware/edd

int13_dev80/  int13_dev84/  int13_dev88/  int13_dev8c/
int13_dev81/  int13_dev85/  int13_dev89/  int13_dev8d/
int13_dev82/  int13_dev86/  int13_dev8a/  int13_dev8e/
int13_dev83/  int13_dev87/  int13_dev8b/  int13_dev8f/

But I have just a single disk. This is the same system BTW.

Unfortunately I do not speak asm language of C; if somebody could provide equivalent fix for current edd.c, I am more than ready to test it.

Thank you

-andrey

#1 lore raw

PATCH 1/1 Ghost EDD devices in /sys again

Quoted 16 lines · Andrey Borzenkov

This is regression but old enough. Apparently I had for whatever reasons EDD turned off till recently. This is 2.6.27-rc5 just in case.

In 2006 I fixed ghost devices due to buggy BIOS:

http://marc.info/?l=linux-kernel&m=114087765422490&w=2

Later edd.S has been rewritten in C, and apparently this patch has been lost:

{pts/1}% ls /sys/firmware/edd

int13_dev80/  int13_dev84/  int13_dev88/  int13_dev8c/
int13_dev81/  int13_dev85/  int13_dev89/  int13_dev8d/
int13_dev82/  int13_dev86/  int13_dev8a/  int13_dev8e/
int13_dev83/  int13_dev87/  int13_dev8b/  int13_dev8f/
Quoted 4 lines

But I have just a single disk. This is the same system BTW.

Unfortunately I do not speak asm language of C; if somebody could provide equivalent fix for current edd.c, I am more than ready to test it.

Was it really that simple?

Subject: [PATCH] Fix ghost devices under /sys/firmware/edd
From: Andrey Borzenkov <[email protected]>

Some BIOSes do not always set CF on error before return from int13. The patch adds additional check for status being zero (AH == 0).

This was fixed 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 |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/boot/edd.c +3 -1
index d93cbc6..bf4ae6f 100644
@@ -32,7 +32,9 @@ static int read_mbr(u8 devno, void *buf)
 		     : "+a" (ax), "+c" (cx), "+d" (dx), "+b" (bx)
 		     : : "esi", "edi", "memory");
 
-	return -(u8)ax;		/* 0 or -1 */
+	/* Some BIOSes do not set carry flag on error but still return
+	 * error in AH. The condition below is expected to catch both */
+	return -!!ax;		/* 0 or -1 */
 }
 
 static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)
#2 lore raw
Quoted 47 lines · Andrey Borzenkov
Quoted 16 lines · Andrey Borzenkov

This is regression but old enough. Apparently I had for whatever reasons EDD turned off till recently. This is 2.6.27-rc5 just in case.

In 2006 I fixed ghost devices due to buggy BIOS:

http://marc.info/?l=linux-kernel&m=114087765422490&w=2

Later edd.S has been rewritten in C, and apparently this patch has been lost:

{pts/1}% ls /sys/firmware/edd

int13_dev80/  int13_dev84/  int13_dev88/  int13_dev8c/
int13_dev81/  int13_dev85/  int13_dev89/  int13_dev8d/
int13_dev82/  int13_dev86/  int13_dev8a/  int13_dev8e/
int13_dev83/  int13_dev87/  int13_dev8b/  int13_dev8f/
Quoted 4 lines

But I have just a single disk. This is the same system BTW.

Unfortunately I do not speak asm language of C; if somebody could provide equivalent fix for current edd.c, I am more than ready to test it.

Was it really that simple?

Subject: [PATCH] Fix ghost devices under /sys/firmware/edd
From: Andrey Borzenkov <[email protected]>

Some BIOSes do not always set CF on error before return from int13. The patch adds additional check for status being zero (AH == 0).

This was fixed 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 |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/boot/edd.c +0 -0
index d93cbc6..bf4ae6f 100644

arch/x86/boot/edd.c static int read_mbr(u8 devno, void *buf) · line 40

Quoted 10 lines
arch/x86/boot/edd.c +3 -1
@@ -32,7 +32,9 @@ static int read_mbr(u8 devno, void *buf)
 		     : "+a" (ax), "+c" (cx), "+d" (dx), "+b" (bx)
 		     : : "esi", "edi", "memory");
 
-	return -(u8)ax;		/* 0 or -1 */
+	/* Some BIOSes do not set carry flag on error but still return
+	 * error in AH. The condition below is expected to catch both */
+	return -!!ax;		/* 0 or -1 */
 }
 
 static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)

looks good to me - applied it to tip/x86/urgent. Thanks Andrey!

Ingo

#3 lore raw
Quoted 1 line · Ingo Molnar

looks good to me - applied it to tip/x86/urgent. Thanks Andrey!

ok - Peter says he'd rather like to investigate this some more and have the fix in v2.6.28 instead - so i moved it from tip/x86/urgent to tip/x86/setup.

Ingo

#4 lore raw
In reply to Andrey Borzenkov
Quoted 9 lines · Andrey Borzenkov

Was it really that simple?

Subject: [PATCH] Fix ghost devices under /sys/firmware/edd
From: Andrey Borzenkov <[email protected]>

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.

-hpa

#5 lore raw
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
index d93cbc6..4c20d31 100644
@@ -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;