Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Handle overlapping variable-range MTRRs fol...



details:   https://anonhg.NetBSD.org/src/rev/bc3be592231d
branches:  trunk
changeset: 760778:bc3be592231d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Jan 12 23:52:38 2011 +0000

description:
Handle overlapping variable-range MTRRs following the rules defined in
section 11.11.4.1 "MTRR Precendes" of the Intel(R) 64 and IA-32
Architectures Software Developer's Manual, Volume 3A.

diffstat:

 sys/arch/x86/x86/mtrr_i686.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 9e0b84f24be0 -r bc3be592231d sys/arch/x86/x86/mtrr_i686.c
--- a/sys/arch/x86/x86/mtrr_i686.c      Wed Jan 12 23:34:00 2011 +0000
+++ b/sys/arch/x86/x86/mtrr_i686.c      Wed Jan 12 23:52:38 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mtrr_i686.c,v 1.22 2010/07/08 09:42:08 cegger Exp $ */
+/*     $NetBSD: mtrr_i686.c,v 1.23 2011/01/12 23:52:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mtrr_i686.c,v 1.22 2010/07/08 09:42:08 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mtrr_i686.c,v 1.23 2011/01/12 23:52:38 jmcneill Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -63,7 +63,7 @@
 static void i686_raw2soft(void);
 static void i686_mtrr_commit(void);
 static int i686_mtrr_setone(struct mtrr *, struct proc *p);
-
+static int i686_mtrr_conflict(uint8_t, uint8_t);
 
 static struct mtrr_state
 mtrr_raw[] = {
@@ -622,7 +622,7 @@
                }
                if (((high >= curlow && high < curhigh) ||
                    (low >= curlow && low < curhigh)) &&
-                   ((mtrr_var[i].type != mtrrp->type) ||
+                   (i686_mtrr_conflict(mtrr_var[i].type, mtrrp->type) ||
                     ((mtrr_var[i].flags & MTRR_PRIVATE) &&
                      (!(mtrrp->flags & MTRR_PRIVATE) || (p == NULL) ||
                       (mtrr_var[i].owner != p->p_pid))))) {
@@ -638,6 +638,17 @@
        return 0;
 }
 
+static int
+i686_mtrr_conflict(uint8_t type1, uint8_t type2)
+{
+       if (type1 == MTRR_TYPE_UC || type2 == MTRR_TYPE_UC)
+               return 0;
+       if ((type1 == MTRR_TYPE_WT && type2 == MTRR_TYPE_WB) ||
+           (type1 == MTRR_TYPE_WB && type2 == MTRR_TYPE_WT))
+               return 0;
+       return 1;
+}
+
 static void
 i686_mtrr_clean(struct proc *p)
 {



Home | Main Index | Thread Index | Old Index