All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@newmail.ru>
To: akpm@linux-foundation.org
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Matt_Domsch@dell.com, hpa@zytor.com, mingo@elte.hu,
	tglx@linutronix.de
Subject: Re: + x86-fix-ghost-entries-under-sys-firmware-edd.patch added to -mm tree
Date: Fri, 3 Oct 2008 21:08:49 +0400	[thread overview]
Message-ID: <200810032108.51047.arvidjaar@newmail.ru> (raw)
In-Reply-To: <200810030634.m936YVDC014640@imap1.linux-foundation.org>


[-- Attachment #1.1: Type: text/plain, Size: 645 bytes --]

On Friday 03 October 2008, akpm@linux-foundation.org wrote:
> hpa:
> 
>    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.
> 
> akpm:
> 
>    A patch in hand is worth...

I am really sorry; I botched this initially and then was distracted by other
things. The patch attached.

[-- Attachment #1.2: fix-edd-detection-v2 --]
[-- Type: text/x-diff, Size: 1518 bytes --]

Subject: [PATCH] Fix ghost entries under /sys/firmware/edd take 3
From: Andrey Borzenkov < arvidjaar@mail.ru>

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>

---

 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 d93cbc6..1aae8f3 100644
--- a/arch/x86/boot/edd.c
+++ b/arch/x86/boot/edd.c
@@ -41,6 +41,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)
@@ -58,11 +59,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)

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2008-10-03 17:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-03  6:34 + x86-fix-ghost-entries-under-sys-firmware-edd.patch added to -mm tree akpm
2008-10-03 17:08 ` Andrey Borzenkov [this message]
2008-10-03 17:15   ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200810032108.51047.arvidjaar@newmail.ru \
    --to=arvidjaar@newmail.ru \
    --cc=Matt_Domsch@dell.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.