X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6601e61aa18bf4f09af135ff61fc7f4771d23b06..0c530ab8987f0ae6a1a3d9284f40182b88852816:/bsd/dev/i386/mem.c diff --git a/bsd/dev/i386/mem.c b/bsd/dev/i386/mem.c index 892be2473..7bcebdae6 100644 --- a/bsd/dev/i386/mem.c +++ b/bsd/dev/i386/mem.c @@ -79,8 +79,9 @@ #include #include /* for kernel_map */ -extern vm_offset_t kvtophys(vm_offset_t va); +extern addr64_t kvtophys(vm_offset_t va); extern boolean_t kernacc(off_t, size_t ); +extern int setup_kmem; static caddr_t devzerobuf; @@ -104,9 +105,14 @@ mmwrite(dev_t dev, struct uio *uio) } int -mmioctl(__unused dev_t dev, u_long cmd, __unused caddr_t data, +mmioctl(dev_t dev, u_long cmd, __unused caddr_t data, __unused int flag, __unused struct proc *p) { + int minnum = minor(dev); + + if ((setup_kmem == 0) && ((minnum == 0) || (minnum == 1))) + return(EINVAL); + switch (cmd) { case FIONBIO: case FIOASYNC: @@ -128,6 +134,7 @@ mmrw(dev_t dev, struct uio *uio, enum uio_rw rw) vm_offset_t where; vm_size_t size; + while (uio_resid(uio) > 0 && error == 0) { if (uio_iov_len(uio) == 0) { uio_next_iov(uio); @@ -140,6 +147,9 @@ mmrw(dev_t dev, struct uio *uio, enum uio_rw rw) /* minor device 0 is physical memory */ case 0: + if (setup_kmem == 0) + return(ENODEV); + v = trunc_page(uio->uio_offset); if (uio->uio_offset >= mem_size) goto fault; @@ -158,6 +168,8 @@ mmrw(dev_t dev, struct uio *uio, enum uio_rw rw) /* minor device 1 is kernel memory */ case 1: + if (setup_kmem == 0) + return(ENODEV); /* Do some sanity checking */ if (((vm_address_t)uio->uio_offset >= VM_MAX_KERNEL_ADDRESS) || ((vm_address_t)uio->uio_offset <= VM_MIN_KERNEL_ADDRESS))