Module Name: src Committed By: jmcneill Date: Wed Jan 12 23:52:38 UTC 2011
Modified Files: src/sys/arch/x86/x86: mtrr_i686.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/x86/mtrr_i686.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/x86/mtrr_i686.c diff -u src/sys/arch/x86/x86/mtrr_i686.c:1.22 src/sys/arch/x86/x86/mtrr_i686.c:1.23 --- src/sys/arch/x86/x86/mtrr_i686.c:1.22 Thu Jul 8 09:42:08 2010 +++ src/sys/arch/x86/x86/mtrr_i686.c Wed Jan 12 23:52:38 2011 @@ -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) {