svn commit: r276600 - in head/sys/amd64: amd64 include
Konstantin Belousov
kib at FreeBSD.org
Sat Jan 3 01:29:00 UTC 2015
Author: kib
Date: Sat Jan 3 01:28:58 2015
New Revision: 276600
URL: https://svnweb.freebsd.org/changeset/base/276600
Log:
For /dev/mem and /dev/kmem accesses, avoid asserting that addresses
are within direct map. We want to return error instead of panicing.
PR: 194995
Sponsored by: The FreeBSD Foundation
Modified:
head/sys/amd64/amd64/mem.c
head/sys/amd64/include/vmparam.h
Modified: head/sys/amd64/amd64/mem.c
==============================================================================
--- head/sys/amd64/amd64/mem.c Sat Jan 3 00:31:52 2015 (r276599)
+++ head/sys/amd64/amd64/mem.c Sat Jan 3 01:28:58 2015 (r276600)
@@ -98,7 +98,7 @@ memrw(struct cdev *dev, struct uio *uio,
kmemphys:
o = v & PAGE_MASK;
c = min(uio->uio_resid, (u_int)(PAGE_SIZE - o));
- vd = PHYS_TO_DMAP(v);
+ vd = PHYS_TO_DMAP_RAW(v);
if (vd < DMAP_MIN_ADDRESS ||
(vd > DMAP_MIN_ADDRESS + dmaplimit &&
vd <= DMAP_MAX_ADDRESS) ||
@@ -112,7 +112,7 @@ kmemphys:
v = uio->uio_offset;
if (v >= DMAP_MIN_ADDRESS && v < DMAP_MAX_ADDRESS) {
- v = DMAP_TO_PHYS(v);
+ v = DMAP_TO_PHYS_RAW(v);
goto kmemphys;
}
Modified: head/sys/amd64/include/vmparam.h
==============================================================================
--- head/sys/amd64/include/vmparam.h Sat Jan 3 00:31:52 2015 (r276599)
+++ head/sys/amd64/include/vmparam.h Sat Jan 3 01:28:58 2015 (r276600)
@@ -183,6 +183,8 @@
#define VM_MAX_ADDRESS UPT_MAX_ADDRESS
#define VM_MIN_ADDRESS (0)
+#define PHYS_TO_DMAP_RAW(x) ((x) | DMAP_MIN_ADDRESS)
+#define DMAP_TO_PHYS_RAW(x) ((x) & ~DMAP_MIN_ADDRESS)
/*
* XXX Allowing dmaplimit == 0 is a temporary workaround for vt(4) efifb's
* early use of PHYS_TO_DMAP before the mapping is actually setup. This works
@@ -193,14 +195,14 @@
KASSERT(dmaplimit == 0 || (x) < dmaplimit, \
("physical address %#jx not covered by the DMAP", \
(uintmax_t)x)); \
- (x) | DMAP_MIN_ADDRESS; })
+ PHYS_TO_DMAP_RAW(x); })
#define DMAP_TO_PHYS(x) ({ \
KASSERT((x) < (DMAP_MIN_ADDRESS + dmaplimit) && \
(x) >= DMAP_MIN_ADDRESS, \
("virtual address %#jx not covered by the DMAP", \
(uintmax_t)x)); \
- (x) & ~DMAP_MIN_ADDRESS; })
+ DMAP_TO_PHYS_RAW(x); })
/*
* How many physical pages per kmem arena virtual page.
More information about the svn-src-head
mailing list