diff options
Diffstat (limited to 'arch/microblaze/kernel/hw_exception_handler.S')
-rw-r--r-- | arch/microblaze/kernel/hw_exception_handler.S | 112 |
1 files changed, 48 insertions, 64 deletions
diff --git a/arch/microblaze/kernel/hw_exception_handler.S b/arch/microblaze/kernel/hw_exception_handler.S index 2b86c03aa841..995a2123635b 100644 --- a/arch/microblaze/kernel/hw_exception_handler.S +++ b/arch/microblaze/kernel/hw_exception_handler.S | |||
@@ -313,13 +313,13 @@ _hw_exception_handler: | |||
313 | mfs r5, rmsr; | 313 | mfs r5, rmsr; |
314 | nop | 314 | nop |
315 | swi r5, r1, 0; | 315 | swi r5, r1, 0; |
316 | mfs r3, resr | 316 | mfs r4, resr |
317 | nop | 317 | nop |
318 | mfs r4, rear; | 318 | mfs r3, rear; |
319 | nop | 319 | nop |
320 | 320 | ||
321 | #ifndef CONFIG_MMU | 321 | #ifndef CONFIG_MMU |
322 | andi r5, r3, 0x1000; /* Check ESR[DS] */ | 322 | andi r5, r4, 0x1000; /* Check ESR[DS] */ |
323 | beqi r5, not_in_delay_slot; /* Branch if ESR[DS] not set */ | 323 | beqi r5, not_in_delay_slot; /* Branch if ESR[DS] not set */ |
324 | mfs r17, rbtr; /* ESR[DS] set - return address in BTR */ | 324 | mfs r17, rbtr; /* ESR[DS] set - return address in BTR */ |
325 | nop | 325 | nop |
@@ -327,13 +327,14 @@ not_in_delay_slot: | |||
327 | swi r17, r1, PT_R17 | 327 | swi r17, r1, PT_R17 |
328 | #endif | 328 | #endif |
329 | 329 | ||
330 | andi r5, r3, 0x1F; /* Extract ESR[EXC] */ | 330 | andi r5, r4, 0x1F; /* Extract ESR[EXC] */ |
331 | 331 | ||
332 | #ifdef CONFIG_MMU | 332 | #ifdef CONFIG_MMU |
333 | /* Calculate exception vector offset = r5 << 2 */ | 333 | /* Calculate exception vector offset = r5 << 2 */ |
334 | addk r6, r5, r5; /* << 1 */ | 334 | addk r6, r5, r5; /* << 1 */ |
335 | addk r6, r6, r6; /* << 2 */ | 335 | addk r6, r6, r6; /* << 2 */ |
336 | 336 | ||
337 | #ifdef DEBUG | ||
337 | /* counting which exception happen */ | 338 | /* counting which exception happen */ |
338 | lwi r5, r0, 0x200 + TOPHYS(r0_ram) | 339 | lwi r5, r0, 0x200 + TOPHYS(r0_ram) |
339 | addi r5, r5, 1 | 340 | addi r5, r5, 1 |
@@ -341,6 +342,7 @@ not_in_delay_slot: | |||
341 | lwi r5, r6, 0x200 + TOPHYS(r0_ram) | 342 | lwi r5, r6, 0x200 + TOPHYS(r0_ram) |
342 | addi r5, r5, 1 | 343 | addi r5, r5, 1 |
343 | swi r5, r6, 0x200 + TOPHYS(r0_ram) | 344 | swi r5, r6, 0x200 + TOPHYS(r0_ram) |
345 | #endif | ||
344 | /* end */ | 346 | /* end */ |
345 | /* Load the HW Exception vector */ | 347 | /* Load the HW Exception vector */ |
346 | lwi r6, r6, TOPHYS(_MB_HW_ExceptionVectorTable) | 348 | lwi r6, r6, TOPHYS(_MB_HW_ExceptionVectorTable) |
@@ -376,7 +378,7 @@ handle_other_ex: /* Handle Other exceptions here */ | |||
376 | swi r18, r1, PT_R18 | 378 | swi r18, r1, PT_R18 |
377 | 379 | ||
378 | or r5, r1, r0 | 380 | or r5, r1, r0 |
379 | andi r6, r3, 0x1F; /* Load ESR[EC] */ | 381 | andi r6, r4, 0x1F; /* Load ESR[EC] */ |
380 | lwi r7, r0, PER_CPU(KM) /* MS: saving current kernel mode to regs */ | 382 | lwi r7, r0, PER_CPU(KM) /* MS: saving current kernel mode to regs */ |
381 | swi r7, r1, PT_MODE | 383 | swi r7, r1, PT_MODE |
382 | mfs r7, rfsr | 384 | mfs r7, rfsr |
@@ -426,11 +428,11 @@ handle_other_ex: /* Handle Other exceptions here */ | |||
426 | */ | 428 | */ |
427 | handle_unaligned_ex: | 429 | handle_unaligned_ex: |
428 | /* Working registers already saved: R3, R4, R5, R6 | 430 | /* Working registers already saved: R3, R4, R5, R6 |
429 | * R3 = ESR | 431 | * R4 = ESR |
430 | * R4 = EAR | 432 | * R3 = EAR |
431 | */ | 433 | */ |
432 | #ifdef CONFIG_MMU | 434 | #ifdef CONFIG_MMU |
433 | andi r6, r3, 0x1000 /* Check ESR[DS] */ | 435 | andi r6, r4, 0x1000 /* Check ESR[DS] */ |
434 | beqi r6, _no_delayslot /* Branch if ESR[DS] not set */ | 436 | beqi r6, _no_delayslot /* Branch if ESR[DS] not set */ |
435 | mfs r17, rbtr; /* ESR[DS] set - return address in BTR */ | 437 | mfs r17, rbtr; /* ESR[DS] set - return address in BTR */ |
436 | nop | 438 | nop |
@@ -439,7 +441,7 @@ _no_delayslot: | |||
439 | RESTORE_STATE; | 441 | RESTORE_STATE; |
440 | bri unaligned_data_trap | 442 | bri unaligned_data_trap |
441 | #endif | 443 | #endif |
442 | andi r6, r3, 0x3E0; /* Mask and extract the register operand */ | 444 | andi r6, r4, 0x3E0; /* Mask and extract the register operand */ |
443 | srl r6, r6; /* r6 >> 5 */ | 445 | srl r6, r6; /* r6 >> 5 */ |
444 | srl r6, r6; | 446 | srl r6, r6; |
445 | srl r6, r6; | 447 | srl r6, r6; |
@@ -448,33 +450,33 @@ _no_delayslot: | |||
448 | /* Store the register operand in a temporary location */ | 450 | /* Store the register operand in a temporary location */ |
449 | sbi r6, r0, TOPHYS(ex_reg_op); | 451 | sbi r6, r0, TOPHYS(ex_reg_op); |
450 | 452 | ||
451 | andi r6, r3, 0x400; /* Extract ESR[S] */ | 453 | andi r6, r4, 0x400; /* Extract ESR[S] */ |
452 | bnei r6, ex_sw; | 454 | bnei r6, ex_sw; |
453 | ex_lw: | 455 | ex_lw: |
454 | andi r6, r3, 0x800; /* Extract ESR[W] */ | 456 | andi r6, r4, 0x800; /* Extract ESR[W] */ |
455 | beqi r6, ex_lhw; | 457 | beqi r6, ex_lhw; |
456 | lbui r5, r4, 0; /* Exception address in r4 */ | 458 | lbui r5, r3, 0; /* Exception address in r3 */ |
457 | /* Load a word, byte-by-byte from destination address | 459 | /* Load a word, byte-by-byte from destination address |
458 | and save it in tmp space */ | 460 | and save it in tmp space */ |
459 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_0); | 461 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_0); |
460 | lbui r5, r4, 1; | 462 | lbui r5, r3, 1; |
461 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_1); | 463 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_1); |
462 | lbui r5, r4, 2; | 464 | lbui r5, r3, 2; |
463 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_2); | 465 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_2); |
464 | lbui r5, r4, 3; | 466 | lbui r5, r3, 3; |
465 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_3); | 467 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_3); |
466 | /* Get the destination register value into r3 */ | 468 | /* Get the destination register value into r4 */ |
467 | lwi r3, r0, TOPHYS(ex_tmp_data_loc_0); | 469 | lwi r4, r0, TOPHYS(ex_tmp_data_loc_0); |
468 | bri ex_lw_tail; | 470 | bri ex_lw_tail; |
469 | ex_lhw: | 471 | ex_lhw: |
470 | lbui r5, r4, 0; /* Exception address in r4 */ | 472 | lbui r5, r3, 0; /* Exception address in r3 */ |
471 | /* Load a half-word, byte-by-byte from destination | 473 | /* Load a half-word, byte-by-byte from destination |
472 | address and save it in tmp space */ | 474 | address and save it in tmp space */ |
473 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_0); | 475 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_0); |
474 | lbui r5, r4, 1; | 476 | lbui r5, r3, 1; |
475 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_1); | 477 | sbi r5, r0, TOPHYS(ex_tmp_data_loc_1); |
476 | /* Get the destination register value into r3 */ | 478 | /* Get the destination register value into r4 */ |
477 | lhui r3, r0, TOPHYS(ex_tmp_data_loc_0); | 479 | lhui r4, r0, TOPHYS(ex_tmp_data_loc_0); |
478 | ex_lw_tail: | 480 | ex_lw_tail: |
479 | /* Get the destination register number into r5 */ | 481 | /* Get the destination register number into r5 */ |
480 | lbui r5, r0, TOPHYS(ex_reg_op); | 482 | lbui r5, r0, TOPHYS(ex_reg_op); |
@@ -502,25 +504,25 @@ ex_sw_tail: | |||
502 | andi r6, r6, 0x800; /* Extract ESR[W] */ | 504 | andi r6, r6, 0x800; /* Extract ESR[W] */ |
503 | beqi r6, ex_shw; | 505 | beqi r6, ex_shw; |
504 | /* Get the word - delay slot */ | 506 | /* Get the word - delay slot */ |
505 | swi r3, r0, TOPHYS(ex_tmp_data_loc_0); | 507 | swi r4, r0, TOPHYS(ex_tmp_data_loc_0); |
506 | /* Store the word, byte-by-byte into destination address */ | 508 | /* Store the word, byte-by-byte into destination address */ |
507 | lbui r3, r0, TOPHYS(ex_tmp_data_loc_0); | 509 | lbui r4, r0, TOPHYS(ex_tmp_data_loc_0); |
508 | sbi r3, r4, 0; | 510 | sbi r4, r3, 0; |
509 | lbui r3, r0, TOPHYS(ex_tmp_data_loc_1); | 511 | lbui r4, r0, TOPHYS(ex_tmp_data_loc_1); |
510 | sbi r3, r4, 1; | 512 | sbi r4, r3, 1; |
511 | lbui r3, r0, TOPHYS(ex_tmp_data_loc_2); | 513 | lbui r4, r0, TOPHYS(ex_tmp_data_loc_2); |
512 | sbi r3, r4, 2; | 514 | sbi r4, r3, 2; |
513 | lbui r3, r0, TOPHYS(ex_tmp_data_loc_3); | 515 | lbui r4, r0, TOPHYS(ex_tmp_data_loc_3); |
514 | sbi r3, r4, 3; | 516 | sbi r4, r3, 3; |
515 | bri ex_handler_done; | 517 | bri ex_handler_done; |
516 | 518 | ||
517 | ex_shw: | 519 | ex_shw: |
518 | /* Store the lower half-word, byte-by-byte into destination address */ | 520 | /* Store the lower half-word, byte-by-byte into destination address */ |
519 | swi r3, r0, TOPHYS(ex_tmp_data_loc_0); | 521 | swi r4, r0, TOPHYS(ex_tmp_data_loc_0); |
520 | lbui r3, r0, TOPHYS(ex_tmp_data_loc_2); | 522 | lbui r4, r0, TOPHYS(ex_tmp_data_loc_2); |
521 | sbi r3, r4, 0; | 523 | sbi r4, r3, 0; |
522 | lbui r3, r0, TOPHYS(ex_tmp_data_loc_3); | 524 | lbui r4, r0, TOPHYS(ex_tmp_data_loc_3); |
523 | sbi r3, r4, 1; | 525 | sbi r4, r3, 1; |
524 | ex_sw_end: /* Exception handling of store word, ends. */ | 526 | ex_sw_end: /* Exception handling of store word, ends. */ |
525 | 527 | ||
526 | ex_handler_done: | 528 | ex_handler_done: |
@@ -560,21 +562,16 @@ ex_handler_done: | |||
560 | */ | 562 | */ |
561 | mfs r11, rpid | 563 | mfs r11, rpid |
562 | nop | 564 | nop |
563 | bri 4 | ||
564 | mfs r3, rear /* Get faulting address */ | ||
565 | nop | ||
566 | /* If we are faulting a kernel address, we have to use the | 565 | /* If we are faulting a kernel address, we have to use the |
567 | * kernel page tables. | 566 | * kernel page tables. |
568 | */ | 567 | */ |
569 | ori r4, r0, CONFIG_KERNEL_START | 568 | ori r5, r0, CONFIG_KERNEL_START |
570 | cmpu r4, r3, r4 | 569 | cmpu r5, r3, r5 |
571 | bgti r4, ex3 | 570 | bgti r5, ex3 |
572 | /* First, check if it was a zone fault (which means a user | 571 | /* First, check if it was a zone fault (which means a user |
573 | * tried to access a kernel or read-protected page - always | 572 | * tried to access a kernel or read-protected page - always |
574 | * a SEGV). All other faults here must be stores, so no | 573 | * a SEGV). All other faults here must be stores, so no |
575 | * need to check ESR_S as well. */ | 574 | * need to check ESR_S as well. */ |
576 | mfs r4, resr | ||
577 | nop | ||
578 | andi r4, r4, 0x800 /* ESR_Z - zone protection */ | 575 | andi r4, r4, 0x800 /* ESR_Z - zone protection */ |
579 | bnei r4, ex2 | 576 | bnei r4, ex2 |
580 | 577 | ||
@@ -589,8 +586,6 @@ ex_handler_done: | |||
589 | * tried to access a kernel or read-protected page - always | 586 | * tried to access a kernel or read-protected page - always |
590 | * a SEGV). All other faults here must be stores, so no | 587 | * a SEGV). All other faults here must be stores, so no |
591 | * need to check ESR_S as well. */ | 588 | * need to check ESR_S as well. */ |
592 | mfs r4, resr | ||
593 | nop | ||
594 | andi r4, r4, 0x800 /* ESR_Z */ | 589 | andi r4, r4, 0x800 /* ESR_Z */ |
595 | bnei r4, ex2 | 590 | bnei r4, ex2 |
596 | /* get current task address */ | 591 | /* get current task address */ |
@@ -665,8 +660,6 @@ ex_handler_done: | |||
665 | * R3 = ESR | 660 | * R3 = ESR |
666 | */ | 661 | */ |
667 | 662 | ||
668 | mfs r3, rear /* Get faulting address */ | ||
669 | nop | ||
670 | RESTORE_STATE; | 663 | RESTORE_STATE; |
671 | bri page_fault_instr_trap | 664 | bri page_fault_instr_trap |
672 | 665 | ||
@@ -677,18 +670,15 @@ ex_handler_done: | |||
677 | */ | 670 | */ |
678 | handle_data_tlb_miss_exception: | 671 | handle_data_tlb_miss_exception: |
679 | /* Working registers already saved: R3, R4, R5, R6 | 672 | /* Working registers already saved: R3, R4, R5, R6 |
680 | * R3 = ESR | 673 | * R3 = EAR, R4 = ESR |
681 | */ | 674 | */ |
682 | mfs r11, rpid | 675 | mfs r11, rpid |
683 | nop | 676 | nop |
684 | bri 4 | ||
685 | mfs r3, rear /* Get faulting address */ | ||
686 | nop | ||
687 | 677 | ||
688 | /* If we are faulting a kernel address, we have to use the | 678 | /* If we are faulting a kernel address, we have to use the |
689 | * kernel page tables. */ | 679 | * kernel page tables. */ |
690 | ori r4, r0, CONFIG_KERNEL_START | 680 | ori r6, r0, CONFIG_KERNEL_START |
691 | cmpu r4, r3, r4 | 681 | cmpu r4, r3, r6 |
692 | bgti r4, ex5 | 682 | bgti r4, ex5 |
693 | ori r4, r0, swapper_pg_dir | 683 | ori r4, r0, swapper_pg_dir |
694 | mts rpid, r0 /* TLB will have 0 TID */ | 684 | mts rpid, r0 /* TLB will have 0 TID */ |
@@ -731,9 +721,8 @@ ex_handler_done: | |||
731 | * Many of these bits are software only. Bits we don't set | 721 | * Many of these bits are software only. Bits we don't set |
732 | * here we (properly should) assume have the appropriate value. | 722 | * here we (properly should) assume have the appropriate value. |
733 | */ | 723 | */ |
724 | brid finish_tlb_load | ||
734 | andni r4, r4, 0x0ce2 /* Make sure 20, 21 are zero */ | 725 | andni r4, r4, 0x0ce2 /* Make sure 20, 21 are zero */ |
735 | |||
736 | bri finish_tlb_load | ||
737 | ex7: | 726 | ex7: |
738 | /* The bailout. Restore registers to pre-exception conditions | 727 | /* The bailout. Restore registers to pre-exception conditions |
739 | * and call the heavyweights to help us out. | 728 | * and call the heavyweights to help us out. |
@@ -754,9 +743,6 @@ ex_handler_done: | |||
754 | */ | 743 | */ |
755 | mfs r11, rpid | 744 | mfs r11, rpid |
756 | nop | 745 | nop |
757 | bri 4 | ||
758 | mfs r3, rear /* Get faulting address */ | ||
759 | nop | ||
760 | 746 | ||
761 | /* If we are faulting a kernel address, we have to use the | 747 | /* If we are faulting a kernel address, we have to use the |
762 | * kernel page tables. | 748 | * kernel page tables. |
@@ -792,7 +778,7 @@ ex_handler_done: | |||
792 | lwi r4, r5, 0 /* Get Linux PTE */ | 778 | lwi r4, r5, 0 /* Get Linux PTE */ |
793 | 779 | ||
794 | andi r6, r4, _PAGE_PRESENT | 780 | andi r6, r4, _PAGE_PRESENT |
795 | beqi r6, ex7 | 781 | beqi r6, ex10 |
796 | 782 | ||
797 | ori r4, r4, _PAGE_ACCESSED | 783 | ori r4, r4, _PAGE_ACCESSED |
798 | swi r4, r5, 0 | 784 | swi r4, r5, 0 |
@@ -805,9 +791,8 @@ ex_handler_done: | |||
805 | * Many of these bits are software only. Bits we don't set | 791 | * Many of these bits are software only. Bits we don't set |
806 | * here we (properly should) assume have the appropriate value. | 792 | * here we (properly should) assume have the appropriate value. |
807 | */ | 793 | */ |
794 | brid finish_tlb_load | ||
808 | andni r4, r4, 0x0ce2 /* Make sure 20, 21 are zero */ | 795 | andni r4, r4, 0x0ce2 /* Make sure 20, 21 are zero */ |
809 | |||
810 | bri finish_tlb_load | ||
811 | ex10: | 796 | ex10: |
812 | /* The bailout. Restore registers to pre-exception conditions | 797 | /* The bailout. Restore registers to pre-exception conditions |
813 | * and call the heavyweights to help us out. | 798 | * and call the heavyweights to help us out. |
@@ -837,9 +822,9 @@ ex_handler_done: | |||
837 | andi r5, r5, (MICROBLAZE_TLB_SIZE-1) | 822 | andi r5, r5, (MICROBLAZE_TLB_SIZE-1) |
838 | ori r6, r0, 1 | 823 | ori r6, r0, 1 |
839 | cmp r31, r5, r6 | 824 | cmp r31, r5, r6 |
840 | blti r31, sem | 825 | blti r31, ex12 |
841 | addik r5, r6, 1 | 826 | addik r5, r6, 1 |
842 | sem: | 827 | ex12: |
843 | /* MS: save back current TLB index */ | 828 | /* MS: save back current TLB index */ |
844 | swi r5, r0, TOPHYS(tlb_index) | 829 | swi r5, r0, TOPHYS(tlb_index) |
845 | 830 | ||
@@ -859,7 +844,6 @@ ex_handler_done: | |||
859 | nop | 844 | nop |
860 | 845 | ||
861 | /* Done...restore registers and get out of here. */ | 846 | /* Done...restore registers and get out of here. */ |
862 | ex12: | ||
863 | mts rpid, r11 | 847 | mts rpid, r11 |
864 | nop | 848 | nop |
865 | bri 4 | 849 | bri 4 |