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
This commit is contained in:
parent
5606bb1e5a
commit
771035aa6c
@ -98,7 +98,7 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
||||
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 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user