diff options
author | David Daney <ddaney@caviumnetworks.com> | 2010-12-27 21:07:57 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-01-18 13:30:23 -0500 |
commit | 2c8c53e28f178577dfdf3a69731b998b7e3df8ae (patch) | |
tree | 0b65ff7fa0ac67795698be7a50559d77d3bc72db /arch/mips/mm/tlbex.c | |
parent | bb3d68c30a00918d4c9fa02a5c17a5aacf597977 (diff) |
MIPS: Optimize TLB handlers for Octeon CPUs
Octeon can use scratch registers in the TLB handlers. Octeon II can
use LDX instructions.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/1904/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/mm/tlbex.c')
-rw-r--r-- | arch/mips/mm/tlbex.c | 361 |
1 files changed, 310 insertions, 51 deletions
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 883cf76fb2bd..083d3412d0bc 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c | |||
@@ -77,6 +77,40 @@ static int use_bbit_insns(void) | |||
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | static int use_lwx_insns(void) | ||
81 | { | ||
82 | switch (current_cpu_type()) { | ||
83 | case CPU_CAVIUM_OCTEON2: | ||
84 | return 1; | ||
85 | default: | ||
86 | return 0; | ||
87 | } | ||
88 | } | ||
89 | #if defined(CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE) && \ | ||
90 | CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0 | ||
91 | static bool scratchpad_available(void) | ||
92 | { | ||
93 | return true; | ||
94 | } | ||
95 | static int scratchpad_offset(int i) | ||
96 | { | ||
97 | /* | ||
98 | * CVMSEG starts at address -32768 and extends for | ||
99 | * CAVIUM_OCTEON_CVMSEG_SIZE 128 byte cache lines. | ||
100 | */ | ||
101 | i += 1; /* Kernel use starts at the top and works down. */ | ||
102 | return CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE * 128 - (8 * i) - 32768; | ||
103 | } | ||
104 | #else | ||
105 | static bool scratchpad_available(void) | ||
106 | { | ||
107 | return false; | ||
108 | } | ||
109 | static int scratchpad_offset(int i) | ||
110 | { | ||
111 | BUG(); | ||
112 | } | ||
113 | #endif | ||
80 | /* | 114 | /* |
81 | * Found by experiment: At least some revisions of the 4kc throw under | 115 | * Found by experiment: At least some revisions of the 4kc throw under |
82 | * some circumstances a machine check exception, triggered by invalid | 116 | * some circumstances a machine check exception, triggered by invalid |
@@ -187,7 +221,7 @@ static struct uasm_reloc relocs[128] __cpuinitdata; | |||
187 | static int check_for_high_segbits __cpuinitdata; | 221 | static int check_for_high_segbits __cpuinitdata; |
188 | #endif | 222 | #endif |
189 | 223 | ||
190 | #ifdef CONFIG_MIPS_PGD_C0_CONTEXT | 224 | static int check_for_high_segbits __cpuinitdata; |
191 | 225 | ||
192 | static unsigned int kscratch_used_mask __cpuinitdata; | 226 | static unsigned int kscratch_used_mask __cpuinitdata; |
193 | 227 | ||
@@ -208,9 +242,12 @@ static int __cpuinit allocate_kscratch(void) | |||
208 | return r; | 242 | return r; |
209 | } | 243 | } |
210 | 244 | ||
245 | static int scratch_reg __cpuinitdata; | ||
211 | static int pgd_reg __cpuinitdata; | 246 | static int pgd_reg __cpuinitdata; |
247 | enum vmalloc64_mode {not_refill, refill_scratch, refill_noscratch}; | ||
248 | |||
249 | #ifndef CONFIG_MIPS_PGD_C0_CONTEXT | ||
212 | 250 | ||
213 | #else /* !CONFIG_MIPS_PGD_C0_CONTEXT*/ | ||
214 | /* | 251 | /* |
215 | * CONFIG_MIPS_PGD_C0_CONTEXT implies 64 bit and lack of pgd_current, | 252 | * CONFIG_MIPS_PGD_C0_CONTEXT implies 64 bit and lack of pgd_current, |
216 | * we cannot do r3000 under these circumstances. | 253 | * we cannot do r3000 under these circumstances. |
@@ -481,21 +518,43 @@ static __cpuinit __maybe_unused void build_convert_pte_to_entrylo(u32 **p, | |||
481 | static __cpuinit void build_restore_pagemask(u32 **p, | 518 | static __cpuinit void build_restore_pagemask(u32 **p, |
482 | struct uasm_reloc **r, | 519 | struct uasm_reloc **r, |
483 | unsigned int tmp, | 520 | unsigned int tmp, |
484 | enum label_id lid) | 521 | enum label_id lid, |
522 | int restore_scratch) | ||
485 | { | 523 | { |
486 | /* Reset default page size */ | 524 | if (restore_scratch) { |
487 | if (PM_DEFAULT_MASK >> 16) { | 525 | /* Reset default page size */ |
488 | uasm_i_lui(p, tmp, PM_DEFAULT_MASK >> 16); | 526 | if (PM_DEFAULT_MASK >> 16) { |
489 | uasm_i_ori(p, tmp, tmp, PM_DEFAULT_MASK & 0xffff); | 527 | uasm_i_lui(p, tmp, PM_DEFAULT_MASK >> 16); |
490 | uasm_il_b(p, r, lid); | 528 | uasm_i_ori(p, tmp, tmp, PM_DEFAULT_MASK & 0xffff); |
491 | uasm_i_mtc0(p, tmp, C0_PAGEMASK); | 529 | uasm_i_mtc0(p, tmp, C0_PAGEMASK); |
492 | } else if (PM_DEFAULT_MASK) { | 530 | uasm_il_b(p, r, lid); |
493 | uasm_i_ori(p, tmp, 0, PM_DEFAULT_MASK); | 531 | } else if (PM_DEFAULT_MASK) { |
494 | uasm_il_b(p, r, lid); | 532 | uasm_i_ori(p, tmp, 0, PM_DEFAULT_MASK); |
495 | uasm_i_mtc0(p, tmp, C0_PAGEMASK); | 533 | uasm_i_mtc0(p, tmp, C0_PAGEMASK); |
534 | uasm_il_b(p, r, lid); | ||
535 | } else { | ||
536 | uasm_i_mtc0(p, 0, C0_PAGEMASK); | ||
537 | uasm_il_b(p, r, lid); | ||
538 | } | ||
539 | if (scratch_reg > 0) | ||
540 | UASM_i_MFC0(p, 1, 31, scratch_reg); | ||
541 | else | ||
542 | UASM_i_LW(p, 1, scratchpad_offset(0), 0); | ||
496 | } else { | 543 | } else { |
497 | uasm_il_b(p, r, lid); | 544 | /* Reset default page size */ |
498 | uasm_i_mtc0(p, 0, C0_PAGEMASK); | 545 | if (PM_DEFAULT_MASK >> 16) { |
546 | uasm_i_lui(p, tmp, PM_DEFAULT_MASK >> 16); | ||
547 | uasm_i_ori(p, tmp, tmp, PM_DEFAULT_MASK & 0xffff); | ||
548 | uasm_il_b(p, r, lid); | ||
549 | uasm_i_mtc0(p, tmp, C0_PAGEMASK); | ||
550 | } else if (PM_DEFAULT_MASK) { | ||
551 | uasm_i_ori(p, tmp, 0, PM_DEFAULT_MASK); | ||
552 | uasm_il_b(p, r, lid); | ||
553 | uasm_i_mtc0(p, tmp, C0_PAGEMASK); | ||
554 | } else { | ||
555 | uasm_il_b(p, r, lid); | ||
556 | uasm_i_mtc0(p, 0, C0_PAGEMASK); | ||
557 | } | ||
499 | } | 558 | } |
500 | } | 559 | } |
501 | 560 | ||
@@ -503,7 +562,8 @@ static __cpuinit void build_huge_tlb_write_entry(u32 **p, | |||
503 | struct uasm_label **l, | 562 | struct uasm_label **l, |
504 | struct uasm_reloc **r, | 563 | struct uasm_reloc **r, |
505 | unsigned int tmp, | 564 | unsigned int tmp, |
506 | enum tlb_write_entry wmode) | 565 | enum tlb_write_entry wmode, |
566 | int restore_scratch) | ||
507 | { | 567 | { |
508 | /* Set huge page tlb entry size */ | 568 | /* Set huge page tlb entry size */ |
509 | uasm_i_lui(p, tmp, PM_HUGE_MASK >> 16); | 569 | uasm_i_lui(p, tmp, PM_HUGE_MASK >> 16); |
@@ -512,7 +572,7 @@ static __cpuinit void build_huge_tlb_write_entry(u32 **p, | |||
512 | 572 | ||
513 | build_tlb_write_entry(p, l, r, wmode); | 573 | build_tlb_write_entry(p, l, r, wmode); |
514 | 574 | ||
515 | build_restore_pagemask(p, r, tmp, label_leave); | 575 | build_restore_pagemask(p, r, tmp, label_leave, restore_scratch); |
516 | } | 576 | } |
517 | 577 | ||
518 | /* | 578 | /* |
@@ -577,7 +637,7 @@ static __cpuinit void build_huge_handler_tail(u32 **p, | |||
577 | UASM_i_SW(p, pte, 0, ptr); | 637 | UASM_i_SW(p, pte, 0, ptr); |
578 | #endif | 638 | #endif |
579 | build_huge_update_entries(p, pte, ptr); | 639 | build_huge_update_entries(p, pte, ptr); |
580 | build_huge_tlb_write_entry(p, l, r, pte, tlb_indexed); | 640 | build_huge_tlb_write_entry(p, l, r, pte, tlb_indexed, 0); |
581 | } | 641 | } |
582 | #endif /* CONFIG_HUGETLB_PAGE */ | 642 | #endif /* CONFIG_HUGETLB_PAGE */ |
583 | 643 | ||
@@ -674,7 +734,6 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, | |||
674 | #endif | 734 | #endif |
675 | } | 735 | } |
676 | 736 | ||
677 | enum vmalloc64_mode {not_refill, refill}; | ||
678 | /* | 737 | /* |
679 | * BVADDR is the faulting address, PTR is scratch. | 738 | * BVADDR is the faulting address, PTR is scratch. |
680 | * PTR will hold the pgd for vmalloc. | 739 | * PTR will hold the pgd for vmalloc. |
@@ -692,7 +751,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, | |||
692 | 751 | ||
693 | uasm_l_vmalloc(l, *p); | 752 | uasm_l_vmalloc(l, *p); |
694 | 753 | ||
695 | if (mode == refill && check_for_high_segbits) { | 754 | if (mode != not_refill && check_for_high_segbits) { |
696 | if (single_insn_swpd) { | 755 | if (single_insn_swpd) { |
697 | uasm_il_bltz(p, r, bvaddr, label_vmalloc_done); | 756 | uasm_il_bltz(p, r, bvaddr, label_vmalloc_done); |
698 | uasm_i_lui(p, ptr, uasm_rel_hi(swpd)); | 757 | uasm_i_lui(p, ptr, uasm_rel_hi(swpd)); |
@@ -715,7 +774,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, | |||
715 | uasm_i_daddiu(p, ptr, ptr, uasm_rel_lo(swpd)); | 774 | uasm_i_daddiu(p, ptr, ptr, uasm_rel_lo(swpd)); |
716 | } | 775 | } |
717 | } | 776 | } |
718 | if (mode == refill && check_for_high_segbits) { | 777 | if (mode != not_refill && check_for_high_segbits) { |
719 | uasm_l_large_segbits_fault(l, *p); | 778 | uasm_l_large_segbits_fault(l, *p); |
720 | /* | 779 | /* |
721 | * We get here if we are an xsseg address, or if we are | 780 | * We get here if we are an xsseg address, or if we are |
@@ -731,7 +790,15 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, | |||
731 | */ | 790 | */ |
732 | UASM_i_LA(p, ptr, (unsigned long)tlb_do_page_fault_0); | 791 | UASM_i_LA(p, ptr, (unsigned long)tlb_do_page_fault_0); |
733 | uasm_i_jr(p, ptr); | 792 | uasm_i_jr(p, ptr); |
734 | uasm_i_nop(p); | 793 | |
794 | if (mode == refill_scratch) { | ||
795 | if (scratch_reg > 0) | ||
796 | UASM_i_MFC0(p, 1, 31, scratch_reg); | ||
797 | else | ||
798 | UASM_i_LW(p, 1, scratchpad_offset(0), 0); | ||
799 | } else { | ||
800 | uasm_i_nop(p); | ||
801 | } | ||
735 | } | 802 | } |
736 | } | 803 | } |
737 | 804 | ||
@@ -888,6 +955,185 @@ static void __cpuinit build_update_entries(u32 **p, unsigned int tmp, | |||
888 | #endif | 955 | #endif |
889 | } | 956 | } |
890 | 957 | ||
958 | struct mips_huge_tlb_info { | ||
959 | int huge_pte; | ||
960 | int restore_scratch; | ||
961 | }; | ||
962 | |||
963 | static struct mips_huge_tlb_info __cpuinit | ||
964 | build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, | ||
965 | struct uasm_reloc **r, unsigned int tmp, | ||
966 | unsigned int ptr, int c0_scratch) | ||
967 | { | ||
968 | struct mips_huge_tlb_info rv; | ||
969 | unsigned int even, odd; | ||
970 | int vmalloc_branch_delay_filled = 0; | ||
971 | const int scratch = 1; /* Our extra working register */ | ||
972 | |||
973 | rv.huge_pte = scratch; | ||
974 | rv.restore_scratch = 0; | ||
975 | |||
976 | if (check_for_high_segbits) { | ||
977 | UASM_i_MFC0(p, tmp, C0_BADVADDR); | ||
978 | |||
979 | if (pgd_reg != -1) | ||
980 | UASM_i_MFC0(p, ptr, 31, pgd_reg); | ||
981 | else | ||
982 | UASM_i_MFC0(p, ptr, C0_CONTEXT); | ||
983 | |||
984 | if (c0_scratch >= 0) | ||
985 | UASM_i_MTC0(p, scratch, 31, c0_scratch); | ||
986 | else | ||
987 | UASM_i_SW(p, scratch, scratchpad_offset(0), 0); | ||
988 | |||
989 | uasm_i_dsrl_safe(p, scratch, tmp, | ||
990 | PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3); | ||
991 | uasm_il_bnez(p, r, scratch, label_vmalloc); | ||
992 | |||
993 | if (pgd_reg == -1) { | ||
994 | vmalloc_branch_delay_filled = 1; | ||
995 | /* Clear lower 23 bits of context. */ | ||
996 | uasm_i_dins(p, ptr, 0, 0, 23); | ||
997 | } | ||
998 | } else { | ||
999 | if (pgd_reg != -1) | ||
1000 | UASM_i_MFC0(p, ptr, 31, pgd_reg); | ||
1001 | else | ||
1002 | UASM_i_MFC0(p, ptr, C0_CONTEXT); | ||
1003 | |||
1004 | UASM_i_MFC0(p, tmp, C0_BADVADDR); | ||
1005 | |||
1006 | if (c0_scratch >= 0) | ||
1007 | UASM_i_MTC0(p, scratch, 31, c0_scratch); | ||
1008 | else | ||
1009 | UASM_i_SW(p, scratch, scratchpad_offset(0), 0); | ||
1010 | |||
1011 | if (pgd_reg == -1) | ||
1012 | /* Clear lower 23 bits of context. */ | ||
1013 | uasm_i_dins(p, ptr, 0, 0, 23); | ||
1014 | |||
1015 | uasm_il_bltz(p, r, tmp, label_vmalloc); | ||
1016 | } | ||
1017 | |||
1018 | if (pgd_reg == -1) { | ||
1019 | vmalloc_branch_delay_filled = 1; | ||
1020 | /* 1 0 1 0 1 << 6 xkphys cached */ | ||
1021 | uasm_i_ori(p, ptr, ptr, 0x540); | ||
1022 | uasm_i_drotr(p, ptr, ptr, 11); | ||
1023 | } | ||
1024 | |||
1025 | #ifdef __PAGETABLE_PMD_FOLDED | ||
1026 | #define LOC_PTEP scratch | ||
1027 | #else | ||
1028 | #define LOC_PTEP ptr | ||
1029 | #endif | ||
1030 | |||
1031 | if (!vmalloc_branch_delay_filled) | ||
1032 | /* get pgd offset in bytes */ | ||
1033 | uasm_i_dsrl_safe(p, scratch, tmp, PGDIR_SHIFT - 3); | ||
1034 | |||
1035 | uasm_l_vmalloc_done(l, *p); | ||
1036 | |||
1037 | /* | ||
1038 | * tmp ptr | ||
1039 | * fall-through case = badvaddr *pgd_current | ||
1040 | * vmalloc case = badvaddr swapper_pg_dir | ||
1041 | */ | ||
1042 | |||
1043 | if (vmalloc_branch_delay_filled) | ||
1044 | /* get pgd offset in bytes */ | ||
1045 | uasm_i_dsrl_safe(p, scratch, tmp, PGDIR_SHIFT - 3); | ||
1046 | |||
1047 | #ifdef __PAGETABLE_PMD_FOLDED | ||
1048 | GET_CONTEXT(p, tmp); /* get context reg */ | ||
1049 | #endif | ||
1050 | uasm_i_andi(p, scratch, scratch, (PTRS_PER_PGD - 1) << 3); | ||
1051 | |||
1052 | if (use_lwx_insns()) { | ||
1053 | UASM_i_LWX(p, LOC_PTEP, scratch, ptr); | ||
1054 | } else { | ||
1055 | uasm_i_daddu(p, ptr, ptr, scratch); /* add in pgd offset */ | ||
1056 | uasm_i_ld(p, LOC_PTEP, 0, ptr); /* get pmd pointer */ | ||
1057 | } | ||
1058 | |||
1059 | #ifndef __PAGETABLE_PMD_FOLDED | ||
1060 | /* get pmd offset in bytes */ | ||
1061 | uasm_i_dsrl_safe(p, scratch, tmp, PMD_SHIFT - 3); | ||
1062 | uasm_i_andi(p, scratch, scratch, (PTRS_PER_PMD - 1) << 3); | ||
1063 | GET_CONTEXT(p, tmp); /* get context reg */ | ||
1064 | |||
1065 | if (use_lwx_insns()) { | ||
1066 | UASM_i_LWX(p, scratch, scratch, ptr); | ||
1067 | } else { | ||
1068 | uasm_i_daddu(p, ptr, ptr, scratch); /* add in pmd offset */ | ||
1069 | UASM_i_LW(p, scratch, 0, ptr); | ||
1070 | } | ||
1071 | #endif | ||
1072 | /* Adjust the context during the load latency. */ | ||
1073 | build_adjust_context(p, tmp); | ||
1074 | |||
1075 | #ifdef CONFIG_HUGETLB_PAGE | ||
1076 | uasm_il_bbit1(p, r, scratch, ilog2(_PAGE_HUGE), label_tlb_huge_update); | ||
1077 | /* | ||
1078 | * The in the LWX case we don't want to do the load in the | ||
1079 | * delay slot. It cannot issue in the same cycle and may be | ||
1080 | * speculative and unneeded. | ||
1081 | */ | ||
1082 | if (use_lwx_insns()) | ||
1083 | uasm_i_nop(p); | ||
1084 | #endif /* CONFIG_HUGETLB_PAGE */ | ||
1085 | |||
1086 | |||
1087 | /* build_update_entries */ | ||
1088 | if (use_lwx_insns()) { | ||
1089 | even = ptr; | ||
1090 | odd = tmp; | ||
1091 | UASM_i_LWX(p, even, scratch, tmp); | ||
1092 | UASM_i_ADDIU(p, tmp, tmp, sizeof(pte_t)); | ||
1093 | UASM_i_LWX(p, odd, scratch, tmp); | ||
1094 | } else { | ||
1095 | UASM_i_ADDU(p, ptr, scratch, tmp); /* add in offset */ | ||
1096 | even = tmp; | ||
1097 | odd = ptr; | ||
1098 | UASM_i_LW(p, even, 0, ptr); /* get even pte */ | ||
1099 | UASM_i_LW(p, odd, sizeof(pte_t), ptr); /* get odd pte */ | ||
1100 | } | ||
1101 | if (kernel_uses_smartmips_rixi) { | ||
1102 | uasm_i_dsrl_safe(p, even, even, ilog2(_PAGE_NO_EXEC)); | ||
1103 | uasm_i_dsrl_safe(p, odd, odd, ilog2(_PAGE_NO_EXEC)); | ||
1104 | uasm_i_drotr(p, even, even, | ||
1105 | ilog2(_PAGE_GLOBAL) - ilog2(_PAGE_NO_EXEC)); | ||
1106 | UASM_i_MTC0(p, even, C0_ENTRYLO0); /* load it */ | ||
1107 | uasm_i_drotr(p, odd, odd, | ||
1108 | ilog2(_PAGE_GLOBAL) - ilog2(_PAGE_NO_EXEC)); | ||
1109 | } else { | ||
1110 | uasm_i_dsrl_safe(p, even, even, ilog2(_PAGE_GLOBAL)); | ||
1111 | UASM_i_MTC0(p, even, C0_ENTRYLO0); /* load it */ | ||
1112 | uasm_i_dsrl_safe(p, odd, odd, ilog2(_PAGE_GLOBAL)); | ||
1113 | } | ||
1114 | UASM_i_MTC0(p, odd, C0_ENTRYLO1); /* load it */ | ||
1115 | |||
1116 | if (c0_scratch >= 0) { | ||
1117 | UASM_i_MFC0(p, scratch, 31, c0_scratch); | ||
1118 | build_tlb_write_entry(p, l, r, tlb_random); | ||
1119 | uasm_l_leave(l, *p); | ||
1120 | rv.restore_scratch = 1; | ||
1121 | } else if (PAGE_SHIFT == 14 || PAGE_SHIFT == 13) { | ||
1122 | build_tlb_write_entry(p, l, r, tlb_random); | ||
1123 | uasm_l_leave(l, *p); | ||
1124 | UASM_i_LW(p, scratch, scratchpad_offset(0), 0); | ||
1125 | } else { | ||
1126 | UASM_i_LW(p, scratch, scratchpad_offset(0), 0); | ||
1127 | build_tlb_write_entry(p, l, r, tlb_random); | ||
1128 | uasm_l_leave(l, *p); | ||
1129 | rv.restore_scratch = 1; | ||
1130 | } | ||
1131 | |||
1132 | uasm_i_eret(p); /* return from trap */ | ||
1133 | |||
1134 | return rv; | ||
1135 | } | ||
1136 | |||
891 | /* | 1137 | /* |
892 | * For a 64-bit kernel, we are using the 64-bit XTLB refill exception | 1138 | * For a 64-bit kernel, we are using the 64-bit XTLB refill exception |
893 | * because EXL == 0. If we wrap, we can also use the 32 instruction | 1139 | * because EXL == 0. If we wrap, we can also use the 32 instruction |
@@ -903,54 +1149,67 @@ static void __cpuinit build_r4000_tlb_refill_handler(void) | |||
903 | struct uasm_reloc *r = relocs; | 1149 | struct uasm_reloc *r = relocs; |
904 | u32 *f; | 1150 | u32 *f; |
905 | unsigned int final_len; | 1151 | unsigned int final_len; |
1152 | struct mips_huge_tlb_info htlb_info; | ||
1153 | enum vmalloc64_mode vmalloc_mode; | ||
906 | 1154 | ||
907 | memset(tlb_handler, 0, sizeof(tlb_handler)); | 1155 | memset(tlb_handler, 0, sizeof(tlb_handler)); |
908 | memset(labels, 0, sizeof(labels)); | 1156 | memset(labels, 0, sizeof(labels)); |
909 | memset(relocs, 0, sizeof(relocs)); | 1157 | memset(relocs, 0, sizeof(relocs)); |
910 | memset(final_handler, 0, sizeof(final_handler)); | 1158 | memset(final_handler, 0, sizeof(final_handler)); |
911 | 1159 | ||
912 | /* | 1160 | if (scratch_reg == 0) |
913 | * create the plain linear handler | 1161 | scratch_reg = allocate_kscratch(); |
914 | */ | ||
915 | if (bcm1250_m3_war()) { | ||
916 | unsigned int segbits = 44; | ||
917 | 1162 | ||
918 | uasm_i_dmfc0(&p, K0, C0_BADVADDR); | 1163 | if ((scratch_reg > 0 || scratchpad_available()) && use_bbit_insns()) { |
919 | uasm_i_dmfc0(&p, K1, C0_ENTRYHI); | 1164 | htlb_info = build_fast_tlb_refill_handler(&p, &l, &r, K0, K1, |
920 | uasm_i_xor(&p, K0, K0, K1); | 1165 | scratch_reg); |
921 | uasm_i_dsrl_safe(&p, K1, K0, 62); | 1166 | vmalloc_mode = refill_scratch; |
922 | uasm_i_dsrl_safe(&p, K0, K0, 12 + 1); | 1167 | } else { |
923 | uasm_i_dsll_safe(&p, K0, K0, 64 + 12 + 1 - segbits); | 1168 | htlb_info.huge_pte = K0; |
924 | uasm_i_or(&p, K0, K0, K1); | 1169 | htlb_info.restore_scratch = 0; |
925 | uasm_il_bnez(&p, &r, K0, label_leave); | 1170 | vmalloc_mode = refill_noscratch; |
926 | /* No need for uasm_i_nop */ | 1171 | /* |
927 | } | 1172 | * create the plain linear handler |
1173 | */ | ||
1174 | if (bcm1250_m3_war()) { | ||
1175 | unsigned int segbits = 44; | ||
1176 | |||
1177 | uasm_i_dmfc0(&p, K0, C0_BADVADDR); | ||
1178 | uasm_i_dmfc0(&p, K1, C0_ENTRYHI); | ||
1179 | uasm_i_xor(&p, K0, K0, K1); | ||
1180 | uasm_i_dsrl_safe(&p, K1, K0, 62); | ||
1181 | uasm_i_dsrl_safe(&p, K0, K0, 12 + 1); | ||
1182 | uasm_i_dsll_safe(&p, K0, K0, 64 + 12 + 1 - segbits); | ||
1183 | uasm_i_or(&p, K0, K0, K1); | ||
1184 | uasm_il_bnez(&p, &r, K0, label_leave); | ||
1185 | /* No need for uasm_i_nop */ | ||
1186 | } | ||
928 | 1187 | ||
929 | #ifdef CONFIG_64BIT | 1188 | #ifdef CONFIG_64BIT |
930 | build_get_pmde64(&p, &l, &r, K0, K1); /* get pmd in K1 */ | 1189 | build_get_pmde64(&p, &l, &r, K0, K1); /* get pmd in K1 */ |
931 | #else | 1190 | #else |
932 | build_get_pgde32(&p, K0, K1); /* get pgd in K1 */ | 1191 | build_get_pgde32(&p, K0, K1); /* get pgd in K1 */ |
933 | #endif | 1192 | #endif |
934 | 1193 | ||
935 | #ifdef CONFIG_HUGETLB_PAGE | 1194 | #ifdef CONFIG_HUGETLB_PAGE |
936 | build_is_huge_pte(&p, &r, K0, K1, label_tlb_huge_update); | 1195 | build_is_huge_pte(&p, &r, K0, K1, label_tlb_huge_update); |
937 | #endif | 1196 | #endif |
938 | 1197 | ||
939 | build_get_ptep(&p, K0, K1); | 1198 | build_get_ptep(&p, K0, K1); |
940 | build_update_entries(&p, K0, K1); | 1199 | build_update_entries(&p, K0, K1); |
941 | build_tlb_write_entry(&p, &l, &r, tlb_random); | 1200 | build_tlb_write_entry(&p, &l, &r, tlb_random); |
942 | uasm_l_leave(&l, p); | 1201 | uasm_l_leave(&l, p); |
943 | uasm_i_eret(&p); /* return from trap */ | 1202 | uasm_i_eret(&p); /* return from trap */ |
944 | 1203 | } | |
945 | #ifdef CONFIG_HUGETLB_PAGE | 1204 | #ifdef CONFIG_HUGETLB_PAGE |
946 | uasm_l_tlb_huge_update(&l, p); | 1205 | uasm_l_tlb_huge_update(&l, p); |
947 | UASM_i_LW(&p, K0, 0, K1); | 1206 | build_huge_update_entries(&p, htlb_info.huge_pte, K1); |
948 | build_huge_update_entries(&p, K0, K1); | 1207 | build_huge_tlb_write_entry(&p, &l, &r, K0, tlb_random, |
949 | build_huge_tlb_write_entry(&p, &l, &r, K0, tlb_random); | 1208 | htlb_info.restore_scratch); |
950 | #endif | 1209 | #endif |
951 | 1210 | ||
952 | #ifdef CONFIG_64BIT | 1211 | #ifdef CONFIG_64BIT |
953 | build_get_pgd_vmalloc64(&p, &l, &r, K0, K1, refill); | 1212 | build_get_pgd_vmalloc64(&p, &l, &r, K0, K1, vmalloc_mode); |
954 | #endif | 1213 | #endif |
955 | 1214 | ||
956 | /* | 1215 | /* |
@@ -1616,7 +1875,7 @@ static void __cpuinit build_r4000_tlb_load_handler(void) | |||
1616 | * We clobbered C0_PAGEMASK, restore it. On the other branch | 1875 | * We clobbered C0_PAGEMASK, restore it. On the other branch |
1617 | * it is restored in build_huge_tlb_write_entry. | 1876 | * it is restored in build_huge_tlb_write_entry. |
1618 | */ | 1877 | */ |
1619 | build_restore_pagemask(&p, &r, K0, label_nopage_tlbl); | 1878 | build_restore_pagemask(&p, &r, K0, label_nopage_tlbl, 0); |
1620 | 1879 | ||
1621 | uasm_l_tlbl_goaround2(&l, p); | 1880 | uasm_l_tlbl_goaround2(&l, p); |
1622 | } | 1881 | } |