Date: Wed, 18 Jan 2017 19:38:54 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r312394 - in stable/11/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 mips/mips powerpc/powerpc sparc64/sparc64 Message-ID: <201701181938.v0IJcs4f001268@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Wed Jan 18 19:38:53 2017 New Revision: 312394 URL: https://svnweb.freebsd.org/changeset/base/312394 Log: 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. Modified: stable/11/sys/amd64/amd64/mem.c stable/11/sys/arm/arm/mem.c stable/11/sys/arm64/arm64/mem.c stable/11/sys/i386/i386/mem.c stable/11/sys/mips/mips/mem.c stable/11/sys/powerpc/powerpc/mem.c stable/11/sys/sparc64/sparc64/mem.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/mem.c ============================================================================== --- stable/11/sys/amd64/amd64/mem.c Wed Jan 18 18:16:57 2017 (r312393) +++ stable/11/sys/amd64/amd64/mem.c Wed Jan 18 19:38:53 2017 (r312394) @@ -172,10 +172,9 @@ memmmap(struct cdev *dev, vm_ooffset_t o 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); } /* Modified: stable/11/sys/arm/arm/mem.c ============================================================================== --- stable/11/sys/arm/arm/mem.c Wed Jan 18 18:16:57 2017 (r312393) +++ stable/11/sys/arm/arm/mem.c Wed Jan 18 19:38:53 2017 (r312394) @@ -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); } Modified: stable/11/sys/arm64/arm64/mem.c ============================================================================== --- stable/11/sys/arm64/arm64/mem.c Wed Jan 18 18:16:57 2017 (r312393) +++ stable/11/sys/arm64/arm64/mem.c Wed Jan 18 19:38:53 2017 (r312394) @@ -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); } Modified: stable/11/sys/i386/i386/mem.c ============================================================================== --- stable/11/sys/i386/i386/mem.c Wed Jan 18 18:16:57 2017 (r312393) +++ stable/11/sys/i386/i386/mem.c Wed Jan 18 19:38:53 2017 (r312394) @@ -168,10 +168,9 @@ memmmap(struct cdev *dev, vm_ooffset_t o 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); } /* Modified: stable/11/sys/mips/mips/mem.c ============================================================================== --- stable/11/sys/mips/mips/mem.c Wed Jan 18 18:16:57 2017 (r312393) +++ stable/11/sys/mips/mips/mem.c Wed Jan 18 19:38:53 2017 (r312394) @@ -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); Modified: stable/11/sys/powerpc/powerpc/mem.c ============================================================================== --- stable/11/sys/powerpc/powerpc/mem.c Wed Jan 18 18:16:57 2017 (r312393) +++ stable/11/sys/powerpc/powerpc/mem.c Wed Jan 18 19:38:53 2017 (r312394) @@ -179,8 +179,6 @@ memmmap(struct cdev *dev, vm_ooffset_t o if (dev2unit(dev) == CDEV_MINOR_MEM) *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); else return (EFAULT); Modified: stable/11/sys/sparc64/sparc64/mem.c ============================================================================== --- stable/11/sys/sparc64/sparc64/mem.c Wed Jan 18 18:16:57 2017 (r312393) +++ stable/11/sys/sparc64/sparc64/mem.c Wed Jan 18 19:38:53 2017 (r312394) @@ -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. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701181938.v0IJcs4f001268>