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:
kib 2015-02-14 08:44:12 +00:00
parent 8483297749
commit c85a726887
5 changed files with 7 additions and 11 deletions

View File

@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/sx.h>
#include <sys/systm.h>
#include <sys/uio.h>
@ -72,6 +73,9 @@ MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
struct mem_range_softc mem_range_softc;
static struct sx tmppt_lock;
SX_SYSINIT(tmppt, &tmppt_lock, "mem4map");
/* ARGSUSED */
int
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;
vm_offset_t addr, eaddr;
GIANT_REQUIRED;
while (uio->uio_resid > 0 && error == 0) {
iov = uio->uio_iov;
if (iov->iov_len == 0) {
@ -109,6 +111,7 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
}
if (!address_valid)
return (EINVAL);
sx_xlock(&tmppt_lock);
pmap_kenter((vm_offset_t)_tmppt, v);
o = (int)uio->uio_offset & 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);
error = uiomove((caddr_t)&_tmppt[o], (int)c, uio);
pmap_qremove((vm_offset_t)_tmppt, 1);
sx_xunlock(&tmppt_lock);
continue;
}
else if (dev2unit(dev) == CDEV_MINOR_KMEM) {

View File

@ -52,7 +52,7 @@ static struct cdev *memdev, *kmemdev;
static struct cdevsw mem_cdevsw = {
.d_version = D_VERSION,
.d_flags = D_MEM|D_NEEDGIANT,
.d_flags = D_MEM,
.d_open = memopen,
.d_read = memrw,
.d_write = memrw,

View File

@ -86,10 +86,6 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
int error = 0;
vm_offset_t addr;
/* XXX UPS Why ? */
GIANT_REQUIRED;
if (dev2unit(dev) != CDEV_MINOR_MEM && dev2unit(dev) != CDEV_MINOR_KMEM)
return EIO;

View File

@ -85,8 +85,6 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
cnt = 0;
error = 0;
GIANT_REQUIRED;
pmap_page_init(&m);
while (uio->uio_resid > 0 && !error) {
iov = uio->uio_iov;

View File

@ -100,8 +100,6 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
error = 0;
ova = 0;
GIANT_REQUIRED;
while (uio->uio_resid > 0 && error == 0) {
iov = uio->uio_iov;
if (iov->iov_len == 0) {