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