MFC r277643:
Remove Giant from /dev/mem and /dev/kmem. MFC r277743: Arm: ensure that _tmppt KVA is used exclusively.
This commit is contained in:
parent
8483297749
commit
c85a726887
@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/signalvar.h>
|
#include <sys/signalvar.h>
|
||||||
|
#include <sys/sx.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
@ -72,6 +73,9 @@ MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
|
|||||||
|
|
||||||
struct mem_range_softc mem_range_softc;
|
struct mem_range_softc mem_range_softc;
|
||||||
|
|
||||||
|
static struct sx tmppt_lock;
|
||||||
|
SX_SYSINIT(tmppt, &tmppt_lock, "mem4map");
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
memrw(struct cdev *dev, struct uio *uio, int flags)
|
memrw(struct cdev *dev, struct uio *uio, int flags)
|
||||||
@ -82,8 +86,6 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
vm_offset_t addr, eaddr;
|
vm_offset_t addr, eaddr;
|
||||||
|
|
||||||
GIANT_REQUIRED;
|
|
||||||
|
|
||||||
while (uio->uio_resid > 0 && error == 0) {
|
while (uio->uio_resid > 0 && error == 0) {
|
||||||
iov = uio->uio_iov;
|
iov = uio->uio_iov;
|
||||||
if (iov->iov_len == 0) {
|
if (iov->iov_len == 0) {
|
||||||
@ -109,6 +111,7 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
|||||||
}
|
}
|
||||||
if (!address_valid)
|
if (!address_valid)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
sx_xlock(&tmppt_lock);
|
||||||
pmap_kenter((vm_offset_t)_tmppt, v);
|
pmap_kenter((vm_offset_t)_tmppt, v);
|
||||||
o = (int)uio->uio_offset & PAGE_MASK;
|
o = (int)uio->uio_offset & PAGE_MASK;
|
||||||
c = (u_int)(PAGE_SIZE - ((int)iov->iov_base & PAGE_MASK));
|
c = (u_int)(PAGE_SIZE - ((int)iov->iov_base & PAGE_MASK));
|
||||||
@ -116,6 +119,7 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
|||||||
c = min(c, (u_int)iov->iov_len);
|
c = min(c, (u_int)iov->iov_len);
|
||||||
error = uiomove((caddr_t)&_tmppt[o], (int)c, uio);
|
error = uiomove((caddr_t)&_tmppt[o], (int)c, uio);
|
||||||
pmap_qremove((vm_offset_t)_tmppt, 1);
|
pmap_qremove((vm_offset_t)_tmppt, 1);
|
||||||
|
sx_xunlock(&tmppt_lock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (dev2unit(dev) == CDEV_MINOR_KMEM) {
|
else if (dev2unit(dev) == CDEV_MINOR_KMEM) {
|
||||||
|
@ -52,7 +52,7 @@ static struct cdev *memdev, *kmemdev;
|
|||||||
|
|
||||||
static struct cdevsw mem_cdevsw = {
|
static struct cdevsw mem_cdevsw = {
|
||||||
.d_version = D_VERSION,
|
.d_version = D_VERSION,
|
||||||
.d_flags = D_MEM|D_NEEDGIANT,
|
.d_flags = D_MEM,
|
||||||
.d_open = memopen,
|
.d_open = memopen,
|
||||||
.d_read = memrw,
|
.d_read = memrw,
|
||||||
.d_write = memrw,
|
.d_write = memrw,
|
||||||
|
@ -86,10 +86,6 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
vm_offset_t addr;
|
vm_offset_t addr;
|
||||||
|
|
||||||
/* XXX UPS Why ? */
|
|
||||||
GIANT_REQUIRED;
|
|
||||||
|
|
||||||
|
|
||||||
if (dev2unit(dev) != CDEV_MINOR_MEM && dev2unit(dev) != CDEV_MINOR_KMEM)
|
if (dev2unit(dev) != CDEV_MINOR_MEM && dev2unit(dev) != CDEV_MINOR_KMEM)
|
||||||
return EIO;
|
return EIO;
|
||||||
|
|
||||||
|
@ -85,8 +85,6 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
|||||||
cnt = 0;
|
cnt = 0;
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
GIANT_REQUIRED;
|
|
||||||
|
|
||||||
pmap_page_init(&m);
|
pmap_page_init(&m);
|
||||||
while (uio->uio_resid > 0 && !error) {
|
while (uio->uio_resid > 0 && !error) {
|
||||||
iov = uio->uio_iov;
|
iov = uio->uio_iov;
|
||||||
|
@ -100,8 +100,6 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
|
|||||||
error = 0;
|
error = 0;
|
||||||
ova = 0;
|
ova = 0;
|
||||||
|
|
||||||
GIANT_REQUIRED;
|
|
||||||
|
|
||||||
while (uio->uio_resid > 0 && error == 0) {
|
while (uio->uio_resid > 0 && error == 0) {
|
||||||
iov = uio->uio_iov;
|
iov = uio->uio_iov;
|
||||||
if (iov->iov_len == 0) {
|
if (iov->iov_len == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user