1 /* arch/sparc64/kernel/ktlb.S: Kernel mapping TLB miss handling.
3 * Copyright (C) 1995, 1997, 2005, 2008 David S. Miller <davem@davemloft.net>
4 * Copyright (C) 1996 Eddie C. Dost (ecd@brainaid.de)
5 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
6 * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
12 #include <asm/pgtable.h>
20 mov TLB_TAG_ACCESS, %g4
21 ldxa [%g4] ASI_IMMU, %g4
23 /* sun4v_itlb_miss branches here with the missing virtual
24 * address already loaded into %g4
28 /* Catch kernel NULL pointer calls. */
29 sethi %hi(PAGE_SIZE), %g5
31 blu,pn %xcc, kvmap_itlb_longpath
34 KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_itlb_load)
37 sethi %hi(LOW_OBP_ADDRESS), %g5
39 blu,pn %xcc, kvmap_itlb_vmalloc_addr
43 blu,pn %xcc, kvmap_itlb_obp
46 kvmap_itlb_vmalloc_addr:
47 KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_itlb_longpath)
49 TSB_LOCK_TAG(%g1, %g2, %g7)
50 TSB_WRITE(%g1, %g5, %g6)
52 /* fallthrough to TLB load */
56 661: stxa %g5, [%g0] ASI_ITLB_DATA_IN
58 .section .sun4v_2insn_patch, "ax"
64 /* For sun4v the ASI_ITLB_DATA_IN store and the retry
65 * instruction get nop'd out and we get here to branch
66 * to the sun4v tlb load code. The registers are setup
73 * The sun4v TLB load wants the PTE in %g3 so we fix that
76 ba,pt %xcc, sun4v_itlb_load
81 661: rdpr %pstate, %g5
82 wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
83 .section .sun4v_2insn_patch, "ax"
90 ba,pt %xcc, sparc64_realfault_common
91 mov FAULT_CODE_ITLB, %g4
94 OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_itlb_longpath)
96 TSB_LOCK_TAG(%g1, %g2, %g7)
98 TSB_WRITE(%g1, %g5, %g6)
100 ba,pt %xcc, kvmap_itlb_load
104 OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_dtlb_longpath)
106 TSB_LOCK_TAG(%g1, %g2, %g7)
108 TSB_WRITE(%g1, %g5, %g6)
110 ba,pt %xcc, kvmap_dtlb_load
114 sethi %hi(kern_linear_pte_xor), %g7
115 ldx [%g7 + %lo(kern_linear_pte_xor)], %g2
116 ba,pt %xcc, kvmap_dtlb_tsb4m_load
120 kvmap_dtlb_tsb4m_load:
121 TSB_LOCK_TAG(%g1, %g2, %g7)
122 TSB_WRITE(%g1, %g5, %g6)
123 ba,pt %xcc, kvmap_dtlb_load
127 /* %g6: TAG TARGET */
128 mov TLB_TAG_ACCESS, %g4
129 ldxa [%g4] ASI_DMMU, %g4
131 /* sun4v_dtlb_miss branches here with the missing virtual
132 * address already loaded into %g4
135 brgez,pn %g4, kvmap_dtlb_nonlinear
138 #ifdef CONFIG_DEBUG_PAGEALLOC
139 /* Index through the base page size TSB even for linear
140 * mappings when using page allocation debugging.
142 KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_dtlb_load)
144 /* Correct TAG_TARGET is already in %g6, check 4mb TSB. */
145 KERN_TSB4M_LOOKUP_TL1(%g6, %g5, %g1, %g2, %g3, kvmap_dtlb_load)
147 /* Linear mapping TSB lookup failed. Fallthrough to kernel
148 * page table based lookup.
150 .globl kvmap_linear_patch
152 ba,a,pt %xcc, kvmap_linear_early
154 kvmap_dtlb_vmalloc_addr:
155 KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath)
157 TSB_LOCK_TAG(%g1, %g2, %g7)
158 TSB_WRITE(%g1, %g5, %g6)
160 /* fallthrough to TLB load */
164 661: stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
166 .section .sun4v_2insn_patch, "ax"
172 /* For sun4v the ASI_DTLB_DATA_IN store and the retry
173 * instruction get nop'd out and we get here to branch
174 * to the sun4v tlb load code. The registers are setup
181 * The sun4v TLB load wants the PTE in %g3 so we fix that
184 ba,pt %xcc, sun4v_dtlb_load
187 #ifdef CONFIG_SPARSEMEM_VMEMMAP
189 KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath)
190 ba,a,pt %xcc, kvmap_dtlb_load
193 kvmap_dtlb_nonlinear:
194 /* Catch kernel NULL pointer derefs. */
195 sethi %hi(PAGE_SIZE), %g5
197 bleu,pn %xcc, kvmap_dtlb_longpath
200 #ifdef CONFIG_SPARSEMEM_VMEMMAP
201 /* Do not use the TSB for vmemmap. */
202 sethi %hi(VMEMMAP_BASE), %g5
203 ldx [%g5 + %lo(VMEMMAP_BASE)], %g5
205 bgeu,pn %xcc, kvmap_vmemmap
209 KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_dtlb_load)
212 sethi %hi(MODULES_VADDR), %g5
214 blu,pn %xcc, kvmap_dtlb_longpath
215 sethi %hi(VMALLOC_END), %g5
216 ldx [%g5 + %lo(VMALLOC_END)], %g5
218 bgeu,pn %xcc, kvmap_dtlb_longpath
222 sethi %hi(LOW_OBP_ADDRESS), %g5
224 blu,pn %xcc, kvmap_dtlb_vmalloc_addr
228 blu,pn %xcc, kvmap_dtlb_obp
230 ba,pt %xcc, kvmap_dtlb_vmalloc_addr
235 661: rdpr %pstate, %g5
236 wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
237 .section .sun4v_2insn_patch, "ax"
240 ldxa [%g0] ASI_SCRATCHPAD, %g5
246 661: mov TLB_TAG_ACCESS, %g4
247 ldxa [%g4] ASI_DMMU, %g5
248 .section .sun4v_2insn_patch, "ax"
250 ldx [%g5 + HV_FAULT_D_ADDR_OFFSET], %g5
254 be,pt %xcc, sparc64_realfault_common
255 mov FAULT_CODE_DTLB, %g4
256 ba,pt %xcc, winfix_trampoline