Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jan 2015 02:35:20 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r276871 - stable/10/sys/amd64/amd64
Message-ID:  <201501090235.t092ZKdb058605@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Jan  9 02:35:19 2015
New Revision: 276871
URL: https://svnweb.freebsd.org/changeset/base/276871

Log:
  MFC r276523:
  Restore access to the page at zero through /dev/mem after r263475.

Modified:
  stable/10/sys/amd64/amd64/mem.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/amd64/mem.c
==============================================================================
--- stable/10/sys/amd64/amd64/mem.c	Fri Jan  9 02:33:12 2015	(r276870)
+++ stable/10/sys/amd64/amd64/mem.c	Fri Jan  9 02:35:19 2015	(r276871)
@@ -77,7 +77,7 @@ int
 memrw(struct cdev *dev, struct uio *uio, int flags)
 {
 	struct iovec *iov;
-	u_long c, v;
+	u_long c, v, vd;
 	int error, o, sflags;
 	vm_offset_t addr, eaddr;
 
@@ -98,15 +98,15 @@ memrw(struct cdev *dev, struct uio *uio,
 kmemphys:
 			o = v & PAGE_MASK;
 			c = min(uio->uio_resid, (u_int)(PAGE_SIZE - o));
-			v = PHYS_TO_DMAP(v);
-			if (v < DMAP_MIN_ADDRESS ||
-			    (v > DMAP_MIN_ADDRESS + dmaplimit &&
-			    v <= DMAP_MAX_ADDRESS) ||
-			    pmap_kextract(v) == 0) {
+			vd = PHYS_TO_DMAP(v);
+			if (vd < DMAP_MIN_ADDRESS ||
+			    (vd > DMAP_MIN_ADDRESS + dmaplimit &&
+			    vd <= DMAP_MAX_ADDRESS) ||
+			    (pmap_kextract(vd) == 0 && (v & PG_FRAME) != 0)) {
 				error = EFAULT;
 				goto ret;
 			}
-			error = uiomove((void *)v, (int)c, uio);
+			error = uiomove((void *)vd, (int)c, uio);
 			continue;
 		} else if (dev2unit(dev) == CDEV_MINOR_KMEM) {
 			v = uio->uio_offset;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501090235.t092ZKdb058605>