aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/exceptions-64s.S
diff options
context:
space:
mode:
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>2013-12-09 14:10:15 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-12-29 22:16:30 -0500
commit4e243b79b0002cd57cf894ddcfb8d4eb51078041 (patch)
tree391d3ccdf86c156ad050119cf0902646291735d3 /arch/powerpc/kernel/exceptions-64s.S
parent75eb3d9b60c280a275099fbed06a890cee2d784b (diff)
powerpc: Fix "attempt to move .org backwards" error
With recent machine check patch series changes, The exception vectors starting from 0x4300 are now overflowing with allyesconfig. Fix that by moving machine_check_common and machine_check_handle_early code out of that region to make enough room for exception vector area. Fixes this build error reportes by Stephen: arch/powerpc/kernel/exceptions-64s.S: Assembler messages: arch/powerpc/kernel/exceptions-64s.S:958: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:959: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:983: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:984: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:1003: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:1013: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:1014: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:1015: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:1016: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:1017: Error: attempt to move .org backwards arch/powerpc/kernel/exceptions-64s.S:1018: Error: attempt to move .org backwards [Moved the code further down as it introduced link errors due to too long relative branches to the masked interrupts handlers from the exception prologs. Also removed the useless feature section --BenH ] Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Tested-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/exceptions-64s.S')
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S278
1 files changed, 138 insertions, 140 deletions
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 862b9dd4a9db..38d507306a11 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -768,146 +768,6 @@ kvmppc_skip_Hinterrupt:
768 768
769 STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception) 769 STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception)
770 770
771 /*
772 * Machine check is different because we use a different
773 * save area: PACA_EXMC instead of PACA_EXGEN.
774 */
775 .align 7
776 .globl machine_check_common
777machine_check_common:
778
779 mfspr r10,SPRN_DAR
780 std r10,PACA_EXGEN+EX_DAR(r13)
781 mfspr r10,SPRN_DSISR
782 stw r10,PACA_EXGEN+EX_DSISR(r13)
783 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
784 FINISH_NAP
785 DISABLE_INTS
786 ld r3,PACA_EXGEN+EX_DAR(r13)
787 lwz r4,PACA_EXGEN+EX_DSISR(r13)
788 std r3,_DAR(r1)
789 std r4,_DSISR(r1)
790 bl .save_nvgprs
791 addi r3,r1,STACK_FRAME_OVERHEAD
792 bl .machine_check_exception
793 b .ret_from_except
794
795#define MACHINE_CHECK_HANDLER_WINDUP \
796 /* Clear MSR_RI before setting SRR0 and SRR1. */\
797 li r0,MSR_RI; \
798 mfmsr r9; /* get MSR value */ \
799 andc r9,r9,r0; \
800 mtmsrd r9,1; /* Clear MSR_RI */ \
801 /* Move original SRR0 and SRR1 into the respective regs */ \
802 ld r9,_MSR(r1); \
803 mtspr SPRN_SRR1,r9; \
804 ld r3,_NIP(r1); \
805 mtspr SPRN_SRR0,r3; \
806 ld r9,_CTR(r1); \
807 mtctr r9; \
808 ld r9,_XER(r1); \
809 mtxer r9; \
810 ld r9,_LINK(r1); \
811 mtlr r9; \
812 REST_GPR(0, r1); \
813 REST_8GPRS(2, r1); \
814 REST_GPR(10, r1); \
815 ld r11,_CCR(r1); \
816 mtcr r11; \
817 /* Decrement paca->in_mce. */ \
818 lhz r12,PACA_IN_MCE(r13); \
819 subi r12,r12,1; \
820 sth r12,PACA_IN_MCE(r13); \
821 REST_GPR(11, r1); \
822 REST_2GPRS(12, r1); \
823 /* restore original r1. */ \
824 ld r1,GPR1(r1)
825
826 /*
827 * Handle machine check early in real mode. We come here with
828 * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack.
829 */
830 .align 7
831 .globl machine_check_handle_early
832machine_check_handle_early:
833BEGIN_FTR_SECTION
834 std r0,GPR0(r1) /* Save r0 */
835 EXCEPTION_PROLOG_COMMON_3(0x200)
836 bl .save_nvgprs
837 addi r3,r1,STACK_FRAME_OVERHEAD
838 bl .machine_check_early
839 ld r12,_MSR(r1)
840#ifdef CONFIG_PPC_P7_NAP
841 /*
842 * Check if thread was in power saving mode. We come here when any
843 * of the following is true:
844 * a. thread wasn't in power saving mode
845 * b. thread was in power saving mode with no state loss or
846 * supervisor state loss
847 *
848 * Go back to nap again if (b) is true.
849 */
850 rlwinm. r11,r12,47-31,30,31 /* Was it in power saving mode? */
851 beq 4f /* No, it wasn;t */
852 /* Thread was in power saving mode. Go back to nap again. */
853 cmpwi r11,2
854 bne 3f
855 /* Supervisor state loss */
856 li r0,1
857 stb r0,PACA_NAPSTATELOST(r13)
8583: bl .machine_check_queue_event
859 MACHINE_CHECK_HANDLER_WINDUP
860 GET_PACA(r13)
861 ld r1,PACAR1(r13)
862 b .power7_enter_nap_mode
8634:
864#endif
865 /*
866 * Check if we are coming from hypervisor userspace. If yes then we
867 * continue in host kernel in V mode to deliver the MC event.
868 */
869 rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */
870 beq 5f
871 andi. r11,r12,MSR_PR /* See if coming from user. */
872 bne 9f /* continue in V mode if we are. */
873
8745:
875#ifdef CONFIG_KVM_BOOK3S_64_HV
876 /*
877 * We are coming from kernel context. Check if we are coming from
878 * guest. if yes, then we can continue. We will fall through
879 * do_kvm_200->kvmppc_interrupt to deliver the MC event to guest.
880 */
881 lbz r11,HSTATE_IN_GUEST(r13)
882 cmpwi r11,0 /* Check if coming from guest */
883 bne 9f /* continue if we are. */
884#endif
885 /*
886 * At this point we are not sure about what context we come from.
887 * Queue up the MCE event and return from the interrupt.
888 * But before that, check if this is an un-recoverable exception.
889 * If yes, then stay on emergency stack and panic.
890 */
891 andi. r11,r12,MSR_RI
892 bne 2f
8931: addi r3,r1,STACK_FRAME_OVERHEAD
894 bl .unrecoverable_exception
895 b 1b
8962:
897 /*
898 * Return from MC interrupt.
899 * Queue up the MCE event so that we can log it later, while
900 * returning from kernel or opal call.
901 */
902 bl .machine_check_queue_event
903 MACHINE_CHECK_HANDLER_WINDUP
904 rfid
9059:
906 /* Deliver the machine check to host kernel in V mode. */
907 MACHINE_CHECK_HANDLER_WINDUP
908 b machine_check_pSeries
909END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
910
911 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ) 771 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ)
912 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt) 772 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt)
913 STD_EXCEPTION_COMMON(0x980, hdecrementer, .hdec_interrupt) 773 STD_EXCEPTION_COMMON(0x980, hdecrementer, .hdec_interrupt)
@@ -1276,6 +1136,30 @@ unrecov_user_slb:
1276#endif /* __DISABLED__ */ 1136#endif /* __DISABLED__ */
1277 1137
1278 1138
1139 /*
1140 * Machine check is different because we use a different
1141 * save area: PACA_EXMC instead of PACA_EXGEN.
1142 */
1143 .align 7
1144 .globl machine_check_common
1145machine_check_common:
1146
1147 mfspr r10,SPRN_DAR
1148 std r10,PACA_EXGEN+EX_DAR(r13)
1149 mfspr r10,SPRN_DSISR
1150 stw r10,PACA_EXGEN+EX_DSISR(r13)
1151 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
1152 FINISH_NAP
1153 DISABLE_INTS
1154 ld r3,PACA_EXGEN+EX_DAR(r13)
1155 lwz r4,PACA_EXGEN+EX_DSISR(r13)
1156 std r3,_DAR(r1)
1157 std r4,_DSISR(r1)
1158 bl .save_nvgprs
1159 addi r3,r1,STACK_FRAME_OVERHEAD
1160 bl .machine_check_exception
1161 b .ret_from_except
1162
1279 .align 7 1163 .align 7
1280 .globl alignment_common 1164 .globl alignment_common
1281alignment_common: 1165alignment_common:
@@ -1459,6 +1343,120 @@ _GLOBAL(opal_mc_secondary_handler)
1459#endif /* CONFIG_PPC_POWERNV */ 1343#endif /* CONFIG_PPC_POWERNV */
1460 1344
1461 1345
1346#define MACHINE_CHECK_HANDLER_WINDUP \
1347 /* Clear MSR_RI before setting SRR0 and SRR1. */\
1348 li r0,MSR_RI; \
1349 mfmsr r9; /* get MSR value */ \
1350 andc r9,r9,r0; \
1351 mtmsrd r9,1; /* Clear MSR_RI */ \
1352 /* Move original SRR0 and SRR1 into the respective regs */ \
1353 ld r9,_MSR(r1); \
1354 mtspr SPRN_SRR1,r9; \
1355 ld r3,_NIP(r1); \
1356 mtspr SPRN_SRR0,r3; \
1357 ld r9,_CTR(r1); \
1358 mtctr r9; \
1359 ld r9,_XER(r1); \
1360 mtxer r9; \
1361 ld r9,_LINK(r1); \
1362 mtlr r9; \
1363 REST_GPR(0, r1); \
1364 REST_8GPRS(2, r1); \
1365 REST_GPR(10, r1); \
1366 ld r11,_CCR(r1); \
1367 mtcr r11; \
1368 /* Decrement paca->in_mce. */ \
1369 lhz r12,PACA_IN_MCE(r13); \
1370 subi r12,r12,1; \
1371 sth r12,PACA_IN_MCE(r13); \
1372 REST_GPR(11, r1); \
1373 REST_2GPRS(12, r1); \
1374 /* restore original r1. */ \
1375 ld r1,GPR1(r1)
1376
1377 /*
1378 * Handle machine check early in real mode. We come here with
1379 * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack.
1380 */
1381 .align 7
1382 .globl machine_check_handle_early
1383machine_check_handle_early:
1384 std r0,GPR0(r1) /* Save r0 */
1385 EXCEPTION_PROLOG_COMMON_3(0x200)
1386 bl .save_nvgprs
1387 addi r3,r1,STACK_FRAME_OVERHEAD
1388 bl .machine_check_early
1389 ld r12,_MSR(r1)
1390#ifdef CONFIG_PPC_P7_NAP
1391 /*
1392 * Check if thread was in power saving mode. We come here when any
1393 * of the following is true:
1394 * a. thread wasn't in power saving mode
1395 * b. thread was in power saving mode with no state loss or
1396 * supervisor state loss
1397 *
1398 * Go back to nap again if (b) is true.
1399 */
1400 rlwinm. r11,r12,47-31,30,31 /* Was it in power saving mode? */
1401 beq 4f /* No, it wasn;t */
1402 /* Thread was in power saving mode. Go back to nap again. */
1403 cmpwi r11,2
1404 bne 3f
1405 /* Supervisor state loss */
1406 li r0,1
1407 stb r0,PACA_NAPSTATELOST(r13)
14083: bl .machine_check_queue_event
1409 MACHINE_CHECK_HANDLER_WINDUP
1410 GET_PACA(r13)
1411 ld r1,PACAR1(r13)
1412 b .power7_enter_nap_mode
14134:
1414#endif
1415 /*
1416 * Check if we are coming from hypervisor userspace. If yes then we
1417 * continue in host kernel in V mode to deliver the MC event.
1418 */
1419 rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */
1420 beq 5f
1421 andi. r11,r12,MSR_PR /* See if coming from user. */
1422 bne 9f /* continue in V mode if we are. */
1423
14245:
1425#ifdef CONFIG_KVM_BOOK3S_64_HV
1426 /*
1427 * We are coming from kernel context. Check if we are coming from
1428 * guest. if yes, then we can continue. We will fall through
1429 * do_kvm_200->kvmppc_interrupt to deliver the MC event to guest.
1430 */
1431 lbz r11,HSTATE_IN_GUEST(r13)
1432 cmpwi r11,0 /* Check if coming from guest */
1433 bne 9f /* continue if we are. */
1434#endif
1435 /*
1436 * At this point we are not sure about what context we come from.
1437 * Queue up the MCE event and return from the interrupt.
1438 * But before that, check if this is an un-recoverable exception.
1439 * If yes, then stay on emergency stack and panic.
1440 */
1441 andi. r11,r12,MSR_RI
1442 bne 2f
14431: addi r3,r1,STACK_FRAME_OVERHEAD
1444 bl .unrecoverable_exception
1445 b 1b
14462:
1447 /*
1448 * Return from MC interrupt.
1449 * Queue up the MCE event so that we can log it later, while
1450 * returning from kernel or opal call.
1451 */
1452 bl .machine_check_queue_event
1453 MACHINE_CHECK_HANDLER_WINDUP
1454 rfid
14559:
1456 /* Deliver the machine check to host kernel in V mode. */
1457 MACHINE_CHECK_HANDLER_WINDUP
1458 b machine_check_pSeries
1459
1462/* 1460/*
1463 * r13 points to the PACA, r9 contains the saved CR, 1461 * r13 points to the PACA, r9 contains the saved CR,
1464 * r12 contain the saved SRR1, SRR0 is still ready for return 1462 * r12 contain the saved SRR1, SRR0 is still ready for return