Changeset 2057572 in mainline for kernel/arch/sparc64/src/mm/tlb.c
- Timestamp:
- 2007-03-27T23:40:25Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 399ece9
- Parents:
- 8d37a06
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/mm/tlb.c
r8d37a06 r2057572 55 55 #endif 56 56 57 static void dtlb_pte_copy(pte_t *t, bool ro);58 static void itlb_pte_copy(pte_t *t );59 static void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, const60 57 static void dtlb_pte_copy(pte_t *t, index_t index, bool ro); 58 static void itlb_pte_copy(pte_t *t, index_t index); 59 static void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, 60 const char *str); 61 61 static void do_fast_data_access_mmu_miss_fault(istate_t *istate, 62 62 tlb_tag_access_reg_t tag, const char *str); 63 63 static void do_fast_data_access_protection_fault(istate_t *istate, 64 64 tlb_tag_access_reg_t tag, const char *str); 65 65 66 66 char *context_encoding[] = { … … 93 93 * @param cacheable True if the mapping is cacheable, false otherwise. 94 94 */ 95 void dtlb_insert_mapping(uintptr_t page, uintptr_t frame, int pagesize, bool96 95 void dtlb_insert_mapping(uintptr_t page, uintptr_t frame, int pagesize, 96 bool locked, bool cacheable) 97 97 { 98 98 tlb_tag_access_reg_t tag; … … 127 127 /** Copy PTE to TLB. 128 128 * 129 * @param t Page Table Entry to be copied. 130 * @param ro If true, the entry will be created read-only, regardless of its w 131 * field. 132 */ 133 void dtlb_pte_copy(pte_t *t, bool ro) 129 * @param t Page Table Entry to be copied. 130 * @param index Zero if lower 8K-subpage, one if higher 8K-subpage. 131 * @param ro If true, the entry will be created read-only, regardless of its 132 * w field. 133 */ 134 void dtlb_pte_copy(pte_t *t, index_t index, bool ro) 134 135 { 135 136 tlb_tag_access_reg_t tag; … … 138 139 frame_address_t fr; 139 140 140 pg.address = t->page ;141 fr.address = t->frame ;141 pg.address = t->page + (index << MMU_PAGE_WIDTH); 142 fr.address = t->frame + (index << MMU_PAGE_WIDTH); 142 143 143 144 tag.value = 0; 144 145 tag.context = t->as->asid; 145 146 tag.vpn = pg.vpn; 146 147 147 148 dtlb_tag_access_write(tag.value); 148 149 149 150 data.value = 0; 150 151 data.v = true; … … 159 160 data.w = ro ? false : t->w; 160 161 data.g = t->g; 161 162 162 163 dtlb_data_in_write(data.value); 163 164 } … … 165 166 /** Copy PTE to ITLB. 166 167 * 167 * @param t Page Table Entry to be copied. 168 */ 169 void itlb_pte_copy(pte_t *t) 168 * @param t Page Table Entry to be copied. 169 * @param index Zero if lower 8K-subpage, one if higher 8K-subpage. 170 */ 171 void itlb_pte_copy(pte_t *t, index_t index) 170 172 { 171 173 tlb_tag_access_reg_t tag; … … 174 176 frame_address_t fr; 175 177 176 pg.address = t->page ;177 fr.address = t->frame ;178 pg.address = t->page + (index << MMU_PAGE_WIDTH); 179 fr.address = t->frame + (index << MMU_PAGE_WIDTH); 178 180 179 181 tag.value = 0; … … 200 202 { 201 203 uintptr_t va = ALIGN_DOWN(istate->tpc, PAGE_SIZE); 204 index_t index = (istate->tpc >> MMU_PAGE_WIDTH) % MMU_PAGES_PER_PAGE; 202 205 pte_t *t; 203 206 … … 210 213 */ 211 214 t->a = true; 212 itlb_pte_copy(t );215 itlb_pte_copy(t, index); 213 216 #ifdef CONFIG_TSB 214 itsb_pte_copy(t );217 itsb_pte_copy(t, index); 215 218 #endif 216 219 page_table_unlock(AS, true); … … 223 226 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 224 227 do_fast_instruction_access_mmu_miss_fault(istate, 225 228 __FUNCTION__); 226 229 } 227 230 } … … 237 240 tlb_tag_access_reg_t tag; 238 241 uintptr_t va; 242 index_t index; 239 243 pte_t *t; 240 244 241 245 tag.value = dtlb_tag_access_read(); 242 va = tag.vpn << PAGE_WIDTH; 246 va = ALIGN_DOWN((uint64_t) tag.vpn << MMU_PAGE_WIDTH, PAGE_SIZE); 247 index = tag.vpn % MMU_PAGES_PER_PAGE; 243 248 244 249 if (tag.context == ASID_KERNEL) { … … 246 251 /* NULL access in kernel */ 247 252 do_fast_data_access_mmu_miss_fault(istate, tag, 248 253 __FUNCTION__); 249 254 } 250 255 do_fast_data_access_mmu_miss_fault(istate, tag, "Unexpected " 251 256 "kernel page fault."); 252 257 } 253 258 … … 260 265 */ 261 266 t->a = true; 262 dtlb_pte_copy(t, true);267 dtlb_pte_copy(t, index, true); 263 268 #ifdef CONFIG_TSB 264 dtsb_pte_copy(t, true);269 dtsb_pte_copy(t, index, true); 265 270 #endif 266 271 page_table_unlock(AS, true); 267 272 } else { 268 273 /* 269 * Forward the page fault to the address space page fault handler. 274 * Forward the page fault to the address space page fault 275 * handler. 270 276 */ 271 277 page_table_unlock(AS, true); 272 278 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 273 279 do_fast_data_access_mmu_miss_fault(istate, tag, 274 280 __FUNCTION__); 275 281 } 276 282 } … … 282 288 tlb_tag_access_reg_t tag; 283 289 uintptr_t va; 290 index_t index; 284 291 pte_t *t; 285 292 286 293 tag.value = dtlb_tag_access_read(); 287 va = tag.vpn << PAGE_WIDTH; 294 va = ALIGN_DOWN((uint64_t) tag.vpn << MMU_PAGE_WIDTH, PAGE_SIZE); 295 index = tag.vpn % MMU_PAGES_PER_PAGE; /* 16K-page emulation */ 288 296 289 297 page_table_lock(AS, true); … … 297 305 t->a = true; 298 306 t->d = true; 299 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, va); 300 dtlb_pte_copy(t, false); 307 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, 308 va + index * MMU_PAGE_SIZE); 309 dtlb_pte_copy(t, index, false); 301 310 #ifdef CONFIG_TSB 302 dtsb_pte_copy(t, false);311 dtsb_pte_copy(t, index, false); 303 312 #endif 304 313 page_table_unlock(AS, true); … … 311 320 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 312 321 do_fast_data_access_protection_fault(istate, tag, 313 322 __FUNCTION__); 314 323 } 315 324 } … … 329 338 330 339 printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, " 331 332 333 334 340 "ie=%d, soft2=%#x, diag=%#x, pfn=%#x, soft=%#x, l=%d, " 341 "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn, 342 t.context, d.v, d.size, d.nfo, d.ie, d.soft2, d.diag, 343 d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g); 335 344 } 336 345 … … 341 350 342 351 printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, " 343 344 345 346 347 } 348 349 } 350 351 void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, const char352 352 "ie=%d, soft2=%#x, diag=%#x, pfn=%#x, soft=%#x, l=%d, " 353 "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn, 354 t.context, d.v, d.size, d.nfo, d.ie, d.soft2, d.diag, 355 d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g); 356 } 357 358 } 359 360 void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, 361 const char *str) 353 362 { 354 363 fault_if_from_uspace(istate, "%s\n", str); … … 357 366 } 358 367 359 void do_fast_data_access_mmu_miss_fault(istate_t *istate, tlb_tag_access_reg_t360 368 void do_fast_data_access_mmu_miss_fault(istate_t *istate, 369 tlb_tag_access_reg_t tag, const char *str) 361 370 { 362 371 uintptr_t va; 363 372 364 va = tag.vpn << PAGE_WIDTH;373 va = tag.vpn << MMU_PAGE_WIDTH; 365 374 366 375 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d)\n", str, va, 367 376 tag.context); 368 377 dump_istate(istate); 369 378 printf("Faulting page: %p, ASID=%d\n", va, tag.context); … … 371 380 } 372 381 373 void do_fast_data_access_protection_fault(istate_t *istate, tlb_tag_access_reg_t374 382 void do_fast_data_access_protection_fault(istate_t *istate, 383 tlb_tag_access_reg_t tag, const char *str) 375 384 { 376 385 uintptr_t va; 377 386 378 va = tag.vpn << PAGE_WIDTH;387 va = tag.vpn << MMU_PAGE_WIDTH; 379 388 380 389 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d)\n", str, va, 381 390 tag.context); 382 391 printf("Faulting page: %p, ASID=%d\n", va, tag.context); 383 392 dump_istate(istate); … … 394 403 395 404 printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, " 396 397 405 "fv=%d\n", sfsr.asi, sfsr.ft, sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, 406 sfsr.ow, sfsr.fv); 398 407 printf("DTLB SFAR: address=%p\n", sfar); 399 408 … … 482 491 mmu_primary_context_write(ctx.v); 483 492 484 for (i = 0; i < cnt ; i++) {493 for (i = 0; i < cnt * MMU_PAGES_PER_PAGE; i++) { 485 494 itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY, 486 page + i * PAGE_SIZE);495 page + i * MMU_PAGE_SIZE); 487 496 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY, 488 page + i * PAGE_SIZE);497 page + i * MMU_PAGE_SIZE); 489 498 } 490 499
Note:
See TracChangeset
for help on using the changeset viewer.