From owner-svn-src-user@FreeBSD.ORG Tue Apr 6 05:06:14 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41C3F106564A; Tue, 6 Apr 2010 05:06:14 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3089D8FC23; Tue, 6 Apr 2010 05:06:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3656EdQ052690; Tue, 6 Apr 2010 05:06:14 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3656EXN052688; Tue, 6 Apr 2010 05:06:14 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201004060506.o3656EXN052688@svn.freebsd.org> From: Juli Mallett Date: Tue, 6 Apr 2010 05:06:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206244 - user/jmallett/octeon/sys/mips/mips X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2010 05:06:14 -0000 Author: jmallett Date: Tue Apr 6 05:06:13 2010 New Revision: 206244 URL: http://svn.freebsd.org/changeset/base/206244 Log: Simplify pmap_kextract, with the added bonus of not using chains of conditionals such that it is possible (er, yeah) to add a case that can not ever be reached. Also panic if we don't know what address space an address is in; that's probably a good sign that something has gone wrong. Modified: user/jmallett/octeon/sys/mips/mips/pmap.c Modified: user/jmallett/octeon/sys/mips/mips/pmap.c ============================================================================== --- user/jmallett/octeon/sys/mips/mips/pmap.c Tue Apr 6 04:57:41 2010 (r206243) +++ user/jmallett/octeon/sys/mips/mips/pmap.c Tue Apr 6 05:06:13 2010 (r206244) @@ -3329,73 +3329,67 @@ pmap_set_modified(vm_offset_t pa) /* PMAP_INLINE */ vm_offset_t pmap_kextract(vm_offset_t va) { - vm_offset_t pa = 0; + /* + * First, the direct-mapped regions. + */ +#if defined(__mips_n64) + if (va >= MIPS_XKPHYS_START && va < MIPS_XKPHYS_END) + return (MIPS_XKPHYS_TO_PHYS(va)); +#endif + + if (va >= MIPS_KSEG0_START && va < MIPS_KSEG0_END) + return (MIPS_KSEG0_TO_PHYS(va)); + + if (va >= MIPS_KSEG1_START && va < MIPS_KSEG1_END) + return (MIPS_KSEG1_TO_PHYS(va)); - if (va < MIPS_KSEG0_START) { - /* user virtual address */ + /* + * User virtual addresses. + */ + if (va < VM_MAXUSER_ADDRESS) { pt_entry_t *ptep; if (curproc && curproc->p_vmspace) { ptep = pmap_pte(&curproc->p_vmspace->vm_pmap, va); - if (ptep) - pa = TLBLO_PTE_TO_PA(*ptep) | - (va & PAGE_MASK); + if (ptep) { + return (TLBLO_PTE_TO_PA(*ptep) | + (va & PAGE_MASK)); + } + return (0); } - } else if (va >= MIPS_KSEG0_START && - va < MIPS_KSEG1_START) - pa = MIPS_KSEG0_TO_PHYS(va); - else if (va >= MIPS_KSEG1_START && - va < MIPS_KSEG2_START) - pa = MIPS_KSEG1_TO_PHYS(va); + } + #ifdef VM_ALLOC_WIRED_TLB_PG_POOL - else if (need_wired_tlb_page_pool && ((va >= VM_MIN_KERNEL_ADDRESS) && + if (need_wired_tlb_page_pool && ((va >= VM_MIN_KERNEL_ADDRESS) && (va < (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_ALLOC_OFFSET)))) - pa = MIPS_KSEG0_TO_PHYS(va); + return (MIPS_KSEG0_TO_PHYS(va)); #endif -#if defined(__mips_n64) - else if (va >= MIPS_XKPHYS_START && va < MIPS_XKPHYS_END) - pa = MIPS_XKPHYS_TO_PHYS(va); -#endif - else if (va >= MIPS_KSEG2_START && va < VM_MAX_KERNEL_ADDRESS) { + + /* + * Kernel virtual. + */ + if (va >= MIPS_KSEG2_START && va < MIPS_KSEG2_END) { pt_entry_t *ptep; /* Is the kernel pmap initialized? */ if (kernel_pmap->pm_active) { #if !defined(__mips_n64) - if (va >= (vm_offset_t)virtual_sys_start) { + if (va < (vm_offset_t)virtual_sys_start) { + panic("%s for special address %p.", __func__, (void *)va); + } #endif - /* Its inside the virtual address range */ - ptep = pmap_pte(kernel_pmap, va); - if (ptep) - pa = TLBLO_PTE_TO_PA(*ptep) | - (va & PAGE_MASK); -#if !defined(__mips_n64) - } else { - int i; - /* - * its inside the special mapping area, I - * don't think this should happen, but if it - * does I want it toa all work right :-) - * Note if it does happen, we assume the - * caller has the lock? FIXME, this needs to - * be checked FIXEM - RRS. - */ - for (i = 0; i < MAXCPU; i++) { - if ((sysmap_lmem[i].valid1) && ((vm_offset_t)sysmap_lmem[i].CADDR1 == va)) { - pa = TLBLO_PTE_TO_PA(sysmap_lmem[i].CMAP1); - break; - } - if ((sysmap_lmem[i].valid2) && ((vm_offset_t)sysmap_lmem[i].CADDR2 == va)) { - pa = TLBLO_PTE_TO_PA(sysmap_lmem[i].CMAP2); - break; - } - } + /* Its inside the virtual address range */ + ptep = pmap_pte(kernel_pmap, va); + if (ptep) { + return (TLBLO_PTE_TO_PA(*ptep) | + (va & PAGE_MASK)); } -#endif + return (0); } } - return pa; + + panic("%s for unknown address space %p.", __func__, (void *)va); } void