Changeset 610 for trunk/hal/tsar_mips32/core
- Timestamp:
- Dec 27, 2018, 7:38:58 PM (6 years ago)
- Location:
- trunk/hal/tsar_mips32/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_exception.c
r587 r610 158 158 // This function is called when an MMU exception has been detected (IBE / DBE). 159 159 // It get the relevant exception arguments from the MMU. 160 // It signal a fatal error in case of illegal access. In case of page unmapped 161 // it checks that the faulty address belongs to a registered vseg. It update the local 160 // It signal a fatal error in case of illegal access. In case of page unmapped, 161 // it get the client process to access the relevant VMM: for a RPC thread, the client 162 // process is NOT the calling thread process. 163 // Then, it checks that the faulty address belongs to a registered vseg, update the local 162 164 // vseg list from the reference cluster if required, and signal a fatal user error 163 165 // in case of illegal virtual address. Finally, it updates the local page table from the … … 183 185 uint32_t bad_vaddr; 184 186 uint32_t excp_code; 185 187 188 // check thread type 189 if( CURRENT_THREAD->type != THREAD_USER ) 190 { 191 printk("\n[KERNEL PANIC] in %s : illegal thread type %s\n", 192 __FUNCTION__, thread_type_str(CURRENT_THREAD->type) ); 193 194 return EXCP_KERNEL_PANIC; 195 } 196 197 // get faulty thread process 186 198 process = this->process; 187 199 … … 207 219 uint32_t cycle = (uint32_t)hal_get_cycles(); 208 220 if( DEBUG_HAL_EXCEPTIONS < cycle ) 209 printk("\n[ DBG] %s : thread[%x,%x] enter / is_ins %d / %s / vaddr %x / cycle %d\n",210 __FUNCTION__, process->pid, this->trdid, 221 printk("\n[%s] thread[%x,%x] on core [%x,%x] enter / is_ins %d / %s / vaddr %x / cycle %d\n", 222 __FUNCTION__, process->pid, this->trdid, local_cxy, this->core->lid, 211 223 is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle); 212 224 #endif … … 215 227 switch( excp_code ) 216 228 { 217 case MMU_WRITE_PT1_UNMAPPED: // non fatal218 case MMU_WRITE_PT2_UNMAPPED: 219 case MMU_READ_PT1_UNMAPPED: 220 case MMU_READ_PT2_UNMAPPED: 229 case MMU_WRITE_PT1_UNMAPPED: // can be non fatal 230 case MMU_WRITE_PT2_UNMAPPED: // can be non fatal 231 case MMU_READ_PT1_UNMAPPED: // can be non fatal 232 case MMU_READ_PT2_UNMAPPED: // can be non fatal 221 233 { 222 234 // try to map the unmapped PTE … … 230 242 cycle = (uint32_t)hal_get_cycles(); 231 243 if( DEBUG_HAL_EXCEPTIONS < cycle ) 232 printk("\n[ DBG] %s : thread[%x,%x] exit / page-fault handled for vaddr = %x\n",233 __FUNCTION__, process->pid, this->trdid, bad_vaddr );244 printk("\n[%s] thread[%x,%x] on core [%x,%x] exit / page-fault handled for vaddr = %x\n", 245 __FUNCTION__, process->pid, this->trdid, local_cxy, this->core->lid, bad_vaddr ); 234 246 #endif 235 247 … … 238 250 else if( error == EXCP_USER_ERROR ) // illegal vaddr 239 251 { 240 printk("\n[USER ERROR] in %s for thread %x in process %x\n" 241 " illegal vaddr = %x / is_ins %d / epc %x\n", 242 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 252 printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n" 253 " %s : epc %x / badvaddr %x / is_ins %d\n", 254 __FUNCTION__, this->process->pid, this->trdid, local_cxy, 255 this->core->lid, (uint32_t)hal_get_cycles(), 256 hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins ); 243 257 244 258 return EXCP_USER_ERROR; … … 246 260 else // error == EXCP_KERNEL_PANIC 247 261 { 248 printk("\n[KERNEL ERROR] in %s for thread %x in process %x\n" 249 " no memory to map vaddr = %x / is_ins %d / epc %x\n", 250 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 262 printk("\n[KERNEL PANIC] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n" 263 " %s : epc %x / badvaddr %x / is_ins %d\n", 264 __FUNCTION__, this->process->pid, this->trdid, local_cxy, 265 this->core->lid, (uint32_t)hal_get_cycles(), 266 hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins ); 251 267 252 268 return EXCP_KERNEL_PANIC; 253 269 } 254 270 } 255 case MMU_WRITE_PRIVILEGE_VIOLATION: // illegal access user error 256 case MMU_READ_PRIVILEGE_VIOLATION: 257 { 258 printk("\n[USER ERROR] in %s : thread %x in process %x\n" 259 " illegal user access to vaddr = %x / is_ins %d / epc %x\n", 260 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 271 case MMU_WRITE_PRIVILEGE_VIOLATION: // illegal user error 272 case MMU_READ_PRIVILEGE_VIOLATION: // illegal 273 { 274 printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n" 275 " %s : epc %x / badvaddr %x / is_ins %d\n", 276 __FUNCTION__, this->process->pid, this->trdid, local_cxy, 277 this->core->lid, (uint32_t)hal_get_cycles(), 278 hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins ); 261 279 262 280 return EXCP_USER_ERROR; 263 281 } 264 case MMU_WRITE_ACCESS_VIOLATION: // user error, or Copy-on-Write 265 { 266 // access page table to get GPT_COW flag 267 bool_t cow = hal_gpt_pte_is_cow( &(process->vmm.gpt), 268 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 269 270 if( cow ) // Copy-on-Write 271 { 272 // try to allocate and copy the page 273 error = vmm_handle_cow( process, 274 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 275 276 if( error == EXCP_NON_FATAL ) // Copy on write successfull 277 { 282 case MMU_WRITE_ACCESS_VIOLATION: // can be non fatal if COW 283 { 284 // try to handle a possible COW 285 error = vmm_handle_cow( process, 286 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 287 288 if( error == EXCP_NON_FATAL ) // COW successfully handled 289 { 278 290 279 291 #if DEBUG_HAL_EXCEPTIONS 280 292 cycle = (uint32_t)hal_get_cycles(); 281 293 if( DEBUG_HAL_EXCEPTIONS < cycle ) 282 printk("\n[ DBG] %s :thread[%x,%x] exit / copy-on-write handled for vaddr = %x\n",294 printk("\n[%s] thread[%x,%x] exit / copy-on-write handled for vaddr = %x\n", 283 295 __FUNCTION__, process->pid, this->trdid, bad_vaddr ); 284 296 #endif 285 286 return EXCP_NON_FATAL; 287 } 288 else if( error == EXCP_USER_ERROR ) // illegal user access 289 { 290 printk("\n[USER ERROR] in %s : thread %x in process %x\n" 291 " cannot cow vaddr = %x / is_ins %d / epc %x\n", 292 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 297 return EXCP_NON_FATAL; 298 } 299 else if( error == EXCP_USER_ERROR ) // illegal write access 300 { 301 printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n" 302 " %s : epc %x / badvaddr %x / is_ins %d\n", 303 __FUNCTION__, this->process->pid, this->trdid, local_cxy, 304 this->core->lid, (uint32_t)hal_get_cycles(), 305 hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins ); 293 306 294 307 return EXCP_USER_ERROR; 295 }296 else // error == EXCP_KERNEL_PANIC297 {298 printk("\n[KERNEL ERROR] in %s : thread %x in process %x\n"299 " no memoty to cow vaddr = %x / is_ins %d / epc %x\n",300 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );301 302 return EXCP_USER_ERROR;303 }304 308 } 305 else // non writable user error 306 { 307 printk("\n[USER ERROR] in %s : thread %x in process %x\n" 308 " non-writable vaddr = %x / is_ins %d / epc %x\n", 309 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 310 311 return EXCP_USER_ERROR; 309 else // error == EXCP_KERNEL_PANIC 310 { 311 printk("\n[KERNEL PANIC] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n" 312 " %s : epc %x / badvaddr %x / is_ins %d\n", 313 __FUNCTION__, this->process->pid, this->trdid, local_cxy, 314 this->core->lid, (uint32_t)hal_get_cycles(), 315 hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins ); 316 317 return EXCP_USER_ERROR; 312 318 } 313 319 } 314 320 case MMU_READ_EXEC_VIOLATION: // user error 315 321 { 316 printk("\n[USER_ERROR] in %s : thread %x in process %x\n" 317 " non-executable vaddr = %x / is_ins %d / epc %x\n", 318 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 322 printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n" 323 " %s : epc %x / badvaddr %x / is_ins %d\n", 324 __FUNCTION__, this->process->pid, this->trdid, local_cxy, 325 this->core->lid, (uint32_t)hal_get_cycles(), 326 hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins ); 319 327 320 328 return EXCP_USER_ERROR; … … 322 330 default: // this is a kernel error 323 331 { 324 printk("\n[KERNEL ERROR] in %s : thread %x in process %x\n" 325 " epc %x / badvaddr %x / is_ins %d\n", 326 __FUNCTION__, this->trdid, this->process->pid, excPC, bad_vaddr, is_ins ); 332 printk("\n[KERNEL PANIC] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n" 333 " %s : epc %x / badvaddr %x / is_ins %d\n", 334 __FUNCTION__, this->process->pid, this->trdid, local_cxy, 335 this->core->lid, (uint32_t)hal_get_cycles(), 336 hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins ); 327 337 328 338 return EXCP_KERNEL_PANIC; … … 359 369 if( error == EXCP_USER_ERROR ) 360 370 { 361 nolock_printk("\n=== USER ERROR / t rdid %x / pid %x / core[%x,%d] / cycle %d ===\n",362 this->trdid, process->pid, local_cxy, core->lid, (uint32_t)hal_get_cycles() );371 nolock_printk("\n=== USER ERROR / thread(%x,%x) / core[%d] / cycle %d ===\n", 372 process->pid, this->trdid, core->lid, (uint32_t)hal_get_cycles() ); 363 373 } 364 374 else 365 375 { 366 nolock_printk("\n=== KERNEL ERROR / trdid %x / pid %x / core[%x,%d] / cycle %d ===\n",367 this->trdid, process->pid, local_cxy, core->lid, (uint32_t)hal_get_cycles() );376 nolock_printk("\n=== KERNEL PANIC / thread(%x,%x) / core[%d] / cycle %d ===\n", 377 process->pid, this->trdid, core->lid, (uint32_t)hal_get_cycles() ); 368 378 } 369 379 … … 400 410 } // end hal_exception_dump() 401 411 402 /////////////////////// 412 ///////////////////////////// 403 413 void hal_do_exception( void ) 404 414 { … … 420 430 uint32_t cycle = (uint32_t)hal_get_cycles(); 421 431 if( DEBUG_HAL_EXCEPTIONS < cycle ) 422 printk("\n[DBG] %s : thread %x in process %x enter / core[%x,%d] / epc %x / xcode %x / cycle %d\n", 423 __FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle ); 432 printk("\n[%s] thread[%x,%x] enter / core[%x,%d] / epc %x / xcode %x / cycle %d\n", 433 __FUNCTION__, this->process->pid, this->trdid, 434 local_cxy, this->core->lid, excPC, excCode, cycle ); 424 435 #endif 425 436 … … 473 484 { 474 485 printk("\n[USER_ERROR] in %s for thread %x in process %x\n" 475 " illegal data load address / epc %x \n",476 __FUNCTION__, this->trdid, this->process->pid, excPC );486 " illegal data load address / epc %x / bad_address %x\n", 487 __FUNCTION__, this->trdid, this->process->pid, excPC, hal_get_bad_vaddr() ); 477 488 478 489 error = EXCP_USER_ERROR; … … 482 493 { 483 494 printk("\n[USER_ERROR] in %s for thread %x in process %x\n" 484 " illegal data store address / epc %x \n",485 __FUNCTION__, this->trdid, this->process->pid, excPC );495 " illegal data store address / epc %x / bad_address %x\n", 496 __FUNCTION__, this->trdid, this->process->pid, excPC, hal_get_bad_vaddr() ); 486 497 487 498 error = EXCP_USER_ERROR; … … 505 516 hal_exception_dump( this , uzone , error ); 506 517 507 assert( false , "Exception raised kernel panic see information below.\n");518 hal_core_sleep(); 508 519 } 509 520 … … 511 522 cycle = (uint32_t)hal_get_cycles(); 512 523 if( DEBUG_HAL_EXCEPTIONS < cycle ) 513 printk("\n[DBG] %s : thread %x in process %x exit / core[%x,%d] / epc %x / xcode %x / cycle %d\n", 514 __FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle ); 524 printk("\n[%s] thread[%x,%x] exit / core[%x,%d] / epc %x / xcode %x / cycle %d\n", 525 __FUNCTION__, this->process->pid, this->trdid, 526 local_cxy, this->core->lid, excPC, excCode, cycle ); 515 527 #endif 516 528 -
trunk/hal/tsar_mips32/core/hal_ppm.c
r570 r610 2 2 * hal_ppm.c - Generic Physical Page Manager API implementation for TSAR 3 3 * 4 * Authors Alain Greiner (2016,2017 )4 * Authors Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 63 63 64 64 // initialize lock protecting the dirty_pages list 65 queuelock_init( &ppm->dirty_lock, LOCK_PPM_DIRTY );65 remote_queuelock_init( XPTR( local_cxy , &ppm->dirty_lock ) , LOCK_PPM_DIRTY ); 66 66 67 67 // initialize all free_pages[] lists as empty -
trunk/hal/tsar_mips32/core/hal_remote.c
r570 r610 381 381 uint32_t scxy = (uint32_t)GET_CXY( src ); 382 382 383 /* 384 if( local_cxy == 1 ) 385 printk("\n@@@ %s : scxy %x / sptr %x / dcxy %x / dptr %x\n", 386 __FUNCTION__, scxy, sptr, dcxy, dptr ); 387 */ 383 388 hal_disable_irq( &save_sr ); 384 389 -
trunk/hal/tsar_mips32/core/hal_uspace.c
r457 r610 43 43 uint32_t dst = (uint32_t)k_dst; 44 44 45 #if DEBUG_HAL_USPACE 46 thread_t * this = CURRENT_THREAD; 47 printk("\n[%s] thread[%x,%x] enter in cluster %x / u_src %x / k_dst %x / size %d\n", 48 __FUNCTION__, this->process->pid, this->trdid, local_cxy, u_src, k_dst, size ); 49 #endif 50 45 51 if( (dst & 0x3) || (src & 0x3) ) wsize = 0; // do it all in bytes 46 52 else wsize = size >> 2; … … 80 86 81 87 hal_restore_irq( save_sr ); 88 89 #if DEBUG_HAL_USPACE 90 printk("\n[%s] thread[%x,%x] exit\n", 91 __FUNCTION__, this->process->pid, this->trdid ); 92 #endif 82 93 83 94 } // end hal_copy_from_uspace() … … 94 105 uint32_t dst = (uint32_t)u_dst; 95 106 107 #if DEBUG_HAL_USPACE 108 thread_t * this = CURRENT_THREAD; 109 printk("\n[%s] thread[%x,%x] enter in cluster %x / k_src %x / u_dst %x / size %d\n", 110 __FUNCTION__, this->process->pid, this->trdid, local_cxy, k_src, u_dst, size ); 111 #endif 112 96 113 if( (dst & 0x3) || (src & 0x3) ) wsize = 0; // not aligned 97 114 else wsize = size >> 2; … … 118 135 asm volatile( 119 136 "mfc2 $15, $1 \n" /* save MMU_MODE */ 120 "l w$13, 0(%0) \n" /* read data from kernel space */137 "lb $13, 0(%0) \n" /* read data from kernel space */ 121 138 "ori $14, $0, 0x7 \n" 122 139 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ … … 130 147 131 148 hal_restore_irq( save_sr ); 149 150 #if DEBUG_HAL_USPACE 151 printk("\n[%s] thread[%x,%x] exit\n", 152 __FUNCTION__, this->process->pid, this->trdid ); 153 #endif 132 154 133 155 } // end hal_copy_to_uspace()
Note: See TracChangeset
for help on using the changeset viewer.