diff options
author | jhb <jhb@FreeBSD.org> | 2017-01-18 19:38:53 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2017-01-18 19:38:53 +0000 |
commit | 408517410d34e87f7bbc6d985b7b49d60ae40e1d (patch) | |
tree | e17792e86cde13f5e919550b89e0e1ab25a0c94a /sys | |
parent | 4d4bfe27534638421ca344bba7e3ed69a6008615 (diff) | |
download | FreeBSD-src-408517410d34e87f7bbc6d985b7b49d60ae40e1d.zip FreeBSD-src-408517410d34e87f7bbc6d985b7b49d60ae40e1d.tar.gz |
MFC 307332,312086: Drop support for using mmap() with /dev/kmem.
307332:
Drop support for using mmap() with /dev/kmem.
Using the device pager with /dev/kmem is not stable since KVA mappings
are transient, but the device pager caches the PA associated with a
given offset forever. Interestingly, mips' implementation of
memmap() already refused requests for /dev/kmem.
Note that kvm_read/kvm_write do not use mmap, but use read and write on
/dev/kmem, so this should not affect libkvm users.
312086:
Trim a few comments on platforms that did not implement mmap of /dev/kmem.
After r307332, no platforms implement mmap for /dev/kmem, so the lack of
it for these platforms is no longer unique.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/amd64/amd64/mem.c | 7 | ||||
-rw-r--r-- | sys/arm/arm/mem.c | 9 | ||||
-rw-r--r-- | sys/arm64/arm64/mem.c | 9 | ||||
-rw-r--r-- | sys/i386/i386/mem.c | 7 | ||||
-rw-r--r-- | sys/mips/mips/mem.c | 6 | ||||
-rw-r--r-- | sys/powerpc/powerpc/mem.c | 2 | ||||
-rw-r--r-- | sys/sparc64/sparc64/mem.c | 2 |
7 files changed, 15 insertions, 27 deletions
diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c index 7325664..c2e74ff 100644 --- a/sys/amd64/amd64/mem.c +++ b/sys/amd64/amd64/mem.c @@ -172,10 +172,9 @@ memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, if (offset > cpu_getmaxphyaddr()) return (-1); *paddr = offset; - } else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } /* diff --git a/sys/arm/arm/mem.c b/sys/arm/arm/mem.c index 096988d..c2cf320 100644 --- a/sys/arm/arm/mem.c +++ b/sys/arm/arm/mem.c @@ -161,10 +161,9 @@ int memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int prot __unused, vm_memattr_t *memattr __unused) { - if (dev2unit(dev) == CDEV_MINOR_MEM) + if (dev2unit(dev) == CDEV_MINOR_MEM) { *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } diff --git a/sys/arm64/arm64/mem.c b/sys/arm64/arm64/mem.c index 9044fb3..e0ea488 100644 --- a/sys/arm64/arm64/mem.c +++ b/sys/arm64/arm64/mem.c @@ -123,10 +123,9 @@ int memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int prot __unused, vm_memattr_t *memattr __unused) { - if (dev2unit(dev) == CDEV_MINOR_MEM) + if (dev2unit(dev) == CDEV_MINOR_MEM) { *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c index 003f207f..accd092 100644 --- a/sys/i386/i386/mem.c +++ b/sys/i386/i386/mem.c @@ -168,10 +168,9 @@ memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, if (offset > cpu_getmaxphyaddr()) return (-1); *paddr = offset; - } else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } /* diff --git a/sys/mips/mips/mem.c b/sys/mips/mips/mem.c index 08bb6b0..30f4b34 100644 --- a/sys/mips/mips/mem.c +++ b/sys/mips/mips/mem.c @@ -151,12 +151,6 @@ int memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int prot, vm_memattr_t *memattr) { - /* - * /dev/mem is the only one that makes sense through this - * interface. For /dev/kmem any physaddr we return here - * could be transient and hence incorrect or invalid at - * a later time. - */ if (dev2unit(dev) != CDEV_MINOR_MEM) return (-1); diff --git a/sys/powerpc/powerpc/mem.c b/sys/powerpc/powerpc/mem.c index a7fbfa3..2bc89fd 100644 --- a/sys/powerpc/powerpc/mem.c +++ b/sys/powerpc/powerpc/mem.c @@ -179,8 +179,6 @@ memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, if (dev2unit(dev) == CDEV_MINOR_MEM) *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); else return (EFAULT); diff --git a/sys/sparc64/sparc64/mem.c b/sys/sparc64/sparc64/mem.c index 6bd5225..a25bef4 100644 --- a/sys/sparc64/sparc64/mem.c +++ b/sys/sparc64/sparc64/mem.c @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$"); /* * Memory special file * - * NOTE: other architectures support mmap()'ing the mem and kmem devices; this + * NOTE: other architectures support mmap()'ing the mem device; this * might cause illegal aliases to be created for the locked kernel page(s), so * it is not implemented. */ |