1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <asm/hw_irq.h>
17#include <asm/exception-64s.h>
18#include <asm/ptrace.h>
19#include <asm/cpuidle.h>
20#include <asm/head-64.h>
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66OPEN_FIXED_SECTION(real_vectors, 0x0100, 0x1900)
67OPEN_FIXED_SECTION(real_trampolines, 0x1900, 0x4000)
68OPEN_FIXED_SECTION(virt_vectors, 0x4000, 0x5900)
69OPEN_FIXED_SECTION(virt_trampolines, 0x5900, 0x7000)
70
71
72
73
74
75
76
77ZERO_FIXED_SECTION(fwnmi_page, 0x7000, 0x8000)
78OPEN_TEXT_SECTION(0x8000)
79#else
80OPEN_TEXT_SECTION(0x7000)
81#endif
82
83USE_FIXED_SECTION(real_vectors)
84
85
86
87
88
89
90
91
92
93 .globl __start_interrupts
94__start_interrupts:
95
96
97EXC_VIRT_NONE(0x4000, 0x100)
98
99
100#ifdef CONFIG_PPC_P7_NAP
101
102
103
104
105
106
107
108
109#define IDLETEST(n) \
110 BEGIN_FTR_SECTION ; \
111 mfspr r10,SPRN_SRR1 ; \
112 rlwinm. r10,r10,47-31,30,31 ; \
113 beq- 1f ; \
114 cmpwi cr1,r10,2 ; \
115 mfspr r3,SPRN_SRR1 ; \
116 bltlr cr1 ; \
117 BRANCH_TO_C000(r10, system_reset_idle_common) ; \
1181: \
119 KVMTEST_PR(n) ; \
120 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
121#else
122#define IDLETEST NOTEST
123#endif
124
125EXC_REAL_BEGIN(system_reset, 0x100, 0x100)
126 SET_SCRATCH0(r13)
127
128
129
130
131 EXCEPTION_PROLOG_PSERIES_NORI(PACA_EXNMI, system_reset_common, EXC_STD,
132 IDLETEST, 0x100)
133
134EXC_REAL_END(system_reset, 0x100, 0x100)
135EXC_VIRT_NONE(0x4100, 0x100)
136TRAMP_KVM(PACA_EXNMI, 0x100)
137
138#ifdef CONFIG_PPC_P7_NAP
139EXC_COMMON_BEGIN(system_reset_idle_common)
140
141
142
143
144 b idle_return_gpr_loss
145#endif
146
147
148
149
150
151
152
153
154
155
156#define ADD_RECONCILE_NMI \
157 li r10,IRQS_ALL_DISABLED; \
158 stb r10,PACAIRQSOFTMASK(r13); \
159 lbz r10,PACAIRQHAPPENED(r13); \
160 std r10,_DAR(r1)
161
162EXC_COMMON_BEGIN(system_reset_common)
163
164
165
166
167
168
169 lhz r10,PACA_IN_NMI(r13)
170 addi r10,r10,1
171 sth r10,PACA_IN_NMI(r13)
172 li r10,MSR_RI
173 mtmsrd r10,1
174
175 mr r10,r1
176 ld r1,PACA_NMI_EMERG_SP(r13)
177 subi r1,r1,INT_FRAME_SIZE
178 EXCEPTION_COMMON_NORET_STACK(PACA_EXNMI, 0x100,
179 system_reset, system_reset_exception,
180 ADD_NVGPRS;ADD_RECONCILE_NMI)
181
182
183
184 li r0,MSR_RI
185 mfmsr r9
186 andc r9,r9,r0
187 mtmsrd r9,1
188
189
190
191
192 lhz r10,PACA_IN_NMI(r13)
193 subi r10,r10,1
194 sth r10,PACA_IN_NMI(r13)
195
196
197
198
199 ld r10,_DAR(r1)
200 stb r10,PACAIRQHAPPENED(r13)
201 ld r10,SOFTE(r1)
202 stb r10,PACAIRQSOFTMASK(r13)
203
204
205
206
207
208
209
210 ld r9,_MSR(r1)
211 mtspr SPRN_SRR1,r9
212 ld r3,_NIP(r1)
213 mtspr SPRN_SRR0,r3
214 ld r9,_CTR(r1)
215 mtctr r9
216 ld r9,_XER(r1)
217 mtxer r9
218 ld r9,_LINK(r1)
219 mtlr r9
220 REST_GPR(0, r1)
221 REST_8GPRS(2, r1)
222 REST_GPR(10, r1)
223 ld r11,_CCR(r1)
224 mtcr r11
225 REST_GPR(11, r1)
226 REST_2GPRS(12, r1)
227
228 ld r1,GPR1(r1)
229 RFI_TO_USER_OR_KERNEL
230
231#ifdef CONFIG_PPC_PSERIES
232
233
234
235TRAMP_REAL_BEGIN(system_reset_fwnmi)
236 SET_SCRATCH0(r13)
237
238 EXCEPTION_PROLOG_PSERIES_NORI(PACA_EXNMI, system_reset_common,
239 EXC_STD, NOTEST, 0x100)
240#endif
241
242
243EXC_REAL_BEGIN(machine_check, 0x200, 0x100)
244
245
246
247
248 SET_SCRATCH0(r13)
249 EXCEPTION_PROLOG_0(PACA_EXMC)
250BEGIN_FTR_SECTION
251 b machine_check_common_early
252FTR_SECTION_ELSE
253 b machine_check_pSeries_0
254ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
255EXC_REAL_END(machine_check, 0x200, 0x100)
256EXC_VIRT_NONE(0x4200, 0x100)
257TRAMP_REAL_BEGIN(machine_check_common_early)
258 EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285 mr r11,r1
286 lhz r10,PACA_IN_MCE(r13)
287 cmpwi r10,0
288 bne 0f
289
290 ld r1,PACAMCEMERGSP(r13)
2910: subi r1,r1,INT_FRAME_SIZE
292 addi r10,r10,1
293 sth r10,PACA_IN_MCE(r13)
294
295 cmpwi r10,MAX_MCE_DEPTH
296 bgt 2f
297 std r11,GPR1(r1)
298 std r11,0(r1)
299 mfspr r11,SPRN_SRR0
300 std r11,_NIP(r1)
301 mfspr r11,SPRN_SRR1
302 std r11,_MSR(r1)
303 mfspr r11,SPRN_DAR
304 std r11,_DAR(r1)
305 mfspr r11,SPRN_DSISR
306 std r11,_DSISR(r1)
307 std r9,_CCR(r1)
308
309 EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
310 mfmsr r11
311BEGIN_FTR_SECTION
312 ori r11,r11,MSR_ME
313END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
314 ori r11,r11,MSR_RI
315 LOAD_HANDLER(r12, machine_check_handle_early)
3161: mtspr SPRN_SRR0,r12
317 mtspr SPRN_SRR1,r11
318 RFI_TO_KERNEL
319 b .
3202:
321
322
323
324
325 addi r1,r1,INT_FRAME_SIZE
326 ld r11,PACAKMSR(r13)
327 LOAD_HANDLER(r12, unrecover_mce)
328 li r10,MSR_ME
329 andc r11,r11,r10
330 b 1b
331 b .
332
333TRAMP_REAL_BEGIN(machine_check_pSeries)
334 .globl machine_check_fwnmi
335machine_check_fwnmi:
336 SET_SCRATCH0(r13)
337 EXCEPTION_PROLOG_0(PACA_EXMC)
338BEGIN_FTR_SECTION
339 b machine_check_common_early
340END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE)
341machine_check_pSeries_0:
342 EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST_PR, 0x200)
343
344
345
346
347
348 EXCEPTION_PROLOG_PSERIES_1_NORI(machine_check_common, EXC_STD)
349
350TRAMP_KVM_SKIP(PACA_EXMC, 0x200)
351
352EXC_COMMON_BEGIN(machine_check_common)
353
354
355
356
357 mfspr r10,SPRN_DAR
358 std r10,PACA_EXMC+EX_DAR(r13)
359 mfspr r10,SPRN_DSISR
360 stw r10,PACA_EXMC+EX_DSISR(r13)
361 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
362 FINISH_NAP
363 RECONCILE_IRQ_STATE(r10, r11)
364 ld r3,PACA_EXMC+EX_DAR(r13)
365 lwz r4,PACA_EXMC+EX_DSISR(r13)
366
367 li r10,MSR_RI
368 mtmsrd r10,1
369 std r3,_DAR(r1)
370 std r4,_DSISR(r1)
371 bl save_nvgprs
372 addi r3,r1,STACK_FRAME_OVERHEAD
373 bl machine_check_exception
374 b ret_from_except
375
376#define MACHINE_CHECK_HANDLER_WINDUP \
377 \
378 li r0,MSR_RI; \
379 mfmsr r9; \
380 andc r9,r9,r0; \
381 mtmsrd r9,1; \
382 \
383 ld r9,_MSR(r1); \
384 mtspr SPRN_SRR1,r9; \
385 ld r3,_NIP(r1); \
386 mtspr SPRN_SRR0,r3; \
387 ld r9,_CTR(r1); \
388 mtctr r9; \
389 ld r9,_XER(r1); \
390 mtxer r9; \
391 ld r9,_LINK(r1); \
392 mtlr r9; \
393 REST_GPR(0, r1); \
394 REST_8GPRS(2, r1); \
395 REST_GPR(10, r1); \
396 ld r11,_CCR(r1); \
397 mtcr r11; \
398 \
399 lhz r12,PACA_IN_MCE(r13); \
400 subi r12,r12,1; \
401 sth r12,PACA_IN_MCE(r13); \
402 REST_GPR(11, r1); \
403 REST_2GPRS(12, r1); \
404 \
405 ld r1,GPR1(r1)
406
407#ifdef CONFIG_PPC_P7_NAP
408
409
410
411
412EXC_COMMON_BEGIN(machine_check_idle_common)
413 bl machine_check_queue_event
414
415
416
417
418
419
420
421
422
423
424
425 ld r3,_MSR(r1)
426 ld r4,_LINK(r1)
427
428 lhz r11,PACA_IN_MCE(r13)
429 subi r11,r11,1
430 sth r11,PACA_IN_MCE(r13)
431
432 mtlr r4
433 rlwinm r10,r3,47-31,30,31
434 cmpwi cr1,r10,2
435 bltlr cr1
436 b idle_return_gpr_loss
437#endif
438
439
440
441
442EXC_COMMON_BEGIN(machine_check_handle_early)
443 std r0,GPR0(r1)
444 EXCEPTION_PROLOG_COMMON_3(0x200)
445 bl save_nvgprs
446 addi r3,r1,STACK_FRAME_OVERHEAD
447 bl machine_check_early
448 std r3,RESULT(r1)
449 ld r12,_MSR(r1)
450BEGIN_FTR_SECTION
451 b 4f
452END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE)
453
454#ifdef CONFIG_PPC_P7_NAP
455
456
457
458
459
460
461
462
463
464 BEGIN_FTR_SECTION
465 rlwinm. r11,r12,47-31,30,31
466 bne machine_check_idle_common
467 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
468#endif
469
470
471
472
473
474 rldicl. r11,r12,4,63
475 beq 5f
4764: andi. r11,r12,MSR_PR
477 bne 9f
478
4795:
480#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
481BEGIN_FTR_SECTION
482
483
484
485
486
487 lbz r11,HSTATE_IN_GUEST(r13)
488 cmpwi r11,0
489 bne 9f
490END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
491#endif
492
493
494
495
496
497
498 andi. r11,r12,MSR_RI
499 bne 2f
5001: mfspr r11,SPRN_SRR0
501 LOAD_HANDLER(r10,unrecover_mce)
502 mtspr SPRN_SRR0,r10
503 ld r10,PACAKMSR(r13)
504
505
506
507
508
509
510
511 li r3,MSR_ME
512 andc r10,r10,r3
513 mtspr SPRN_SRR1,r10
514 RFI_TO_KERNEL
515 b .
5162:
517
518
519
520
521 ld r3,RESULT(r1)
522 cmpdi r3,0
523
524 beq 1b
525BEGIN_FTR_SECTION
526
527
528
529
530
531 bl machine_check_queue_event
532 MACHINE_CHECK_HANDLER_WINDUP
533 RFI_TO_USER_OR_KERNEL
534FTR_SECTION_ELSE
535
536
537
538
539 LOAD_HANDLER(r10,mce_return)
540 mtspr SPRN_SRR0,r10
541 ld r10,PACAKMSR(r13)
542 mtspr SPRN_SRR1,r10
543 RFI_TO_KERNEL
544 b .
545ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
5469:
547
548 MACHINE_CHECK_HANDLER_WINDUP
549 SET_SCRATCH0(r13)
550 EXCEPTION_PROLOG_0(PACA_EXMC)
551 b machine_check_pSeries_0
552
553EXC_COMMON_BEGIN(unrecover_mce)
554
555 addi r3,r1,STACK_FRAME_OVERHEAD
556 bl machine_check_exception
557
558
559
560
5611: addi r3,r1,STACK_FRAME_OVERHEAD
562 bl unrecoverable_exception
563 b 1b
564
565EXC_COMMON_BEGIN(mce_return)
566
567 addi r3,r1,STACK_FRAME_OVERHEAD
568 bl machine_check_exception
569 MACHINE_CHECK_HANDLER_WINDUP
570 RFI_TO_KERNEL
571 b .
572
573EXC_REAL(data_access, 0x300, 0x80)
574EXC_VIRT(data_access, 0x4300, 0x80, 0x300)
575TRAMP_KVM_SKIP(PACA_EXGEN, 0x300)
576
577EXC_COMMON_BEGIN(data_access_common)
578
579
580
581
582
583 mfspr r10,SPRN_DAR
584 std r10,PACA_EXGEN+EX_DAR(r13)
585 mfspr r10,SPRN_DSISR
586 stw r10,PACA_EXGEN+EX_DSISR(r13)
587 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
588 RECONCILE_IRQ_STATE(r10, r11)
589 ld r12,_MSR(r1)
590 ld r3,PACA_EXGEN+EX_DAR(r13)
591 lwz r4,PACA_EXGEN+EX_DSISR(r13)
592 li r5,0x300
593 std r3,_DAR(r1)
594 std r4,_DSISR(r1)
595BEGIN_MMU_FTR_SECTION
596 b do_hash_page
597MMU_FTR_SECTION_ELSE
598 b handle_page_fault
599ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
600
601
602EXC_REAL_BEGIN(data_access_slb, 0x380, 0x80)
603 SET_SCRATCH0(r13)
604 EXCEPTION_PROLOG_0(PACA_EXSLB)
605 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380)
606 mr r12,r3
607 mfspr r3,SPRN_DAR
608 mfspr r11,SPRN_SRR1
609 crset 4*cr6+eq
610 BRANCH_TO_COMMON(r10, slb_miss_common)
611EXC_REAL_END(data_access_slb, 0x380, 0x80)
612
613EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80)
614 SET_SCRATCH0(r13)
615 EXCEPTION_PROLOG_0(PACA_EXSLB)
616 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
617 mr r12,r3
618 mfspr r3,SPRN_DAR
619 mfspr r11,SPRN_SRR1
620 crset 4*cr6+eq
621 BRANCH_TO_COMMON(r10, slb_miss_common)
622EXC_VIRT_END(data_access_slb, 0x4380, 0x80)
623TRAMP_KVM_SKIP(PACA_EXSLB, 0x380)
624
625
626EXC_REAL(instruction_access, 0x400, 0x80)
627EXC_VIRT(instruction_access, 0x4400, 0x80, 0x400)
628TRAMP_KVM(PACA_EXGEN, 0x400)
629
630EXC_COMMON_BEGIN(instruction_access_common)
631 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
632 RECONCILE_IRQ_STATE(r10, r11)
633 ld r12,_MSR(r1)
634 ld r3,_NIP(r1)
635 andis. r4,r12,DSISR_SRR1_MATCH_64S@h
636 li r5,0x400
637 std r3,_DAR(r1)
638 std r4,_DSISR(r1)
639BEGIN_MMU_FTR_SECTION
640 b do_hash_page
641MMU_FTR_SECTION_ELSE
642 b handle_page_fault
643ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
644
645
646EXC_REAL_BEGIN(instruction_access_slb, 0x480, 0x80)
647 SET_SCRATCH0(r13)
648 EXCEPTION_PROLOG_0(PACA_EXSLB)
649 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
650 mr r12,r3
651 mfspr r3,SPRN_SRR0
652 mfspr r11,SPRN_SRR1
653 crclr 4*cr6+eq
654 BRANCH_TO_COMMON(r10, slb_miss_common)
655EXC_REAL_END(instruction_access_slb, 0x480, 0x80)
656
657EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x80)
658 SET_SCRATCH0(r13)
659 EXCEPTION_PROLOG_0(PACA_EXSLB)
660 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480)
661 mr r12,r3
662 mfspr r3,SPRN_SRR0
663 mfspr r11,SPRN_SRR1
664 crclr 4*cr6+eq
665 BRANCH_TO_COMMON(r10, slb_miss_common)
666EXC_VIRT_END(instruction_access_slb, 0x4480, 0x80)
667TRAMP_KVM(PACA_EXSLB, 0x480)
668
669
670
671
672
673
674EXC_COMMON_BEGIN(slb_miss_common)
675
676
677
678
679
680
681
682
683
684
685 mflr r10
686 stw r9,PACA_EXSLB+EX_CCR(r13)
687 std r10,PACA_EXSLB+EX_LR(r13)
688
689 andi. r9,r11,MSR_PR
690 cmpdi cr4,r9,MSR_PR
691
692
693
694
695
696
697
698 andi. r11,r11,MSR_RI
699 cmpdi cr5,r11,MSR_RI
700
701 crset 4*cr0+eq
702#ifdef CONFIG_PPC_BOOK3S_64
703BEGIN_MMU_FTR_SECTION
704 bl slb_allocate
705END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX)
706#endif
707
708 ld r10,PACA_EXSLB+EX_LR(r13)
709 lwz r9,PACA_EXSLB+EX_CCR(r13)
710 mtlr r10
711
712
713
714
715 beq- 8f
716
717 bne- cr5,2f
718
719
720
721 bne cr4,1f
722
723 mtcrf 0x80,r9
724 mtcrf 0x08,r9
725 mtcrf 0x04,r9
726 mtcrf 0x02,r9
727 mtcrf 0x01,r9
728
729 RESTORE_CTR(r9, PACA_EXSLB)
730 RESTORE_PPR_PACA(PACA_EXSLB, r9)
731 mr r3,r12
732 ld r9,PACA_EXSLB+EX_R9(r13)
733 ld r10,PACA_EXSLB+EX_R10(r13)
734 ld r11,PACA_EXSLB+EX_R11(r13)
735 ld r12,PACA_EXSLB+EX_R12(r13)
736 ld r13,PACA_EXSLB+EX_R13(r13)
737 RFI_TO_USER
738 b .
7391:
740 mtcrf 0x80,r9
741 mtcrf 0x08,r9
742 mtcrf 0x04,r9
743 mtcrf 0x02,r9
744 mtcrf 0x01,r9
745
746 RESTORE_CTR(r9, PACA_EXSLB)
747 RESTORE_PPR_PACA(PACA_EXSLB, r9)
748 mr r3,r12
749 ld r9,PACA_EXSLB+EX_R9(r13)
750 ld r10,PACA_EXSLB+EX_R10(r13)
751 ld r11,PACA_EXSLB+EX_R11(r13)
752 ld r12,PACA_EXSLB+EX_R12(r13)
753 ld r13,PACA_EXSLB+EX_R13(r13)
754 RFI_TO_KERNEL
755 b .
756
757
7582: std r3,PACA_EXSLB+EX_DAR(r13)
759 mr r3,r12
760 mfspr r11,SPRN_SRR0
761 mfspr r12,SPRN_SRR1
762 LOAD_HANDLER(r10,unrecov_slb)
763 mtspr SPRN_SRR0,r10
764 ld r10,PACAKMSR(r13)
765 mtspr SPRN_SRR1,r10
766 RFI_TO_KERNEL
767 b .
768
7698: std r3,PACA_EXSLB+EX_DAR(r13)
770 mr r3,r12
771 mfspr r11,SPRN_SRR0
772 mfspr r12,SPRN_SRR1
773 LOAD_HANDLER(r10, large_addr_slb)
774 mtspr SPRN_SRR0,r10
775 ld r10,PACAKMSR(r13)
776 mtspr SPRN_SRR1,r10
777 RFI_TO_KERNEL
778 b .
779
780EXC_COMMON_BEGIN(unrecov_slb)
781 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
782 RECONCILE_IRQ_STATE(r10, r11)
783 bl save_nvgprs
7841: addi r3,r1,STACK_FRAME_OVERHEAD
785 bl unrecoverable_exception
786 b 1b
787
788EXC_COMMON_BEGIN(large_addr_slb)
789 EXCEPTION_PROLOG_COMMON(0x380, PACA_EXSLB)
790 RECONCILE_IRQ_STATE(r10, r11)
791 ld r3, PACA_EXSLB+EX_DAR(r13)
792 std r3, _DAR(r1)
793 beq cr6, 2f
794 li r10, 0x481
795 std r10, _TRAP(r1)
7962: bl save_nvgprs
797 addi r3, r1, STACK_FRAME_OVERHEAD
798 bl slb_miss_large_addr
799 b ret_from_except
800
801EXC_REAL_BEGIN(hardware_interrupt, 0x500, 0x100)
802 .globl hardware_interrupt_hv;
803hardware_interrupt_hv:
804 BEGIN_FTR_SECTION
805 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt_common,
806 EXC_HV, SOFTEN_TEST_HV,
807 IRQS_DISABLED)
808 FTR_SECTION_ELSE
809 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt_common,
810 EXC_STD, SOFTEN_TEST_PR,
811 IRQS_DISABLED)
812 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
813EXC_REAL_END(hardware_interrupt, 0x500, 0x100)
814
815EXC_VIRT_BEGIN(hardware_interrupt, 0x4500, 0x100)
816 .globl hardware_interrupt_relon_hv;
817hardware_interrupt_relon_hv:
818 BEGIN_FTR_SECTION
819 _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt_common,
820 EXC_HV, SOFTEN_TEST_HV,
821 IRQS_DISABLED)
822 FTR_SECTION_ELSE
823 _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt_common,
824 EXC_STD, SOFTEN_TEST_PR,
825 IRQS_DISABLED)
826 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
827EXC_VIRT_END(hardware_interrupt, 0x4500, 0x100)
828
829TRAMP_KVM(PACA_EXGEN, 0x500)
830TRAMP_KVM_HV(PACA_EXGEN, 0x500)
831EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ)
832
833
834EXC_REAL(alignment, 0x600, 0x100)
835EXC_VIRT(alignment, 0x4600, 0x100, 0x600)
836TRAMP_KVM(PACA_EXGEN, 0x600)
837EXC_COMMON_BEGIN(alignment_common)
838 mfspr r10,SPRN_DAR
839 std r10,PACA_EXGEN+EX_DAR(r13)
840 mfspr r10,SPRN_DSISR
841 stw r10,PACA_EXGEN+EX_DSISR(r13)
842 EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
843 ld r3,PACA_EXGEN+EX_DAR(r13)
844 lwz r4,PACA_EXGEN+EX_DSISR(r13)
845 std r3,_DAR(r1)
846 std r4,_DSISR(r1)
847 bl save_nvgprs
848 RECONCILE_IRQ_STATE(r10, r11)
849 addi r3,r1,STACK_FRAME_OVERHEAD
850 bl alignment_exception
851 b ret_from_except
852
853
854EXC_REAL(program_check, 0x700, 0x100)
855EXC_VIRT(program_check, 0x4700, 0x100, 0x700)
856TRAMP_KVM(PACA_EXGEN, 0x700)
857EXC_COMMON_BEGIN(program_check_common)
858
859
860
861
862
863
864
865
866 li r10,MSR_PR
867 oris r10,r10,0x200000@h
868 and r10,r10,r12
869 srdi r10,r10,8
870 cmpldi r10,(0x200000 >> 8)
871 bne 1f
872
873
874 andi. r10,r12,MSR_PR;
875
876 mr r10,r1
877 ld r1,PACAEMERGSP(r13)
878 subi r1,r1,INT_FRAME_SIZE
879 b 3f
8801: EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
881 bl save_nvgprs
882 RECONCILE_IRQ_STATE(r10, r11)
883 addi r3,r1,STACK_FRAME_OVERHEAD
884 bl program_check_exception
885 b ret_from_except
886
887
888EXC_REAL(fp_unavailable, 0x800, 0x100)
889EXC_VIRT(fp_unavailable, 0x4800, 0x100, 0x800)
890TRAMP_KVM(PACA_EXGEN, 0x800)
891EXC_COMMON_BEGIN(fp_unavailable_common)
892 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
893 bne 1f
894 bl save_nvgprs
895 RECONCILE_IRQ_STATE(r10, r11)
896 addi r3,r1,STACK_FRAME_OVERHEAD
897 bl kernel_fp_unavailable_exception
8980: trap
899 EMIT_BUG_ENTRY 0b, __FILE__, __LINE__, 0
9001:
901#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
902BEGIN_FTR_SECTION
903
904
905
906 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
907 bne- 2f
908END_FTR_SECTION_IFSET(CPU_FTR_TM)
909#endif
910 bl load_up_fpu
911 b fast_exception_return
912#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
9132:
914 bl save_nvgprs
915 RECONCILE_IRQ_STATE(r10, r11)
916 addi r3,r1,STACK_FRAME_OVERHEAD
917 bl fp_unavailable_tm
918 b ret_from_except
919#endif
920
921
922EXC_REAL_OOL_MASKABLE(decrementer, 0x900, 0x80, IRQS_DISABLED)
923EXC_VIRT_MASKABLE(decrementer, 0x4900, 0x80, 0x900, IRQS_DISABLED)
924TRAMP_KVM(PACA_EXGEN, 0x900)
925EXC_COMMON_ASYNC(decrementer_common, 0x900, timer_interrupt)
926
927
928EXC_REAL_HV(hdecrementer, 0x980, 0x80)
929EXC_VIRT_HV(hdecrementer, 0x4980, 0x80, 0x980)
930TRAMP_KVM_HV(PACA_EXGEN, 0x980)
931EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
932
933
934EXC_REAL_MASKABLE(doorbell_super, 0xa00, 0x100, IRQS_DISABLED)
935EXC_VIRT_MASKABLE(doorbell_super, 0x4a00, 0x100, 0xa00, IRQS_DISABLED)
936TRAMP_KVM(PACA_EXGEN, 0xa00)
937#ifdef CONFIG_PPC_DOORBELL
938EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, doorbell_exception)
939#else
940EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, unknown_exception)
941#endif
942
943
944EXC_REAL(trap_0b, 0xb00, 0x100)
945EXC_VIRT(trap_0b, 0x4b00, 0x100, 0xb00)
946TRAMP_KVM(PACA_EXGEN, 0xb00)
947EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
986
987
988
989
990
991
992
993
994#define SYSCALL_KVMTEST \
995 mtctr r13; \
996 GET_PACA(r13); \
997 std r10,PACA_EXGEN+EX_R10(r13); \
998 INTERRUPT_TO_KERNEL; \
999 KVMTEST_PR(0xc00); \
1000 HMT_MEDIUM; \
1001 mfctr r9;
1002
1003#else
1004#define SYSCALL_KVMTEST \
1005 HMT_MEDIUM; \
1006 mr r9,r13; \
1007 GET_PACA(r13); \
1008 INTERRUPT_TO_KERNEL;
1009#endif
1010
1011#define LOAD_SYSCALL_HANDLER(reg) \
1012 __LOAD_HANDLER(reg, system_call_common)
1013
1014
1015
1016
1017
1018#define SYSCALL_REAL \
1019 mfspr r11,SPRN_SRR0 ; \
1020 mfspr r12,SPRN_SRR1 ; \
1021 LOAD_SYSCALL_HANDLER(r10) ; \
1022 mtspr SPRN_SRR0,r10 ; \
1023 ld r10,PACAKMSR(r13) ; \
1024 mtspr SPRN_SRR1,r10 ; \
1025 RFI_TO_KERNEL ; \
1026 b . ;
1027
1028#ifdef CONFIG_PPC_FAST_ENDIAN_SWITCH
1029#define SYSCALL_FASTENDIAN_TEST \
1030BEGIN_FTR_SECTION \
1031 cmpdi r0,0x1ebe ; \
1032 beq- 1f ; \
1033END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
1034
1035#define SYSCALL_FASTENDIAN \
1036 \
10371: mfspr r12,SPRN_SRR1 ; \
1038 xori r12,r12,MSR_LE ; \
1039 mtspr SPRN_SRR1,r12 ; \
1040 mr r13,r9 ; \
1041 RFI_TO_USER ; \
1042 b . ;
1043#else
1044#define SYSCALL_FASTENDIAN_TEST
1045#define SYSCALL_FASTENDIAN
1046#endif
1047
1048
1049
1050
1051
1052
1053#define SYSCALL_VIRT \
1054 LOAD_SYSCALL_HANDLER(r10) ; \
1055 mtctr r10 ; \
1056 mfspr r11,SPRN_SRR0 ; \
1057 mfspr r12,SPRN_SRR1 ; \
1058 li r10,MSR_RI ; \
1059 mtmsrd r10,1 ; \
1060 bctr ;
1061#else
1062
1063#define SYSCALL_VIRT \
1064 mfspr r11,SPRN_SRR0 ; \
1065 mfspr r12,SPRN_SRR1 ; \
1066 li r10,MSR_RI ; \
1067 mtmsrd r10,1 ; \
1068 b system_call_common ;
1069#endif
1070
1071EXC_REAL_BEGIN(system_call, 0xc00, 0x100)
1072 SYSCALL_KVMTEST
1073 SYSCALL_FASTENDIAN_TEST
1074 SYSCALL_REAL
1075 SYSCALL_FASTENDIAN
1076EXC_REAL_END(system_call, 0xc00, 0x100)
1077
1078EXC_VIRT_BEGIN(system_call, 0x4c00, 0x100)
1079 SYSCALL_KVMTEST
1080 SYSCALL_FASTENDIAN_TEST
1081 SYSCALL_VIRT
1082 SYSCALL_FASTENDIAN
1083EXC_VIRT_END(system_call, 0x4c00, 0x100)
1084
1085#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
1086
1087
1088
1089
1090
1091
1092
1093TRAMP_KVM_BEGIN(do_kvm_0xc00)
1094
1095
1096
1097
1098
1099 OPT_GET_SPR(r10, SPRN_PPR, CPU_FTR_HAS_PPR)
1100 HMT_MEDIUM
1101 OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r10, CPU_FTR_HAS_PPR)
1102 mfctr r10
1103 SET_SCRATCH0(r10)
1104 std r9,PACA_EXGEN+EX_R9(r13)
1105 mfcr r9
1106 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
1107#endif
1108
1109
1110EXC_REAL(single_step, 0xd00, 0x100)
1111EXC_VIRT(single_step, 0x4d00, 0x100, 0xd00)
1112TRAMP_KVM(PACA_EXGEN, 0xd00)
1113EXC_COMMON(single_step_common, 0xd00, single_step_exception)
1114
1115EXC_REAL_OOL_HV(h_data_storage, 0xe00, 0x20)
1116EXC_VIRT_OOL_HV(h_data_storage, 0x4e00, 0x20, 0xe00)
1117TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0xe00)
1118EXC_COMMON_BEGIN(h_data_storage_common)
1119 mfspr r10,SPRN_HDAR
1120 std r10,PACA_EXGEN+EX_DAR(r13)
1121 mfspr r10,SPRN_HDSISR
1122 stw r10,PACA_EXGEN+EX_DSISR(r13)
1123 EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
1124 bl save_nvgprs
1125 RECONCILE_IRQ_STATE(r10, r11)
1126 addi r3,r1,STACK_FRAME_OVERHEAD
1127BEGIN_MMU_FTR_SECTION
1128 ld r4,PACA_EXGEN+EX_DAR(r13)
1129 lwz r5,PACA_EXGEN+EX_DSISR(r13)
1130 std r4,_DAR(r1)
1131 std r5,_DSISR(r1)
1132 li r5,SIGSEGV
1133 bl bad_page_fault
1134MMU_FTR_SECTION_ELSE
1135 bl unknown_exception
1136ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_TYPE_RADIX)
1137 b ret_from_except
1138
1139
1140EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0x20)
1141EXC_VIRT_OOL_HV(h_instr_storage, 0x4e20, 0x20, 0xe20)
1142TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
1143EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
1144
1145
1146EXC_REAL_OOL_HV(emulation_assist, 0xe40, 0x20)
1147EXC_VIRT_OOL_HV(emulation_assist, 0x4e40, 0x20, 0xe40)
1148TRAMP_KVM_HV(PACA_EXGEN, 0xe40)
1149EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
1150
1151
1152
1153
1154
1155
1156
1157__EXC_REAL_OOL_HV_DIRECT(hmi_exception, 0xe60, 0x20, hmi_exception_early)
1158__TRAMP_REAL_OOL_MASKABLE_HV(hmi_exception, 0xe60, IRQS_DISABLED)
1159EXC_VIRT_NONE(0x4e60, 0x20)
1160TRAMP_KVM_HV(PACA_EXGEN, 0xe60)
1161TRAMP_REAL_BEGIN(hmi_exception_early)
1162 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, 0xe60)
1163 mr r10,r1
1164 ld r1,PACAEMERGSP(r13)
1165 subi r1,r1,INT_FRAME_SIZE
1166 mfspr r11,SPRN_HSRR0
1167 mfspr r12,SPRN_HSRR1
1168 EXCEPTION_PROLOG_COMMON_1()
1169 EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
1170 EXCEPTION_PROLOG_COMMON_3(0xe60)
1171 addi r3,r1,STACK_FRAME_OVERHEAD
1172 BRANCH_LINK_TO_FAR(hmi_exception_realmode)
1173 cmpdi cr0,r3,0
1174
1175
1176
1177 ld r9,_MSR(r1)
1178 mtspr SPRN_HSRR1,r9
1179 ld r3,_NIP(r1)
1180 mtspr SPRN_HSRR0,r3
1181 ld r9,_CTR(r1)
1182 mtctr r9
1183 ld r9,_XER(r1)
1184 mtxer r9
1185 ld r9,_LINK(r1)
1186 mtlr r9
1187 REST_GPR(0, r1)
1188 REST_8GPRS(2, r1)
1189 REST_GPR(10, r1)
1190 ld r11,_CCR(r1)
1191 REST_2GPRS(12, r1)
1192 bne 1f
1193 mtcr r11
1194 REST_GPR(11, r1)
1195 ld r1,GPR1(r1)
1196 HRFI_TO_USER_OR_KERNEL
1197
11981: mtcr r11
1199 REST_GPR(11, r1)
1200 ld r1,GPR1(r1)
1201
1202
1203
1204
1205
1206 .globl hmi_exception_after_realmode
1207hmi_exception_after_realmode:
1208 SET_SCRATCH0(r13)
1209 EXCEPTION_PROLOG_0(PACA_EXGEN)
1210 b tramp_real_hmi_exception
1211
1212EXC_COMMON_BEGIN(hmi_exception_common)
1213EXCEPTION_COMMON(PACA_EXGEN, 0xe60, hmi_exception_common, handle_hmi_exception,
1214 ret_from_except, FINISH_NAP;ADD_NVGPRS;ADD_RECONCILE;RUNLATCH_ON)
1215
1216EXC_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80, 0x20, IRQS_DISABLED)
1217EXC_VIRT_OOL_MASKABLE_HV(h_doorbell, 0x4e80, 0x20, 0xe80, IRQS_DISABLED)
1218TRAMP_KVM_HV(PACA_EXGEN, 0xe80)
1219#ifdef CONFIG_PPC_DOORBELL
1220EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
1221#else
1222EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, unknown_exception)
1223#endif
1224
1225
1226EXC_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0, 0x20, IRQS_DISABLED)
1227EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x20, 0xea0, IRQS_DISABLED)
1228TRAMP_KVM_HV(PACA_EXGEN, 0xea0)
1229EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
1230
1231
1232EXC_REAL_NONE(0xec0, 0x20)
1233EXC_VIRT_NONE(0x4ec0, 0x20)
1234EXC_REAL_NONE(0xee0, 0x20)
1235EXC_VIRT_NONE(0x4ee0, 0x20)
1236
1237
1238EXC_REAL_OOL_MASKABLE(performance_monitor, 0xf00, 0x20, IRQS_PMI_DISABLED)
1239EXC_VIRT_OOL_MASKABLE(performance_monitor, 0x4f00, 0x20, 0xf00, IRQS_PMI_DISABLED)
1240TRAMP_KVM(PACA_EXGEN, 0xf00)
1241EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, performance_monitor_exception)
1242
1243
1244EXC_REAL_OOL(altivec_unavailable, 0xf20, 0x20)
1245EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x20, 0xf20)
1246TRAMP_KVM(PACA_EXGEN, 0xf20)
1247EXC_COMMON_BEGIN(altivec_unavailable_common)
1248 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
1249#ifdef CONFIG_ALTIVEC
1250BEGIN_FTR_SECTION
1251 beq 1f
1252#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1253 BEGIN_FTR_SECTION_NESTED(69)
1254
1255
1256
1257 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1258 bne- 2f
1259 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1260#endif
1261 bl load_up_altivec
1262 b fast_exception_return
1263#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
12642:
1265 bl save_nvgprs
1266 RECONCILE_IRQ_STATE(r10, r11)
1267 addi r3,r1,STACK_FRAME_OVERHEAD
1268 bl altivec_unavailable_tm
1269 b ret_from_except
1270#endif
12711:
1272END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1273#endif
1274 bl save_nvgprs
1275 RECONCILE_IRQ_STATE(r10, r11)
1276 addi r3,r1,STACK_FRAME_OVERHEAD
1277 bl altivec_unavailable_exception
1278 b ret_from_except
1279
1280
1281EXC_REAL_OOL(vsx_unavailable, 0xf40, 0x20)
1282EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x20, 0xf40)
1283TRAMP_KVM(PACA_EXGEN, 0xf40)
1284EXC_COMMON_BEGIN(vsx_unavailable_common)
1285 EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
1286#ifdef CONFIG_VSX
1287BEGIN_FTR_SECTION
1288 beq 1f
1289#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1290 BEGIN_FTR_SECTION_NESTED(69)
1291
1292
1293
1294 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1295 bne- 2f
1296 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1297#endif
1298 b load_up_vsx
1299#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
13002:
1301 bl save_nvgprs
1302 RECONCILE_IRQ_STATE(r10, r11)
1303 addi r3,r1,STACK_FRAME_OVERHEAD
1304 bl vsx_unavailable_tm
1305 b ret_from_except
1306#endif
13071:
1308END_FTR_SECTION_IFSET(CPU_FTR_VSX)
1309#endif
1310 bl save_nvgprs
1311 RECONCILE_IRQ_STATE(r10, r11)
1312 addi r3,r1,STACK_FRAME_OVERHEAD
1313 bl vsx_unavailable_exception
1314 b ret_from_except
1315
1316
1317EXC_REAL_OOL(facility_unavailable, 0xf60, 0x20)
1318EXC_VIRT_OOL(facility_unavailable, 0x4f60, 0x20, 0xf60)
1319TRAMP_KVM(PACA_EXGEN, 0xf60)
1320EXC_COMMON(facility_unavailable_common, 0xf60, facility_unavailable_exception)
1321
1322
1323EXC_REAL_OOL_HV(h_facility_unavailable, 0xf80, 0x20)
1324EXC_VIRT_OOL_HV(h_facility_unavailable, 0x4f80, 0x20, 0xf80)
1325TRAMP_KVM_HV(PACA_EXGEN, 0xf80)
1326EXC_COMMON(h_facility_unavailable_common, 0xf80, facility_unavailable_exception)
1327
1328
1329EXC_REAL_NONE(0xfa0, 0x20)
1330EXC_VIRT_NONE(0x4fa0, 0x20)
1331EXC_REAL_NONE(0xfc0, 0x20)
1332EXC_VIRT_NONE(0x4fc0, 0x20)
1333EXC_REAL_NONE(0xfe0, 0x20)
1334EXC_VIRT_NONE(0x4fe0, 0x20)
1335
1336EXC_REAL_NONE(0x1000, 0x100)
1337EXC_VIRT_NONE(0x5000, 0x100)
1338EXC_REAL_NONE(0x1100, 0x100)
1339EXC_VIRT_NONE(0x5100, 0x100)
1340
1341#ifdef CONFIG_CBE_RAS
1342EXC_REAL_HV(cbe_system_error, 0x1200, 0x100)
1343EXC_VIRT_NONE(0x5200, 0x100)
1344TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1200)
1345EXC_COMMON(cbe_system_error_common, 0x1200, cbe_system_error_exception)
1346#else
1347EXC_REAL_NONE(0x1200, 0x100)
1348EXC_VIRT_NONE(0x5200, 0x100)
1349#endif
1350
1351
1352EXC_REAL(instruction_breakpoint, 0x1300, 0x100)
1353EXC_VIRT(instruction_breakpoint, 0x5300, 0x100, 0x1300)
1354TRAMP_KVM_SKIP(PACA_EXGEN, 0x1300)
1355EXC_COMMON(instruction_breakpoint_common, 0x1300, instruction_breakpoint_exception)
1356
1357EXC_REAL_NONE(0x1400, 0x100)
1358EXC_VIRT_NONE(0x5400, 0x100)
1359
1360EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x100)
1361 mtspr SPRN_SPRG_HSCRATCH0,r13
1362 EXCEPTION_PROLOG_0(PACA_EXGEN)
1363 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500)
1364
1365#ifdef CONFIG_PPC_DENORMALISATION
1366 mfspr r10,SPRN_HSRR1
1367 andis. r10,r10,(HSRR1_DENORM)@h
1368 bne+ denorm_assist
1369#endif
1370
1371 KVMTEST_HV(0x1500)
1372 EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV)
1373EXC_REAL_END(denorm_exception_hv, 0x1500, 0x100)
1374
1375#ifdef CONFIG_PPC_DENORMALISATION
1376EXC_VIRT_BEGIN(denorm_exception, 0x5500, 0x100)
1377 b exc_real_0x1500_denorm_exception_hv
1378EXC_VIRT_END(denorm_exception, 0x5500, 0x100)
1379#else
1380EXC_VIRT_NONE(0x5500, 0x100)
1381#endif
1382
1383TRAMP_KVM_HV(PACA_EXGEN, 0x1500)
1384
1385#ifdef CONFIG_PPC_DENORMALISATION
1386TRAMP_REAL_BEGIN(denorm_assist)
1387BEGIN_FTR_SECTION
1388
1389
1390
1391
1392 mfmsr r10
1393 ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1)
1394 xori r10,r10,(MSR_FE0|MSR_FE1)
1395 mtmsrd r10
1396 sync
1397
1398#define FMR2(n) fmr (n), (n) ; fmr n+1, n+1
1399#define FMR4(n) FMR2(n) ; FMR2(n+2)
1400#define FMR8(n) FMR4(n) ; FMR4(n+4)
1401#define FMR16(n) FMR8(n) ; FMR8(n+8)
1402#define FMR32(n) FMR16(n) ; FMR16(n+16)
1403 FMR32(0)
1404
1405FTR_SECTION_ELSE
1406
1407
1408
1409
1410 mfmsr r10
1411 oris r10,r10,MSR_VSX@h
1412 mtmsrd r10
1413 sync
1414
1415#define XVCPSGNDP2(n) XVCPSGNDP(n,n,n) ; XVCPSGNDP(n+1,n+1,n+1)
1416#define XVCPSGNDP4(n) XVCPSGNDP2(n) ; XVCPSGNDP2(n+2)
1417#define XVCPSGNDP8(n) XVCPSGNDP4(n) ; XVCPSGNDP4(n+4)
1418#define XVCPSGNDP16(n) XVCPSGNDP8(n) ; XVCPSGNDP8(n+8)
1419#define XVCPSGNDP32(n) XVCPSGNDP16(n) ; XVCPSGNDP16(n+16)
1420 XVCPSGNDP32(0)
1421
1422ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206)
1423
1424BEGIN_FTR_SECTION
1425 b denorm_done
1426END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
1427
1428
1429
1430
1431 XVCPSGNDP32(32)
1432denorm_done:
1433 mfspr r11,SPRN_HSRR0
1434 subi r11,r11,4
1435 mtspr SPRN_HSRR0,r11
1436 mtcrf 0x80,r9
1437 ld r9,PACA_EXGEN+EX_R9(r13)
1438 RESTORE_PPR_PACA(PACA_EXGEN, r10)
1439BEGIN_FTR_SECTION
1440 ld r10,PACA_EXGEN+EX_CFAR(r13)
1441 mtspr SPRN_CFAR,r10
1442END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
1443 ld r10,PACA_EXGEN+EX_R10(r13)
1444 ld r11,PACA_EXGEN+EX_R11(r13)
1445 ld r12,PACA_EXGEN+EX_R12(r13)
1446 ld r13,PACA_EXGEN+EX_R13(r13)
1447 HRFI_TO_UNKNOWN
1448 b .
1449#endif
1450
1451EXC_COMMON(denorm_common, 0x1500, unknown_exception)
1452
1453
1454#ifdef CONFIG_CBE_RAS
1455EXC_REAL_HV(cbe_maintenance, 0x1600, 0x100)
1456EXC_VIRT_NONE(0x5600, 0x100)
1457TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1600)
1458EXC_COMMON(cbe_maintenance_common, 0x1600, cbe_maintenance_exception)
1459#else
1460EXC_REAL_NONE(0x1600, 0x100)
1461EXC_VIRT_NONE(0x5600, 0x100)
1462#endif
1463
1464
1465EXC_REAL(altivec_assist, 0x1700, 0x100)
1466EXC_VIRT(altivec_assist, 0x5700, 0x100, 0x1700)
1467TRAMP_KVM(PACA_EXGEN, 0x1700)
1468#ifdef CONFIG_ALTIVEC
1469EXC_COMMON(altivec_assist_common, 0x1700, altivec_assist_exception)
1470#else
1471EXC_COMMON(altivec_assist_common, 0x1700, unknown_exception)
1472#endif
1473
1474
1475#ifdef CONFIG_CBE_RAS
1476EXC_REAL_HV(cbe_thermal, 0x1800, 0x100)
1477EXC_VIRT_NONE(0x5800, 0x100)
1478TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1800)
1479EXC_COMMON(cbe_thermal_common, 0x1800, cbe_thermal_exception)
1480#else
1481EXC_REAL_NONE(0x1800, 0x100)
1482EXC_VIRT_NONE(0x5800, 0x100)
1483#endif
1484
1485#ifdef CONFIG_PPC_WATCHDOG
1486
1487#define MASKED_DEC_HANDLER_LABEL 3f
1488
1489#define MASKED_DEC_HANDLER(_H) \
14903: \
1491 std r12,PACA_EXGEN+EX_R12(r13); \
1492 GET_SCRATCH0(r10); \
1493 std r10,PACA_EXGEN+EX_R13(r13); \
1494 EXCEPTION_PROLOG_PSERIES_1(soft_nmi_common, _H)
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505EXC_COMMON_BEGIN(soft_nmi_common)
1506 mr r10,r1
1507 ld r1,PACAEMERGSP(r13)
1508 subi r1,r1,INT_FRAME_SIZE
1509 EXCEPTION_COMMON_NORET_STACK(PACA_EXGEN, 0x900,
1510 system_reset, soft_nmi_interrupt,
1511 ADD_NVGPRS;ADD_RECONCILE)
1512 b ret_from_except
1513
1514#else
1515#define MASKED_DEC_HANDLER_LABEL 2f
1516#define MASKED_DEC_HANDLER(_H)
1517#endif
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529#define MASKED_INTERRUPT(_H) \
1530masked_
1531 std r11,PACA_EXGEN+EX_R11(r13); \
1532 lbz r11,PACAIRQHAPPENED(r13); \
1533 or r11,r11,r10; \
1534 stb r11,PACAIRQHAPPENED(r13); \
1535 cmpwi r10,PACA_IRQ_DEC; \
1536 bne 1f; \
1537 lis r10,0x7fff; \
1538 ori r10,r10,0xffff; \
1539 mtspr SPRN_DEC,r10; \
1540 b MASKED_DEC_HANDLER_LABEL; \
15411: andi. r10,r10,PACA_IRQ_MUST_HARD_MASK; \
1542 beq 2f; \
1543 mfspr r10,SPRN_
1544 xori r10,r10,MSR_EE; \
1545 mtspr SPRN_
15462: mtcrf 0x80,r9; \
1547 std r1,PACAR1(r13); \
1548 ld r9,PACA_EXGEN+EX_R9(r13); \
1549 ld r10,PACA_EXGEN+EX_R10(r13); \
1550 ld r11,PACA_EXGEN+EX_R11(r13); \
1551 \
1552
1553 b .; \
1554 MASKED_DEC_HANDLER(_H)
1555
1556TRAMP_REAL_BEGIN(stf_barrier_fallback)
1557 std r9,PACA_EXRFI+EX_R9(r13)
1558 std r10,PACA_EXRFI+EX_R10(r13)
1559 sync
1560 ld r9,PACA_EXRFI+EX_R9(r13)
1561 ld r10,PACA_EXRFI+EX_R10(r13)
1562 ori 31,31,0
1563 .rept 14
1564 b 1f
15651:
1566 .endr
1567 blr
1568
1569TRAMP_REAL_BEGIN(rfi_flush_fallback)
1570 SET_SCRATCH0(r13);
1571 GET_PACA(r13);
1572 std r9,PACA_EXRFI+EX_R9(r13)
1573 std r10,PACA_EXRFI+EX_R10(r13)
1574 std r11,PACA_EXRFI+EX_R11(r13)
1575 mfctr r9
1576 ld r10,PACA_RFI_FLUSH_FALLBACK_AREA(r13)
1577 ld r11,PACA_L1D_FLUSH_SIZE(r13)
1578 srdi r11,r11,(7 + 3)
1579 mtctr r11
1580 DCBT_BOOK3S_STOP_ALL_STREAM_IDS(r11)
1581
1582
1583 sync
1584
1585
1586
1587
1588
1589
15901:
1591 ld r11,(0x80 + 8)*0(r10)
1592 ld r11,(0x80 + 8)*1(r10)
1593 ld r11,(0x80 + 8)*2(r10)
1594 ld r11,(0x80 + 8)*3(r10)
1595 ld r11,(0x80 + 8)*4(r10)
1596 ld r11,(0x80 + 8)*5(r10)
1597 ld r11,(0x80 + 8)*6(r10)
1598 ld r11,(0x80 + 8)*7(r10)
1599 addi r10,r10,0x80*8
1600 bdnz 1b
1601
1602 mtctr r9
1603 ld r9,PACA_EXRFI+EX_R9(r13)
1604 ld r10,PACA_EXRFI+EX_R10(r13)
1605 ld r11,PACA_EXRFI+EX_R11(r13)
1606 GET_SCRATCH0(r13);
1607 rfid
1608
1609TRAMP_REAL_BEGIN(hrfi_flush_fallback)
1610 SET_SCRATCH0(r13);
1611 GET_PACA(r13);
1612 std r9,PACA_EXRFI+EX_R9(r13)
1613 std r10,PACA_EXRFI+EX_R10(r13)
1614 std r11,PACA_EXRFI+EX_R11(r13)
1615 mfctr r9
1616 ld r10,PACA_RFI_FLUSH_FALLBACK_AREA(r13)
1617 ld r11,PACA_L1D_FLUSH_SIZE(r13)
1618 srdi r11,r11,(7 + 3)
1619 mtctr r11
1620 DCBT_BOOK3S_STOP_ALL_STREAM_IDS(r11)
1621
1622
1623 sync
1624
1625
1626
1627
1628
1629
16301:
1631 ld r11,(0x80 + 8)*0(r10)
1632 ld r11,(0x80 + 8)*1(r10)
1633 ld r11,(0x80 + 8)*2(r10)
1634 ld r11,(0x80 + 8)*3(r10)
1635 ld r11,(0x80 + 8)*4(r10)
1636 ld r11,(0x80 + 8)*5(r10)
1637 ld r11,(0x80 + 8)*6(r10)
1638 ld r11,(0x80 + 8)*7(r10)
1639 addi r10,r10,0x80*8
1640 bdnz 1b
1641
1642 mtctr r9
1643 ld r9,PACA_EXRFI+EX_R9(r13)
1644 ld r10,PACA_EXRFI+EX_R10(r13)
1645 ld r11,PACA_EXRFI+EX_R11(r13)
1646 GET_SCRATCH0(r13);
1647 hrfid
1648
1649
1650
1651
1652
1653
1654USE_FIXED_SECTION(virt_trampolines)
1655 MASKED_INTERRUPT()
1656 MASKED_INTERRUPT(H)
1657
1658#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
1659TRAMP_REAL_BEGIN(kvmppc_skip_interrupt)
1660
1661
1662
1663
1664 mfspr r13, SPRN_SRR0
1665 addi r13, r13, 4
1666 mtspr SPRN_SRR0, r13
1667 GET_SCRATCH0(r13)
1668 RFI_TO_KERNEL
1669 b .
1670
1671TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
1672
1673
1674
1675
1676 mfspr r13, SPRN_HSRR0
1677 addi r13, r13, 4
1678 mtspr SPRN_HSRR0, r13
1679 GET_SCRATCH0(r13)
1680 HRFI_TO_KERNEL
1681 b .
1682#endif
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
1711 b __ppc64_runlatch_on
1712
1713USE_FIXED_SECTION(virt_trampolines)
1714
1715
1716
1717
1718
1719
1720
1721 .align 7
1722 .globl __end_interrupts
1723__end_interrupts:
1724DEFINE_FIXED_SYMBOL(__end_interrupts)
1725
1726#ifdef CONFIG_PPC_970_NAP
1727EXC_COMMON_BEGIN(power4_fixup_nap)
1728 andc r9,r9,r10
1729 std r9,TI_LOCAL_FLAGS(r11)
1730 ld r10,_LINK(r1)
1731 std r10,_NIP(r1)
1732 blr
1733#endif
1734
1735CLOSE_FIXED_SECTION(real_vectors);
1736CLOSE_FIXED_SECTION(real_trampolines);
1737CLOSE_FIXED_SECTION(virt_vectors);
1738CLOSE_FIXED_SECTION(virt_trampolines);
1739
1740USE_TEXT_SECTION()
1741
1742
1743
1744
1745 .balign IFETCH_ALIGN_BYTES
1746do_hash_page:
1747#ifdef CONFIG_PPC_BOOK3S_64
1748 lis r0,(DSISR_BAD_FAULT_64S | DSISR_DABRMATCH | DSISR_KEYFAULT)@h
1749 ori r0,r0,DSISR_BAD_FAULT_64S@l
1750 and. r0,r4,r0
1751 bne- handle_page_fault
1752 CURRENT_THREAD_INFO(r11, r1)
1753 lwz r0,TI_PREEMPT(r11)
1754 andis. r0,r0,NMI_MASK@h
1755 bne 77f
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765 mr r4,r12
1766 ld r6,_DSISR(r1)
1767 bl __hash_page
1768 cmpdi r3,0
1769
1770
1771 beq fast_exc_return_irq
1772
1773
1774 blt- 13f
1775
1776
1777 ld r4,_DSISR(r1)
1778#endif
1779
1780
1781handle_page_fault:
178211: andis. r0,r4,DSISR_DABRMATCH@h
1783 bne- handle_dabr_fault
1784 ld r4,_DAR(r1)
1785 ld r5,_DSISR(r1)
1786 addi r3,r1,STACK_FRAME_OVERHEAD
1787 bl do_page_fault
1788 cmpdi r3,0
1789 beq+ ret_from_except_lite
1790 bl save_nvgprs
1791 mr r5,r3
1792 addi r3,r1,STACK_FRAME_OVERHEAD
1793 lwz r4,_DAR(r1)
1794 bl bad_page_fault
1795 b ret_from_except
1796
1797
1798handle_dabr_fault:
1799 bl save_nvgprs
1800 ld r4,_DAR(r1)
1801 ld r5,_DSISR(r1)
1802 addi r3,r1,STACK_FRAME_OVERHEAD
1803 bl do_break
1804
1805
1806
1807
1808
1809 b ret_from_except
1810
1811
1812#ifdef CONFIG_PPC_BOOK3S_64
1813
1814
1815
181613: bl save_nvgprs
1817 mr r5,r3
1818 addi r3,r1,STACK_FRAME_OVERHEAD
1819 ld r4,_DAR(r1)
1820 bl low_hash_fault
1821 b ret_from_except
1822#endif
1823
1824
1825
1826
1827
1828
1829
1830
183177: bl save_nvgprs
1832 mr r4,r3
1833 addi r3,r1,STACK_FRAME_OVERHEAD
1834 li r5,SIGSEGV
1835 bl bad_page_fault
1836 b ret_from_except
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846bad_stack:
1847 ld r1,PACAEMERGSP(r13)
1848 subi r1,r1,64+INT_FRAME_SIZE
1849 std r9,_CCR(r1)
1850 std r10,GPR1(r1)
1851 std r11,_NIP(r1)
1852 std r12,_MSR(r1)
1853 mfspr r11,SPRN_DAR
1854 mfspr r12,SPRN_DSISR
1855 std r11,_DAR(r1)
1856 std r12,_DSISR(r1)
1857 mflr r10
1858 mfctr r11
1859 mfxer r12
1860 std r10,_LINK(r1)
1861 std r11,_CTR(r1)
1862 std r12,_XER(r1)
1863 SAVE_GPR(0,r1)
1864 SAVE_GPR(2,r1)
1865 ld r10,EX_R3(r3)
1866 std r10,GPR3(r1)
1867 SAVE_GPR(4,r1)
1868 SAVE_4GPRS(5,r1)
1869 ld r9,EX_R9(r3)
1870 ld r10,EX_R10(r3)
1871 SAVE_2GPRS(9,r1)
1872 ld r9,EX_R11(r3)
1873 ld r10,EX_R12(r3)
1874 ld r11,EX_R13(r3)
1875 std r9,GPR11(r1)
1876 std r10,GPR12(r1)
1877 std r11,GPR13(r1)
1878BEGIN_FTR_SECTION
1879 ld r10,EX_CFAR(r3)
1880 std r10,ORIG_GPR3(r1)
1881END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
1882 SAVE_8GPRS(14,r1)
1883 SAVE_10GPRS(22,r1)
1884 lhz r12,PACA_TRAP_SAVE(r13)
1885 std r12,_TRAP(r1)
1886 addi r11,r1,INT_FRAME_SIZE
1887 std r11,0(r1)
1888 li r12,0
1889 std r12,0(r11)
1890 ld r2,PACATOC(r13)
1891 ld r11,exception_marker@toc(r2)
1892 std r12,RESULT(r1)
1893 std r11,STACK_FRAME_OVERHEAD-16(r1)
18941: addi r3,r1,STACK_FRAME_OVERHEAD
1895 bl kernel_bad_stack
1896 b 1b
1897_ASM_NOKPROBE_SYMBOL(bad_stack);
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908h_doorbell_common_msgclr:
1909 LOAD_REG_IMMEDIATE(r3, PPC_DBELL_MSGTYPE << (63-36))
1910 PPC_MSGCLR(3)
1911 b h_doorbell_common
1912
1913doorbell_super_common_msgclr:
1914 LOAD_REG_IMMEDIATE(r3, PPC_DBELL_MSGTYPE << (63-36))
1915 PPC_MSGCLRP(3)
1916 b doorbell_super_common
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932_GLOBAL(__replay_interrupt)
1933
1934
1935
1936
1937 mfmsr r12
1938 LOAD_REG_ADDR(r11, replay_interrupt_return)
1939 mfcr r9
1940 ori r12,r12,MSR_EE
1941 cmpwi r3,0x900
1942 beq decrementer_common
1943 cmpwi r3,0x500
1944BEGIN_FTR_SECTION
1945 beq h_virt_irq_common
1946FTR_SECTION_ELSE
1947 beq hardware_interrupt_common
1948ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_300)
1949 cmpwi r3,0xf00
1950 beq performance_monitor_common
1951BEGIN_FTR_SECTION
1952 cmpwi r3,0xa00
1953 beq h_doorbell_common_msgclr
1954 cmpwi r3,0xe60
1955 beq hmi_exception_common
1956FTR_SECTION_ELSE
1957 cmpwi r3,0xa00
1958 beq doorbell_super_common_msgclr
1959ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
1960replay_interrupt_return:
1961 blr
1962
1963_ASM_NOKPROBE_SYMBOL(__replay_interrupt)
1964