aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/memcontrol/memcontrol.c
diff options
context:
space:
mode:
authorDavid Malone <dwmalone@FreeBSD.org>2002-04-14 20:19:13 +0000
committerDavid Malone <dwmalone@FreeBSD.org>2002-04-14 20:19:13 +0000
commitb0f4bb511e9932d15818cbd17638b6de2b28b0b6 (patch)
tree6ebab0959ad6208b39369a74fec1bbdda1f550fb /usr.sbin/memcontrol/memcontrol.c
parent7376ec0dd789cd9713b53bfd62c683289eab8e3f (diff)
downloadsrc-b0f4bb511e9932d15818cbd17638b6de2b28b0b6.tar.gz
src-b0f4bb511e9932d15818cbd17638b6de2b28b0b6.zip
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 ;-) I'd like to MFC this before the 4.6 code freeze - please let me know if it causes any problems. PR: 28418, 25958 Tested by: jkh, Christopher Masto <chris@netmonger.net> MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=94684
Diffstat (limited to 'usr.sbin/memcontrol/memcontrol.c')
-rw-r--r--usr.sbin/memcontrol/memcontrol.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/usr.sbin/memcontrol/memcontrol.c b/usr.sbin/memcontrol/memcontrol.c
index 88d4768f6814..2554723733a9 100644
--- a/usr.sbin/memcontrol/memcontrol.c
+++ b/usr.sbin/memcontrol/memcontrol.c
@@ -50,6 +50,7 @@ struct
{"write-through", MDF_WRITETHROUGH, MDF_SETTABLE},
{"write-back", MDF_WRITEBACK, MDF_SETTABLE},
{"write-protect", MDF_WRITEPROTECT, MDF_SETTABLE},
+ {"unknown", MDF_UNKNOWN, 0},
{"fixed-base", MDF_FIXBASE, 0},
{"fixed-length", MDF_FIXLEN, 0},
{"set-by-firmware", MDF_FIRMWARE, 0},