CVS commit: [netbsd-6] src/sys/arch/mips/mips
Module Name:src Committed By: bouyer Date: Sat Aug 27 14:34:55 UTC 2016 Modified Files: src/sys/arch/mips/mips [netbsd-6]: pmap.c Log Message: Pull up following revision(s) (requested by skrll in ticket #1390): sys/arch/mips/mips/pmap.c: revision 1.221 sys/arch/mips/mips/pmap.c: revision 1.222 sys/arch/mips/mips/pmap.c: revision 1.223 Fix a bug introduced by me in 1.214 where unmanaged mappings would be affected by calls to pmap_page_protect which is wrong. Now PV_KENTER mappings are left intact. Thanks to chuq for spotting my mistake and reviewing this diff. Thanks to everyone who tested it as well. Fix PR/51288 reproducable panic on evbmips64-eb (erlite) pmap_page_remove from the previous change neglected to terminate the pv list correctly when it started with an initial unmanaged mapping and subsequent managed mappings. Fix this. Fix MIPS3_NO_PV_UNCACHED alias handling by looping through the pv_list looking for bad aliases and removing the bad entries. That is, revert to the code before the matt-mips64 merge. Additionally, fix the pmap_update call to not use the (recently removed/freed) pv for the pmap_t. Fixes the following two PRs PR/49903: Panic during installation on WorkPad Z50 (hpcmips) whilst uncompressing base.tgz PR/51226: Install bug for hpcmips NetBSD V7 using FTP Full installation To generate a diff of this commit: cvs rdiff -u -r1.207.2.3 -r1.207.2.4 src/sys/arch/mips/mips/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/mips/pmap.c diff -u src/sys/arch/mips/mips/pmap.c:1.207.2.3 src/sys/arch/mips/mips/pmap.c:1.207.2.4 --- src/sys/arch/mips/mips/pmap.c:1.207.2.3 Wed Jun 11 15:38:05 2014 +++ src/sys/arch/mips/mips/pmap.c Sat Aug 27 14:34:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.207.2.3 2014/06/11 15:38:05 msaitoh Exp $ */ +/* $NetBSD: pmap.c,v 1.207.2.4 2016/08/27 14:34:55 bouyer Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.3 2014/06/11 15:38:05 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.4 2016/08/27 14:34:55 bouyer Exp $"); /* * Manages physical address maps. @@ -316,6 +316,7 @@ u_int pmap_page_colormask; (pm) == curlwp->l_proc->p_vmspace->vm_map.pmap) /* Forward function declarations */ +void pmap_page_remove(struct vm_page *); void pmap_remove_pv(pmap_t, vaddr_t, struct vm_page *, bool); void pmap_enter_pv(pmap_t, vaddr_t, struct vm_page *, u_int *, int); pt_entry_t *pmap_pte(pmap_t, vaddr_t); @@ -1063,6 +1064,10 @@ pmap_page_protect(struct vm_page *pg, vm while (pv != NULL) { const pmap_t pmap = pv->pv_pmap; const uint16_t gen = PG_MD_PVLIST_GEN(md); +if (pv->pv_va & PV_KENTER) { + pv = pv->pv_next; + continue; +} va = trunc_page(pv->pv_va); PG_MD_PVLIST_UNLOCK(md); pmap_protect(pmap, va, va + PAGE_SIZE, prot); @@ -1087,17 +1092,7 @@ pmap_page_protect(struct vm_page *pg, vm if (pmap_clear_mdpage_attributes(md, PG_MD_EXECPAGE)) { PMAP_COUNT(exec_uncached_page_protect); } - (void)PG_MD_PVLIST_LOCK(md, false); - pv = >pvh_first; - while (pv->pv_pmap != NULL) { - const pmap_t pmap = pv->pv_pmap; - va = trunc_page(pv->pv_va); - PG_MD_PVLIST_UNLOCK(md); - pmap_remove(pmap, va, va + PAGE_SIZE); - pmap_update(pmap); - (void)PG_MD_PVLIST_LOCK(md, false); - } - PG_MD_PVLIST_UNLOCK(md); + pmap_page_remove(pg); } } @@ -2069,6 +2064,32 @@ pmap_set_modified(paddr_t pa) / pv_entry management / static void +pmap_check_alias(struct vm_page *pg) +{ +#ifdef MIPS3_PLUS /* XXX mmu XXX */ +#ifndef MIPS3_NO_PV_UNCACHED + struct vm_page_md * const md = VM_PAGE_TO_MD(pg); + + if (MIPS_HAS_R4K_MMU && PG_MD_UNCACHED_P(md)) { + /* + * Page is currently uncached, check if alias mapping has been + * removed. If it was, then reenable caching. + */ + pv_entry_t pv = >pvh_first; + pv_entry_t pv0 = pv->pv_next; + + for (; pv0; pv0 = pv0->pv_next) { + if (mips_cache_badalias(pv->pv_va, pv0->pv_va)) +break; + } + if (pv0 == NULL) + pmap_page_cache(pg, true); + } +#endif +#endif /* MIPS3_PLUS */ +} + +static void pmap_check_pvlist(struct vm_page_md *md) { #ifdef PARANOIADIAG @@ -2155,12 +2176,12 @@ again: * be mapped with one index at any given time. */ - if (mips_cache_badalias(pv->pv_va, va)) { -for (npv = pv; npv; npv = npv->pv_next) { - vaddr_t nva = trunc_page(npv->pv_va); - pmap_remove(npv->pv_pmap, nva, - nva + PAGE_SIZE); - pmap_update(npv->pv_pmap); + for (npv = pv; npv; npv = npv->pv_next) { +vaddr_t nva = trunc_page(npv->pv_va); +pmap_t npm = npv->pv_pmap; +if (mips_cache_badalias(nva, va)) { + pmap_remove(npm, nva, nva + PAGE_SIZE); + pmap_update(npm); goto again; } } @@ -2283,6
CVS commit: [netbsd-6] src/sys/arch/mips/mips
Module Name:src Committed By: bouyer Date: Wed May 21 20:36:11 UTC 2014 Modified Files: src/sys/arch/mips/mips [netbsd-6]: bus_dma.c Log Message: Pull up following revision(s) (requested by skrll in ticket #1055): sys/arch/mips/mips/bus_dma.c: revision 1.28 When decide to coalesce segments, if the d_cache isn't coherent also make sure the VA is contiguous as well. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.27.8.1 src/sys/arch/mips/mips/bus_dma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/mips/bus_dma.c diff -u src/sys/arch/mips/mips/bus_dma.c:1.27 src/sys/arch/mips/mips/bus_dma.c:1.27.8.1 --- src/sys/arch/mips/mips/bus_dma.c:1.27 Sun Jul 10 23:13:22 2011 +++ src/sys/arch/mips/mips/bus_dma.c Wed May 21 20:36:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_dma.c,v 1.27 2011/07/10 23:13:22 matt Exp $ */ +/* $NetBSD: bus_dma.c,v 1.27.8.1 2014/05/21 20:36:11 bouyer Exp $ */ /*- * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include sys/cdefs.h /* RCS ID Copyright macro defns */ -__KERNEL_RCSID(0, $NetBSD: bus_dma.c,v 1.27 2011/07/10 23:13:22 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: bus_dma.c,v 1.27.8.1 2014/05/21 20:36:11 bouyer Exp $); #define _MIPS_BUS_DMA_PRIVATE @@ -97,26 +97,29 @@ EVCNT_ATTACH_STATIC(bus_dma_bounced_dest paddr_t kvtophys(vaddr_t); /* XXX */ /* - * Utility function to load a linear buffer. lastaddrp holds state - * between invocations (for multiple-buffer loads). segp contains - * the starting segment on entrance, and the ending segment on exit. - * first indicates if this is the first invocation of this function. + * Utility function to load a linear buffer. segp contains the starting + * segment on entrance, and the ending segment on exit. first indicates + * if this is the first invocation of this function. */ static int _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf, bus_size_t buflen, struct vmspace *vm, int flags, -paddr_t *lastaddrp, int *segp, int first) +int *segp, bool first) { bus_size_t sgsize; - bus_size_t bmask; paddr_t baddr, curaddr, lastaddr; - vaddr_t vaddr = (vaddr_t)buf; - int seg; + vaddr_t vaddr = (vaddr_t)buf, lastvaddr; + int seg = *segp; + bus_dma_segment_t *ds = map-dm_segs[seg]; + bus_dma_segment_t * const eds = map-dm_segs[map-_dm_segcnt]; + const bool d_cache_coherent = + (mips_options.mips_cpu_flags CPU_MIPS_D_CACHE_COHERENT) != 0; + + lastaddr = ds-ds_addr + ds-ds_len; + lastvaddr = ds-_ds_vaddr + ds-ds_len; + const bus_size_t bmask = ~(map-_dm_boundary - 1); - lastaddr = *lastaddrp; - bmask = ~(map-_dm_boundary - 1); - - for (seg = *segp; buflen 0 ; ) { + while (buflen 0) { /* * Get the physical address for this segment. */ @@ -130,9 +133,9 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, * If we're beyond the current DMA window, indicate * that and try to fall back onto something else. */ - if (curaddr t-_bounce_alloc_lo || - (t-_bounce_alloc_hi != 0 - curaddr = t-_bounce_alloc_hi)) + if (curaddr t-_bounce_alloc_lo + || (t-_bounce_alloc_hi != 0 + curaddr = t-_bounce_alloc_hi)) return (EINVAL); #if BUS_DMA_DEBUG printf(dma: addr %#PRIxPADDR - %#PRIxPADDR\n, curaddr, @@ -144,18 +147,21 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, * Compute the segment size, and adjust counts. */ sgsize = PAGE_SIZE - ((uintptr_t)vaddr PGOFSET); - if (buflen sgsize) + if (sgsize buflen) { sgsize = buflen; - if (map-dm_maxsegsz sgsize) + } + if (sgsize map-dm_maxsegsz) { sgsize = map-dm_maxsegsz; + } /* * Make sure we don't cross any boundaries. */ if (map-_dm_boundary 0) { baddr = (curaddr + map-_dm_boundary) bmask; - if (sgsize (baddr - curaddr)) -sgsize = (baddr - curaddr); + if (sgsize baddr - curaddr) { +sgsize = baddr - curaddr; + } } /* @@ -163,34 +169,31 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, * the previous segment if possible. */ if (first) { - map-dm_segs[seg].ds_addr = curaddr; - map-dm_segs[seg].ds_len = sgsize; - map-dm_segs[seg]._ds_vaddr = vaddr; - first = 0; + ds-ds_addr = curaddr; + ds-ds_len = sgsize; + ds-_ds_vaddr = vaddr; + first = false; + } else if (curaddr == lastaddr + (d_cache_coherent || lastvaddr == vaddr) + ds-ds_len + sgsize = map-dm_maxsegsz + (map-_dm_boundary == 0 + || ((ds-ds_addr ^ curaddr) bmask) == 0)) { + ds-ds_len += sgsize; } else { - if (curaddr == lastaddr - (map-dm_segs[seg].ds_len + sgsize) = - map-dm_maxsegsz - (map-_dm_boundary == 0 || - (map-dm_segs[seg].ds_addr bmask) == - (curaddr bmask))) -map-dm_segs[seg].ds_len += sgsize; - else { -if (++seg = map-_dm_segcnt) - break; -map-dm_segs[seg].ds_addr = curaddr; -
CVS commit: [netbsd-6] src/sys/arch/mips/mips
Module Name:src Committed By: bouyer Date: Wed May 21 20:39:17 UTC 2014 Modified Files: src/sys/arch/mips/mips [netbsd-6]: pmap.c vm_machdep.c Log Message: Pull up following revision(s) (requested by skrll in ticket #1056): sys/arch/mips/mips/pmap.c: revision 1.211 sys/arch/mips/mips/pmap.c: revision 1.212 sys/arch/mips/mips/pmap.c: revision 1.213 sys/arch/mips/mips/vm_machdep.c: revision 1.143 sys/arch/mips/mips/pmap.c: revision 1.210 Fix a logic inversion introduced with the matt-nb5-mips64 for pmap_{zero,copy}_page cache alias handing. The check previously used PG_MD_UNCACHED_P, where it now uses PG_MD_CACHED_P, when considering if a cache invalidation is required. Additionally flush the cache for the uarea va to avoid potential (future) cache aliases in cpu_uarea_free when handing pages back to uvm for later use. ok matt@ Hopefully this addresses the instability reported in the following PRs: PR/44900 - R5000/Rm5200 mips ports are broken PR/46170 - NetBSD/cobalt 6.0_BETA does not boot PR/46890 - upcoming NetBSD 6.0 release is very unstable / unusable on cobalt qube 2 PR/48628 - cobalt and hpcmips ports are dead Grab pv_list lock in pmap_unmap_ephemeral_page only when needed. Make PARANOIADIAG compile. Use pmap_tlb_asid_check to reduce code cp. To generate a diff of this commit: cvs rdiff -u -r1.207.2.1 -r1.207.2.2 src/sys/arch/mips/mips/pmap.c cvs rdiff -u -r1.141 -r1.141.8.1 src/sys/arch/mips/mips/vm_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/mips/pmap.c diff -u src/sys/arch/mips/mips/pmap.c:1.207.2.1 src/sys/arch/mips/mips/pmap.c:1.207.2.2 --- src/sys/arch/mips/mips/pmap.c:1.207.2.1 Thu Jul 5 18:39:42 2012 +++ src/sys/arch/mips/mips/pmap.c Wed May 21 20:39:17 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.207.2.1 2012/07/05 18:39:42 riz Exp $ */ +/* $NetBSD: pmap.c,v 1.207.2.2 2014/05/21 20:39:17 bouyer Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.207.2.1 2012/07/05 18:39:42 riz Exp $); +__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.207.2.2 2014/05/21 20:39:17 bouyer Exp $); /* * Manages physical address maps. @@ -453,19 +453,21 @@ pmap_unmap_ephemeral_page(struct vm_page struct vm_page_md * const md = VM_PAGE_TO_MD(pg); pv_entry_t pv = md-pvh_first; - (void)PG_MD_PVLIST_LOCK(md, false); - if (MIPS_CACHE_VIRTUAL_ALIAS - (PG_MD_UNCACHED_P(md) - || (pv-pv_pmap != NULL - mips_cache_badalias(pv-pv_va, va { - /* - * If this page was previously uncached or we had to use an - * incompatible alias and it has a valid mapping, flush it - * from the cache. - */ - mips_dcache_wbinv_range(va, PAGE_SIZE); + if (MIPS_CACHE_VIRTUAL_ALIAS) { + (void)PG_MD_PVLIST_LOCK(md, false); + if (PG_MD_CACHED_P(md) + || (pv-pv_pmap != NULL + mips_cache_badalias(pv-pv_va, va))) { + + /* + * If this page was previously cached or we had to use an + * incompatible alias and it has a valid mapping, flush it + * from the cache. + */ + mips_dcache_wbinv_range(va, PAGE_SIZE); + } + PG_MD_PVLIST_UNLOCK(md); } - PG_MD_PVLIST_UNLOCK(md); #ifndef _LP64 /* * If we had to map using a page table entry, unmap it now. @@ -575,7 +577,7 @@ pmap_bootstrap(void) /* * Now actually allocate the kernel PTE array (must be done - * after virtual_end is initialized). + * after mips_virtual_end is initialized). */ Sysmap = (pt_entry_t *) uvm_pageboot_alloc(sizeof(pt_entry_t) * Sysmapsize); @@ -1023,15 +1025,7 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va if (eva VM_MAXUSER_ADDRESS) panic(pmap_remove: uva not in range); if (PMAP_IS_ACTIVE(pmap)) { - struct pmap_asid_info * const pai = PMAP_PAI(pmap, curcpu()); - uint32_t asid; - - __asm volatile(mfc0 %0,$10; nop : =r(asid)); - asid = (MIPS_HAS_R4K_MMU) ? (asid 0xff) : (asid 0xfc0) 6; - if (asid != pai-pai_asid) { - panic(inconsistency for active TLB flush: %d - %d, - asid, pai-pai_asid); - } + pmap_tlb_asid_check(); } #endif #ifdef PMAP_FAULTINFO @@ -1214,15 +1208,7 @@ pmap_protect(pmap_t pmap, vaddr_t sva, v if (eva VM_MAXUSER_ADDRESS) panic(pmap_protect: uva not in range); if (PMAP_IS_ACTIVE(pmap)) { - struct pmap_asid_info * const pai = PMAP_PAI(pmap, curcpu()); - uint32_t asid; - - __asm volatile(mfc0 %0,$10; nop : =r(asid)); - asid = (MIPS_HAS_R4K_MMU) ? (asid 0xff) : (asid 0xfc0) 6; - if (asid != pai-pai_asid) { - panic(inconsistency for active TLB update: %d - %d, - asid, pai-pai_asid); - } + pmap_tlb_asid_check(); } #endif @@ -1586,6 +1572,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd #ifdef PARANOIADIAG if (PMAP_IS_ACTIVE(pmap)) { + struct pmap_asid_info * const pai = PMAP_PAI(pmap, curcpu()); uint32_t asid; __asm volatile(mfc0 %0,$10; nop :
CVS commit: [netbsd-6] src/sys/arch/mips/mips
Module Name:src Committed By: msaitoh Date: Sun Nov 18 18:14:40 UTC 2012 Modified Files: src/sys/arch/mips/mips [netbsd-6]: mips_emul.c Log Message: Pull up following revision(s) (requested by skrll in ticket #661): sys/arch/mips/mips/mips_emul.c: revision 1.26 We need to jump out of two switches to emulate rdhwr rt,$29 correctly. Only one would result in segv. Fixes pthread apps on mips1. Tested using gxemul. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.25.8.1 src/sys/arch/mips/mips/mips_emul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/mips/mips_emul.c diff -u src/sys/arch/mips/mips/mips_emul.c:1.25 src/sys/arch/mips/mips/mips_emul.c:1.25.8.1 --- src/sys/arch/mips/mips/mips_emul.c:1.25 Thu Aug 18 21:04:23 2011 +++ src/sys/arch/mips/mips/mips_emul.c Sun Nov 18 18:14:39 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: mips_emul.c,v 1.25 2011/08/18 21:04:23 matt Exp $ */ +/* $NetBSD: mips_emul.c,v 1.25.8.1 2012/11/18 18:14:39 msaitoh Exp $ */ /* * Copyright (c) 1999 Shuichiro URATA. All rights reserved. @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: mips_emul.c,v 1.25 2011/08/18 21:04:23 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: mips_emul.c,v 1.25.8.1 2012/11/18 18:14:39 msaitoh Exp $); #include sys/param.h #include sys/systm.h @@ -457,7 +457,7 @@ mips_emul_special3(uint32_t inst, struct case 29: tf-tf_regs[instfmt.RType.rt] = (mips_reg_t)(intptr_t)curlwp-l_private; - break; + goto done; } /* FALLTHROUGH */ illopc: @@ -472,7 +472,7 @@ mips_emul_special3(uint32_t inst, struct (*curproc-p_emul-e_trapsignal)(curlwp, ksi); return; } - +done: update_pc(tf, cause); }
CVS commit: [netbsd-6] src/sys/arch/mips/mips
Module Name:src Committed By: riz Date: Fri Mar 2 16:42:22 UTC 2012 Modified Files: src/sys/arch/mips/mips [netbsd-6]: mips_fpu.c Log Message: Pull up following revision(s) (requested by skrll in ticket #66): sys/arch/mips/mips/mips_fpu.c: revision 1.8 Remove an incorrect KASSERT To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/arch/mips/mips/mips_fpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/mips/mips_fpu.c diff -u src/sys/arch/mips/mips/mips_fpu.c:1.7 src/sys/arch/mips/mips/mips_fpu.c:1.7.8.1 --- src/sys/arch/mips/mips/mips_fpu.c:1.7 Sat Oct 29 20:55:36 2011 +++ src/sys/arch/mips/mips/mips_fpu.c Fri Mar 2 16:42:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: mips_fpu.c,v 1.7 2011/10/29 20:55:36 christos Exp $ */ +/* $NetBSD: mips_fpu.c,v 1.7.8.1 2012/03/02 16:42:22 riz Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: mips_fpu.c,v 1.7 2011/10/29 20:55:36 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: mips_fpu.c,v 1.7.8.1 2012/03/02 16:42:22 riz Exp $); #include opt_multiprocessor.h @@ -346,6 +346,5 @@ void mips_fpu_state_release(lwp_t *l) { - KASSERT(l == curlwp); l-l_md.md_utf-tf_regs[_R_SR] = ~MIPS_SR_COP_1_BIT; }