From owner-svn-src-projects@FreeBSD.ORG Tue Jun 16 01:43:34 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1AFCC106566B; Tue, 16 Jun 2009 01:43:34 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E38F48FC16; Tue, 16 Jun 2009 01:43:33 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5G1hXLc008370; Tue, 16 Jun 2009 01:43:33 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5G1hX1Y008369; Tue, 16 Jun 2009 01:43:33 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <200906160143.n5G1hX1Y008369@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Tue, 16 Jun 2009 01:43:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194275 - projects/mips/sys/mips/mips X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2009 01:43:34 -0000 Author: gonzo Date: Tue Jun 16 01:43:33 2009 New Revision: 194275 URL: http://svn.freebsd.org/changeset/base/194275 Log: - Handle KSEG0/KSEG1 addresses for /dev/mem as well. netstat requires it Modified: projects/mips/sys/mips/mips/mem.c Modified: projects/mips/sys/mips/mips/mem.c ============================================================================== --- projects/mips/sys/mips/mips/mem.c Tue Jun 16 00:09:06 2009 (r194274) +++ projects/mips/sys/mips/mips/mem.c Tue Jun 16 01:43:33 2009 (r194275) @@ -124,8 +124,10 @@ memrw(dev, uio, flags) pmap_unmap_fpage(pa, fp); sched_unpin(); mtx_unlock(&sysmaps->lock); - } else + } else { + printf("NOT OK\n"); return (EFAULT); + } continue; } @@ -133,6 +135,7 @@ memrw(dev, uio, flags) else if (dev2unit(dev) == CDEV_MINOR_KMEM) { v = uio->uio_offset; c = min(iov->iov_len, MAXPHYS); + vm_offset_t addr, eaddr; vm_offset_t wired_tlb_virtmem_end; @@ -143,25 +146,37 @@ memrw(dev, uio, flags) addr = trunc_page(uio->uio_offset); eaddr = round_page(uio->uio_offset + c); - if (addr < (vm_offset_t) VM_MIN_KERNEL_ADDRESS) - return EFAULT; - - wired_tlb_virtmem_end = VM_MIN_KERNEL_ADDRESS + - VM_KERNEL_ALLOC_OFFSET; - if ((addr < wired_tlb_virtmem_end) && - (eaddr >= wired_tlb_virtmem_end)) - addr = wired_tlb_virtmem_end; - - if (addr >= wired_tlb_virtmem_end) { - for (; addr < eaddr; addr += PAGE_SIZE) - if (pmap_extract(kernel_pmap,addr) == 0) - return EFAULT; - - if (!kernacc((caddr_t)(int)uio->uio_offset, c, - uio->uio_rw == UIO_READ ? - VM_PROT_READ : VM_PROT_WRITE)) + if (addr > (vm_offset_t) VM_MIN_KERNEL_ADDRESS) { + wired_tlb_virtmem_end = VM_MIN_KERNEL_ADDRESS + + VM_KERNEL_ALLOC_OFFSET; + if ((addr < wired_tlb_virtmem_end) && + (eaddr >= wired_tlb_virtmem_end)) + addr = wired_tlb_virtmem_end; + + if (addr >= wired_tlb_virtmem_end) { + for (; addr < eaddr; addr += PAGE_SIZE) + if (pmap_extract(kernel_pmap, + addr) == 0) + return EFAULT; + + if (!kernacc( + (caddr_t)(int)uio->uio_offset, c, + uio->uio_rw == UIO_READ ? + VM_PROT_READ : VM_PROT_WRITE)) + return (EFAULT); + } + } + else if (MIPS_IS_KSEG0_ADDR(v)) { + if (MIPS_KSEG0_TO_PHYS(v + c) >= ctob(physmem)) return (EFAULT); } + else if (MIPS_IS_KSEG1_ADDR(v)) { + if (MIPS_KSEG1_TO_PHYS(v + c) >= ctob(physmem)) + return (EFAULT); + } + else + return (EFAULT); + error = uiomove((caddr_t)v, c, uio); continue;