diff options
author | Andrey Borzenkov <arvidjaar@newmail.ru> | 2008-10-03 21:08:49 +0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-10-03 10:15:29 -0700 |
commit | 6cdcdb99cf7c2e1835fc5b471864d21161c3e679 (patch) | |
tree | e3dab8fad3748c93fc0870964cbfa8ec8f2e84b6 /arch/x86/boot | |
parent | 464f04c9e9b3b1c4f5ffb89c51d8ba2a2034c846 (diff) | |
download | blackbird-op-linux-6cdcdb99cf7c2e1835fc5b471864d21161c3e679.tar.gz blackbird-op-linux-6cdcdb99cf7c2e1835fc5b471864d21161c3e679.zip |
x86 setup: fix ghost entries under /sys/firmware/edd take 3
Some BIOSes do not indicate error when trying to read from non-
existing device. Zero buffer before reading and check that we
possibly have valid MBR by looking for MBR magic.
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.
Signed-off-by: Andrey Borzenkov < arvidjaar@mail.ru>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/boot')
-rw-r--r-- | arch/x86/boot/edd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/x86/boot/edd.c b/arch/x86/boot/edd.c index bf4ae6ff518e..067e28cd3c5f 100644 --- a/arch/x86/boot/edd.c +++ b/arch/x86/boot/edd.c @@ -43,6 +43,7 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig) char *mbrbuf_ptr, *mbrbuf_end; u32 buf_base, mbr_base; extern char _end[]; + u16 mbr_magic; sector_size = ei->params.bytes_per_sector; if (!sector_size) @@ -60,11 +61,15 @@ 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; + mbr_magic = *(u16 *)&mbrbuf_ptr[510]; + + /* check for valid MBR magic */ + return mbr_magic == 0xAA55 ? 0 : -1; } static int get_edd_info(u8 devno, struct edd_info *ei) |