1 /* arch/sparc64/kernel/ktlb.S: Kernel mapping TLB miss handling.
3 * Copyright (C) 1995, 1997, 2005 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)
9 #include <linux/config.h>
13 #include <asm/pgtable.h>
22 mov TLB_TAG_ACCESS, %g4
23 ldxa [%g4] ASI_IMMU, %g4
26 /* Catch kernel NULL pointer calls. */
27 sethi %hi(PAGE_SIZE), %g5
29 bleu,pn %xcc, kvmap_dtlb_longpath
32 KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_itlb_load)
35 sethi %hi(LOW_OBP_ADDRESS), %g5
37 blu,pn %xcc, kvmap_itlb_vmalloc_addr
41 blu,pn %xcc, kvmap_itlb_obp
44 kvmap_itlb_vmalloc_addr:
45 KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_itlb_longpath)
47 KTSB_LOCK_TAG(%g1, %g2, %g4)
49 /* Load and check PTE. */
50 ldxa [%g5] ASI_PHYS_USE_EC, %g5
51 brgez,a,pn %g5, kvmap_itlb_longpath
54 KTSB_WRITE(%g1, %g5, %g6)
56 /* fallthrough to TLB load */
59 stxa %g5, [%g0] ASI_ITLB_DATA_IN ! Reload TLB
64 wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
66 ba,pt %xcc, sparc64_realfault_common
67 mov FAULT_CODE_ITLB, %g4
70 OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_itlb_longpath)
72 KTSB_LOCK_TAG(%g1, %g2, %g4)
74 KTSB_WRITE(%g1, %g5, %g6)
76 ba,pt %xcc, kvmap_itlb_load
80 OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_dtlb_longpath)
82 KTSB_LOCK_TAG(%g1, %g2, %g4)
84 KTSB_WRITE(%g1, %g5, %g6)
86 ba,pt %xcc, kvmap_dtlb_load
93 mov TLB_TAG_ACCESS, %g4
94 ldxa [%g4] ASI_DMMU, %g4
95 brgez,pn %g4, kvmap_dtlb_nonlinear
98 #define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)
99 #define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
101 sethi %uhi(KERN_HIGHBITS), %g2
102 or %g2, %ulo(KERN_HIGHBITS), %g2
104 or %g2, KERN_LOWBITS, %g2
109 .globl kvmap_linear_patch
111 ba,pt %xcc, kvmap_dtlb_load
114 kvmap_dtlb_vmalloc_addr:
115 KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath)
117 KTSB_LOCK_TAG(%g1, %g2, %g4)
119 /* Load and check PTE. */
120 ldxa [%g5] ASI_PHYS_USE_EC, %g5
121 brgez,a,pn %g5, kvmap_dtlb_longpath
124 KTSB_WRITE(%g1, %g5, %g6)
126 /* fallthrough to TLB load */
129 stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
132 kvmap_dtlb_nonlinear:
133 /* Catch kernel NULL pointer derefs. */
134 sethi %hi(PAGE_SIZE), %g5
136 bleu,pn %xcc, kvmap_dtlb_longpath
139 KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_dtlb_load)
142 sethi %hi(MODULES_VADDR), %g5
144 blu,pn %xcc, kvmap_dtlb_longpath
145 mov (VMALLOC_END >> 24), %g5
148 bgeu,pn %xcc, kvmap_dtlb_longpath
152 sethi %hi(LOW_OBP_ADDRESS), %g5
154 blu,pn %xcc, kvmap_dtlb_vmalloc_addr
158 blu,pn %xcc, kvmap_dtlb_obp
160 ba,pt %xcc, kvmap_dtlb_vmalloc_addr
165 wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
168 mov TLB_TAG_ACCESS, %g4
169 ldxa [%g4] ASI_DMMU, %g5
170 be,pt %xcc, sparc64_realfault_common
171 mov FAULT_CODE_DTLB, %g4
172 ba,pt %xcc, winfix_trampoline