Module Name:    src
Committed By:   jmcneill
Date:           Tue Jan 18 17:44:16 UTC 2011

Modified Files:
        src/sys/arch/x86/x86: mtrr_i686.c

Log Message:
- fix an off-by-one that disallowed adjacent mappings with conflicting
  types from being created
- only allow MTRR_TYPE_WC mappings if the processor supports it


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 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.23 src/sys/arch/x86/x86/mtrr_i686.c:1.24
--- src/sys/arch/x86/x86/mtrr_i686.c:1.23	Wed Jan 12 23:52:38 2011
+++ src/sys/arch/x86/x86/mtrr_i686.c	Tue Jan 18 17:44:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtrr_i686.c,v 1.23 2011/01/12 23:52:38 jmcneill Exp $ */
+/*	$NetBSD: mtrr_i686.c,v 1.24 2011/01/18 17:44:15 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.23 2011/01/12 23:52:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mtrr_i686.c,v 1.24 2011/01/18 17:44:15 jmcneill Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -481,6 +481,14 @@
 	    || mtrrp->type > MTRR_TYPE_WB) && (mtrrp->flags & MTRR_VALID))
 		return EINVAL;
 
+	/* 
+	 * If write-combining is requested, make sure that the WC feature   
+	 * is supported by the processor.
+	 */
+	if (mtrrp->type == MTRR_TYPE_WC &&
+	    !(i686_mtrr_cap & MTRR_I686_CAP_WC_MASK))
+		return ENODEV;
+
 	/*
 	 * Only use fixed ranges < 1M.
 	 */
@@ -604,7 +612,7 @@
 	 * XXX could be more sophisticated here by merging ranges.
 	 */
 	low = mtrrp->base;
-	high = low + mtrrp->len;
+	high = low + mtrrp->len - 1;
 	freep = NULL;
 	for (i = 0; i < i686_mtrr_vcnt; i++) {
 		if (!(mtrr_var[i].flags & MTRR_VALID)) {
@@ -612,7 +620,7 @@
 			continue;
 		}
 		curlow = mtrr_var[i].base;
-		curhigh = curlow + mtrr_var[i].len;
+		curhigh = curlow + mtrr_var[i].len - 1;
 		if (low == curlow && high == curhigh &&
 		    (!(mtrr_var[i].flags & MTRR_PRIVATE) ||
 		     ((mtrrp->flags & MTRR_PRIVATE) && (p != NULL) &&

Reply via email to