diff options
author | Takuya ASADA <syuu@cvs.openbsd.org> | 2010-01-05 06:44:59 +0000 |
---|---|---|
committer | Takuya ASADA <syuu@cvs.openbsd.org> | 2010-01-05 06:44:59 +0000 |
commit | 477076752b7770cea6c16096132b1fb23d952479 (patch) | |
tree | 68fac107bdb39e7f98098cd383d3948816f557a8 | |
parent | 772e89cb237b0c3daf3b850ea024b5e608242a8e (diff) |
Dynamic allocation for ASID and ASID generation number on struct pmap. ok miod@
-rw-r--r-- | sys/arch/mips64/include/pmap.h | 22 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/context.S | 6 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/genassym.cf | 4 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/pmap.c | 79 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/ip30.h | 3 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/ip30_machdep.c | 27 |
6 files changed, 86 insertions, 55 deletions
diff --git a/sys/arch/mips64/include/pmap.h b/sys/arch/mips64/include/pmap.h index f1778730471..93cf0a690a9 100644 --- a/sys/arch/mips64/include/pmap.h +++ b/sys/arch/mips64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.18 2009/12/30 01:17:59 syuu Exp $ */ +/* $OpenBSD: pmap.h,v 1.19 2010/01/05 06:44:58 syuu Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -91,6 +91,11 @@ struct segtab { pt_entry_t *seg_tab[PMAP_SEGTABSIZE]; }; +struct pmap_asid_info { + u_int pma_asid; /* address space tag */ + u_int pma_asidgen; /* TLB PID generation number */ +}; + /* * Machine dependent pmap structure. */ @@ -98,11 +103,18 @@ typedef struct pmap { int pm_count; /* pmap reference count */ simple_lock_data_t pm_lock; /* lock on pmap */ struct pmap_statistics pm_stats; /* pmap statistics */ - u_int pm_tlbpid[MAXCPUS]; /* address space tag */ - u_int pm_tlbgen[MAXCPUS]; /* TLB PID generation number */ struct segtab *pm_segtab; /* pointers to pages of PTEs */ + struct pmap_asid_info pm_asid[1]; /* ASID information */ } *pmap_t; +/* + * Compute the sizeof of a pmap structure. Subtract one because one + * ASID info structure is already included in the pmap structure itself. + */ +#define PMAP_SIZEOF(x) \ + (ALIGN(sizeof(struct pmap) + \ + (sizeof(struct pmap_asid_info) * ((x) - 1)))) + /* flags for pv_entry */ #define PV_UNCACHED PG_PMAP0 /* Page is mapped unchached */ @@ -111,11 +123,11 @@ typedef struct pmap { #define PV_ATTR_REF PG_PMAP3 #define PV_PRESERVE (PV_ATTR_MOD | PV_ATTR_REF) -extern struct pmap kernel_pmap_store; +extern struct pmap *const kernel_pmap_ptr; #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) -#define pmap_kernel() (&kernel_pmap_store) +#define pmap_kernel() (kernel_pmap_ptr) #define pmap_phys_address(ppn) ptoa(ppn) #define PMAP_STEAL_MEMORY /* Enable 'stealing' during boot */ diff --git a/sys/arch/mips64/mips64/context.S b/sys/arch/mips64/mips64/context.S index 9ffb46bbaae..d37997091cf 100644 --- a/sys/arch/mips64/mips64/context.S +++ b/sys/arch/mips64/mips64/context.S @@ -1,4 +1,4 @@ -/* $OpenBSD: context.S,v 1.35 2009/12/28 06:55:27 syuu Exp $ */ +/* $OpenBSD: context.S,v 1.36 2010/01/05 06:44:58 syuu Exp $ */ /* * Copyright (c) 2002-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -148,10 +148,10 @@ NON_LEAF(cpu_switchto, FRAMESZ(CF_SZ), ra) PTR_L t1, VMSPACE_PMAP(t0) # ->vm_map.pmap #ifdef MULTIPROCESSOR HW_CPU_NUMBER(v0) # cpuid - PTR_SLL v0, v0, 0x2 + PTR_SLL v0, v0, 0x3 # size of pmap_asid_info PTR_ADDU t1, t1, v0 #endif - lw v0, PM_TLBPID(t1) # ->pm_tlbpid[cpuid] + lw v0, PM_ASID(t1) # ->pm_asid[cpuid].pma_asid #if UPAGES > 1 or v0, t3 diff --git a/sys/arch/mips64/mips64/genassym.cf b/sys/arch/mips64/mips64/genassym.cf index c2f139e06de..e87b1f3f3fc 100644 --- a/sys/arch/mips64/mips64/genassym.cf +++ b/sys/arch/mips64/mips64/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.1 2010/01/03 14:17:27 miod Exp $ +# $OpenBSD: genassym.cf,v 1.2 2010/01/05 06:44:58 syuu Exp $ # # Copyright (c) 1997 Per Fogelstrom / Opsycon AB # @@ -70,7 +70,7 @@ struct vmspace member VMSPACE_PMAP vm_map.pmap struct pmap -member pm_tlbpid +member PM_ASID pm_asid[0].pma_asid export NPTEPG export PMAP_SEGTABSIZE export SEGSHIFT diff --git a/sys/arch/mips64/mips64/pmap.c b/sys/arch/mips64/mips64/pmap.c index 2bfde56729c..e3d3bb607ed 100644 --- a/sys/arch/mips64/mips64/pmap.c +++ b/sys/arch/mips64/mips64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.45 2009/12/30 01:17:59 syuu Exp $ */ +/* $OpenBSD: pmap.c,v 1.46 2010/01/05 06:44:58 syuu Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -133,15 +133,16 @@ int pmapdebug = PDB_ENTER|PDB_FOLLOW; #endif /* PMAPDEBUG */ - -struct pmap kernel_pmap_store; +static struct pmap kernel_pmap_store + [(PMAP_SIZEOF(MAXCPUS) + sizeof(struct pmap) - 1) + / sizeof(struct pmap)]; +struct pmap *const kernel_pmap_ptr = kernel_pmap_store; psize_t mem_size; /* memory size in bytes */ vaddr_t virtual_start; /* VA of first avail page (after kernel bss)*/ vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */ -u_int tlbpid_gen[MAXCPUS]; /* TLB PID generation count */ -u_int tlbpid_cnt[MAXCPUS]; /* next available TLB PID */ +static struct pmap_asid_info pmap_asid_info[MAXCPUS]; pt_entry_t *Sysmap; /* kernel pte table */ u_int Sysmapsize; /* number of pte's in Sysmap */ @@ -191,10 +192,11 @@ pmap_invalidate_user_page(pmap_t pmap, vaddr_t va) if (cpuset_isset(&cpus_running, ci)) { unsigned int i = ci->ci_cpuid; unsigned int m = 1 << i; - if (pmap->pm_tlbgen[i] != tlbpid_gen[i]) + if (pmap->pm_asid[i].pma_asidgen != + pmap_asid_info[i].pma_asidgen) continue; else if (ci->ci_curpmap != pmap) { - pmap->pm_tlbgen[i] = 0; + pmap->pm_asid[i].pma_asidgen = 0; continue; } cpumask |= m; @@ -214,7 +216,7 @@ pmap_invalidate_user_page_action(void *arg) unsigned int cpuid = cpu_number(); u_long asid; - asid = pmap->pm_tlbpid[cpuid] << VMTLB_PID_SHIFT; + asid = pmap->pm_asid[cpuid].pma_asid << VMTLB_PID_SHIFT; tlb_flush_addr(va | asid); } @@ -263,10 +265,11 @@ pmap_update_user_page(pmap_t pmap, vaddr_t va, pt_entry_t entry) if (cpuset_isset(&cpus_running, ci)) { unsigned int i = ci->ci_cpuid; unsigned int m = 1 << i; - if (pmap->pm_tlbgen[i] != tlbpid_gen[i]) + if (pmap->pm_asid[i].pma_asidgen != + pmap_asid_info[i].pma_asidgen) continue; else if (ci->ci_curpmap != pmap) { - pmap->pm_tlbgen[i] = 0; + pmap->pm_asid[i].pma_asidgen = 0; continue; } cpumask |= m; @@ -288,7 +291,7 @@ pmap_update_user_page_action(void *arg) unsigned int cpuid = cpu_number(); u_long asid; - asid = pmap->pm_tlbpid[cpuid] << VMTLB_PID_SHIFT; + asid = pmap->pm_asid[cpuid].pma_asid << VMTLB_PID_SHIFT; tlb_update(va | asid, entry); } #else @@ -302,9 +305,10 @@ static void pmap_invalidate_user_page(pmap_t pmap, vaddr_t va) { u_long cpuid = cpu_number(); - u_long asid = pmap->pm_tlbpid[cpuid] << VMTLB_PID_SHIFT; + u_long asid = pmap->pm_asid[cpuid].pma_asid << VMTLB_PID_SHIFT; - if (pmap->pm_tlbgen[cpuid] == tlbpid_gen[cpuid]) + if (pmap->pm_asid[cpuid].pma_asidgen == + pmap_asid_info[cpuid].pma_asidgen) tlb_flush_addr(va | asid); } @@ -318,9 +322,10 @@ void pmap_update_user_page(pmap_t pmap, vaddr_t va, pt_entry_t entry) { u_long cpuid = cpu_number(); - u_long asid = pmap->pm_tlbpid[cpuid] << VMTLB_PID_SHIFT; + u_long asid = pmap->pm_asid[cpuid].pma_asid << VMTLB_PID_SHIFT; - if (pmap->pm_tlbgen[cpuid] == tlbpid_gen[cpuid]) + if (pmap->pm_asid[cpuid].pma_asidgen == + pmap_asid_info[cpuid].pma_asidgen) tlb_update(va | asid, entry); } #endif @@ -329,7 +334,7 @@ pmap_update_user_page(pmap_t pmap, vaddr_t va, pt_entry_t entry) * Bootstrap the system enough to run with virtual memory. */ void -pmap_bootstrap() +pmap_bootstrap(void) { u_int i; pt_entry_t *spte; @@ -351,7 +356,7 @@ pmap_bootstrap() Sysmap = (pt_entry_t *) uvm_pageboot_alloc(sizeof(pt_entry_t) * Sysmapsize); - pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0,"pmappl", NULL); + pool_init(&pmap_pmap_pool, PMAP_SIZEOF(ncpusfound), 0, 0, 0,"pmappl", NULL); pool_init(&pmap_pv_pool, sizeof(struct pv_entry), 0, 0, 0,"pvpl", NULL); pool_init(&pmap_pg_pool, PMAP_L2SIZE, PMAP_L2SIZE, 0, 0, "pmappgpl", &pmap_pg_allocator); @@ -371,8 +376,8 @@ pmap_bootstrap() *spte = PG_G; for (i = 0; i < MAXCPUS; i++) { - tlbpid_gen[i] = 1; - tlbpid_cnt[i] = 2; + pmap_asid_info[i].pma_asidgen = 1; + pmap_asid_info[i].pma_asid = 2; } } @@ -496,15 +501,16 @@ extern struct user *proc0paddr; * The initial process has already been allocated a TLBPID * in mach_init(). */ - for (i = 0; i < MAXCPUS; i++) { - pmap->pm_tlbpid[i] = 1; - pmap->pm_tlbgen[i] = tlbpid_gen[i]; + for (i = 0; i < ncpusfound; i++) { + pmap->pm_asid[i].pma_asid = 1; + pmap->pm_asid[i].pma_asidgen = + pmap_asid_info[i].pma_asidgen; } proc0paddr->u_pcb.pcb_segtab = pmap->pm_segtab; } else { - for (i = 0; i < MAXCPUS; i++) { - pmap->pm_tlbpid[i] = 0; - pmap->pm_tlbgen[i] = 0; + for (i = 0; i < ncpusfound; i++) { + pmap->pm_asid[i].pma_asid = 0; + pmap->pm_asid[i].pma_asidgen = 0; } } @@ -961,9 +967,10 @@ pmap_enter(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) * MIPS pages in a OpenBSD page. */ npte |= vad_to_pfn(pa); - if (pmap->pm_tlbgen[cpuid] == tlbpid_gen[cpuid]) { + if (pmap->pm_asid[cpuid].pma_asidgen == + pmap_asid_info[cpuid].pma_asidgen) { DPRINTF(PDB_ENTER, ("pmap_enter: new pte 0x%08x tlbpid %u\n", - npte, pmap->pm_tlbpid[cpuid])); + npte, pmap->pm_asid[cpuid].pma_asid)); } else { DPRINTF(PDB_ENTER, ("pmap_enter: new pte 0x%08x\n", npte)); } @@ -1381,20 +1388,22 @@ pmap_alloc_tlbpid(struct proc *p) u_long cpuid = cpu_number(); pmap = p->p_vmspace->vm_map.pmap; - if (pmap->pm_tlbgen[cpuid] != tlbpid_gen[cpuid]) { - id = tlbpid_cnt[cpuid]; + if (pmap->pm_asid[cpuid].pma_asidgen != + pmap_asid_info[cpuid].pma_asidgen) { + id = pmap_asid_info[cpuid].pma_asid; if (id >= VMNUM_PIDS) { tlb_flush(sys_config.cpu[0].tlbsize); /* reserve tlbpid_gen == 0 to alway mean invalid */ - if (++tlbpid_gen[cpuid] == 0) - tlbpid_gen[cpuid] = 1; + if (++pmap_asid_info[cpuid].pma_asidgen == 0) + pmap_asid_info[cpuid].pma_asidgen = 1; id = 1; } - tlbpid_cnt[cpuid] = id + 1; - pmap->pm_tlbpid[cpuid] = id; - pmap->pm_tlbgen[cpuid] = tlbpid_gen[cpuid]; + pmap_asid_info[cpuid].pma_asid = id + 1; + pmap->pm_asid[cpuid].pma_asid = id; + pmap->pm_asid[cpuid].pma_asidgen = + pmap_asid_info[cpuid].pma_asidgen; } else { - id = pmap->pm_tlbpid[cpuid]; + id = pmap->pm_asid[cpuid].pma_asid; } if (curproc) { diff --git a/sys/arch/sgi/sgi/ip30.h b/sys/arch/sgi/sgi/ip30.h index e9f2c6f2e4b..3b31c4ee1af 100644 --- a/sys/arch/sgi/sgi/ip30.h +++ b/sys/arch/sgi/sgi/ip30.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip30.h,v 1.5 2009/10/31 00:20:46 miod Exp $ */ +/* $OpenBSD: ip30.h,v 1.6 2010/01/05 06:44:58 syuu Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -73,3 +73,4 @@ #define MPCONF_IDLEFLAG(i) ((i) * MPCONF_LEN + 0x58) #define MPCONF_MAGIC_VAL 0xbaddeed2 + diff --git a/sys/arch/sgi/sgi/ip30_machdep.c b/sys/arch/sgi/sgi/ip30_machdep.c index 7367c9bbe10..ea2de7e835b 100644 --- a/sys/arch/sgi/sgi/ip30_machdep.c +++ b/sys/arch/sgi/sgi/ip30_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip30_machdep.c,v 1.28 2009/12/28 06:55:27 syuu Exp $ */ +/* $OpenBSD: ip30_machdep.c,v 1.29 2010/01/05 06:44:58 syuu Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -67,6 +67,7 @@ paddr_t ip30_widget_short(int16_t, u_int); paddr_t ip30_widget_long(int16_t, u_int); paddr_t ip30_widget_map(int16_t, u_int, bus_addr_t *, bus_size_t *); int ip30_widget_id(int16_t, u_int, uint32_t *); +static u_long ip30_get_ncpusfound(void); static paddr_t ip30_iocbase; @@ -185,6 +186,8 @@ ip30_setup() hw_prod = "Octane"; else hw_prod = "Octane2"; + + ncpusfound = ip30_get_ncpusfound(); } /* @@ -201,14 +204,12 @@ ip30_autoconf(struct device *parent) maa.maa_name = "cpu"; config_found(parent, &maa, mbprint); +#ifdef MULTIPROCESSOR int cpuid; for(cpuid = 1; cpuid < MAXCPUS; cpuid++) - if (ip30_cpu_exists(cpuid) == 0) { - ncpusfound++; -#ifdef MULTIPROCESSOR + if (ip30_cpu_exists(cpuid)) config_found(parent, &maa, mbprint); #endif - } maa.maa_name = "clock"; config_found(parent, &maa, mbprint); maa.maa_name = "xbow"; @@ -310,10 +311,18 @@ ip30_cpu_exists(int cpuid) { uint32_t magic = *(volatile uint32_t *)(mpconf + MPCONF_MAGIC(cpuid)); - if (magic == MPCONF_MAGIC_VAL) - return 0; - else - return 1; + return magic == MPCONF_MAGIC_VAL; +} + +u_long +ip30_get_ncpusfound(void) +{ + int i; + for (i = 1; i < MAXCPUS; i++) + if (!ip30_cpu_exists(i)) + break; + + return i; } #ifdef MULTIPROCESSOR |