]>
Commit | Line | Data |
---|---|---|
0ebc4cda BH |
1 | /* |
2 | * This file contains the 64-bit "server" PowerPC variant | |
3 | * of the low level exception handling including exception | |
4 | * vectors, exception return, part of the slb and stab | |
5 | * handling and other fixed offset specific things. | |
6 | * | |
7 | * This file is meant to be #included from head_64.S due to | |
25985edc | 8 | * position dependent assembly. |
0ebc4cda BH |
9 | * |
10 | * Most of this originates from head_64.S and thus has the same | |
11 | * copyright history. | |
12 | * | |
13 | */ | |
14 | ||
7230c564 | 15 | #include <asm/hw_irq.h> |
8aa34ab8 | 16 | #include <asm/exception-64s.h> |
46f52210 | 17 | #include <asm/ptrace.h> |
8aa34ab8 | 18 | |
0ebc4cda BH |
19 | /* |
20 | * We layout physical memory as follows: | |
21 | * 0x0000 - 0x00ff : Secondary processor spin code | |
c1fb6816 MN |
22 | * 0x0100 - 0x17ff : pSeries Interrupt prologs |
23 | * 0x1800 - 0x4000 : interrupt support common interrupt prologs | |
24 | * 0x4000 - 0x5fff : pSeries interrupts with IR=1,DR=1 | |
25 | * 0x6000 - 0x6fff : more interrupt support including for IR=1,DR=1 | |
0ebc4cda | 26 | * 0x7000 - 0x7fff : FWNMI data area |
c1fb6816 MN |
27 | * 0x8000 - 0x8fff : Initial (CPU0) segment table |
28 | * 0x9000 - : Early init and support code | |
0ebc4cda | 29 | */ |
742415d6 MN |
30 | /* Syscall routine is used twice, in reloc-off and reloc-on paths */ |
31 | #define SYSCALL_PSERIES_1 \ | |
32 | BEGIN_FTR_SECTION \ | |
33 | cmpdi r0,0x1ebe ; \ | |
34 | beq- 1f ; \ | |
35 | END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \ | |
36 | mr r9,r13 ; \ | |
37 | GET_PACA(r13) ; \ | |
38 | mfspr r11,SPRN_SRR0 ; \ | |
39 | 0: | |
40 | ||
41 | #define SYSCALL_PSERIES_2_RFID \ | |
42 | mfspr r12,SPRN_SRR1 ; \ | |
43 | ld r10,PACAKBASE(r13) ; \ | |
44 | LOAD_HANDLER(r10, system_call_entry) ; \ | |
45 | mtspr SPRN_SRR0,r10 ; \ | |
46 | ld r10,PACAKMSR(r13) ; \ | |
47 | mtspr SPRN_SRR1,r10 ; \ | |
48 | rfid ; \ | |
49 | b . ; /* prevent speculative execution */ | |
50 | ||
51 | #define SYSCALL_PSERIES_3 \ | |
52 | /* Fast LE/BE switch system call */ \ | |
53 | 1: mfspr r12,SPRN_SRR1 ; \ | |
54 | xori r12,r12,MSR_LE ; \ | |
55 | mtspr SPRN_SRR1,r12 ; \ | |
56 | rfid ; /* return to userspace */ \ | |
742415d6 MN |
57 | b . ; /* prevent speculative execution */ |
58 | ||
4700dfaf MN |
59 | #if defined(CONFIG_RELOCATABLE) |
60 | /* | |
61 | * We can't branch directly; in the direct case we use LR | |
62 | * and system_call_entry restores LR. (We thus need to move | |
63 | * LR to r10 in the RFID case too.) | |
64 | */ | |
65 | #define SYSCALL_PSERIES_2_DIRECT \ | |
66 | mflr r10 ; \ | |
67 | ld r12,PACAKBASE(r13) ; \ | |
68 | LOAD_HANDLER(r12, system_call_entry_direct) ; \ | |
6a404806 | 69 | mtctr r12 ; \ |
4700dfaf MN |
70 | mfspr r12,SPRN_SRR1 ; \ |
71 | /* Re-use of r13... No spare regs to do this */ \ | |
72 | li r13,MSR_RI ; \ | |
73 | mtmsrd r13,1 ; \ | |
74 | GET_PACA(r13) ; /* get r13 back */ \ | |
6a404806 | 75 | bctr ; |
4700dfaf MN |
76 | #else |
77 | /* We can branch directly */ | |
78 | #define SYSCALL_PSERIES_2_DIRECT \ | |
79 | mfspr r12,SPRN_SRR1 ; \ | |
80 | li r10,MSR_RI ; \ | |
81 | mtmsrd r10,1 ; /* Set RI (EE=0) */ \ | |
82 | b system_call_entry_direct ; | |
83 | #endif | |
0ebc4cda | 84 | |
0ebc4cda BH |
85 | /* |
86 | * This is the start of the interrupt handlers for pSeries | |
87 | * This code runs with relocation off. | |
88 | * Code from here to __end_interrupts gets copied down to real | |
89 | * address 0x100 when we are running a relocatable kernel. | |
90 | * Therefore any relative branches in this section must only | |
91 | * branch to labels in this section. | |
92 | */ | |
93 | . = 0x100 | |
94 | .globl __start_interrupts | |
95 | __start_interrupts: | |
96 | ||
948cf67c BH |
97 | .globl system_reset_pSeries; |
98 | system_reset_pSeries: | |
44e9309f | 99 | HMT_MEDIUM_PPR_DISCARD |
948cf67c BH |
100 | SET_SCRATCH0(r13) |
101 | #ifdef CONFIG_PPC_P7_NAP | |
102 | BEGIN_FTR_SECTION | |
103 | /* Running native on arch 2.06 or later, check if we are | |
104 | * waking up from nap. We only handle no state loss and | |
105 | * supervisor state loss. We do -not- handle hypervisor | |
106 | * state loss at this time. | |
107 | */ | |
108 | mfspr r13,SPRN_SRR1 | |
371fefd6 PM |
109 | rlwinm. r13,r13,47-31,30,31 |
110 | beq 9f | |
111 | ||
112 | /* waking up from powersave (nap) state */ | |
113 | cmpwi cr1,r13,2 | |
948cf67c BH |
114 | /* Total loss of HV state is fatal, we could try to use the |
115 | * PIR to locate a PACA, then use an emergency stack etc... | |
aca79d2b VS |
116 | * OPAL v3 based powernv platforms have new idle states |
117 | * which fall in this catagory. | |
948cf67c | 118 | */ |
aca79d2b | 119 | bgt cr1,8f |
371fefd6 PM |
120 | GET_PACA(r13) |
121 | ||
3a167bea | 122 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
f0888f70 PM |
123 | li r0,KVM_HWTHREAD_IN_KERNEL |
124 | stb r0,HSTATE_HWTHREAD_STATE(r13) | |
125 | /* Order setting hwthread_state vs. testing hwthread_req */ | |
126 | sync | |
127 | lbz r0,HSTATE_HWTHREAD_REQ(r13) | |
128 | cmpwi r0,0 | |
129 | beq 1f | |
371fefd6 PM |
130 | b kvm_start_guest |
131 | 1: | |
132 | #endif | |
133 | ||
134 | beq cr1,2f | |
b1576fec AB |
135 | b power7_wakeup_noloss |
136 | 2: b power7_wakeup_loss | |
aca79d2b VS |
137 | |
138 | /* Fast Sleep wakeup on PowerNV */ | |
139 | 8: GET_PACA(r13) | |
b1576fec | 140 | b power7_wakeup_tb_loss |
aca79d2b | 141 | |
371fefd6 | 142 | 9: |
969391c5 | 143 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
948cf67c | 144 | #endif /* CONFIG_PPC_P7_NAP */ |
b01c8b54 PM |
145 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, |
146 | NOTEST, 0x100) | |
0ebc4cda BH |
147 | |
148 | . = 0x200 | |
b01c8b54 PM |
149 | machine_check_pSeries_1: |
150 | /* This is moved out of line as it can be patched by FW, but | |
151 | * some code path might still want to branch into the original | |
152 | * vector | |
153 | */ | |
1707dd16 PM |
154 | HMT_MEDIUM_PPR_DISCARD |
155 | SET_SCRATCH0(r13) /* save r13 */ | |
1c51089f MS |
156 | #ifdef CONFIG_PPC_P7_NAP |
157 | BEGIN_FTR_SECTION | |
158 | /* Running native on arch 2.06 or later, check if we are | |
159 | * waking up from nap. We only handle no state loss and | |
160 | * supervisor state loss. We do -not- handle hypervisor | |
161 | * state loss at this time. | |
162 | */ | |
163 | mfspr r13,SPRN_SRR1 | |
164 | rlwinm. r13,r13,47-31,30,31 | |
d410ae21 | 165 | OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) |
1c51089f MS |
166 | beq 9f |
167 | ||
d410ae21 MS |
168 | mfspr r13,SPRN_SRR1 |
169 | rlwinm. r13,r13,47-31,30,31 | |
1c51089f MS |
170 | /* waking up from powersave (nap) state */ |
171 | cmpwi cr1,r13,2 | |
172 | /* Total loss of HV state is fatal. let's just stay stuck here */ | |
d410ae21 | 173 | OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) |
1c51089f MS |
174 | bgt cr1,. |
175 | 9: | |
d410ae21 | 176 | OPT_SET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) |
1c51089f MS |
177 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
178 | #endif /* CONFIG_PPC_P7_NAP */ | |
1707dd16 | 179 | EXCEPTION_PROLOG_0(PACA_EXMC) |
1e9b4507 MS |
180 | BEGIN_FTR_SECTION |
181 | b machine_check_pSeries_early | |
182 | FTR_SECTION_ELSE | |
1707dd16 | 183 | b machine_check_pSeries_0 |
1e9b4507 | 184 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) |
0ebc4cda BH |
185 | |
186 | . = 0x300 | |
187 | .globl data_access_pSeries | |
188 | data_access_pSeries: | |
44e9309f | 189 | HMT_MEDIUM_PPR_DISCARD |
673b189a | 190 | SET_SCRATCH0(r13) |
0ebc4cda | 191 | BEGIN_FTR_SECTION |
b01c8b54 PM |
192 | b data_access_check_stab |
193 | data_access_not_stab: | |
194 | END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB) | |
b01c8b54 | 195 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD, |
697d3899 | 196 | KVMTEST, 0x300) |
0ebc4cda BH |
197 | |
198 | . = 0x380 | |
199 | .globl data_access_slb_pSeries | |
200 | data_access_slb_pSeries: | |
44e9309f | 201 | HMT_MEDIUM_PPR_DISCARD |
673b189a | 202 | SET_SCRATCH0(r13) |
1707dd16 | 203 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
697d3899 | 204 | EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380) |
0ebc4cda BH |
205 | std r3,PACA_EXSLB+EX_R3(r13) |
206 | mfspr r3,SPRN_DAR | |
0ebc4cda BH |
207 | #ifdef __DISABLED__ |
208 | /* Keep that around for when we re-implement dynamic VSIDs */ | |
209 | cmpdi r3,0 | |
210 | bge slb_miss_user_pseries | |
211 | #endif /* __DISABLED__ */ | |
b01c8b54 | 212 | mfspr r12,SPRN_SRR1 |
0ebc4cda | 213 | #ifndef CONFIG_RELOCATABLE |
b1576fec | 214 | b slb_miss_realmode |
0ebc4cda BH |
215 | #else |
216 | /* | |
ad0289e4 | 217 | * We can't just use a direct branch to slb_miss_realmode |
0ebc4cda BH |
218 | * because the distance from here to there depends on where |
219 | * the kernel ends up being put. | |
220 | */ | |
221 | mfctr r11 | |
222 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 223 | LOAD_HANDLER(r10, slb_miss_realmode) |
0ebc4cda BH |
224 | mtctr r10 |
225 | bctr | |
226 | #endif | |
227 | ||
b3e6b5df | 228 | STD_EXCEPTION_PSERIES(0x400, 0x400, instruction_access) |
0ebc4cda BH |
229 | |
230 | . = 0x480 | |
231 | .globl instruction_access_slb_pSeries | |
232 | instruction_access_slb_pSeries: | |
44e9309f | 233 | HMT_MEDIUM_PPR_DISCARD |
673b189a | 234 | SET_SCRATCH0(r13) |
1707dd16 | 235 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
de56a948 | 236 | EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480) |
0ebc4cda BH |
237 | std r3,PACA_EXSLB+EX_R3(r13) |
238 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ | |
0ebc4cda BH |
239 | #ifdef __DISABLED__ |
240 | /* Keep that around for when we re-implement dynamic VSIDs */ | |
241 | cmpdi r3,0 | |
242 | bge slb_miss_user_pseries | |
243 | #endif /* __DISABLED__ */ | |
b01c8b54 | 244 | mfspr r12,SPRN_SRR1 |
0ebc4cda | 245 | #ifndef CONFIG_RELOCATABLE |
b1576fec | 246 | b slb_miss_realmode |
0ebc4cda BH |
247 | #else |
248 | mfctr r11 | |
249 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 250 | LOAD_HANDLER(r10, slb_miss_realmode) |
0ebc4cda BH |
251 | mtctr r10 |
252 | bctr | |
253 | #endif | |
254 | ||
b3e6b5df BH |
255 | /* We open code these as we can't have a ". = x" (even with |
256 | * x = "." within a feature section | |
257 | */ | |
a5d4f3ad | 258 | . = 0x500; |
b3e6b5df BH |
259 | .globl hardware_interrupt_pSeries; |
260 | .globl hardware_interrupt_hv; | |
a5d4f3ad | 261 | hardware_interrupt_pSeries: |
b3e6b5df | 262 | hardware_interrupt_hv: |
a485c709 | 263 | HMT_MEDIUM_PPR_DISCARD |
a5d4f3ad | 264 | BEGIN_FTR_SECTION |
b01c8b54 PM |
265 | _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt, |
266 | EXC_HV, SOFTEN_TEST_HV) | |
267 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502) | |
de56a948 PM |
268 | FTR_SECTION_ELSE |
269 | _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt, | |
9e368f29 | 270 | EXC_STD, SOFTEN_TEST_HV_201) |
de56a948 | 271 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500) |
969391c5 | 272 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
a5d4f3ad | 273 | |
b3e6b5df | 274 | STD_EXCEPTION_PSERIES(0x600, 0x600, alignment) |
de56a948 | 275 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600) |
b01c8b54 | 276 | |
b3e6b5df | 277 | STD_EXCEPTION_PSERIES(0x700, 0x700, program_check) |
de56a948 | 278 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700) |
b01c8b54 | 279 | |
b3e6b5df | 280 | STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable) |
de56a948 | 281 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800) |
a5d4f3ad | 282 | |
a485c709 PM |
283 | . = 0x900 |
284 | .globl decrementer_pSeries | |
285 | decrementer_pSeries: | |
286 | _MASKABLE_EXCEPTION_PSERIES(0x900, decrementer, EXC_STD, SOFTEN_TEST_PR) | |
287 | ||
dabe859e | 288 | STD_EXCEPTION_HV(0x980, 0x982, hdecrementer) |
a5d4f3ad | 289 | |
1dbdafec | 290 | MASKABLE_EXCEPTION_PSERIES(0xa00, 0xa00, doorbell_super) |
de56a948 | 291 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00) |
b01c8b54 | 292 | |
b3e6b5df | 293 | STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b) |
de56a948 | 294 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00) |
0ebc4cda BH |
295 | |
296 | . = 0xc00 | |
297 | .globl system_call_pSeries | |
298 | system_call_pSeries: | |
299 | HMT_MEDIUM | |
b01c8b54 PM |
300 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
301 | SET_SCRATCH0(r13) | |
302 | GET_PACA(r13) | |
303 | std r9,PACA_EXGEN+EX_R9(r13) | |
304 | std r10,PACA_EXGEN+EX_R10(r13) | |
305 | mfcr r9 | |
306 | KVMTEST(0xc00) | |
307 | GET_SCRATCH0(r13) | |
308 | #endif | |
742415d6 MN |
309 | SYSCALL_PSERIES_1 |
310 | SYSCALL_PSERIES_2_RFID | |
311 | SYSCALL_PSERIES_3 | |
b01c8b54 PM |
312 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00) |
313 | ||
b3e6b5df | 314 | STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step) |
de56a948 | 315 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00) |
b3e6b5df BH |
316 | |
317 | /* At 0xe??? we have a bunch of hypervisor exceptions, we branch | |
318 | * out of line to handle them | |
319 | */ | |
320 | . = 0xe00 | |
d671ddd6 | 321 | hv_data_storage_trampoline: |
1707dd16 PM |
322 | SET_SCRATCH0(r13) |
323 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
b3e6b5df | 324 | b h_data_storage_hv |
1707dd16 | 325 | |
b3e6b5df | 326 | . = 0xe20 |
d671ddd6 | 327 | hv_instr_storage_trampoline: |
1707dd16 PM |
328 | SET_SCRATCH0(r13) |
329 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
b3e6b5df | 330 | b h_instr_storage_hv |
1707dd16 | 331 | |
b3e6b5df | 332 | . = 0xe40 |
d671ddd6 | 333 | emulation_assist_trampoline: |
1707dd16 PM |
334 | SET_SCRATCH0(r13) |
335 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
b3e6b5df | 336 | b emulation_assist_hv |
1707dd16 | 337 | |
b3e6b5df | 338 | . = 0xe60 |
d671ddd6 | 339 | hv_exception_trampoline: |
1707dd16 PM |
340 | SET_SCRATCH0(r13) |
341 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
b3e6b5df | 342 | b hmi_exception_hv |
1707dd16 | 343 | |
655bb3f4 | 344 | . = 0xe80 |
d671ddd6 | 345 | hv_doorbell_trampoline: |
1707dd16 PM |
346 | SET_SCRATCH0(r13) |
347 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
655bb3f4 | 348 | b h_doorbell_hv |
0ebc4cda BH |
349 | |
350 | /* We need to deal with the Altivec unavailable exception | |
351 | * here which is at 0xf20, thus in the middle of the | |
352 | * prolog code of the PerformanceMonitor one. A little | |
353 | * trickery is thus necessary | |
354 | */ | |
355 | . = 0xf00 | |
fa111f1f | 356 | performance_monitor_pseries_trampoline: |
1707dd16 PM |
357 | SET_SCRATCH0(r13) |
358 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
0ebc4cda BH |
359 | b performance_monitor_pSeries |
360 | ||
361 | . = 0xf20 | |
fa111f1f | 362 | altivec_unavailable_pseries_trampoline: |
1707dd16 PM |
363 | SET_SCRATCH0(r13) |
364 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
0ebc4cda BH |
365 | b altivec_unavailable_pSeries |
366 | ||
367 | . = 0xf40 | |
fa111f1f | 368 | vsx_unavailable_pseries_trampoline: |
1707dd16 PM |
369 | SET_SCRATCH0(r13) |
370 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
0ebc4cda BH |
371 | b vsx_unavailable_pSeries |
372 | ||
d0c0c9a1 | 373 | . = 0xf60 |
fa111f1f | 374 | facility_unavailable_trampoline: |
d0c0c9a1 MN |
375 | SET_SCRATCH0(r13) |
376 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
021424a1 | 377 | b facility_unavailable_pSeries |
d0c0c9a1 | 378 | |
b14b6260 | 379 | . = 0xf80 |
fa111f1f | 380 | hv_facility_unavailable_trampoline: |
b14b6260 ME |
381 | SET_SCRATCH0(r13) |
382 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
383 | b facility_unavailable_hv | |
384 | ||
0ebc4cda | 385 | #ifdef CONFIG_CBE_RAS |
b3e6b5df | 386 | STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error) |
5ccf55dd | 387 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202) |
0ebc4cda | 388 | #endif /* CONFIG_CBE_RAS */ |
b01c8b54 | 389 | |
b3e6b5df | 390 | STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint) |
de56a948 | 391 | KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300) |
b01c8b54 | 392 | |
b92a66a6 | 393 | . = 0x1500 |
51cf2b30 | 394 | .global denorm_exception_hv |
b92a66a6 | 395 | denorm_exception_hv: |
44e9309f | 396 | HMT_MEDIUM_PPR_DISCARD |
b92a66a6 | 397 | mtspr SPRN_SPRG_HSCRATCH0,r13 |
1707dd16 | 398 | EXCEPTION_PROLOG_0(PACA_EXGEN) |
630573c1 | 399 | EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500) |
b92a66a6 MN |
400 | |
401 | #ifdef CONFIG_PPC_DENORMALISATION | |
402 | mfspr r10,SPRN_HSRR1 | |
403 | mfspr r11,SPRN_HSRR0 /* save HSRR0 */ | |
404 | andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ | |
405 | addi r11,r11,-4 /* HSRR0 is next instruction */ | |
406 | bne+ denorm_assist | |
407 | #endif | |
408 | ||
630573c1 | 409 | KVMTEST(0x1500) |
b92a66a6 MN |
410 | EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV) |
411 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500) | |
412 | ||
0ebc4cda | 413 | #ifdef CONFIG_CBE_RAS |
b3e6b5df | 414 | STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance) |
5ccf55dd | 415 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602) |
0ebc4cda | 416 | #endif /* CONFIG_CBE_RAS */ |
b01c8b54 | 417 | |
b3e6b5df | 418 | STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist) |
de56a948 | 419 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700) |
b01c8b54 | 420 | |
0ebc4cda | 421 | #ifdef CONFIG_CBE_RAS |
b3e6b5df | 422 | STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal) |
5ccf55dd | 423 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802) |
faab4dd2 MN |
424 | #else |
425 | . = 0x1800 | |
0ebc4cda BH |
426 | #endif /* CONFIG_CBE_RAS */ |
427 | ||
0ebc4cda | 428 | |
b3e6b5df BH |
429 | /*** Out of line interrupts support ***/ |
430 | ||
faab4dd2 | 431 | .align 7 |
b01c8b54 | 432 | /* moved from 0x200 */ |
1e9b4507 MS |
433 | machine_check_pSeries_early: |
434 | BEGIN_FTR_SECTION | |
435 | EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200) | |
436 | /* | |
437 | * Register contents: | |
438 | * R13 = PACA | |
439 | * R9 = CR | |
440 | * Original R9 to R13 is saved on PACA_EXMC | |
441 | * | |
442 | * Switch to mc_emergency stack and handle re-entrancy (though we | |
443 | * currently don't test for overflow). Save MCE registers srr1, | |
444 | * srr0, dar and dsisr and then set ME=1 | |
445 | * | |
446 | * We use paca->in_mce to check whether this is the first entry or | |
447 | * nested machine check. We increment paca->in_mce to track nested | |
448 | * machine checks. | |
449 | * | |
450 | * If this is the first entry then set stack pointer to | |
451 | * paca->mc_emergency_sp, otherwise r1 is already pointing to | |
452 | * stack frame on mc_emergency stack. | |
453 | * | |
454 | * NOTE: We are here with MSR_ME=0 (off), which means we risk a | |
455 | * checkstop if we get another machine check exception before we do | |
456 | * rfid with MSR_ME=1. | |
457 | */ | |
458 | mr r11,r1 /* Save r1 */ | |
459 | lhz r10,PACA_IN_MCE(r13) | |
460 | cmpwi r10,0 /* Are we in nested machine check */ | |
461 | bne 0f /* Yes, we are. */ | |
462 | /* First machine check entry */ | |
463 | ld r1,PACAMCEMERGSP(r13) /* Use MC emergency stack */ | |
464 | 0: subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ | |
465 | addi r10,r10,1 /* increment paca->in_mce */ | |
466 | sth r10,PACA_IN_MCE(r13) | |
467 | std r11,GPR1(r1) /* Save r1 on the stack. */ | |
468 | std r11,0(r1) /* make stack chain pointer */ | |
469 | mfspr r11,SPRN_SRR0 /* Save SRR0 */ | |
470 | std r11,_NIP(r1) | |
471 | mfspr r11,SPRN_SRR1 /* Save SRR1 */ | |
472 | std r11,_MSR(r1) | |
473 | mfspr r11,SPRN_DAR /* Save DAR */ | |
474 | std r11,_DAR(r1) | |
475 | mfspr r11,SPRN_DSISR /* Save DSISR */ | |
476 | std r11,_DSISR(r1) | |
477 | std r9,_CCR(r1) /* Save CR in stackframe */ | |
478 | /* Save r9 through r13 from EXMC save area to stack frame. */ | |
479 | EXCEPTION_PROLOG_COMMON_2(PACA_EXMC) | |
480 | mfmsr r11 /* get MSR value */ | |
481 | ori r11,r11,MSR_ME /* turn on ME bit */ | |
482 | ori r11,r11,MSR_RI /* turn on RI bit */ | |
483 | ld r12,PACAKBASE(r13) /* get high part of &label */ | |
484 | LOAD_HANDLER(r12, machine_check_handle_early) | |
485 | mtspr SPRN_SRR0,r12 | |
486 | mtspr SPRN_SRR1,r11 | |
487 | rfid | |
488 | b . /* prevent speculative execution */ | |
489 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) | |
490 | ||
b01c8b54 PM |
491 | machine_check_pSeries: |
492 | .globl machine_check_fwnmi | |
493 | machine_check_fwnmi: | |
44e9309f | 494 | HMT_MEDIUM_PPR_DISCARD |
b01c8b54 | 495 | SET_SCRATCH0(r13) /* save r13 */ |
1707dd16 PM |
496 | EXCEPTION_PROLOG_0(PACA_EXMC) |
497 | machine_check_pSeries_0: | |
498 | EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200) | |
499 | EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD) | |
b01c8b54 PM |
500 | KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200) |
501 | ||
b01c8b54 PM |
502 | /* moved from 0x300 */ |
503 | data_access_check_stab: | |
504 | GET_PACA(r13) | |
505 | std r9,PACA_EXSLB+EX_R9(r13) | |
506 | std r10,PACA_EXSLB+EX_R10(r13) | |
507 | mfspr r10,SPRN_DAR | |
508 | mfspr r9,SPRN_DSISR | |
509 | srdi r10,r10,60 | |
510 | rlwimi r10,r9,16,0x20 | |
7aa79938 | 511 | #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE |
3c42bf8a | 512 | lbz r9,HSTATE_IN_GUEST(r13) |
b01c8b54 PM |
513 | rlwimi r10,r9,8,0x300 |
514 | #endif | |
515 | mfcr r9 | |
516 | cmpwi r10,0x2c | |
517 | beq do_stab_bolted_pSeries | |
518 | mtcrf 0x80,r9 | |
519 | ld r9,PACA_EXSLB+EX_R9(r13) | |
520 | ld r10,PACA_EXSLB+EX_R10(r13) | |
521 | b data_access_not_stab | |
522 | do_stab_bolted_pSeries: | |
523 | std r11,PACA_EXSLB+EX_R11(r13) | |
524 | std r12,PACA_EXSLB+EX_R12(r13) | |
525 | GET_SCRATCH0(r10) | |
526 | std r10,PACA_EXSLB+EX_R13(r13) | |
ad0289e4 | 527 | EXCEPTION_PROLOG_PSERIES_1(do_stab_bolted, EXC_STD) |
b01c8b54 | 528 | |
697d3899 PM |
529 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300) |
530 | KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380) | |
de56a948 PM |
531 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400) |
532 | KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480) | |
533 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900) | |
b01c8b54 PM |
534 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982) |
535 | ||
b92a66a6 MN |
536 | #ifdef CONFIG_PPC_DENORMALISATION |
537 | denorm_assist: | |
538 | BEGIN_FTR_SECTION | |
539 | /* | |
540 | * To denormalise we need to move a copy of the register to itself. | |
541 | * For POWER6 do that here for all FP regs. | |
542 | */ | |
543 | mfmsr r10 | |
544 | ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1) | |
545 | xori r10,r10,(MSR_FE0|MSR_FE1) | |
546 | mtmsrd r10 | |
547 | sync | |
d7c67fb1 MN |
548 | |
549 | #define FMR2(n) fmr (n), (n) ; fmr n+1, n+1 | |
550 | #define FMR4(n) FMR2(n) ; FMR2(n+2) | |
551 | #define FMR8(n) FMR4(n) ; FMR4(n+4) | |
552 | #define FMR16(n) FMR8(n) ; FMR8(n+8) | |
553 | #define FMR32(n) FMR16(n) ; FMR16(n+16) | |
554 | FMR32(0) | |
555 | ||
b92a66a6 MN |
556 | FTR_SECTION_ELSE |
557 | /* | |
558 | * To denormalise we need to move a copy of the register to itself. | |
559 | * For POWER7 do that here for the first 32 VSX registers only. | |
560 | */ | |
561 | mfmsr r10 | |
562 | oris r10,r10,MSR_VSX@h | |
563 | mtmsrd r10 | |
564 | sync | |
d7c67fb1 MN |
565 | |
566 | #define XVCPSGNDP2(n) XVCPSGNDP(n,n,n) ; XVCPSGNDP(n+1,n+1,n+1) | |
567 | #define XVCPSGNDP4(n) XVCPSGNDP2(n) ; XVCPSGNDP2(n+2) | |
568 | #define XVCPSGNDP8(n) XVCPSGNDP4(n) ; XVCPSGNDP4(n+4) | |
569 | #define XVCPSGNDP16(n) XVCPSGNDP8(n) ; XVCPSGNDP8(n+8) | |
570 | #define XVCPSGNDP32(n) XVCPSGNDP16(n) ; XVCPSGNDP16(n+16) | |
571 | XVCPSGNDP32(0) | |
572 | ||
b92a66a6 | 573 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206) |
fb0fce3e MN |
574 | |
575 | BEGIN_FTR_SECTION | |
576 | b denorm_done | |
577 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |
578 | /* | |
579 | * To denormalise we need to move a copy of the register to itself. | |
580 | * For POWER8 we need to do that for all 64 VSX registers | |
581 | */ | |
582 | XVCPSGNDP32(32) | |
583 | denorm_done: | |
b92a66a6 MN |
584 | mtspr SPRN_HSRR0,r11 |
585 | mtcrf 0x80,r9 | |
586 | ld r9,PACA_EXGEN+EX_R9(r13) | |
44e9309f | 587 | RESTORE_PPR_PACA(PACA_EXGEN, r10) |
630573c1 PM |
588 | BEGIN_FTR_SECTION |
589 | ld r10,PACA_EXGEN+EX_CFAR(r13) | |
590 | mtspr SPRN_CFAR,r10 | |
591 | END_FTR_SECTION_IFSET(CPU_FTR_CFAR) | |
b92a66a6 MN |
592 | ld r10,PACA_EXGEN+EX_R10(r13) |
593 | ld r11,PACA_EXGEN+EX_R11(r13) | |
594 | ld r12,PACA_EXGEN+EX_R12(r13) | |
595 | ld r13,PACA_EXGEN+EX_R13(r13) | |
596 | HRFID | |
597 | b . | |
598 | #endif | |
599 | ||
b01c8b54 | 600 | .align 7 |
b3e6b5df | 601 | /* moved from 0xe00 */ |
1707dd16 | 602 | STD_EXCEPTION_HV_OOL(0xe02, h_data_storage) |
b01c8b54 | 603 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02) |
1707dd16 | 604 | STD_EXCEPTION_HV_OOL(0xe22, h_instr_storage) |
b01c8b54 | 605 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22) |
1707dd16 | 606 | STD_EXCEPTION_HV_OOL(0xe42, emulation_assist) |
b01c8b54 | 607 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42) |
1707dd16 | 608 | STD_EXCEPTION_HV_OOL(0xe62, hmi_exception) /* need to flush cache ? */ |
b01c8b54 | 609 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62) |
1707dd16 | 610 | MASKABLE_EXCEPTION_HV_OOL(0xe82, h_doorbell) |
655bb3f4 | 611 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe82) |
0ebc4cda BH |
612 | |
613 | /* moved from 0xf00 */ | |
1707dd16 | 614 | STD_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor) |
de56a948 | 615 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00) |
1707dd16 | 616 | STD_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable) |
de56a948 | 617 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20) |
1707dd16 | 618 | STD_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable) |
de56a948 | 619 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40) |
021424a1 | 620 | STD_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable) |
d0c0c9a1 | 621 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf60) |
b14b6260 ME |
622 | STD_EXCEPTION_HV_OOL(0xf82, facility_unavailable) |
623 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xf82) | |
0ebc4cda BH |
624 | |
625 | /* | |
fe9e1d54 IM |
626 | * An interrupt came in while soft-disabled. We set paca->irq_happened, then: |
627 | * - If it was a decrementer interrupt, we bump the dec to max and and return. | |
628 | * - If it was a doorbell we return immediately since doorbells are edge | |
629 | * triggered and won't automatically refire. | |
630 | * - else we hard disable and return. | |
631 | * This is called with r10 containing the value to OR to the paca field. | |
0ebc4cda | 632 | */ |
7230c564 BH |
633 | #define MASKED_INTERRUPT(_H) \ |
634 | masked_##_H##interrupt: \ | |
635 | std r11,PACA_EXGEN+EX_R11(r13); \ | |
636 | lbz r11,PACAIRQHAPPENED(r13); \ | |
637 | or r11,r11,r10; \ | |
638 | stb r11,PACAIRQHAPPENED(r13); \ | |
fe9e1d54 IM |
639 | cmpwi r10,PACA_IRQ_DEC; \ |
640 | bne 1f; \ | |
7230c564 BH |
641 | lis r10,0x7fff; \ |
642 | ori r10,r10,0xffff; \ | |
643 | mtspr SPRN_DEC,r10; \ | |
644 | b 2f; \ | |
fe9e1d54 IM |
645 | 1: cmpwi r10,PACA_IRQ_DBELL; \ |
646 | beq 2f; \ | |
647 | mfspr r10,SPRN_##_H##SRR1; \ | |
7230c564 BH |
648 | rldicl r10,r10,48,1; /* clear MSR_EE */ \ |
649 | rotldi r10,r10,16; \ | |
650 | mtspr SPRN_##_H##SRR1,r10; \ | |
651 | 2: mtcrf 0x80,r9; \ | |
652 | ld r9,PACA_EXGEN+EX_R9(r13); \ | |
653 | ld r10,PACA_EXGEN+EX_R10(r13); \ | |
654 | ld r11,PACA_EXGEN+EX_R11(r13); \ | |
655 | GET_SCRATCH0(r13); \ | |
656 | ##_H##rfid; \ | |
0ebc4cda | 657 | b . |
7230c564 BH |
658 | |
659 | MASKED_INTERRUPT() | |
660 | MASKED_INTERRUPT(H) | |
0ebc4cda | 661 | |
7230c564 BH |
662 | /* |
663 | * Called from arch_local_irq_enable when an interrupt needs | |
fe9e1d54 IM |
664 | * to be resent. r3 contains 0x500, 0x900, 0xa00 or 0xe80 to indicate |
665 | * which kind of interrupt. MSR:EE is already off. We generate a | |
7230c564 BH |
666 | * stackframe like if a real interrupt had happened. |
667 | * | |
668 | * Note: While MSR:EE is off, we need to make sure that _MSR | |
669 | * in the generated frame has EE set to 1 or the exception | |
670 | * handler will not properly re-enable them. | |
671 | */ | |
672 | _GLOBAL(__replay_interrupt) | |
673 | /* We are going to jump to the exception common code which | |
674 | * will retrieve various register values from the PACA which | |
675 | * we don't give a damn about, so we don't bother storing them. | |
676 | */ | |
677 | mfmsr r12 | |
678 | mflr r11 | |
679 | mfcr r9 | |
680 | ori r12,r12,MSR_EE | |
fe9e1d54 IM |
681 | cmpwi r3,0x900 |
682 | beq decrementer_common | |
683 | cmpwi r3,0x500 | |
684 | beq hardware_interrupt_common | |
685 | BEGIN_FTR_SECTION | |
686 | cmpwi r3,0xe80 | |
687 | beq h_doorbell_common | |
688 | FTR_SECTION_ELSE | |
689 | cmpwi r3,0xa00 | |
690 | beq doorbell_super_common | |
691 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) | |
692 | blr | |
a5d4f3ad | 693 | |
0ebc4cda BH |
694 | #ifdef CONFIG_PPC_PSERIES |
695 | /* | |
696 | * Vectors for the FWNMI option. Share common code. | |
697 | */ | |
698 | .globl system_reset_fwnmi | |
699 | .align 7 | |
700 | system_reset_fwnmi: | |
44e9309f | 701 | HMT_MEDIUM_PPR_DISCARD |
673b189a | 702 | SET_SCRATCH0(r13) /* save r13 */ |
b01c8b54 PM |
703 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, |
704 | NOTEST, 0x100) | |
0ebc4cda BH |
705 | |
706 | #endif /* CONFIG_PPC_PSERIES */ | |
707 | ||
708 | #ifdef __DISABLED__ | |
709 | /* | |
710 | * This is used for when the SLB miss handler has to go virtual, | |
711 | * which doesn't happen for now anymore but will once we re-implement | |
712 | * dynamic VSIDs for shared page tables | |
713 | */ | |
714 | slb_miss_user_pseries: | |
715 | std r10,PACA_EXGEN+EX_R10(r13) | |
716 | std r11,PACA_EXGEN+EX_R11(r13) | |
717 | std r12,PACA_EXGEN+EX_R12(r13) | |
673b189a | 718 | GET_SCRATCH0(r10) |
0ebc4cda BH |
719 | ld r11,PACA_EXSLB+EX_R9(r13) |
720 | ld r12,PACA_EXSLB+EX_R3(r13) | |
721 | std r10,PACA_EXGEN+EX_R13(r13) | |
722 | std r11,PACA_EXGEN+EX_R9(r13) | |
723 | std r12,PACA_EXGEN+EX_R3(r13) | |
724 | clrrdi r12,r13,32 | |
725 | mfmsr r10 | |
726 | mfspr r11,SRR0 /* save SRR0 */ | |
727 | ori r12,r12,slb_miss_user_common@l /* virt addr of handler */ | |
728 | ori r10,r10,MSR_IR|MSR_DR|MSR_RI | |
729 | mtspr SRR0,r12 | |
730 | mfspr r12,SRR1 /* and SRR1 */ | |
731 | mtspr SRR1,r10 | |
732 | rfid | |
733 | b . /* prevent spec. execution */ | |
734 | #endif /* __DISABLED__ */ | |
735 | ||
4f6c11db PM |
736 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
737 | kvmppc_skip_interrupt: | |
738 | /* | |
739 | * Here all GPRs are unchanged from when the interrupt happened | |
740 | * except for r13, which is saved in SPRG_SCRATCH0. | |
741 | */ | |
742 | mfspr r13, SPRN_SRR0 | |
743 | addi r13, r13, 4 | |
744 | mtspr SPRN_SRR0, r13 | |
745 | GET_SCRATCH0(r13) | |
746 | rfid | |
747 | b . | |
748 | ||
749 | kvmppc_skip_Hinterrupt: | |
750 | /* | |
751 | * Here all GPRs are unchanged from when the interrupt happened | |
752 | * except for r13, which is saved in SPRG_SCRATCH0. | |
753 | */ | |
754 | mfspr r13, SPRN_HSRR0 | |
755 | addi r13, r13, 4 | |
756 | mtspr SPRN_HSRR0, r13 | |
757 | GET_SCRATCH0(r13) | |
758 | hrfid | |
759 | b . | |
760 | #endif | |
761 | ||
0ebc4cda BH |
762 | /* |
763 | * Code from here down to __end_handlers is invoked from the | |
764 | * exception prologs above. Because the prologs assemble the | |
765 | * addresses of these handlers using the LOAD_HANDLER macro, | |
61e2390e MN |
766 | * which uses an ori instruction, these handlers must be in |
767 | * the first 64k of the kernel image. | |
0ebc4cda BH |
768 | */ |
769 | ||
770 | /*** Common interrupt handlers ***/ | |
771 | ||
772 | STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception) | |
773 | ||
7450f6f0 BH |
774 | STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ) |
775 | STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt) | |
dabe859e | 776 | STD_EXCEPTION_COMMON(0x980, hdecrementer, .hdec_interrupt) |
1dbdafec IM |
777 | #ifdef CONFIG_PPC_DOORBELL |
778 | STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, .doorbell_exception) | |
779 | #else | |
780 | STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, .unknown_exception) | |
781 | #endif | |
0ebc4cda BH |
782 | STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) |
783 | STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) | |
784 | STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception) | |
bf593907 | 785 | STD_EXCEPTION_COMMON(0xe40, emulation_assist, .emulation_assist_interrupt) |
278a6cdc | 786 | STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception) |
655bb3f4 IM |
787 | #ifdef CONFIG_PPC_DOORBELL |
788 | STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, .doorbell_exception) | |
789 | #else | |
790 | STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, .unknown_exception) | |
791 | #endif | |
7450f6f0 | 792 | STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, .performance_monitor_exception) |
0ebc4cda | 793 | STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception) |
b92a66a6 | 794 | STD_EXCEPTION_COMMON(0x1502, denorm, .unknown_exception) |
0ebc4cda BH |
795 | #ifdef CONFIG_ALTIVEC |
796 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception) | |
797 | #else | |
798 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception) | |
799 | #endif | |
800 | #ifdef CONFIG_CBE_RAS | |
801 | STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception) | |
802 | STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception) | |
803 | STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception) | |
804 | #endif /* CONFIG_CBE_RAS */ | |
805 | ||
c1fb6816 MN |
806 | /* |
807 | * Relocation-on interrupts: A subset of the interrupts can be delivered | |
808 | * with IR=1/DR=1, if AIL==2 and MSR.HV won't be changed by delivering | |
809 | * it. Addresses are the same as the original interrupt addresses, but | |
810 | * offset by 0xc000000000004000. | |
811 | * It's impossible to receive interrupts below 0x300 via this mechanism. | |
812 | * KVM: None of these traps are from the guest ; anything that escalated | |
813 | * to HV=1 from HV=0 is delivered via real mode handlers. | |
814 | */ | |
815 | ||
816 | /* | |
817 | * This uses the standard macro, since the original 0x300 vector | |
818 | * only has extra guff for STAB-based processors -- which never | |
819 | * come here. | |
820 | */ | |
821 | STD_RELON_EXCEPTION_PSERIES(0x4300, 0x300, data_access) | |
822 | . = 0x4380 | |
823 | .globl data_access_slb_relon_pSeries | |
824 | data_access_slb_relon_pSeries: | |
c1fb6816 | 825 | SET_SCRATCH0(r13) |
1707dd16 | 826 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
c1fb6816 MN |
827 | EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380) |
828 | std r3,PACA_EXSLB+EX_R3(r13) | |
829 | mfspr r3,SPRN_DAR | |
830 | mfspr r12,SPRN_SRR1 | |
831 | #ifndef CONFIG_RELOCATABLE | |
b1576fec | 832 | b slb_miss_realmode |
c1fb6816 MN |
833 | #else |
834 | /* | |
ad0289e4 | 835 | * We can't just use a direct branch to slb_miss_realmode |
c1fb6816 MN |
836 | * because the distance from here to there depends on where |
837 | * the kernel ends up being put. | |
838 | */ | |
839 | mfctr r11 | |
840 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 841 | LOAD_HANDLER(r10, slb_miss_realmode) |
c1fb6816 MN |
842 | mtctr r10 |
843 | bctr | |
844 | #endif | |
845 | ||
846 | STD_RELON_EXCEPTION_PSERIES(0x4400, 0x400, instruction_access) | |
847 | . = 0x4480 | |
848 | .globl instruction_access_slb_relon_pSeries | |
849 | instruction_access_slb_relon_pSeries: | |
c1fb6816 | 850 | SET_SCRATCH0(r13) |
1707dd16 | 851 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
c1fb6816 MN |
852 | EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480) |
853 | std r3,PACA_EXSLB+EX_R3(r13) | |
854 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ | |
855 | mfspr r12,SPRN_SRR1 | |
856 | #ifndef CONFIG_RELOCATABLE | |
b1576fec | 857 | b slb_miss_realmode |
c1fb6816 MN |
858 | #else |
859 | mfctr r11 | |
860 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 861 | LOAD_HANDLER(r10, slb_miss_realmode) |
c1fb6816 MN |
862 | mtctr r10 |
863 | bctr | |
864 | #endif | |
865 | ||
866 | . = 0x4500 | |
867 | .globl hardware_interrupt_relon_pSeries; | |
868 | .globl hardware_interrupt_relon_hv; | |
869 | hardware_interrupt_relon_pSeries: | |
870 | hardware_interrupt_relon_hv: | |
871 | BEGIN_FTR_SECTION | |
872 | _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV) | |
873 | FTR_SECTION_ELSE | |
874 | _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR) | |
3e96ca7f | 875 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) |
c1fb6816 MN |
876 | STD_RELON_EXCEPTION_PSERIES(0x4600, 0x600, alignment) |
877 | STD_RELON_EXCEPTION_PSERIES(0x4700, 0x700, program_check) | |
878 | STD_RELON_EXCEPTION_PSERIES(0x4800, 0x800, fp_unavailable) | |
879 | MASKABLE_RELON_EXCEPTION_PSERIES(0x4900, 0x900, decrementer) | |
880 | STD_RELON_EXCEPTION_HV(0x4980, 0x982, hdecrementer) | |
1dbdafec | 881 | MASKABLE_RELON_EXCEPTION_PSERIES(0x4a00, 0xa00, doorbell_super) |
c1fb6816 MN |
882 | STD_RELON_EXCEPTION_PSERIES(0x4b00, 0xb00, trap_0b) |
883 | ||
884 | . = 0x4c00 | |
885 | .globl system_call_relon_pSeries | |
886 | system_call_relon_pSeries: | |
887 | HMT_MEDIUM | |
888 | SYSCALL_PSERIES_1 | |
889 | SYSCALL_PSERIES_2_DIRECT | |
890 | SYSCALL_PSERIES_3 | |
891 | ||
892 | STD_RELON_EXCEPTION_PSERIES(0x4d00, 0xd00, single_step) | |
893 | ||
894 | . = 0x4e00 | |
1d567cb4 | 895 | b . /* Can't happen, see v2.07 Book III-S section 6.5 */ |
c1fb6816 MN |
896 | |
897 | . = 0x4e20 | |
1d567cb4 | 898 | b . /* Can't happen, see v2.07 Book III-S section 6.5 */ |
c1fb6816 MN |
899 | |
900 | . = 0x4e40 | |
d671ddd6 | 901 | emulation_assist_relon_trampoline: |
1707dd16 PM |
902 | SET_SCRATCH0(r13) |
903 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
904 | b emulation_assist_relon_hv |
905 | ||
c1fb6816 | 906 | . = 0x4e60 |
1d567cb4 | 907 | b . /* Can't happen, see v2.07 Book III-S section 6.5 */ |
c1fb6816 | 908 | |
655bb3f4 | 909 | . = 0x4e80 |
d671ddd6 | 910 | h_doorbell_relon_trampoline: |
1707dd16 PM |
911 | SET_SCRATCH0(r13) |
912 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
655bb3f4 | 913 | b h_doorbell_relon_hv |
c1fb6816 | 914 | |
c1fb6816 | 915 | . = 0x4f00 |
fa111f1f | 916 | performance_monitor_relon_pseries_trampoline: |
1707dd16 PM |
917 | SET_SCRATCH0(r13) |
918 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
919 | b performance_monitor_relon_pSeries |
920 | ||
c1fb6816 | 921 | . = 0x4f20 |
fa111f1f | 922 | altivec_unavailable_relon_pseries_trampoline: |
1707dd16 PM |
923 | SET_SCRATCH0(r13) |
924 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
925 | b altivec_unavailable_relon_pSeries |
926 | ||
c1fb6816 | 927 | . = 0x4f40 |
fa111f1f | 928 | vsx_unavailable_relon_pseries_trampoline: |
1707dd16 PM |
929 | SET_SCRATCH0(r13) |
930 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
931 | b vsx_unavailable_relon_pSeries |
932 | ||
d0c0c9a1 | 933 | . = 0x4f60 |
fa111f1f | 934 | facility_unavailable_relon_trampoline: |
d0c0c9a1 MN |
935 | SET_SCRATCH0(r13) |
936 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
021424a1 | 937 | b facility_unavailable_relon_pSeries |
d0c0c9a1 | 938 | |
b14b6260 | 939 | . = 0x4f80 |
fa111f1f | 940 | hv_facility_unavailable_relon_trampoline: |
b14b6260 ME |
941 | SET_SCRATCH0(r13) |
942 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
88f09412 | 943 | b hv_facility_unavailable_relon_hv |
b14b6260 | 944 | |
c1fb6816 MN |
945 | STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint) |
946 | #ifdef CONFIG_PPC_DENORMALISATION | |
947 | . = 0x5500 | |
948 | b denorm_exception_hv | |
949 | #endif | |
c1fb6816 | 950 | STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist) |
c1fb6816 MN |
951 | |
952 | /* Other future vectors */ | |
953 | .align 7 | |
954 | .globl __end_interrupts | |
955 | __end_interrupts: | |
956 | ||
0ebc4cda | 957 | .align 7 |
c1fb6816 MN |
958 | system_call_entry_direct: |
959 | #if defined(CONFIG_RELOCATABLE) | |
960 | /* The first level prologue may have used LR to get here, saving | |
961 | * orig in r10. To save hacking/ifdeffing common code, restore here. | |
962 | */ | |
963 | mtlr r10 | |
964 | #endif | |
0ebc4cda BH |
965 | system_call_entry: |
966 | b system_call_common | |
967 | ||
fe1952fc | 968 | ppc64_runlatch_on_trampoline: |
b1576fec | 969 | b __ppc64_runlatch_on |
fe1952fc | 970 | |
0ebc4cda BH |
971 | /* |
972 | * Here we have detected that the kernel stack pointer is bad. | |
973 | * R9 contains the saved CR, r13 points to the paca, | |
974 | * r10 contains the (bad) kernel stack pointer, | |
975 | * r11 and r12 contain the saved SRR0 and SRR1. | |
976 | * We switch to using an emergency stack, save the registers there, | |
977 | * and call kernel_bad_stack(), which panics. | |
978 | */ | |
979 | bad_stack: | |
980 | ld r1,PACAEMERGSP(r13) | |
981 | subi r1,r1,64+INT_FRAME_SIZE | |
982 | std r9,_CCR(r1) | |
983 | std r10,GPR1(r1) | |
984 | std r11,_NIP(r1) | |
985 | std r12,_MSR(r1) | |
986 | mfspr r11,SPRN_DAR | |
987 | mfspr r12,SPRN_DSISR | |
988 | std r11,_DAR(r1) | |
989 | std r12,_DSISR(r1) | |
990 | mflr r10 | |
991 | mfctr r11 | |
992 | mfxer r12 | |
993 | std r10,_LINK(r1) | |
994 | std r11,_CTR(r1) | |
995 | std r12,_XER(r1) | |
996 | SAVE_GPR(0,r1) | |
997 | SAVE_GPR(2,r1) | |
1977b502 PM |
998 | ld r10,EX_R3(r3) |
999 | std r10,GPR3(r1) | |
1000 | SAVE_GPR(4,r1) | |
1001 | SAVE_4GPRS(5,r1) | |
1002 | ld r9,EX_R9(r3) | |
1003 | ld r10,EX_R10(r3) | |
1004 | SAVE_2GPRS(9,r1) | |
1005 | ld r9,EX_R11(r3) | |
1006 | ld r10,EX_R12(r3) | |
1007 | ld r11,EX_R13(r3) | |
1008 | std r9,GPR11(r1) | |
1009 | std r10,GPR12(r1) | |
1010 | std r11,GPR13(r1) | |
48404f2e PM |
1011 | BEGIN_FTR_SECTION |
1012 | ld r10,EX_CFAR(r3) | |
1013 | std r10,ORIG_GPR3(r1) | |
1014 | END_FTR_SECTION_IFSET(CPU_FTR_CFAR) | |
1977b502 | 1015 | SAVE_8GPRS(14,r1) |
0ebc4cda BH |
1016 | SAVE_10GPRS(22,r1) |
1017 | lhz r12,PACA_TRAP_SAVE(r13) | |
1018 | std r12,_TRAP(r1) | |
1019 | addi r11,r1,INT_FRAME_SIZE | |
1020 | std r11,0(r1) | |
1021 | li r12,0 | |
1022 | std r12,0(r11) | |
1023 | ld r2,PACATOC(r13) | |
1977b502 PM |
1024 | ld r11,exception_marker@toc(r2) |
1025 | std r12,RESULT(r1) | |
1026 | std r11,STACK_FRAME_OVERHEAD-16(r1) | |
0ebc4cda | 1027 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1028 | bl kernel_bad_stack |
0ebc4cda BH |
1029 | b 1b |
1030 | ||
1031 | /* | |
1032 | * Here r13 points to the paca, r9 contains the saved CR, | |
1033 | * SRR0 and SRR1 are saved in r11 and r12, | |
1034 | * r9 - r13 are saved in paca->exgen. | |
1035 | */ | |
1036 | .align 7 | |
1037 | .globl data_access_common | |
1038 | data_access_common: | |
1039 | mfspr r10,SPRN_DAR | |
1040 | std r10,PACA_EXGEN+EX_DAR(r13) | |
1041 | mfspr r10,SPRN_DSISR | |
1042 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
1043 | EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN) | |
a546498f BH |
1044 | DISABLE_INTS |
1045 | ld r12,_MSR(r1) | |
0ebc4cda BH |
1046 | ld r3,PACA_EXGEN+EX_DAR(r13) |
1047 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
1048 | li r5,0x300 | |
b1576fec | 1049 | b do_hash_page /* Try to handle as hpte fault */ |
0ebc4cda | 1050 | |
b3e6b5df | 1051 | .align 7 |
278a6cdc | 1052 | .globl h_data_storage_common |
b3e6b5df | 1053 | h_data_storage_common: |
278a6cdc MN |
1054 | mfspr r10,SPRN_HDAR |
1055 | std r10,PACA_EXGEN+EX_DAR(r13) | |
1056 | mfspr r10,SPRN_HDSISR | |
1057 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
1058 | EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN) | |
b1576fec | 1059 | bl save_nvgprs |
a546498f | 1060 | DISABLE_INTS |
278a6cdc | 1061 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1062 | bl unknown_exception |
1063 | b ret_from_except | |
b3e6b5df | 1064 | |
0ebc4cda BH |
1065 | .align 7 |
1066 | .globl instruction_access_common | |
1067 | instruction_access_common: | |
1068 | EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN) | |
a546498f BH |
1069 | DISABLE_INTS |
1070 | ld r12,_MSR(r1) | |
0ebc4cda BH |
1071 | ld r3,_NIP(r1) |
1072 | andis. r4,r12,0x5820 | |
1073 | li r5,0x400 | |
b1576fec | 1074 | b do_hash_page /* Try to handle as hpte fault */ |
0ebc4cda | 1075 | |
278a6cdc | 1076 | STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception) |
b3e6b5df | 1077 | |
0ebc4cda BH |
1078 | /* |
1079 | * Here is the common SLB miss user that is used when going to virtual | |
1080 | * mode for SLB misses, that is currently not used | |
1081 | */ | |
1082 | #ifdef __DISABLED__ | |
1083 | .align 7 | |
1084 | .globl slb_miss_user_common | |
1085 | slb_miss_user_common: | |
1086 | mflr r10 | |
1087 | std r3,PACA_EXGEN+EX_DAR(r13) | |
1088 | stw r9,PACA_EXGEN+EX_CCR(r13) | |
1089 | std r10,PACA_EXGEN+EX_LR(r13) | |
1090 | std r11,PACA_EXGEN+EX_SRR0(r13) | |
b1576fec | 1091 | bl slb_allocate_user |
0ebc4cda BH |
1092 | |
1093 | ld r10,PACA_EXGEN+EX_LR(r13) | |
1094 | ld r3,PACA_EXGEN+EX_R3(r13) | |
1095 | lwz r9,PACA_EXGEN+EX_CCR(r13) | |
1096 | ld r11,PACA_EXGEN+EX_SRR0(r13) | |
1097 | mtlr r10 | |
1098 | beq- slb_miss_fault | |
1099 | ||
1100 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ | |
1101 | beq- unrecov_user_slb | |
1102 | mfmsr r10 | |
1103 | ||
1104 | .machine push | |
1105 | .machine "power4" | |
1106 | mtcrf 0x80,r9 | |
1107 | .machine pop | |
1108 | ||
1109 | clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */ | |
1110 | mtmsrd r10,1 | |
1111 | ||
1112 | mtspr SRR0,r11 | |
1113 | mtspr SRR1,r12 | |
1114 | ||
1115 | ld r9,PACA_EXGEN+EX_R9(r13) | |
1116 | ld r10,PACA_EXGEN+EX_R10(r13) | |
1117 | ld r11,PACA_EXGEN+EX_R11(r13) | |
1118 | ld r12,PACA_EXGEN+EX_R12(r13) | |
1119 | ld r13,PACA_EXGEN+EX_R13(r13) | |
1120 | rfid | |
1121 | b . | |
1122 | ||
1123 | slb_miss_fault: | |
1124 | EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN) | |
1125 | ld r4,PACA_EXGEN+EX_DAR(r13) | |
1126 | li r5,0 | |
1127 | std r4,_DAR(r1) | |
1128 | std r5,_DSISR(r1) | |
1129 | b handle_page_fault | |
1130 | ||
1131 | unrecov_user_slb: | |
1132 | EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN) | |
1133 | DISABLE_INTS | |
b1576fec | 1134 | bl save_nvgprs |
0ebc4cda | 1135 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1136 | bl unrecoverable_exception |
0ebc4cda BH |
1137 | b 1b |
1138 | ||
1139 | #endif /* __DISABLED__ */ | |
1140 | ||
1141 | ||
4e243b79 MS |
1142 | /* |
1143 | * Machine check is different because we use a different | |
1144 | * save area: PACA_EXMC instead of PACA_EXGEN. | |
1145 | */ | |
1146 | .align 7 | |
1147 | .globl machine_check_common | |
1148 | machine_check_common: | |
1149 | ||
1150 | mfspr r10,SPRN_DAR | |
1151 | std r10,PACA_EXGEN+EX_DAR(r13) | |
1152 | mfspr r10,SPRN_DSISR | |
1153 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
1154 | EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) | |
1155 | FINISH_NAP | |
1156 | DISABLE_INTS | |
1157 | ld r3,PACA_EXGEN+EX_DAR(r13) | |
1158 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
1159 | std r3,_DAR(r1) | |
1160 | std r4,_DSISR(r1) | |
b1576fec | 1161 | bl save_nvgprs |
4e243b79 | 1162 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1163 | bl machine_check_exception |
1164 | b ret_from_except | |
4e243b79 | 1165 | |
0ebc4cda BH |
1166 | .align 7 |
1167 | .globl alignment_common | |
1168 | alignment_common: | |
1169 | mfspr r10,SPRN_DAR | |
1170 | std r10,PACA_EXGEN+EX_DAR(r13) | |
1171 | mfspr r10,SPRN_DSISR | |
1172 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
1173 | EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN) | |
1174 | ld r3,PACA_EXGEN+EX_DAR(r13) | |
1175 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
1176 | std r3,_DAR(r1) | |
1177 | std r4,_DSISR(r1) | |
b1576fec | 1178 | bl save_nvgprs |
a3512b2d | 1179 | DISABLE_INTS |
0ebc4cda | 1180 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1181 | bl alignment_exception |
1182 | b ret_from_except | |
0ebc4cda BH |
1183 | |
1184 | .align 7 | |
1185 | .globl program_check_common | |
1186 | program_check_common: | |
1187 | EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) | |
b1576fec | 1188 | bl save_nvgprs |
54321242 | 1189 | DISABLE_INTS |
922b9f86 | 1190 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1191 | bl program_check_exception |
1192 | b ret_from_except | |
0ebc4cda BH |
1193 | |
1194 | .align 7 | |
1195 | .globl fp_unavailable_common | |
1196 | fp_unavailable_common: | |
1197 | EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) | |
1198 | bne 1f /* if from user, just load it up */ | |
b1576fec | 1199 | bl save_nvgprs |
9f2f79e3 | 1200 | DISABLE_INTS |
0ebc4cda | 1201 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1202 | bl kernel_fp_unavailable_exception |
0ebc4cda | 1203 | BUG_OPCODE |
bc2a9408 MN |
1204 | 1: |
1205 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | |
1206 | BEGIN_FTR_SECTION | |
1207 | /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in | |
1208 | * transaction), go do TM stuff | |
1209 | */ | |
1210 | rldicl. r0, r12, (64-MSR_TS_LG), (64-2) | |
1211 | bne- 2f | |
1212 | END_FTR_SECTION_IFSET(CPU_FTR_TM) | |
1213 | #endif | |
b1576fec | 1214 | bl load_up_fpu |
0ebc4cda | 1215 | b fast_exception_return |
bc2a9408 MN |
1216 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1217 | 2: /* User process was in a transaction */ | |
b1576fec | 1218 | bl save_nvgprs |
bc2a9408 MN |
1219 | DISABLE_INTS |
1220 | addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec AB |
1221 | bl fp_unavailable_tm |
1222 | b ret_from_except | |
bc2a9408 | 1223 | #endif |
0ebc4cda BH |
1224 | .align 7 |
1225 | .globl altivec_unavailable_common | |
1226 | altivec_unavailable_common: | |
1227 | EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN) | |
1228 | #ifdef CONFIG_ALTIVEC | |
1229 | BEGIN_FTR_SECTION | |
1230 | beq 1f | |
bc2a9408 MN |
1231 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1232 | BEGIN_FTR_SECTION_NESTED(69) | |
1233 | /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in | |
1234 | * transaction), go do TM stuff | |
1235 | */ | |
1236 | rldicl. r0, r12, (64-MSR_TS_LG), (64-2) | |
1237 | bne- 2f | |
1238 | END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69) | |
1239 | #endif | |
b1576fec | 1240 | bl load_up_altivec |
0ebc4cda | 1241 | b fast_exception_return |
bc2a9408 MN |
1242 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1243 | 2: /* User process was in a transaction */ | |
b1576fec | 1244 | bl save_nvgprs |
bc2a9408 MN |
1245 | DISABLE_INTS |
1246 | addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec AB |
1247 | bl altivec_unavailable_tm |
1248 | b ret_from_except | |
bc2a9408 | 1249 | #endif |
0ebc4cda BH |
1250 | 1: |
1251 | END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) | |
1252 | #endif | |
b1576fec | 1253 | bl save_nvgprs |
9f2f79e3 | 1254 | DISABLE_INTS |
0ebc4cda | 1255 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1256 | bl altivec_unavailable_exception |
1257 | b ret_from_except | |
0ebc4cda BH |
1258 | |
1259 | .align 7 | |
1260 | .globl vsx_unavailable_common | |
1261 | vsx_unavailable_common: | |
1262 | EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN) | |
1263 | #ifdef CONFIG_VSX | |
1264 | BEGIN_FTR_SECTION | |
7230c564 | 1265 | beq 1f |
bc2a9408 MN |
1266 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1267 | BEGIN_FTR_SECTION_NESTED(69) | |
1268 | /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in | |
1269 | * transaction), go do TM stuff | |
1270 | */ | |
1271 | rldicl. r0, r12, (64-MSR_TS_LG), (64-2) | |
1272 | bne- 2f | |
1273 | END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69) | |
1274 | #endif | |
b1576fec | 1275 | b load_up_vsx |
bc2a9408 MN |
1276 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1277 | 2: /* User process was in a transaction */ | |
b1576fec | 1278 | bl save_nvgprs |
bc2a9408 MN |
1279 | DISABLE_INTS |
1280 | addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec AB |
1281 | bl vsx_unavailable_tm |
1282 | b ret_from_except | |
bc2a9408 | 1283 | #endif |
0ebc4cda BH |
1284 | 1: |
1285 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) | |
1286 | #endif | |
b1576fec | 1287 | bl save_nvgprs |
9f2f79e3 | 1288 | DISABLE_INTS |
0ebc4cda | 1289 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1290 | bl vsx_unavailable_exception |
1291 | b ret_from_except | |
0ebc4cda | 1292 | |
021424a1 | 1293 | STD_EXCEPTION_COMMON(0xf60, facility_unavailable, .facility_unavailable_exception) |
88f09412 | 1294 | STD_EXCEPTION_COMMON(0xf80, hv_facility_unavailable, .facility_unavailable_exception) |
d0c0c9a1 | 1295 | |
0ebc4cda BH |
1296 | .align 7 |
1297 | .globl __end_handlers | |
1298 | __end_handlers: | |
1299 | ||
61383407 | 1300 | /* Equivalents to the above handlers for relocation-on interrupt vectors */ |
1707dd16 | 1301 | STD_RELON_EXCEPTION_HV_OOL(0xe40, emulation_assist) |
1707dd16 | 1302 | MASKABLE_RELON_EXCEPTION_HV_OOL(0xe80, h_doorbell) |
61383407 | 1303 | |
1707dd16 PM |
1304 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor) |
1305 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable) | |
1306 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable) | |
021424a1 | 1307 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable) |
88f09412 | 1308 | STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable) |
61383407 BH |
1309 | |
1310 | #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) | |
1311 | /* | |
1312 | * Data area reserved for FWNMI option. | |
1313 | * This address (0x7000) is fixed by the RPA. | |
1314 | */ | |
1315 | .= 0x7000 | |
1316 | .globl fwnmi_data_area | |
1317 | fwnmi_data_area: | |
1318 | ||
1319 | /* pseries and powernv need to keep the whole page from | |
1320 | * 0x7000 to 0x8000 free for use by the firmware | |
1321 | */ | |
1322 | . = 0x8000 | |
1323 | #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */ | |
1324 | ||
1325 | /* Space for CPU0's segment table */ | |
1326 | .balign 4096 | |
1327 | .globl initial_stab | |
1328 | initial_stab: | |
1329 | .space 4096 | |
1330 | ||
1331 | #ifdef CONFIG_PPC_POWERNV | |
1332 | _GLOBAL(opal_mc_secondary_handler) | |
1333 | HMT_MEDIUM_PPR_DISCARD | |
1334 | SET_SCRATCH0(r13) | |
1335 | GET_PACA(r13) | |
1336 | clrldi r3,r3,2 | |
1337 | tovirt(r3,r3) | |
1338 | std r3,PACA_OPAL_MC_EVT(r13) | |
1339 | ld r13,OPAL_MC_SRR0(r3) | |
1340 | mtspr SPRN_SRR0,r13 | |
1341 | ld r13,OPAL_MC_SRR1(r3) | |
1342 | mtspr SPRN_SRR1,r13 | |
1343 | ld r3,OPAL_MC_GPR3(r3) | |
1344 | GET_SCRATCH0(r13) | |
1345 | b machine_check_pSeries | |
1346 | #endif /* CONFIG_PPC_POWERNV */ | |
1347 | ||
1348 | ||
4e243b79 MS |
1349 | #define MACHINE_CHECK_HANDLER_WINDUP \ |
1350 | /* Clear MSR_RI before setting SRR0 and SRR1. */\ | |
1351 | li r0,MSR_RI; \ | |
1352 | mfmsr r9; /* get MSR value */ \ | |
1353 | andc r9,r9,r0; \ | |
1354 | mtmsrd r9,1; /* Clear MSR_RI */ \ | |
1355 | /* Move original SRR0 and SRR1 into the respective regs */ \ | |
1356 | ld r9,_MSR(r1); \ | |
1357 | mtspr SPRN_SRR1,r9; \ | |
1358 | ld r3,_NIP(r1); \ | |
1359 | mtspr SPRN_SRR0,r3; \ | |
1360 | ld r9,_CTR(r1); \ | |
1361 | mtctr r9; \ | |
1362 | ld r9,_XER(r1); \ | |
1363 | mtxer r9; \ | |
1364 | ld r9,_LINK(r1); \ | |
1365 | mtlr r9; \ | |
1366 | REST_GPR(0, r1); \ | |
1367 | REST_8GPRS(2, r1); \ | |
1368 | REST_GPR(10, r1); \ | |
1369 | ld r11,_CCR(r1); \ | |
1370 | mtcr r11; \ | |
1371 | /* Decrement paca->in_mce. */ \ | |
1372 | lhz r12,PACA_IN_MCE(r13); \ | |
1373 | subi r12,r12,1; \ | |
1374 | sth r12,PACA_IN_MCE(r13); \ | |
1375 | REST_GPR(11, r1); \ | |
1376 | REST_2GPRS(12, r1); \ | |
1377 | /* restore original r1. */ \ | |
1378 | ld r1,GPR1(r1) | |
1379 | ||
1380 | /* | |
1381 | * Handle machine check early in real mode. We come here with | |
1382 | * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack. | |
1383 | */ | |
1384 | .align 7 | |
1385 | .globl machine_check_handle_early | |
1386 | machine_check_handle_early: | |
1387 | std r0,GPR0(r1) /* Save r0 */ | |
1388 | EXCEPTION_PROLOG_COMMON_3(0x200) | |
b1576fec | 1389 | bl save_nvgprs |
4e243b79 | 1390 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1391 | bl machine_check_early |
4e243b79 MS |
1392 | ld r12,_MSR(r1) |
1393 | #ifdef CONFIG_PPC_P7_NAP | |
1394 | /* | |
1395 | * Check if thread was in power saving mode. We come here when any | |
1396 | * of the following is true: | |
1397 | * a. thread wasn't in power saving mode | |
1398 | * b. thread was in power saving mode with no state loss or | |
1399 | * supervisor state loss | |
1400 | * | |
1401 | * Go back to nap again if (b) is true. | |
1402 | */ | |
1403 | rlwinm. r11,r12,47-31,30,31 /* Was it in power saving mode? */ | |
1404 | beq 4f /* No, it wasn;t */ | |
1405 | /* Thread was in power saving mode. Go back to nap again. */ | |
1406 | cmpwi r11,2 | |
1407 | bne 3f | |
1408 | /* Supervisor state loss */ | |
1409 | li r0,1 | |
1410 | stb r0,PACA_NAPSTATELOST(r13) | |
b1576fec | 1411 | 3: bl machine_check_queue_event |
4e243b79 MS |
1412 | MACHINE_CHECK_HANDLER_WINDUP |
1413 | GET_PACA(r13) | |
1414 | ld r1,PACAR1(r13) | |
b1576fec | 1415 | b power7_enter_nap_mode |
4e243b79 MS |
1416 | 4: |
1417 | #endif | |
1418 | /* | |
1419 | * Check if we are coming from hypervisor userspace. If yes then we | |
1420 | * continue in host kernel in V mode to deliver the MC event. | |
1421 | */ | |
1422 | rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */ | |
1423 | beq 5f | |
1424 | andi. r11,r12,MSR_PR /* See if coming from user. */ | |
1425 | bne 9f /* continue in V mode if we are. */ | |
1426 | ||
1427 | 5: | |
1428 | #ifdef CONFIG_KVM_BOOK3S_64_HV | |
1429 | /* | |
1430 | * We are coming from kernel context. Check if we are coming from | |
1431 | * guest. if yes, then we can continue. We will fall through | |
1432 | * do_kvm_200->kvmppc_interrupt to deliver the MC event to guest. | |
1433 | */ | |
1434 | lbz r11,HSTATE_IN_GUEST(r13) | |
1435 | cmpwi r11,0 /* Check if coming from guest */ | |
1436 | bne 9f /* continue if we are. */ | |
1437 | #endif | |
1438 | /* | |
1439 | * At this point we are not sure about what context we come from. | |
1440 | * Queue up the MCE event and return from the interrupt. | |
1441 | * But before that, check if this is an un-recoverable exception. | |
1442 | * If yes, then stay on emergency stack and panic. | |
1443 | */ | |
1444 | andi. r11,r12,MSR_RI | |
1445 | bne 2f | |
1446 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec | 1447 | bl unrecoverable_exception |
4e243b79 MS |
1448 | b 1b |
1449 | 2: | |
1450 | /* | |
1451 | * Return from MC interrupt. | |
1452 | * Queue up the MCE event so that we can log it later, while | |
1453 | * returning from kernel or opal call. | |
1454 | */ | |
b1576fec | 1455 | bl machine_check_queue_event |
4e243b79 MS |
1456 | MACHINE_CHECK_HANDLER_WINDUP |
1457 | rfid | |
1458 | 9: | |
1459 | /* Deliver the machine check to host kernel in V mode. */ | |
1460 | MACHINE_CHECK_HANDLER_WINDUP | |
1461 | b machine_check_pSeries | |
1462 | ||
087aa036 CG |
1463 | /* |
1464 | * r13 points to the PACA, r9 contains the saved CR, | |
1465 | * r12 contain the saved SRR1, SRR0 is still ready for return | |
1466 | * r3 has the faulting address | |
1467 | * r9 - r13 are saved in paca->exslb. | |
1468 | * r3 is saved in paca->slb_r3 | |
1469 | * We assume we aren't going to take any exceptions during this procedure. | |
1470 | */ | |
ad0289e4 | 1471 | slb_miss_realmode: |
087aa036 CG |
1472 | mflr r10 |
1473 | #ifdef CONFIG_RELOCATABLE | |
1474 | mtctr r11 | |
1475 | #endif | |
1476 | ||
1477 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ | |
1478 | std r10,PACA_EXSLB+EX_LR(r13) /* save LR */ | |
1479 | ||
b1576fec | 1480 | bl slb_allocate_realmode |
087aa036 CG |
1481 | |
1482 | /* All done -- return from exception. */ | |
1483 | ||
1484 | ld r10,PACA_EXSLB+EX_LR(r13) | |
1485 | ld r3,PACA_EXSLB+EX_R3(r13) | |
1486 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ | |
1487 | ||
1488 | mtlr r10 | |
1489 | ||
1490 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ | |
1491 | beq- 2f | |
1492 | ||
1493 | .machine push | |
1494 | .machine "power4" | |
1495 | mtcrf 0x80,r9 | |
1496 | mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ | |
1497 | .machine pop | |
1498 | ||
1499 | RESTORE_PPR_PACA(PACA_EXSLB, r9) | |
1500 | ld r9,PACA_EXSLB+EX_R9(r13) | |
1501 | ld r10,PACA_EXSLB+EX_R10(r13) | |
1502 | ld r11,PACA_EXSLB+EX_R11(r13) | |
1503 | ld r12,PACA_EXSLB+EX_R12(r13) | |
1504 | ld r13,PACA_EXSLB+EX_R13(r13) | |
1505 | rfid | |
1506 | b . /* prevent speculative execution */ | |
1507 | ||
1508 | 2: mfspr r11,SPRN_SRR0 | |
1509 | ld r10,PACAKBASE(r13) | |
1510 | LOAD_HANDLER(r10,unrecov_slb) | |
1511 | mtspr SPRN_SRR0,r10 | |
1512 | ld r10,PACAKMSR(r13) | |
1513 | mtspr SPRN_SRR1,r10 | |
1514 | rfid | |
1515 | b . | |
1516 | ||
1517 | unrecov_slb: | |
1518 | EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB) | |
1519 | DISABLE_INTS | |
b1576fec | 1520 | bl save_nvgprs |
087aa036 | 1521 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1522 | bl unrecoverable_exception |
087aa036 CG |
1523 | b 1b |
1524 | ||
1525 | ||
1526 | #ifdef CONFIG_PPC_970_NAP | |
1527 | power4_fixup_nap: | |
1528 | andc r9,r9,r10 | |
1529 | std r9,TI_LOCAL_FLAGS(r11) | |
1530 | ld r10,_LINK(r1) /* make idle task do the */ | |
1531 | std r10,_NIP(r1) /* equivalent of a blr */ | |
1532 | blr | |
1533 | #endif | |
1534 | ||
0ebc4cda BH |
1535 | /* |
1536 | * Hash table stuff | |
1537 | */ | |
1538 | .align 7 | |
1539 | _STATIC(do_hash_page) | |
1540 | std r3,_DAR(r1) | |
1541 | std r4,_DSISR(r1) | |
1542 | ||
9c7cc234 | 1543 | andis. r0,r4,0xa410 /* weird error? */ |
0ebc4cda | 1544 | bne- handle_page_fault /* if not, try to insert a HPTE */ |
9c7cc234 P |
1545 | andis. r0,r4,DSISR_DABRMATCH@h |
1546 | bne- handle_dabr_fault | |
1547 | ||
0ebc4cda BH |
1548 | BEGIN_FTR_SECTION |
1549 | andis. r0,r4,0x0020 /* Is it a segment table fault? */ | |
1550 | bne- do_ste_alloc /* If so handle it */ | |
44ae3ab3 | 1551 | END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB) |
0ebc4cda | 1552 | |
9778b696 | 1553 | CURRENT_THREAD_INFO(r11, r1) |
9c1e1052 PM |
1554 | lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */ |
1555 | andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */ | |
1556 | bne 77f /* then don't call hash_page now */ | |
0ebc4cda BH |
1557 | /* |
1558 | * We need to set the _PAGE_USER bit if MSR_PR is set or if we are | |
1559 | * accessing a userspace segment (even from the kernel). We assume | |
1560 | * kernel addresses always have the high bit set. | |
1561 | */ | |
1562 | rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */ | |
1563 | rotldi r0,r3,15 /* Move high bit into MSR_PR posn */ | |
1564 | orc r0,r12,r0 /* MSR_PR | ~high_bit */ | |
1565 | rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */ | |
1566 | ori r4,r4,1 /* add _PAGE_PRESENT */ | |
1567 | rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */ | |
1568 | ||
1569 | /* | |
1570 | * r3 contains the faulting address | |
1571 | * r4 contains the required access permissions | |
1572 | * r5 contains the trap number | |
1573 | * | |
7230c564 | 1574 | * at return r3 = 0 for success, 1 for page fault, negative for error |
0ebc4cda | 1575 | */ |
b1576fec | 1576 | bl hash_page /* build HPTE if possible */ |
0ebc4cda BH |
1577 | cmpdi r3,0 /* see if hash_page succeeded */ |
1578 | ||
7230c564 | 1579 | /* Success */ |
0ebc4cda | 1580 | beq fast_exc_return_irq /* Return from exception on success */ |
0ebc4cda | 1581 | |
7230c564 BH |
1582 | /* Error */ |
1583 | blt- 13f | |
9c7cc234 | 1584 | |
0ebc4cda BH |
1585 | /* Here we have a page fault that hash_page can't handle. */ |
1586 | handle_page_fault: | |
0ebc4cda BH |
1587 | 11: ld r4,_DAR(r1) |
1588 | ld r5,_DSISR(r1) | |
1589 | addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec | 1590 | bl do_page_fault |
0ebc4cda | 1591 | cmpdi r3,0 |
a546498f | 1592 | beq+ 12f |
b1576fec | 1593 | bl save_nvgprs |
0ebc4cda BH |
1594 | mr r5,r3 |
1595 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1596 | lwz r4,_DAR(r1) | |
b1576fec AB |
1597 | bl bad_page_fault |
1598 | b ret_from_except | |
0ebc4cda | 1599 | |
a546498f BH |
1600 | /* We have a data breakpoint exception - handle it */ |
1601 | handle_dabr_fault: | |
b1576fec | 1602 | bl save_nvgprs |
a546498f BH |
1603 | ld r4,_DAR(r1) |
1604 | ld r5,_DSISR(r1) | |
1605 | addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec AB |
1606 | bl do_break |
1607 | 12: b ret_from_except_lite | |
a546498f | 1608 | |
0ebc4cda BH |
1609 | |
1610 | /* We have a page fault that hash_page could handle but HV refused | |
1611 | * the PTE insertion | |
1612 | */ | |
b1576fec | 1613 | 13: bl save_nvgprs |
0ebc4cda BH |
1614 | mr r5,r3 |
1615 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1616 | ld r4,_DAR(r1) | |
b1576fec AB |
1617 | bl low_hash_fault |
1618 | b ret_from_except | |
0ebc4cda | 1619 | |
9c1e1052 PM |
1620 | /* |
1621 | * We come here as a result of a DSI at a point where we don't want | |
1622 | * to call hash_page, such as when we are accessing memory (possibly | |
1623 | * user memory) inside a PMU interrupt that occurred while interrupts | |
1624 | * were soft-disabled. We want to invoke the exception handler for | |
1625 | * the access, or panic if there isn't a handler. | |
1626 | */ | |
b1576fec | 1627 | 77: bl save_nvgprs |
9c1e1052 PM |
1628 | mr r4,r3 |
1629 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1630 | li r5,SIGSEGV | |
b1576fec AB |
1631 | bl bad_page_fault |
1632 | b ret_from_except | |
9c1e1052 | 1633 | |
0ebc4cda BH |
1634 | /* here we have a segment miss */ |
1635 | do_ste_alloc: | |
b1576fec | 1636 | bl ste_allocate /* try to insert stab entry */ |
0ebc4cda BH |
1637 | cmpdi r3,0 |
1638 | bne- handle_page_fault | |
1639 | b fast_exception_return | |
1640 | ||
1641 | /* | |
1642 | * r13 points to the PACA, r9 contains the saved CR, | |
1643 | * r11 and r12 contain the saved SRR0 and SRR1. | |
1644 | * r9 - r13 are saved in paca->exslb. | |
1645 | * We assume we aren't going to take any exceptions during this procedure. | |
1646 | * We assume (DAR >> 60) == 0xc. | |
1647 | */ | |
1648 | .align 7 | |
ad0289e4 | 1649 | do_stab_bolted: |
0ebc4cda BH |
1650 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ |
1651 | std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */ | |
c60ac569 | 1652 | mfspr r11,SPRN_DAR /* ea */ |
0ebc4cda | 1653 | |
c60ac569 AK |
1654 | /* |
1655 | * check for bad kernel/user address | |
1656 | * (ea & ~REGION_MASK) >= PGTABLE_RANGE | |
1657 | */ | |
1658 | rldicr. r9,r11,4,(63 - 46 - 4) | |
1659 | li r9,0 /* VSID = 0 for bad address */ | |
1660 | bne- 0f | |
1661 | ||
1662 | /* | |
1663 | * Calculate VSID: | |
1664 | * This is the kernel vsid, we take the top for context from | |
1665 | * the range. context = (MAX_USER_CONTEXT) + ((ea >> 60) - 0xc) + 1 | |
1666 | * Here we know that (ea >> 60) == 0xc | |
1667 | */ | |
1668 | lis r9,(MAX_USER_CONTEXT + 1)@ha | |
1669 | addi r9,r9,(MAX_USER_CONTEXT + 1)@l | |
1670 | ||
1671 | srdi r10,r11,SID_SHIFT | |
af81d787 | 1672 | rldimi r10,r9,ESID_BITS,0 /* proto vsid */ |
c60ac569 AK |
1673 | ASM_VSID_SCRAMBLE(r10, r9, 256M) |
1674 | rldic r9,r10,12,16 /* r9 = vsid << 12 */ | |
1675 | ||
1676 | 0: | |
0ebc4cda BH |
1677 | /* Hash to the primary group */ |
1678 | ld r10,PACASTABVIRT(r13) | |
c60ac569 | 1679 | srdi r11,r11,SID_SHIFT |
0ebc4cda BH |
1680 | rldimi r10,r11,7,52 /* r10 = first ste of the group */ |
1681 | ||
0ebc4cda BH |
1682 | /* Search the primary group for a free entry */ |
1683 | 1: ld r11,0(r10) /* Test valid bit of the current ste */ | |
1684 | andi. r11,r11,0x80 | |
1685 | beq 2f | |
1686 | addi r10,r10,16 | |
1687 | andi. r11,r10,0x70 | |
1688 | bne 1b | |
1689 | ||
1690 | /* Stick for only searching the primary group for now. */ | |
1691 | /* At least for now, we use a very simple random castout scheme */ | |
1692 | /* Use the TB as a random number ; OR in 1 to avoid entry 0 */ | |
1693 | mftb r11 | |
1694 | rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */ | |
1695 | ori r11,r11,0x10 | |
1696 | ||
1697 | /* r10 currently points to an ste one past the group of interest */ | |
1698 | /* make it point to the randomly selected entry */ | |
1699 | subi r10,r10,128 | |
1700 | or r10,r10,r11 /* r10 is the entry to invalidate */ | |
1701 | ||
1702 | isync /* mark the entry invalid */ | |
1703 | ld r11,0(r10) | |
1704 | rldicl r11,r11,56,1 /* clear the valid bit */ | |
1705 | rotldi r11,r11,8 | |
1706 | std r11,0(r10) | |
1707 | sync | |
1708 | ||
1709 | clrrdi r11,r11,28 /* Get the esid part of the ste */ | |
1710 | slbie r11 | |
1711 | ||
1712 | 2: std r9,8(r10) /* Store the vsid part of the ste */ | |
1713 | eieio | |
1714 | ||
1715 | mfspr r11,SPRN_DAR /* Get the new esid */ | |
1716 | clrrdi r11,r11,28 /* Permits a full 32b of ESID */ | |
1717 | ori r11,r11,0x90 /* Turn on valid and kp */ | |
1718 | std r11,0(r10) /* Put new entry back into the stab */ | |
1719 | ||
1720 | sync | |
1721 | ||
1722 | /* All done -- return from exception. */ | |
1723 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ | |
1724 | ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */ | |
1725 | ||
1726 | andi. r10,r12,MSR_RI | |
1727 | beq- unrecov_slb | |
1728 | ||
1729 | mtcrf 0x80,r9 /* restore CR */ | |
1730 | ||
1731 | mfmsr r10 | |
1732 | clrrdi r10,r10,2 | |
1733 | mtmsrd r10,1 | |
1734 | ||
1735 | mtspr SPRN_SRR0,r11 | |
1736 | mtspr SPRN_SRR1,r12 | |
1737 | ld r9,PACA_EXSLB+EX_R9(r13) | |
1738 | ld r10,PACA_EXSLB+EX_R10(r13) | |
1739 | ld r11,PACA_EXSLB+EX_R11(r13) | |
1740 | ld r12,PACA_EXSLB+EX_R12(r13) | |
1741 | ld r13,PACA_EXSLB+EX_R13(r13) | |
1742 | rfid | |
1743 | b . /* prevent speculative execution */ |