mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jan Beulich" <jbeulich@novell.com>
To: "Andrew Morton" <akpm@osdl.org>,
	"Andreas Mohr" <andi@rhlx01.fht-esslingen.de>
Cc: <rgooch@atnf.csiro.au>, "Kurt Garloff" <garloff@suse.de>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] fix buggy MTRR address checks
Date: Wed, 04 Oct 2006 09:53:30 +0100	[thread overview]
Message-ID: <452392AA.76E4.0078.0@novell.com> (raw)
In-Reply-To: <20061003125553.GA3648@rhlx01.fht-esslingen.de>

Ack

>>> Andreas Mohr <andi@rhlx01.fht-esslingen.de> 03.10.06 14:55 >>>
Fix checks that failed to realize that values are 4-kB-unit-sized
(note the format strings in this same diff context which *do* realize the
unit size, via appended "000"!).
Also fix an incorrect below-1MB area check (as gathered from Jan Beulich's
unapplied patch at
http://www.ussg.iu.edu/hypermail/linux/kernel/0411.1/1378.html )
Update mtrr_add_page() docu to make 4-kB-sized calculation more obvious.



Given several further items mentioned in Jan's patch mail, all in all
MTRR code seems surprisingly buggy, for a surprisingly long period of time
(many years). Further work/investigation would be useful.

Note that my patch is pretty much UNTESTED, since I can only verify that
it successfully boots my machine, but I cannot test against actual buggy
hardware which would require these (formerly broken) checks.
Long -mm simmering would make sense, especially since these now-working
checks might turn out to have adverse effects on unaffected hardware.

Signed-off-by: Andreas Mohr <andi@lisas.de>


diff -urN linux-2.6.18-mm3.orig/arch/i386/kernel/cpu/mtrr/generic.c
linux-2.6.18-mm3/arch/i386/kernel/cpu/mtrr/generic.c
--- linux-2.6.18-mm3.orig/arch/i386/kernel/cpu/mtrr/generic.c	2006-10-11 11:59:45.000000000 +0200
+++ linux-2.6.18-mm3/arch/i386/kernel/cpu/mtrr/generic.c	2006-10-11 12:04:37.000000000 +0200
@@ -366,7 +366,7 @@
 			printk(KERN_WARNING "mtrr: base(0x%lx000) is not 4 MiB aligned\n", base);
 			return -EINVAL;
 		}
-		if (!(base + size < 0x70000000 || base > 0x7003FFFF) &&
+		if (!(base + size < 0x70000 || base > 0x7003F) &&
 		    (type == MTRR_TYPE_WRCOMB
 		     || type == MTRR_TYPE_WRBACK)) {
 			printk(KERN_WARNING "mtrr: writable mtrr between 0x70000000 and 0x7003FFFF may hang the
CPU.\n");
@@ -374,7 +374,7 @@
 		}
 	}
 
-	if (base + size < 0x100) {
+	if (base < 0x100) {
 		printk(KERN_WARNING "mtrr: cannot set region below 1 MiB (0x%lx000,0x%lx000)\n",
 		       base, size);
 		return -EINVAL;
diff -urN linux-2.6.18-mm3.orig/arch/i386/kernel/cpu/mtrr/main.c linux-2.6.18-mm3/arch/i386/kernel/cpu/mtrr/main.c
--- linux-2.6.18-mm3.orig/arch/i386/kernel/cpu/mtrr/main.c	2006-08-18 20:03:00.000000000 +0200
+++ linux-2.6.18-mm3/arch/i386/kernel/cpu/mtrr/main.c	2006-10-11 12:04:37.000000000 +0200
@@ -263,8 +263,8 @@
 
 /**
  *	mtrr_add_page - Add a memory type region
- *	@base: Physical base address of region in pages (4 KB)
- *	@size: Physical size of region in pages (4 KB)
+ *	@base: Physical base address of region in pages (in units of 4 kB!)
+ *	@size: Physical size of region in pages (4 kB)
  *	@type: Type of MTRR desired
  *	@increment: If this is true do usage counting on the region
  *

      reply	other threads:[~2006-10-04  8:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-03 12:55 Andreas Mohr
2006-10-04  8:53 ` Jan Beulich [this message]

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=452392AA.76E4.0078.0@novell.com \
    --to=jbeulich@novell.com \
    --cc=akpm@osdl.org \
    --cc=andi@rhlx01.fht-esslingen.de \
    --cc=garloff@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rgooch@atnf.csiro.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome