tlb.h (93687) | tlb.h (96998) |
---|---|
1/*- 2 * Copyright (c) 2001 Jake Burkholder. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2001 Jake Burkholder. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/sparc64/include/tlb.h 93687 2002-04-02 17:50:13Z tmm $ | 26 * $FreeBSD: head/sys/sparc64/include/tlb.h 96998 2002-05-20 16:10:17Z jake $ |
27 */ 28 29#ifndef _MACHINE_TLB_H_ 30#define _MACHINE_TLB_H_ 31 32#define TLB_DAR_SLOT_SHIFT (3) 33#define TLB_DAR_SLOT(slot) ((slot) << TLB_DAR_SLOT_SHIFT) 34 --- 43 unchanged lines hidden (view full) --- 78#define MMU_SFSR_FT_SIZE (6) 79#define MMU_SFSR_CT_SIZE (2) 80 81#define MMU_SFSR_W (1L << MMU_SFSR_W_SHIFT) 82 83extern int kernel_tlb_slots; 84extern struct tte *kernel_ttes; 85 | 27 */ 28 29#ifndef _MACHINE_TLB_H_ 30#define _MACHINE_TLB_H_ 31 32#define TLB_DAR_SLOT_SHIFT (3) 33#define TLB_DAR_SLOT(slot) ((slot) << TLB_DAR_SLOT_SHIFT) 34 --- 43 unchanged lines hidden (view full) --- 78#define MMU_SFSR_FT_SIZE (6) 79#define MMU_SFSR_CT_SIZE (2) 80 81#define MMU_SFSR_W (1L << MMU_SFSR_W_SHIFT) 82 83extern int kernel_tlb_slots; 84extern struct tte *kernel_ttes; 85 |
86/* 87 * Some tlb operations must be atomic, so no interrupt or trap can be allowed 88 * while they are in progress. Traps should not happen, but interrupts need to 89 * be explicitely disabled. critical_enter() cannot be used here, since it only 90 * disables soft interrupts. 91 */ | 86void tlb_context_demap(struct pmap *pm); 87void tlb_page_demap(u_int tlb, struct pmap *pm, vm_offset_t va); 88void tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end); |
92 | 89 |
93static __inline void 94tlb_context_demap(struct pmap *pm) 95{ 96 void *cookie; 97 u_long s; 98 99 /* 100 * It is important that we are not interrupted or preempted while 101 * doing the IPIs. The interrupted CPU may hold locks, and since 102 * it will wait for the CPU that sent the IPI, this can lead 103 * to a deadlock when an interrupt comes in on that CPU and it's 104 * handler tries to grab one of that locks. This will only happen for 105 * spin locks, but these IPI types are delivered even if normal 106 * interrupts are disabled, so the lock critical section will not 107 * protect the target processor from entering the IPI handler with 108 * the lock held. 109 */ 110 critical_enter(); 111 cookie = ipi_tlb_context_demap(pm); 112 if (pm->pm_active & PCPU_GET(cpumask)) { 113 KASSERT(pm->pm_context[PCPU_GET(cpuid)] != -1, 114 ("tlb_context_demap: inactive pmap?")); 115 s = intr_disable(); 116 stxa(TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, ASI_DMMU_DEMAP, 0); 117 stxa(TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, ASI_IMMU_DEMAP, 0); 118 membar(Sync); 119 intr_restore(s); 120 } 121 ipi_wait(cookie); 122 critical_exit(); 123} 124 125static __inline void 126tlb_page_demap(u_int tlb, struct pmap *pm, vm_offset_t va) 127{ 128 u_long flags; 129 void *cookie; 130 u_long s; 131 132 critical_enter(); 133 cookie = ipi_tlb_page_demap(tlb, pm, va); 134 if (pm->pm_active & PCPU_GET(cpumask)) { 135 KASSERT(pm->pm_context[PCPU_GET(cpuid)] != -1, 136 ("tlb_page_demap: inactive pmap?")); 137 if (pm == kernel_pmap) 138 flags = TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE; 139 else 140 flags = TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE; 141 142 s = intr_disable(); 143 if (tlb & TLB_DTLB) { 144 stxa(TLB_DEMAP_VA(va) | flags, ASI_DMMU_DEMAP, 0); 145 membar(Sync); 146 } 147 if (tlb & TLB_ITLB) { 148 stxa(TLB_DEMAP_VA(va) | flags, ASI_IMMU_DEMAP, 0); 149 membar(Sync); 150 } 151 intr_restore(s); 152 } 153 ipi_wait(cookie); 154 critical_exit(); 155} 156 157static __inline void 158tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) 159{ 160 vm_offset_t va; 161 void *cookie; 162 u_long flags; 163 u_long s; 164 165 critical_enter(); 166 cookie = ipi_tlb_range_demap(pm, start, end); 167 if (pm->pm_active & PCPU_GET(cpumask)) { 168 KASSERT(pm->pm_context[PCPU_GET(cpuid)] != -1, 169 ("tlb_range_demap: inactive pmap?")); 170 if (pm == kernel_pmap) 171 flags = TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE; 172 else 173 flags = TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE; 174 175 s = intr_disable(); 176 for (va = start; va < end; va += PAGE_SIZE) { 177 stxa(TLB_DEMAP_VA(va) | flags, ASI_DMMU_DEMAP, 0); 178 stxa(TLB_DEMAP_VA(va) | flags, ASI_IMMU_DEMAP, 0); 179 membar(Sync); 180 } 181 intr_restore(s); 182 } 183 ipi_wait(cookie); 184 critical_exit(); 185} 186 | |
187#define tlb_tte_demap(tte, pm) \ 188 tlb_page_demap(TD_GET_TLB((tte).tte_data), pm, \ 189 TV_GET_VA((tte).tte_vpn)); 190 191#endif /* !_MACHINE_TLB_H_ */ | 90#define tlb_tte_demap(tte, pm) \ 91 tlb_page_demap(TD_GET_TLB((tte).tte_data), pm, \ 92 TV_GET_VA((tte).tte_vpn)); 93 94#endif /* !_MACHINE_TLB_H_ */ |