Module Name: src Committed By: matt Date: Thu Jun 11 15:50:17 UTC 2015
Modified Files: src/sys/arch/mips/include: cpu.h pmap.h src/sys/arch/mips/mips: cpu_subr.c genassym.cf pmap.c pmap_segtab.c trap.c Log Message: Define (but not use) separate kernel and user pagetables. Move to the new names. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/arch/mips/include/cpu.h cvs rdiff -u -r1.66 -r1.67 src/sys/arch/mips/include/pmap.h cvs rdiff -u -r1.25 -r1.26 src/sys/arch/mips/mips/cpu_subr.c cvs rdiff -u -r1.60 -r1.61 src/sys/arch/mips/mips/genassym.cf cvs rdiff -u -r1.217 -r1.218 src/sys/arch/mips/mips/pmap.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/mips/pmap_segtab.c cvs rdiff -u -r1.237 -r1.238 src/sys/arch/mips/mips/trap.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/include/cpu.h diff -u src/sys/arch/mips/include/cpu.h:1.116 src/sys/arch/mips/include/cpu.h:1.117 --- src/sys/arch/mips/include/cpu.h:1.116 Wed Jun 10 22:31:00 2015 +++ src/sys/arch/mips/include/cpu.h Thu Jun 11 15:50:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.116 2015/06/10 22:31:00 matt Exp $ */ +/* $NetBSD: cpu.h,v 1.117 2015/06/11 15:50:17 matt Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -115,9 +115,13 @@ struct cpu_info { int ci_tlb_slot; /* reserved tlb entry for cpu_info */ u_int ci_pmap_asid_cur; /* current ASID */ struct pmap_tlb_info *ci_tlb_info; /* tlb information for this cpu */ - union segtab *ci_pmap_seg0tab; + union pmap_segtab *ci_pmap_segtabs[2]; +#define ci_pmap_user_segtab ci_pmap_segtabs[0] +#define ci_pmap_kern_segtab ci_pmap_segtabs[1] #ifdef _LP64 - union segtab *ci_pmap_segtab; + union pmap_segtab *ci_pmap_seg0tabs[2]; +#define ci_pmap_user_seg0tab ci_pmap_seg0tabs[0] +#define ci_pmap_kern_seg0tab ci_pmap_seg0tabs[1] #else vaddr_t ci_pmap_srcbase; /* starting VA of ephemeral src space */ vaddr_t ci_pmap_dstbase; /* starting VA of ephemeral dst space */ Index: src/sys/arch/mips/include/pmap.h diff -u src/sys/arch/mips/include/pmap.h:1.66 src/sys/arch/mips/include/pmap.h:1.67 --- src/sys/arch/mips/include/pmap.h:1.66 Thu Jun 11 08:22:09 2015 +++ src/sys/arch/mips/include/pmap.h Thu Jun 11 15:50:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.66 2015/06/11 08:22:09 matt Exp $ */ +/* $NetBSD: pmap.h,v 1.67 2015/06/11 15:50:17 matt Exp $ */ /* * Copyright (c) 1992, 1993 @@ -108,6 +108,7 @@ #define pmap_trunc_seg(x) ((vaddr_t)(x) & ~SEGOFSET) #define pmap_round_seg(x) (((vaddr_t)(x) + SEGOFSET) & ~SEGOFSET) +#define PMAP_INVALID_SEGTAB NULL #ifdef _LP64 #define PMAP_SEGTABSIZE NSEGPG #else @@ -116,16 +117,16 @@ union pt_entry; -union segtab { +union pmap_segtab { #ifdef _LP64 - union segtab *seg_seg[PMAP_SEGTABSIZE]; + union pmap_segtab *seg_seg[PMAP_SEGTABSIZE]; #else - union segtab *seg_seg[1]; + union pmap_segtab *seg_seg[1]; #endif union pt_entry *seg_tab[PMAP_SEGTABSIZE]; }; -typedef union segtab pmap_segtab_t; +typedef union pmap_segtab pmap_segtab_t; /* * Structure defining an tlb entry data set. Index: src/sys/arch/mips/mips/cpu_subr.c diff -u src/sys/arch/mips/mips/cpu_subr.c:1.25 src/sys/arch/mips/mips/cpu_subr.c:1.26 --- src/sys/arch/mips/mips/cpu_subr.c:1.25 Thu Jun 11 08:22:09 2015 +++ src/sys/arch/mips/mips/cpu_subr.c Thu Jun 11 15:50:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_subr.c,v 1.25 2015/06/11 08:22:09 matt Exp $ */ +/* $NetBSD: cpu_subr.c,v 1.26 2015/06/11 15:50:17 matt Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.25 2015/06/11 08:22:09 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.26 2015/06/11 15:50:17 matt Exp $"); #include "opt_cputype.h" #include "opt_ddb.h" @@ -80,9 +80,9 @@ struct cpu_info cpu_info_store = { .ci_curlwp = &lwp0, .ci_tlb_info = &pmap_tlb0_info, - .ci_pmap_seg0tab = (void *)(MIPS_KSEG2_START + 0x1eadbeef), + .ci_pmap_user_segtab = (void *)(MIPS_KSEG2_START + 0x1eadbeef), #ifdef _LP64 - .ci_pmap_segtab = (void *)(MIPS_KSEG2_START + 0x1eadbeef), + .ci_pmap_user_seg0tab = (void *)(MIPS_KSEG2_START + 0x1eadbeef), #endif .ci_cpl = IPL_HIGH, .ci_tlb_slot = -1, Index: src/sys/arch/mips/mips/genassym.cf diff -u src/sys/arch/mips/mips/genassym.cf:1.60 src/sys/arch/mips/mips/genassym.cf:1.61 --- src/sys/arch/mips/mips/genassym.cf:1.60 Thu Jun 11 08:16:47 2015 +++ src/sys/arch/mips/mips/genassym.cf Thu Jun 11 15:50:17 2015 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.60 2015/06/11 08:16:47 matt Exp $ +# $NetBSD: genassym.cf,v 1.61 2015/06/11 15:50:17 matt Exp $ # # Copyright (c) 1992, 1993 # The Regents of the University of California. All rights reserved. @@ -290,9 +290,11 @@ define CPU_INFO_IDEPTH offsetof(struct define CPU_INFO_CURLWP offsetof(struct cpu_info, ci_curlwp) define CPU_INFO_IDLELWP offsetof(struct cpu_info, ci_data.cpu_idlelwp) define CPU_INFO_EV_TLBMISSES offsetof(struct cpu_info, ci_ev_tlbmisses.ev_count) -define CPU_INFO_PMAP_SEG0TAB offsetof(struct cpu_info, ci_pmap_seg0tab) ifdef _LP64 -define CPU_INFO_PMAP_SEGTAB offsetof(struct cpu_info, ci_pmap_segtab) +define CPU_INFO_PMAP_SEGTAB offsetof(struct cpu_info, ci_pmap_segtabs[0]) +define CPU_INFO_PMAP_SEG0TAB offsetof(struct cpu_info, ci_pmap_seg0tabs[0]) +else +define CPU_INFO_PMAP_SEG0TAB offsetof(struct cpu_info, ci_pmap_segtabs[0]) endif define CPU_INFO_DIVISOR_DELAY offsetof(struct cpu_info, ci_divisor_delay) define CPU_INFO_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) Index: src/sys/arch/mips/mips/pmap.c diff -u src/sys/arch/mips/mips/pmap.c:1.217 src/sys/arch/mips/mips/pmap.c:1.218 --- src/sys/arch/mips/mips/pmap.c:1.217 Thu Jun 11 15:13:34 2015 +++ src/sys/arch/mips/mips/pmap.c Thu Jun 11 15:50:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.217 2015/06/11 15:13:34 matt Exp $ */ +/* $NetBSD: pmap.c,v 1.218 2015/06/11 15:50:17 matt 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.217 2015/06/11 15:13:34 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.218 2015/06/11 15:50:17 matt Exp $"); /* * Manages physical address maps. @@ -907,11 +907,9 @@ pmap_deactivate(struct lwp *l) kpreempt_disable(); KASSERT(l == curlwp || l->l_cpu == curlwp->l_cpu); + curcpu()->ci_pmap_user_segtab = (void *)(MIPS_KSEG2_START + 0x1eadbeef); #ifdef _LP64 - curcpu()->ci_pmap_segtab = (void *)(MIPS_KSEG2_START + 0x1eadbeef); - curcpu()->ci_pmap_seg0tab = NULL; -#else - curcpu()->ci_pmap_seg0tab = (void *)(MIPS_KSEG2_START + 0x1eadbeef); + curcpu()->ci_pmap_user_seg0tab = NULL; #endif pmap_tlb_asid_deactivate(l->l_proc->p_vmspace->vm_map.pmap); kpreempt_enable(); @@ -1631,7 +1629,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd #ifdef DEBUG if (pmapdebug & PDB_ENTER) printf("pmap_enter: flush I cache va %#"PRIxVADDR" (%#"PRIxPADDR")\n", - va - (vaddr_t)NBPG, pa); + va - NBPG, pa); #endif PMAP_COUNT(exec_mappings); if (!PG_MD_EXECPAGE_P(md) && PG_MD_CACHED_P(md)) { Index: src/sys/arch/mips/mips/pmap_segtab.c diff -u src/sys/arch/mips/mips/pmap_segtab.c:1.9 src/sys/arch/mips/mips/pmap_segtab.c:1.10 --- src/sys/arch/mips/mips/pmap_segtab.c:1.9 Thu Jun 11 08:22:09 2015 +++ src/sys/arch/mips/mips/pmap_segtab.c Thu Jun 11 15:50:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_segtab.c,v 1.9 2015/06/11 08:22:09 matt Exp $ */ +/* $NetBSD: pmap_segtab.c,v 1.10 2015/06/11 15:50:17 matt Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.9 2015/06/11 08:22:09 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.10 2015/06/11 15:50:17 matt Exp $"); /* * Manages physical address maps. @@ -349,16 +349,17 @@ pmap_segtab_activate(struct pmap *pm, st { if (l == curlwp) { KASSERT(pm == l->l_proc->p_vmspace->vm_map.pmap); + if (pm == pmap_kernel()) { + l->l_cpu->ci_pmap_user_segtab = PMAP_INVALID_SEGTAB; #ifdef _LP64 - l->l_cpu->ci_pmap_segtab = pm->pm_segtab; - if (pm != pmap_kernel()) { - l->l_cpu->ci_pmap_seg0tab = pm->pm_segtab->seg_seg[0]; + l->l_cpu->ci_pmap_user_seg0tab = PMAP_INVALID_SEGTAB; +#endif } else { - l->l_cpu->ci_pmap_seg0tab = NULL; - } -#else - l->l_cpu->ci_pmap_seg0tab = pm->pm_segtab; + l->l_cpu->ci_pmap_user_segtab = pm->pm_segtab; +#ifdef _LP64 + l->l_cpu->ci_pmap_user_seg0tab = pm->pm_segtab->seg_seg[0]; #endif + } } } Index: src/sys/arch/mips/mips/trap.c diff -u src/sys/arch/mips/mips/trap.c:1.237 src/sys/arch/mips/mips/trap.c:1.238 --- src/sys/arch/mips/mips/trap.c:1.237 Sat Jun 6 20:53:38 2015 +++ src/sys/arch/mips/mips/trap.c Thu Jun 11 15:50:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.237 2015/06/06 20:53:38 matt Exp $ */ +/* $NetBSD: trap.c,v 1.238 2015/06/11 15:50:17 matt Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.237 2015/06/06 20:53:38 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.238 2015/06/11 15:50:17 matt Exp $"); #include "opt_cputype.h" /* which mips CPU levels do we support? */ #include "opt_ddb.h" @@ -381,9 +381,10 @@ trap(uint32_t status, uint32_t cause, va */ struct cpu_info * const ci = curcpu(); if ((va >> XSEGSHIFT) == 0 && - __predict_false(ci->ci_pmap_seg0tab == NULL - && ci->ci_pmap_segtab->seg_seg[0] != NULL)) { - ci->ci_pmap_seg0tab = ci->ci_pmap_segtab->seg_seg[0]; + __predict_false(ci->ci_pmap_user_seg0tab == NULL + && ci->ci_pmap_user_segtab->seg_seg[0] != NULL)) { + ci->ci_pmap_user_seg0tab = + ci->ci_pmap_user_segtab->seg_seg[0]; kpreempt_enable(); if (type & T_USER) { userret(l);