summaryrefslogtreecommitdiff
path: root/usr.sbin/memconfig
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2002-10-14 21:01:02 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2002-10-14 21:01:02 +0000
commit99fd6307b3a15281afcbf8ba8d4d4c32a0b0df90 (patch)
treed67a170ef234f9437ba4657e9d721b54699cbdb5 /usr.sbin/memconfig
parenta68c2438ac22f2fbb5fb53e11f16a45095a38b78 (diff)
Fix from FreeBSD for atlhon problems with mtrr and XFree86. Ok deraadt@
FreeBSD commit messages say: Some BIOSs are using MTRR values that are only documented under NDA to control the mapping of things like the ACPI and APM into memory. The problem is that starting X changes these values, so if something was using the bits of BIOS mapped into memory (say ACPI or APM), then next time they access this memory the machine would hang. This patch refuse to change MTRR values it doesn't understand, unless a new "force" option is given. This means X doesn't change them by accident but someone can override that if they really want to. PR: 28418 Tested by: Christopher Masto <chris at netmonger dot net>, David Bushong <david at bushong dot net>, Santos <casd at myrealbox dot com> Make the MTRR code a bit more defensive - this should help people trying to run X on some Athlon systems where the BIOS does odd things (mines an ASUS A7A266, but it seems to also help on other systems). Here's a description of the problem and my fix: The problem with the old MTRR code is that it only expects to find documented values in the bytes of MTRR registers. To convert the MTRR byte into a FreeBSD "Memory Range Type" (mrt) it uses the byte value and looks it up in an array. If the value is not in range then the mrt value ends up containing random junk. This isn't an immediate problem. The mrt value is only used later when rewriting the MTRR registers. When we finally go to write a value back again, the function i686_mtrrtype() searches for the junk value and returns -1 when it fails to find it. This is converted to a byte (0xff) and written back to the register, causing a GPF as 0xff is an illegal value for a MTRR byte. To work around this problem I've added a new mrt flag MDF_UNKNOWN. We set this when we read a MTRR byte which we do not understand. If we try to convert a MDF_UNKNOWN back into a MTRR value, then the new function, i686_mrt2mtrr, just returns the old value of the MTRR byte. This leaves the memory range type unchanged. I have seen one side effect of the fix, which is that ACPI calls after X has been run seem to hang my machine. As running X would previously panic the machine, this is still an improvement ;-) PR: 28418, 25958 Tested by: jkh, Christopher Masto <chris at netmonger dot net>
Diffstat (limited to 'usr.sbin/memconfig')
-rw-r--r--usr.sbin/memconfig/memconfig.87
-rw-r--r--usr.sbin/memconfig/memconfig.c6
2 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/memconfig/memconfig.8 b/usr.sbin/memconfig/memconfig.8
index 71da1624d63..76aa4d42fcb 100644
--- a/usr.sbin/memconfig/memconfig.8
+++ b/usr.sbin/memconfig/memconfig.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: memconfig.8,v 1.6 2001/08/17 11:13:58 mpech Exp $
+.\" $OpenBSD: memconfig.8,v 1.7 2002/10/14 21:01:01 matthieu Exp $
.\"
.\" Copyright (c) 1999 Chris Costello
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/usr.sbin/memcontrol/memcontrol.8,v 1.2 1999/10/09 16:37:37 chris Exp $
+.\" $FreeBSD: /home/ncvs/src/usr.sbin/memcontrol/memcontrol.8,v 1.9 2002/09/15 15:07:55 dwmalone Exp $
.\"
.Dd November 14, 1999
.Dt MEMCONFIG 8
@@ -83,7 +83,8 @@ Length of memory range in bytes, power of 2.
.It Fl o Ar owner
Text identifier for this setting (7 char max).
.It Ar attribute
-Attributes applied to this range; one of
+Attributes applied to this range; combinations of
+.Ar force ,
.Ar uncacheable ,
.Ar write-combine ,
.Ar write-through ,
diff --git a/usr.sbin/memconfig/memconfig.c b/usr.sbin/memconfig/memconfig.c
index b58da845765..bdd182ad516 100644
--- a/usr.sbin/memconfig/memconfig.c
+++ b/usr.sbin/memconfig/memconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memconfig.c,v 1.5 2002/05/30 19:09:05 deraadt Exp $ */
+/* $OpenBSD: memconfig.c,v 1.6 2002/10/14 21:01:01 matthieu Exp $ */
/*-
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/memcontrol/memcontrol.c,v 1.3 1999/08/28 01:17:00 peter Exp $
+ * $FreeBSD: /home/ncvs/src/usr.sbin/memcontrol/memcontrol.c,v 1.8 2002/09/15 15:07:55 dwmalone Exp $
*/
#include <sys/types.h>
@@ -50,6 +50,8 @@ struct
{"write-through", MDF_WRITETHROUGH, MDF_SETTABLE},
{"write-back", MDF_WRITEBACK, MDF_SETTABLE},
{"write-protect", MDF_WRITEPROTECT, MDF_SETTABLE},
+ {"force", MDF_FORCE, MDF_SETTABLE},
+ {"unknown", MDF_UNKNOWN, 0},
{"fixed-base", MDF_FIXBASE, 0},
{"fixed-length", MDF_FIXLEN, 0},
{"set-by-firmware", MDF_FIRMWARE, 0},