Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 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 |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8 | * position dependent assembly. |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 9 | * |
| 10 | * Most of this originates from head_64.S and thus has the same |
| 11 | * copyright history. |
| 12 | * |
| 13 | */ |
| 14 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 15 | #include <asm/hw_irq.h> |
Benjamin Herrenschmidt | 8aa34ab | 2009-07-14 20:52:52 +0000 | [diff] [blame] | 16 | #include <asm/exception-64s.h> |
Stephen Rothwell | 46f5221 | 2010-11-18 15:06:17 +0000 | [diff] [blame] | 17 | #include <asm/ptrace.h> |
Benjamin Herrenschmidt | 8aa34ab | 2009-07-14 20:52:52 +0000 | [diff] [blame] | 18 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 19 | /* |
| 20 | * We layout physical memory as follows: |
| 21 | * 0x0000 - 0x00ff : Secondary processor spin code |
| 22 | * 0x0100 - 0x2fff : pSeries Interrupt prologs |
Benjamin Herrenschmidt | 4f8cf36 | 2012-02-28 13:44:58 +1100 | [diff] [blame] | 23 | * 0x3000 - 0x5fff : interrupt support common interrupt prologs |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 24 | * 0x6000 - 0x6fff : Initial (CPU0) segment table |
| 25 | * 0x7000 - 0x7fff : FWNMI data area |
| 26 | * 0x8000 - : Early init and support code |
| 27 | */ |
Michael Neuling | 742415d | 2012-11-02 17:16:01 +1100 | [diff] [blame^] | 28 | /* Syscall routine is used twice, in reloc-off and reloc-on paths */ |
| 29 | #define SYSCALL_PSERIES_1 \ |
| 30 | BEGIN_FTR_SECTION \ |
| 31 | cmpdi r0,0x1ebe ; \ |
| 32 | beq- 1f ; \ |
| 33 | END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \ |
| 34 | mr r9,r13 ; \ |
| 35 | GET_PACA(r13) ; \ |
| 36 | mfspr r11,SPRN_SRR0 ; \ |
| 37 | 0: |
| 38 | |
| 39 | #define SYSCALL_PSERIES_2_RFID \ |
| 40 | mfspr r12,SPRN_SRR1 ; \ |
| 41 | ld r10,PACAKBASE(r13) ; \ |
| 42 | LOAD_HANDLER(r10, system_call_entry) ; \ |
| 43 | mtspr SPRN_SRR0,r10 ; \ |
| 44 | ld r10,PACAKMSR(r13) ; \ |
| 45 | mtspr SPRN_SRR1,r10 ; \ |
| 46 | rfid ; \ |
| 47 | b . ; /* prevent speculative execution */ |
| 48 | |
| 49 | #define SYSCALL_PSERIES_3 \ |
| 50 | /* Fast LE/BE switch system call */ \ |
| 51 | 1: mfspr r12,SPRN_SRR1 ; \ |
| 52 | xori r12,r12,MSR_LE ; \ |
| 53 | mtspr SPRN_SRR1,r12 ; \ |
| 54 | rfid ; /* return to userspace */ \ |
| 55 | b . ; \ |
| 56 | 2: mfspr r12,SPRN_SRR1 ; \ |
| 57 | andi. r12,r12,MSR_PR ; \ |
| 58 | bne 0b ; \ |
| 59 | mtspr SPRN_SRR0,r3 ; \ |
| 60 | mtspr SPRN_SRR1,r4 ; \ |
| 61 | mtspr SPRN_SDR1,r5 ; \ |
| 62 | rfid ; \ |
| 63 | b . ; /* prevent speculative execution */ |
| 64 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 65 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 66 | /* |
| 67 | * This is the start of the interrupt handlers for pSeries |
| 68 | * This code runs with relocation off. |
| 69 | * Code from here to __end_interrupts gets copied down to real |
| 70 | * address 0x100 when we are running a relocatable kernel. |
| 71 | * Therefore any relative branches in this section must only |
| 72 | * branch to labels in this section. |
| 73 | */ |
| 74 | . = 0x100 |
| 75 | .globl __start_interrupts |
| 76 | __start_interrupts: |
| 77 | |
Benjamin Herrenschmidt | 948cf67 | 2011-01-24 18:42:41 +1100 | [diff] [blame] | 78 | .globl system_reset_pSeries; |
| 79 | system_reset_pSeries: |
| 80 | HMT_MEDIUM; |
Benjamin Herrenschmidt | 948cf67 | 2011-01-24 18:42:41 +1100 | [diff] [blame] | 81 | SET_SCRATCH0(r13) |
| 82 | #ifdef CONFIG_PPC_P7_NAP |
| 83 | BEGIN_FTR_SECTION |
| 84 | /* Running native on arch 2.06 or later, check if we are |
| 85 | * waking up from nap. We only handle no state loss and |
| 86 | * supervisor state loss. We do -not- handle hypervisor |
| 87 | * state loss at this time. |
| 88 | */ |
| 89 | mfspr r13,SPRN_SRR1 |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 90 | rlwinm. r13,r13,47-31,30,31 |
| 91 | beq 9f |
| 92 | |
| 93 | /* waking up from powersave (nap) state */ |
| 94 | cmpwi cr1,r13,2 |
Benjamin Herrenschmidt | 948cf67 | 2011-01-24 18:42:41 +1100 | [diff] [blame] | 95 | /* Total loss of HV state is fatal, we could try to use the |
| 96 | * PIR to locate a PACA, then use an emergency stack etc... |
| 97 | * but for now, let's just stay stuck here |
| 98 | */ |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 99 | bgt cr1,. |
| 100 | GET_PACA(r13) |
| 101 | |
| 102 | #ifdef CONFIG_KVM_BOOK3S_64_HV |
Paul Mackerras | f0888f7 | 2012-02-03 00:54:17 +0000 | [diff] [blame] | 103 | li r0,KVM_HWTHREAD_IN_KERNEL |
| 104 | stb r0,HSTATE_HWTHREAD_STATE(r13) |
| 105 | /* Order setting hwthread_state vs. testing hwthread_req */ |
| 106 | sync |
| 107 | lbz r0,HSTATE_HWTHREAD_REQ(r13) |
| 108 | cmpwi r0,0 |
| 109 | beq 1f |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 110 | b kvm_start_guest |
| 111 | 1: |
| 112 | #endif |
| 113 | |
| 114 | beq cr1,2f |
| 115 | b .power7_wakeup_noloss |
| 116 | 2: b .power7_wakeup_loss |
| 117 | 9: |
Paul Mackerras | 969391c | 2011-06-29 00:26:11 +0000 | [diff] [blame] | 118 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
Benjamin Herrenschmidt | 948cf67 | 2011-01-24 18:42:41 +1100 | [diff] [blame] | 119 | #endif /* CONFIG_PPC_P7_NAP */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 120 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, |
| 121 | NOTEST, 0x100) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 122 | |
| 123 | . = 0x200 |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 124 | machine_check_pSeries_1: |
| 125 | /* This is moved out of line as it can be patched by FW, but |
| 126 | * some code path might still want to branch into the original |
| 127 | * vector |
| 128 | */ |
| 129 | b machine_check_pSeries |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 130 | |
| 131 | . = 0x300 |
| 132 | .globl data_access_pSeries |
| 133 | data_access_pSeries: |
| 134 | HMT_MEDIUM |
Paul Mackerras | 673b189 | 2011-04-05 13:59:58 +1000 | [diff] [blame] | 135 | SET_SCRATCH0(r13) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 136 | BEGIN_FTR_SECTION |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 137 | b data_access_check_stab |
| 138 | data_access_not_stab: |
| 139 | END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 140 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD, |
Paul Mackerras | 697d389 | 2011-12-12 12:36:37 +0000 | [diff] [blame] | 141 | KVMTEST, 0x300) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 142 | |
| 143 | . = 0x380 |
| 144 | .globl data_access_slb_pSeries |
| 145 | data_access_slb_pSeries: |
| 146 | HMT_MEDIUM |
Paul Mackerras | 673b189 | 2011-04-05 13:59:58 +1000 | [diff] [blame] | 147 | SET_SCRATCH0(r13) |
Paul Mackerras | 697d389 | 2011-12-12 12:36:37 +0000 | [diff] [blame] | 148 | EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 149 | std r3,PACA_EXSLB+EX_R3(r13) |
| 150 | mfspr r3,SPRN_DAR |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 151 | #ifdef __DISABLED__ |
| 152 | /* Keep that around for when we re-implement dynamic VSIDs */ |
| 153 | cmpdi r3,0 |
| 154 | bge slb_miss_user_pseries |
| 155 | #endif /* __DISABLED__ */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 156 | mfspr r12,SPRN_SRR1 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 157 | #ifndef CONFIG_RELOCATABLE |
| 158 | b .slb_miss_realmode |
| 159 | #else |
| 160 | /* |
| 161 | * We can't just use a direct branch to .slb_miss_realmode |
| 162 | * because the distance from here to there depends on where |
| 163 | * the kernel ends up being put. |
| 164 | */ |
| 165 | mfctr r11 |
| 166 | ld r10,PACAKBASE(r13) |
| 167 | LOAD_HANDLER(r10, .slb_miss_realmode) |
| 168 | mtctr r10 |
| 169 | bctr |
| 170 | #endif |
| 171 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 172 | STD_EXCEPTION_PSERIES(0x400, 0x400, instruction_access) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 173 | |
| 174 | . = 0x480 |
| 175 | .globl instruction_access_slb_pSeries |
| 176 | instruction_access_slb_pSeries: |
| 177 | HMT_MEDIUM |
Paul Mackerras | 673b189 | 2011-04-05 13:59:58 +1000 | [diff] [blame] | 178 | SET_SCRATCH0(r13) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 179 | EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 180 | std r3,PACA_EXSLB+EX_R3(r13) |
| 181 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 182 | #ifdef __DISABLED__ |
| 183 | /* Keep that around for when we re-implement dynamic VSIDs */ |
| 184 | cmpdi r3,0 |
| 185 | bge slb_miss_user_pseries |
| 186 | #endif /* __DISABLED__ */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 187 | mfspr r12,SPRN_SRR1 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 188 | #ifndef CONFIG_RELOCATABLE |
| 189 | b .slb_miss_realmode |
| 190 | #else |
| 191 | mfctr r11 |
| 192 | ld r10,PACAKBASE(r13) |
| 193 | LOAD_HANDLER(r10, .slb_miss_realmode) |
| 194 | mtctr r10 |
| 195 | bctr |
| 196 | #endif |
| 197 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 198 | /* We open code these as we can't have a ". = x" (even with |
| 199 | * x = "." within a feature section |
| 200 | */ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 201 | . = 0x500; |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 202 | .globl hardware_interrupt_pSeries; |
| 203 | .globl hardware_interrupt_hv; |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 204 | hardware_interrupt_pSeries: |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 205 | hardware_interrupt_hv: |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 206 | BEGIN_FTR_SECTION |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 207 | _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt, |
| 208 | EXC_HV, SOFTEN_TEST_HV) |
| 209 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 210 | FTR_SECTION_ELSE |
| 211 | _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt, |
Paul Mackerras | 9e368f2 | 2011-06-29 00:40:08 +0000 | [diff] [blame] | 212 | EXC_STD, SOFTEN_TEST_HV_201) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 213 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500) |
Paul Mackerras | 969391c | 2011-06-29 00:26:11 +0000 | [diff] [blame] | 214 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 215 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 216 | STD_EXCEPTION_PSERIES(0x600, 0x600, alignment) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 217 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 218 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 219 | STD_EXCEPTION_PSERIES(0x700, 0x700, program_check) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 220 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 221 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 222 | STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 223 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 224 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 225 | MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer) |
Paul Mackerras | dabe859 | 2012-07-26 13:56:11 +0000 | [diff] [blame] | 226 | STD_EXCEPTION_HV(0x980, 0x982, hdecrementer) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 227 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 228 | STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 229 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 230 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 231 | STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 232 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 233 | |
| 234 | . = 0xc00 |
| 235 | .globl system_call_pSeries |
| 236 | system_call_pSeries: |
| 237 | HMT_MEDIUM |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 238 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
| 239 | SET_SCRATCH0(r13) |
| 240 | GET_PACA(r13) |
| 241 | std r9,PACA_EXGEN+EX_R9(r13) |
| 242 | std r10,PACA_EXGEN+EX_R10(r13) |
| 243 | mfcr r9 |
| 244 | KVMTEST(0xc00) |
| 245 | GET_SCRATCH0(r13) |
| 246 | #endif |
Michael Neuling | 742415d | 2012-11-02 17:16:01 +1100 | [diff] [blame^] | 247 | SYSCALL_PSERIES_1 |
| 248 | SYSCALL_PSERIES_2_RFID |
| 249 | SYSCALL_PSERIES_3 |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 250 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00) |
| 251 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 252 | STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 253 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00) |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 254 | |
| 255 | /* At 0xe??? we have a bunch of hypervisor exceptions, we branch |
| 256 | * out of line to handle them |
| 257 | */ |
| 258 | . = 0xe00 |
Michael Ellerman | e6a74c6 | 2012-07-03 20:29:41 +0000 | [diff] [blame] | 259 | hv_exception_trampoline: |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 260 | b h_data_storage_hv |
| 261 | . = 0xe20 |
| 262 | b h_instr_storage_hv |
| 263 | . = 0xe40 |
| 264 | b emulation_assist_hv |
| 265 | . = 0xe50 |
| 266 | b hmi_exception_hv |
| 267 | . = 0xe60 |
| 268 | b hmi_exception_hv |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 269 | |
| 270 | /* We need to deal with the Altivec unavailable exception |
| 271 | * here which is at 0xf20, thus in the middle of the |
| 272 | * prolog code of the PerformanceMonitor one. A little |
| 273 | * trickery is thus necessary |
| 274 | */ |
Anton Blanchard | c86e2ea | 2009-10-18 01:24:06 +0000 | [diff] [blame] | 275 | performance_monitor_pSeries_1: |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 276 | . = 0xf00 |
| 277 | b performance_monitor_pSeries |
| 278 | |
Anton Blanchard | c86e2ea | 2009-10-18 01:24:06 +0000 | [diff] [blame] | 279 | altivec_unavailable_pSeries_1: |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 280 | . = 0xf20 |
| 281 | b altivec_unavailable_pSeries |
| 282 | |
Anton Blanchard | c86e2ea | 2009-10-18 01:24:06 +0000 | [diff] [blame] | 283 | vsx_unavailable_pSeries_1: |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 284 | . = 0xf40 |
| 285 | b vsx_unavailable_pSeries |
| 286 | |
| 287 | #ifdef CONFIG_CBE_RAS |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 288 | STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error) |
Alexander Graf | 5ccf55d | 2011-09-13 04:15:31 +0000 | [diff] [blame] | 289 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 290 | #endif /* CONFIG_CBE_RAS */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 291 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 292 | STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 293 | KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 294 | |
Michael Neuling | b92a66a | 2012-09-10 00:35:26 +0000 | [diff] [blame] | 295 | . = 0x1500 |
Michael Neuling | 51cf2b3 | 2012-10-31 18:58:36 +0000 | [diff] [blame] | 296 | .global denorm_exception_hv |
Michael Neuling | b92a66a | 2012-09-10 00:35:26 +0000 | [diff] [blame] | 297 | denorm_exception_hv: |
| 298 | HMT_MEDIUM |
| 299 | mtspr SPRN_SPRG_HSCRATCH0,r13 |
| 300 | mfspr r13,SPRN_SPRG_HPACA |
| 301 | std r9,PACA_EXGEN+EX_R9(r13) |
| 302 | std r10,PACA_EXGEN+EX_R10(r13) |
| 303 | std r11,PACA_EXGEN+EX_R11(r13) |
| 304 | std r12,PACA_EXGEN+EX_R12(r13) |
| 305 | mfspr r9,SPRN_SPRG_HSCRATCH0 |
| 306 | std r9,PACA_EXGEN+EX_R13(r13) |
| 307 | mfcr r9 |
| 308 | |
| 309 | #ifdef CONFIG_PPC_DENORMALISATION |
| 310 | mfspr r10,SPRN_HSRR1 |
| 311 | mfspr r11,SPRN_HSRR0 /* save HSRR0 */ |
| 312 | andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ |
| 313 | addi r11,r11,-4 /* HSRR0 is next instruction */ |
| 314 | bne+ denorm_assist |
| 315 | #endif |
| 316 | |
| 317 | EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV) |
| 318 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500) |
| 319 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 320 | #ifdef CONFIG_CBE_RAS |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 321 | STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance) |
Alexander Graf | 5ccf55d | 2011-09-13 04:15:31 +0000 | [diff] [blame] | 322 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 323 | #endif /* CONFIG_CBE_RAS */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 324 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 325 | STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 326 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 327 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 328 | #ifdef CONFIG_CBE_RAS |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 329 | STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal) |
Alexander Graf | 5ccf55d | 2011-09-13 04:15:31 +0000 | [diff] [blame] | 330 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802) |
Michael Neuling | faab4dd2 | 2012-11-02 13:53:36 +1100 | [diff] [blame] | 331 | #else |
| 332 | . = 0x1800 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 333 | #endif /* CONFIG_CBE_RAS */ |
| 334 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 335 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 336 | /*** Out of line interrupts support ***/ |
| 337 | |
Michael Neuling | faab4dd2 | 2012-11-02 13:53:36 +1100 | [diff] [blame] | 338 | .align 7 |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 339 | /* moved from 0x200 */ |
| 340 | machine_check_pSeries: |
| 341 | .globl machine_check_fwnmi |
| 342 | machine_check_fwnmi: |
| 343 | HMT_MEDIUM |
| 344 | SET_SCRATCH0(r13) /* save r13 */ |
| 345 | EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common, |
| 346 | EXC_STD, KVMTEST, 0x200) |
| 347 | KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200) |
| 348 | |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 349 | /* moved from 0x300 */ |
| 350 | data_access_check_stab: |
| 351 | GET_PACA(r13) |
| 352 | std r9,PACA_EXSLB+EX_R9(r13) |
| 353 | std r10,PACA_EXSLB+EX_R10(r13) |
| 354 | mfspr r10,SPRN_DAR |
| 355 | mfspr r9,SPRN_DSISR |
| 356 | srdi r10,r10,60 |
| 357 | rlwimi r10,r9,16,0x20 |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 358 | #ifdef CONFIG_KVM_BOOK3S_PR |
Paul Mackerras | 3c42bf8 | 2011-06-29 00:20:58 +0000 | [diff] [blame] | 359 | lbz r9,HSTATE_IN_GUEST(r13) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 360 | rlwimi r10,r9,8,0x300 |
| 361 | #endif |
| 362 | mfcr r9 |
| 363 | cmpwi r10,0x2c |
| 364 | beq do_stab_bolted_pSeries |
| 365 | mtcrf 0x80,r9 |
| 366 | ld r9,PACA_EXSLB+EX_R9(r13) |
| 367 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 368 | b data_access_not_stab |
| 369 | do_stab_bolted_pSeries: |
| 370 | std r11,PACA_EXSLB+EX_R11(r13) |
| 371 | std r12,PACA_EXSLB+EX_R12(r13) |
| 372 | GET_SCRATCH0(r10) |
| 373 | std r10,PACA_EXSLB+EX_R13(r13) |
| 374 | EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 375 | |
Paul Mackerras | 697d389 | 2011-12-12 12:36:37 +0000 | [diff] [blame] | 376 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300) |
| 377 | KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 378 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400) |
| 379 | KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480) |
| 380 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 381 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982) |
| 382 | |
Michael Neuling | b92a66a | 2012-09-10 00:35:26 +0000 | [diff] [blame] | 383 | #ifdef CONFIG_PPC_DENORMALISATION |
| 384 | denorm_assist: |
| 385 | BEGIN_FTR_SECTION |
| 386 | /* |
| 387 | * To denormalise we need to move a copy of the register to itself. |
| 388 | * For POWER6 do that here for all FP regs. |
| 389 | */ |
| 390 | mfmsr r10 |
| 391 | ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1) |
| 392 | xori r10,r10,(MSR_FE0|MSR_FE1) |
| 393 | mtmsrd r10 |
| 394 | sync |
| 395 | fmr 0,0 |
| 396 | fmr 1,1 |
| 397 | fmr 2,2 |
| 398 | fmr 3,3 |
| 399 | fmr 4,4 |
| 400 | fmr 5,5 |
| 401 | fmr 6,6 |
| 402 | fmr 7,7 |
| 403 | fmr 8,8 |
| 404 | fmr 9,9 |
| 405 | fmr 10,10 |
| 406 | fmr 11,11 |
| 407 | fmr 12,12 |
| 408 | fmr 13,13 |
| 409 | fmr 14,14 |
| 410 | fmr 15,15 |
| 411 | fmr 16,16 |
| 412 | fmr 17,17 |
| 413 | fmr 18,18 |
| 414 | fmr 19,19 |
| 415 | fmr 20,20 |
| 416 | fmr 21,21 |
| 417 | fmr 22,22 |
| 418 | fmr 23,23 |
| 419 | fmr 24,24 |
| 420 | fmr 25,25 |
| 421 | fmr 26,26 |
| 422 | fmr 27,27 |
| 423 | fmr 28,28 |
| 424 | fmr 29,29 |
| 425 | fmr 30,30 |
| 426 | fmr 31,31 |
| 427 | FTR_SECTION_ELSE |
| 428 | /* |
| 429 | * To denormalise we need to move a copy of the register to itself. |
| 430 | * For POWER7 do that here for the first 32 VSX registers only. |
| 431 | */ |
| 432 | mfmsr r10 |
| 433 | oris r10,r10,MSR_VSX@h |
| 434 | mtmsrd r10 |
| 435 | sync |
| 436 | XVCPSGNDP(0,0,0) |
| 437 | XVCPSGNDP(1,1,1) |
| 438 | XVCPSGNDP(2,2,2) |
| 439 | XVCPSGNDP(3,3,3) |
| 440 | XVCPSGNDP(4,4,4) |
| 441 | XVCPSGNDP(5,5,5) |
| 442 | XVCPSGNDP(6,6,6) |
| 443 | XVCPSGNDP(7,7,7) |
| 444 | XVCPSGNDP(8,8,8) |
| 445 | XVCPSGNDP(9,9,9) |
| 446 | XVCPSGNDP(10,10,10) |
| 447 | XVCPSGNDP(11,11,11) |
| 448 | XVCPSGNDP(12,12,12) |
| 449 | XVCPSGNDP(13,13,13) |
| 450 | XVCPSGNDP(14,14,14) |
| 451 | XVCPSGNDP(15,15,15) |
| 452 | XVCPSGNDP(16,16,16) |
| 453 | XVCPSGNDP(17,17,17) |
| 454 | XVCPSGNDP(18,18,18) |
| 455 | XVCPSGNDP(19,19,19) |
| 456 | XVCPSGNDP(20,20,20) |
| 457 | XVCPSGNDP(21,21,21) |
| 458 | XVCPSGNDP(22,22,22) |
| 459 | XVCPSGNDP(23,23,23) |
| 460 | XVCPSGNDP(24,24,24) |
| 461 | XVCPSGNDP(25,25,25) |
| 462 | XVCPSGNDP(26,26,26) |
| 463 | XVCPSGNDP(27,27,27) |
| 464 | XVCPSGNDP(28,28,28) |
| 465 | XVCPSGNDP(29,29,29) |
| 466 | XVCPSGNDP(30,30,30) |
| 467 | XVCPSGNDP(31,31,31) |
| 468 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206) |
| 469 | mtspr SPRN_HSRR0,r11 |
| 470 | mtcrf 0x80,r9 |
| 471 | ld r9,PACA_EXGEN+EX_R9(r13) |
| 472 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 473 | ld r11,PACA_EXGEN+EX_R11(r13) |
| 474 | ld r12,PACA_EXGEN+EX_R12(r13) |
| 475 | ld r13,PACA_EXGEN+EX_R13(r13) |
| 476 | HRFID |
| 477 | b . |
| 478 | #endif |
| 479 | |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 480 | .align 7 |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 481 | /* moved from 0xe00 */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 482 | STD_EXCEPTION_HV(., 0xe02, h_data_storage) |
| 483 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02) |
| 484 | STD_EXCEPTION_HV(., 0xe22, h_instr_storage) |
| 485 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22) |
| 486 | STD_EXCEPTION_HV(., 0xe42, emulation_assist) |
| 487 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42) |
| 488 | STD_EXCEPTION_HV(., 0xe62, hmi_exception) /* need to flush cache ? */ |
| 489 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 490 | |
| 491 | /* moved from 0xf00 */ |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 492 | STD_EXCEPTION_PSERIES(., 0xf00, performance_monitor) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 493 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00) |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 494 | STD_EXCEPTION_PSERIES(., 0xf20, altivec_unavailable) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 495 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20) |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 496 | STD_EXCEPTION_PSERIES(., 0xf40, vsx_unavailable) |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 497 | KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 498 | |
| 499 | /* |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 500 | * An interrupt came in while soft-disabled. We set paca->irq_happened, |
| 501 | * then, if it was a decrementer interrupt, we bump the dec to max and |
| 502 | * and return, else we hard disable and return. This is called with |
| 503 | * r10 containing the value to OR to the paca field. |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 504 | */ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 505 | #define MASKED_INTERRUPT(_H) \ |
| 506 | masked_##_H##interrupt: \ |
| 507 | std r11,PACA_EXGEN+EX_R11(r13); \ |
| 508 | lbz r11,PACAIRQHAPPENED(r13); \ |
| 509 | or r11,r11,r10; \ |
| 510 | stb r11,PACAIRQHAPPENED(r13); \ |
| 511 | andi. r10,r10,PACA_IRQ_DEC; \ |
| 512 | beq 1f; \ |
| 513 | lis r10,0x7fff; \ |
| 514 | ori r10,r10,0xffff; \ |
| 515 | mtspr SPRN_DEC,r10; \ |
| 516 | b 2f; \ |
| 517 | 1: mfspr r10,SPRN_##_H##SRR1; \ |
| 518 | rldicl r10,r10,48,1; /* clear MSR_EE */ \ |
| 519 | rotldi r10,r10,16; \ |
| 520 | mtspr SPRN_##_H##SRR1,r10; \ |
| 521 | 2: mtcrf 0x80,r9; \ |
| 522 | ld r9,PACA_EXGEN+EX_R9(r13); \ |
| 523 | ld r10,PACA_EXGEN+EX_R10(r13); \ |
| 524 | ld r11,PACA_EXGEN+EX_R11(r13); \ |
| 525 | GET_SCRATCH0(r13); \ |
| 526 | ##_H##rfid; \ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 527 | b . |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 528 | |
| 529 | MASKED_INTERRUPT() |
| 530 | MASKED_INTERRUPT(H) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 531 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 532 | /* |
| 533 | * Called from arch_local_irq_enable when an interrupt needs |
| 534 | * to be resent. r3 contains 0x500 or 0x900 to indicate which |
| 535 | * kind of interrupt. MSR:EE is already off. We generate a |
| 536 | * stackframe like if a real interrupt had happened. |
| 537 | * |
| 538 | * Note: While MSR:EE is off, we need to make sure that _MSR |
| 539 | * in the generated frame has EE set to 1 or the exception |
| 540 | * handler will not properly re-enable them. |
| 541 | */ |
| 542 | _GLOBAL(__replay_interrupt) |
| 543 | /* We are going to jump to the exception common code which |
| 544 | * will retrieve various register values from the PACA which |
| 545 | * we don't give a damn about, so we don't bother storing them. |
| 546 | */ |
| 547 | mfmsr r12 |
| 548 | mflr r11 |
| 549 | mfcr r9 |
| 550 | ori r12,r12,MSR_EE |
| 551 | andi. r3,r3,0x0800 |
| 552 | bne decrementer_common |
| 553 | b hardware_interrupt_common |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 554 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 555 | #ifdef CONFIG_PPC_PSERIES |
| 556 | /* |
| 557 | * Vectors for the FWNMI option. Share common code. |
| 558 | */ |
| 559 | .globl system_reset_fwnmi |
| 560 | .align 7 |
| 561 | system_reset_fwnmi: |
| 562 | HMT_MEDIUM |
Paul Mackerras | 673b189 | 2011-04-05 13:59:58 +1000 | [diff] [blame] | 563 | SET_SCRATCH0(r13) /* save r13 */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 564 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, |
| 565 | NOTEST, 0x100) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 566 | |
| 567 | #endif /* CONFIG_PPC_PSERIES */ |
| 568 | |
| 569 | #ifdef __DISABLED__ |
| 570 | /* |
| 571 | * This is used for when the SLB miss handler has to go virtual, |
| 572 | * which doesn't happen for now anymore but will once we re-implement |
| 573 | * dynamic VSIDs for shared page tables |
| 574 | */ |
| 575 | slb_miss_user_pseries: |
| 576 | std r10,PACA_EXGEN+EX_R10(r13) |
| 577 | std r11,PACA_EXGEN+EX_R11(r13) |
| 578 | std r12,PACA_EXGEN+EX_R12(r13) |
Paul Mackerras | 673b189 | 2011-04-05 13:59:58 +1000 | [diff] [blame] | 579 | GET_SCRATCH0(r10) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 580 | ld r11,PACA_EXSLB+EX_R9(r13) |
| 581 | ld r12,PACA_EXSLB+EX_R3(r13) |
| 582 | std r10,PACA_EXGEN+EX_R13(r13) |
| 583 | std r11,PACA_EXGEN+EX_R9(r13) |
| 584 | std r12,PACA_EXGEN+EX_R3(r13) |
| 585 | clrrdi r12,r13,32 |
| 586 | mfmsr r10 |
| 587 | mfspr r11,SRR0 /* save SRR0 */ |
| 588 | ori r12,r12,slb_miss_user_common@l /* virt addr of handler */ |
| 589 | ori r10,r10,MSR_IR|MSR_DR|MSR_RI |
| 590 | mtspr SRR0,r12 |
| 591 | mfspr r12,SRR1 /* and SRR1 */ |
| 592 | mtspr SRR1,r10 |
| 593 | rfid |
| 594 | b . /* prevent spec. execution */ |
| 595 | #endif /* __DISABLED__ */ |
| 596 | |
| 597 | .align 7 |
| 598 | .globl __end_interrupts |
| 599 | __end_interrupts: |
| 600 | |
| 601 | /* |
| 602 | * Code from here down to __end_handlers is invoked from the |
| 603 | * exception prologs above. Because the prologs assemble the |
| 604 | * addresses of these handlers using the LOAD_HANDLER macro, |
Michael Neuling | 61e2390 | 2012-11-05 17:10:35 +1100 | [diff] [blame] | 605 | * which uses an ori instruction, these handlers must be in |
| 606 | * the first 64k of the kernel image. |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 607 | */ |
| 608 | |
| 609 | /*** Common interrupt handlers ***/ |
| 610 | |
| 611 | STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception) |
| 612 | |
| 613 | /* |
| 614 | * Machine check is different because we use a different |
| 615 | * save area: PACA_EXMC instead of PACA_EXGEN. |
| 616 | */ |
| 617 | .align 7 |
| 618 | .globl machine_check_common |
| 619 | machine_check_common: |
| 620 | EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) |
| 621 | FINISH_NAP |
| 622 | DISABLE_INTS |
| 623 | bl .save_nvgprs |
| 624 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 625 | bl .machine_check_exception |
| 626 | b .ret_from_except |
| 627 | |
Benjamin Herrenschmidt | 7450f6f | 2012-03-01 10:52:01 +1100 | [diff] [blame] | 628 | STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ) |
| 629 | STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt) |
Paul Mackerras | dabe859 | 2012-07-26 13:56:11 +0000 | [diff] [blame] | 630 | STD_EXCEPTION_COMMON(0x980, hdecrementer, .hdec_interrupt) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 631 | STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception) |
| 632 | STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) |
| 633 | STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) |
| 634 | STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception) |
Michael Neuling | 278a6cd | 2012-11-02 14:11:51 +1100 | [diff] [blame] | 635 | STD_EXCEPTION_COMMON(0xe40, emulation_assist, .program_check_exception) |
| 636 | STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception) |
Benjamin Herrenschmidt | 7450f6f | 2012-03-01 10:52:01 +1100 | [diff] [blame] | 637 | STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, .performance_monitor_exception) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 638 | STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception) |
Michael Neuling | b92a66a | 2012-09-10 00:35:26 +0000 | [diff] [blame] | 639 | STD_EXCEPTION_COMMON(0x1502, denorm, .unknown_exception) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 640 | #ifdef CONFIG_ALTIVEC |
| 641 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception) |
| 642 | #else |
| 643 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception) |
| 644 | #endif |
| 645 | #ifdef CONFIG_CBE_RAS |
| 646 | STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception) |
| 647 | STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception) |
| 648 | STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception) |
| 649 | #endif /* CONFIG_CBE_RAS */ |
| 650 | |
| 651 | .align 7 |
| 652 | system_call_entry: |
| 653 | b system_call_common |
| 654 | |
Benjamin Herrenschmidt | fe1952f | 2012-03-01 12:45:27 +1100 | [diff] [blame] | 655 | ppc64_runlatch_on_trampoline: |
| 656 | b .__ppc64_runlatch_on |
| 657 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 658 | /* |
| 659 | * Here we have detected that the kernel stack pointer is bad. |
| 660 | * R9 contains the saved CR, r13 points to the paca, |
| 661 | * r10 contains the (bad) kernel stack pointer, |
| 662 | * r11 and r12 contain the saved SRR0 and SRR1. |
| 663 | * We switch to using an emergency stack, save the registers there, |
| 664 | * and call kernel_bad_stack(), which panics. |
| 665 | */ |
| 666 | bad_stack: |
| 667 | ld r1,PACAEMERGSP(r13) |
| 668 | subi r1,r1,64+INT_FRAME_SIZE |
| 669 | std r9,_CCR(r1) |
| 670 | std r10,GPR1(r1) |
| 671 | std r11,_NIP(r1) |
| 672 | std r12,_MSR(r1) |
| 673 | mfspr r11,SPRN_DAR |
| 674 | mfspr r12,SPRN_DSISR |
| 675 | std r11,_DAR(r1) |
| 676 | std r12,_DSISR(r1) |
| 677 | mflr r10 |
| 678 | mfctr r11 |
| 679 | mfxer r12 |
| 680 | std r10,_LINK(r1) |
| 681 | std r11,_CTR(r1) |
| 682 | std r12,_XER(r1) |
| 683 | SAVE_GPR(0,r1) |
| 684 | SAVE_GPR(2,r1) |
Paul Mackerras | 1977b50 | 2011-05-01 19:46:44 +0000 | [diff] [blame] | 685 | ld r10,EX_R3(r3) |
| 686 | std r10,GPR3(r1) |
| 687 | SAVE_GPR(4,r1) |
| 688 | SAVE_4GPRS(5,r1) |
| 689 | ld r9,EX_R9(r3) |
| 690 | ld r10,EX_R10(r3) |
| 691 | SAVE_2GPRS(9,r1) |
| 692 | ld r9,EX_R11(r3) |
| 693 | ld r10,EX_R12(r3) |
| 694 | ld r11,EX_R13(r3) |
| 695 | std r9,GPR11(r1) |
| 696 | std r10,GPR12(r1) |
| 697 | std r11,GPR13(r1) |
Paul Mackerras | 48404f2 | 2011-05-01 19:48:20 +0000 | [diff] [blame] | 698 | BEGIN_FTR_SECTION |
| 699 | ld r10,EX_CFAR(r3) |
| 700 | std r10,ORIG_GPR3(r1) |
| 701 | END_FTR_SECTION_IFSET(CPU_FTR_CFAR) |
Paul Mackerras | 1977b50 | 2011-05-01 19:46:44 +0000 | [diff] [blame] | 702 | SAVE_8GPRS(14,r1) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 703 | SAVE_10GPRS(22,r1) |
| 704 | lhz r12,PACA_TRAP_SAVE(r13) |
| 705 | std r12,_TRAP(r1) |
| 706 | addi r11,r1,INT_FRAME_SIZE |
| 707 | std r11,0(r1) |
| 708 | li r12,0 |
| 709 | std r12,0(r11) |
| 710 | ld r2,PACATOC(r13) |
Paul Mackerras | 1977b50 | 2011-05-01 19:46:44 +0000 | [diff] [blame] | 711 | ld r11,exception_marker@toc(r2) |
| 712 | std r12,RESULT(r1) |
| 713 | std r11,STACK_FRAME_OVERHEAD-16(r1) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 714 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 715 | bl .kernel_bad_stack |
| 716 | b 1b |
| 717 | |
| 718 | /* |
| 719 | * Here r13 points to the paca, r9 contains the saved CR, |
| 720 | * SRR0 and SRR1 are saved in r11 and r12, |
| 721 | * r9 - r13 are saved in paca->exgen. |
| 722 | */ |
| 723 | .align 7 |
| 724 | .globl data_access_common |
| 725 | data_access_common: |
| 726 | mfspr r10,SPRN_DAR |
| 727 | std r10,PACA_EXGEN+EX_DAR(r13) |
| 728 | mfspr r10,SPRN_DSISR |
| 729 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 730 | EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN) |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 731 | DISABLE_INTS |
| 732 | ld r12,_MSR(r1) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 733 | ld r3,PACA_EXGEN+EX_DAR(r13) |
| 734 | lwz r4,PACA_EXGEN+EX_DSISR(r13) |
| 735 | li r5,0x300 |
Michael Neuling | 278a6cd | 2012-11-02 14:11:51 +1100 | [diff] [blame] | 736 | b .do_hash_page /* Try to handle as hpte fault */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 737 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 738 | .align 7 |
Michael Neuling | 278a6cd | 2012-11-02 14:11:51 +1100 | [diff] [blame] | 739 | .globl h_data_storage_common |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 740 | h_data_storage_common: |
Michael Neuling | 278a6cd | 2012-11-02 14:11:51 +1100 | [diff] [blame] | 741 | mfspr r10,SPRN_HDAR |
| 742 | std r10,PACA_EXGEN+EX_DAR(r13) |
| 743 | mfspr r10,SPRN_HDSISR |
| 744 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 745 | EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN) |
| 746 | bl .save_nvgprs |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 747 | DISABLE_INTS |
Michael Neuling | 278a6cd | 2012-11-02 14:11:51 +1100 | [diff] [blame] | 748 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 749 | bl .unknown_exception |
| 750 | b .ret_from_except |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 751 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 752 | .align 7 |
| 753 | .globl instruction_access_common |
| 754 | instruction_access_common: |
| 755 | EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN) |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 756 | DISABLE_INTS |
| 757 | ld r12,_MSR(r1) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 758 | ld r3,_NIP(r1) |
| 759 | andis. r4,r12,0x5820 |
| 760 | li r5,0x400 |
| 761 | b .do_hash_page /* Try to handle as hpte fault */ |
| 762 | |
Michael Neuling | 278a6cd | 2012-11-02 14:11:51 +1100 | [diff] [blame] | 763 | STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception) |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 764 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 765 | /* |
| 766 | * Here is the common SLB miss user that is used when going to virtual |
| 767 | * mode for SLB misses, that is currently not used |
| 768 | */ |
| 769 | #ifdef __DISABLED__ |
| 770 | .align 7 |
| 771 | .globl slb_miss_user_common |
| 772 | slb_miss_user_common: |
| 773 | mflr r10 |
| 774 | std r3,PACA_EXGEN+EX_DAR(r13) |
| 775 | stw r9,PACA_EXGEN+EX_CCR(r13) |
| 776 | std r10,PACA_EXGEN+EX_LR(r13) |
| 777 | std r11,PACA_EXGEN+EX_SRR0(r13) |
| 778 | bl .slb_allocate_user |
| 779 | |
| 780 | ld r10,PACA_EXGEN+EX_LR(r13) |
| 781 | ld r3,PACA_EXGEN+EX_R3(r13) |
| 782 | lwz r9,PACA_EXGEN+EX_CCR(r13) |
| 783 | ld r11,PACA_EXGEN+EX_SRR0(r13) |
| 784 | mtlr r10 |
| 785 | beq- slb_miss_fault |
| 786 | |
| 787 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ |
| 788 | beq- unrecov_user_slb |
| 789 | mfmsr r10 |
| 790 | |
| 791 | .machine push |
| 792 | .machine "power4" |
| 793 | mtcrf 0x80,r9 |
| 794 | .machine pop |
| 795 | |
| 796 | clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */ |
| 797 | mtmsrd r10,1 |
| 798 | |
| 799 | mtspr SRR0,r11 |
| 800 | mtspr SRR1,r12 |
| 801 | |
| 802 | ld r9,PACA_EXGEN+EX_R9(r13) |
| 803 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 804 | ld r11,PACA_EXGEN+EX_R11(r13) |
| 805 | ld r12,PACA_EXGEN+EX_R12(r13) |
| 806 | ld r13,PACA_EXGEN+EX_R13(r13) |
| 807 | rfid |
| 808 | b . |
| 809 | |
| 810 | slb_miss_fault: |
| 811 | EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN) |
| 812 | ld r4,PACA_EXGEN+EX_DAR(r13) |
| 813 | li r5,0 |
| 814 | std r4,_DAR(r1) |
| 815 | std r5,_DSISR(r1) |
| 816 | b handle_page_fault |
| 817 | |
| 818 | unrecov_user_slb: |
| 819 | EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN) |
| 820 | DISABLE_INTS |
| 821 | bl .save_nvgprs |
| 822 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 823 | bl .unrecoverable_exception |
| 824 | b 1b |
| 825 | |
| 826 | #endif /* __DISABLED__ */ |
| 827 | |
| 828 | |
| 829 | /* |
| 830 | * r13 points to the PACA, r9 contains the saved CR, |
| 831 | * r12 contain the saved SRR1, SRR0 is still ready for return |
| 832 | * r3 has the faulting address |
| 833 | * r9 - r13 are saved in paca->exslb. |
| 834 | * r3 is saved in paca->slb_r3 |
| 835 | * We assume we aren't going to take any exceptions during this procedure. |
| 836 | */ |
| 837 | _GLOBAL(slb_miss_realmode) |
| 838 | mflr r10 |
| 839 | #ifdef CONFIG_RELOCATABLE |
| 840 | mtctr r11 |
| 841 | #endif |
| 842 | |
| 843 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ |
| 844 | std r10,PACA_EXSLB+EX_LR(r13) /* save LR */ |
| 845 | |
| 846 | bl .slb_allocate_realmode |
| 847 | |
| 848 | /* All done -- return from exception. */ |
| 849 | |
| 850 | ld r10,PACA_EXSLB+EX_LR(r13) |
| 851 | ld r3,PACA_EXSLB+EX_R3(r13) |
| 852 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 853 | |
| 854 | mtlr r10 |
| 855 | |
| 856 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ |
| 857 | beq- 2f |
| 858 | |
| 859 | .machine push |
| 860 | .machine "power4" |
| 861 | mtcrf 0x80,r9 |
| 862 | mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ |
| 863 | .machine pop |
| 864 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 865 | ld r9,PACA_EXSLB+EX_R9(r13) |
| 866 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 867 | ld r11,PACA_EXSLB+EX_R11(r13) |
| 868 | ld r12,PACA_EXSLB+EX_R12(r13) |
| 869 | ld r13,PACA_EXSLB+EX_R13(r13) |
| 870 | rfid |
| 871 | b . /* prevent speculative execution */ |
| 872 | |
Benjamin Herrenschmidt | 4f8cf36 | 2012-02-28 13:44:58 +1100 | [diff] [blame] | 873 | 2: mfspr r11,SPRN_SRR0 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 874 | ld r10,PACAKBASE(r13) |
| 875 | LOAD_HANDLER(r10,unrecov_slb) |
| 876 | mtspr SPRN_SRR0,r10 |
| 877 | ld r10,PACAKMSR(r13) |
| 878 | mtspr SPRN_SRR1,r10 |
| 879 | rfid |
| 880 | b . |
| 881 | |
| 882 | unrecov_slb: |
| 883 | EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB) |
| 884 | DISABLE_INTS |
| 885 | bl .save_nvgprs |
| 886 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 887 | bl .unrecoverable_exception |
| 888 | b 1b |
| 889 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 890 | |
| 891 | #ifdef CONFIG_PPC_970_NAP |
| 892 | power4_fixup_nap: |
| 893 | andc r9,r9,r10 |
| 894 | std r9,TI_LOCAL_FLAGS(r11) |
| 895 | ld r10,_LINK(r1) /* make idle task do the */ |
| 896 | std r10,_NIP(r1) /* equivalent of a blr */ |
| 897 | blr |
| 898 | #endif |
| 899 | |
| 900 | .align 7 |
| 901 | .globl alignment_common |
| 902 | alignment_common: |
| 903 | mfspr r10,SPRN_DAR |
| 904 | std r10,PACA_EXGEN+EX_DAR(r13) |
| 905 | mfspr r10,SPRN_DSISR |
| 906 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 907 | EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN) |
| 908 | ld r3,PACA_EXGEN+EX_DAR(r13) |
| 909 | lwz r4,PACA_EXGEN+EX_DSISR(r13) |
| 910 | std r3,_DAR(r1) |
| 911 | std r4,_DSISR(r1) |
| 912 | bl .save_nvgprs |
Benjamin Herrenschmidt | a3512b2 | 2012-05-08 13:38:50 +1000 | [diff] [blame] | 913 | DISABLE_INTS |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 914 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 915 | bl .alignment_exception |
| 916 | b .ret_from_except |
| 917 | |
| 918 | .align 7 |
| 919 | .globl program_check_common |
| 920 | program_check_common: |
| 921 | EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) |
| 922 | bl .save_nvgprs |
Benjamin Herrenschmidt | 5432124 | 2012-02-13 20:42:18 +0000 | [diff] [blame] | 923 | DISABLE_INTS |
Michael Ellerman | 922b9f8 | 2012-02-20 21:32:30 +0000 | [diff] [blame] | 924 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 925 | bl .program_check_exception |
| 926 | b .ret_from_except |
| 927 | |
| 928 | .align 7 |
| 929 | .globl fp_unavailable_common |
| 930 | fp_unavailable_common: |
| 931 | EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) |
| 932 | bne 1f /* if from user, just load it up */ |
| 933 | bl .save_nvgprs |
Benjamin Herrenschmidt | 9f2f79e | 2012-03-01 15:47:44 +1100 | [diff] [blame] | 934 | DISABLE_INTS |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 935 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 936 | bl .kernel_fp_unavailable_exception |
| 937 | BUG_OPCODE |
| 938 | 1: bl .load_up_fpu |
| 939 | b fast_exception_return |
| 940 | |
| 941 | .align 7 |
| 942 | .globl altivec_unavailable_common |
| 943 | altivec_unavailable_common: |
| 944 | EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN) |
| 945 | #ifdef CONFIG_ALTIVEC |
| 946 | BEGIN_FTR_SECTION |
| 947 | beq 1f |
| 948 | bl .load_up_altivec |
| 949 | b fast_exception_return |
| 950 | 1: |
| 951 | END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) |
| 952 | #endif |
| 953 | bl .save_nvgprs |
Benjamin Herrenschmidt | 9f2f79e | 2012-03-01 15:47:44 +1100 | [diff] [blame] | 954 | DISABLE_INTS |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 955 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 956 | bl .altivec_unavailable_exception |
| 957 | b .ret_from_except |
| 958 | |
| 959 | .align 7 |
| 960 | .globl vsx_unavailable_common |
| 961 | vsx_unavailable_common: |
| 962 | EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN) |
| 963 | #ifdef CONFIG_VSX |
| 964 | BEGIN_FTR_SECTION |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 965 | beq 1f |
| 966 | b .load_up_vsx |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 967 | 1: |
| 968 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) |
| 969 | #endif |
| 970 | bl .save_nvgprs |
Benjamin Herrenschmidt | 9f2f79e | 2012-03-01 15:47:44 +1100 | [diff] [blame] | 971 | DISABLE_INTS |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 972 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 973 | bl .vsx_unavailable_exception |
| 974 | b .ret_from_except |
| 975 | |
| 976 | .align 7 |
| 977 | .globl __end_handlers |
| 978 | __end_handlers: |
| 979 | |
| 980 | /* |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 981 | * Hash table stuff |
| 982 | */ |
| 983 | .align 7 |
| 984 | _STATIC(do_hash_page) |
| 985 | std r3,_DAR(r1) |
| 986 | std r4,_DSISR(r1) |
| 987 | |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 988 | andis. r0,r4,0xa410 /* weird error? */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 989 | bne- handle_page_fault /* if not, try to insert a HPTE */ |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 990 | andis. r0,r4,DSISR_DABRMATCH@h |
| 991 | bne- handle_dabr_fault |
| 992 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 993 | BEGIN_FTR_SECTION |
| 994 | andis. r0,r4,0x0020 /* Is it a segment table fault? */ |
| 995 | bne- do_ste_alloc /* If so handle it */ |
Matt Evans | 44ae3ab | 2011-04-06 19:48:50 +0000 | [diff] [blame] | 996 | END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 997 | |
Stuart Yoder | 9778b69 | 2012-07-05 04:41:35 +0000 | [diff] [blame] | 998 | CURRENT_THREAD_INFO(r11, r1) |
Paul Mackerras | 9c1e105 | 2009-08-17 15:17:54 +1000 | [diff] [blame] | 999 | lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */ |
| 1000 | andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */ |
| 1001 | bne 77f /* then don't call hash_page now */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1002 | /* |
| 1003 | * We need to set the _PAGE_USER bit if MSR_PR is set or if we are |
| 1004 | * accessing a userspace segment (even from the kernel). We assume |
| 1005 | * kernel addresses always have the high bit set. |
| 1006 | */ |
| 1007 | rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */ |
| 1008 | rotldi r0,r3,15 /* Move high bit into MSR_PR posn */ |
| 1009 | orc r0,r12,r0 /* MSR_PR | ~high_bit */ |
| 1010 | rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */ |
| 1011 | ori r4,r4,1 /* add _PAGE_PRESENT */ |
| 1012 | rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */ |
| 1013 | |
| 1014 | /* |
| 1015 | * r3 contains the faulting address |
| 1016 | * r4 contains the required access permissions |
| 1017 | * r5 contains the trap number |
| 1018 | * |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 1019 | * at return r3 = 0 for success, 1 for page fault, negative for error |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1020 | */ |
| 1021 | bl .hash_page /* build HPTE if possible */ |
| 1022 | cmpdi r3,0 /* see if hash_page succeeded */ |
| 1023 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 1024 | /* Success */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1025 | beq fast_exc_return_irq /* Return from exception on success */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1026 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 1027 | /* Error */ |
| 1028 | blt- 13f |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1029 | |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 1030 | /* Here we have a page fault that hash_page can't handle. */ |
| 1031 | handle_page_fault: |
| 1032 | 11: ld r4,_DAR(r1) |
| 1033 | ld r5,_DSISR(r1) |
| 1034 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 1035 | bl .do_page_fault |
| 1036 | cmpdi r3,0 |
| 1037 | beq+ 12f |
| 1038 | bl .save_nvgprs |
| 1039 | mr r5,r3 |
| 1040 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 1041 | lwz r4,_DAR(r1) |
| 1042 | bl .bad_page_fault |
| 1043 | b .ret_from_except |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1044 | |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 1045 | /* We have a data breakpoint exception - handle it */ |
| 1046 | handle_dabr_fault: |
K.Prasad | 5aae8a5 | 2010-06-15 11:35:19 +0530 | [diff] [blame] | 1047 | bl .save_nvgprs |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 1048 | ld r4,_DAR(r1) |
| 1049 | ld r5,_DSISR(r1) |
| 1050 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 1051 | bl .do_dabr |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 1052 | 12: b .ret_from_except_lite |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 1053 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1054 | |
| 1055 | /* We have a page fault that hash_page could handle but HV refused |
| 1056 | * the PTE insertion |
| 1057 | */ |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 1058 | 13: bl .save_nvgprs |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1059 | mr r5,r3 |
| 1060 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 1061 | ld r4,_DAR(r1) |
| 1062 | bl .low_hash_fault |
| 1063 | b .ret_from_except |
| 1064 | |
Paul Mackerras | 9c1e105 | 2009-08-17 15:17:54 +1000 | [diff] [blame] | 1065 | /* |
| 1066 | * We come here as a result of a DSI at a point where we don't want |
| 1067 | * to call hash_page, such as when we are accessing memory (possibly |
| 1068 | * user memory) inside a PMU interrupt that occurred while interrupts |
| 1069 | * were soft-disabled. We want to invoke the exception handler for |
| 1070 | * the access, or panic if there isn't a handler. |
| 1071 | */ |
| 1072 | 77: bl .save_nvgprs |
| 1073 | mr r4,r3 |
| 1074 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 1075 | li r5,SIGSEGV |
| 1076 | bl .bad_page_fault |
| 1077 | b .ret_from_except |
| 1078 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1079 | /* here we have a segment miss */ |
| 1080 | do_ste_alloc: |
| 1081 | bl .ste_allocate /* try to insert stab entry */ |
| 1082 | cmpdi r3,0 |
| 1083 | bne- handle_page_fault |
| 1084 | b fast_exception_return |
| 1085 | |
| 1086 | /* |
| 1087 | * r13 points to the PACA, r9 contains the saved CR, |
| 1088 | * r11 and r12 contain the saved SRR0 and SRR1. |
| 1089 | * r9 - r13 are saved in paca->exslb. |
| 1090 | * We assume we aren't going to take any exceptions during this procedure. |
| 1091 | * We assume (DAR >> 60) == 0xc. |
| 1092 | */ |
| 1093 | .align 7 |
| 1094 | _GLOBAL(do_stab_bolted) |
| 1095 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ |
| 1096 | std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */ |
| 1097 | |
| 1098 | /* Hash to the primary group */ |
| 1099 | ld r10,PACASTABVIRT(r13) |
| 1100 | mfspr r11,SPRN_DAR |
| 1101 | srdi r11,r11,28 |
| 1102 | rldimi r10,r11,7,52 /* r10 = first ste of the group */ |
| 1103 | |
| 1104 | /* Calculate VSID */ |
Aneesh Kumar K.V | 048ee09 | 2012-09-10 02:52:55 +0000 | [diff] [blame] | 1105 | /* This is a kernel address, so protovsid = ESID | 1 << 37 */ |
| 1106 | li r9,0x1 |
| 1107 | rldimi r11,r9,(CONTEXT_BITS + USER_ESID_BITS),0 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1108 | ASM_VSID_SCRAMBLE(r11, r9, 256M) |
| 1109 | rldic r9,r11,12,16 /* r9 = vsid << 12 */ |
| 1110 | |
| 1111 | /* Search the primary group for a free entry */ |
| 1112 | 1: ld r11,0(r10) /* Test valid bit of the current ste */ |
| 1113 | andi. r11,r11,0x80 |
| 1114 | beq 2f |
| 1115 | addi r10,r10,16 |
| 1116 | andi. r11,r10,0x70 |
| 1117 | bne 1b |
| 1118 | |
| 1119 | /* Stick for only searching the primary group for now. */ |
| 1120 | /* At least for now, we use a very simple random castout scheme */ |
| 1121 | /* Use the TB as a random number ; OR in 1 to avoid entry 0 */ |
| 1122 | mftb r11 |
| 1123 | rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */ |
| 1124 | ori r11,r11,0x10 |
| 1125 | |
| 1126 | /* r10 currently points to an ste one past the group of interest */ |
| 1127 | /* make it point to the randomly selected entry */ |
| 1128 | subi r10,r10,128 |
| 1129 | or r10,r10,r11 /* r10 is the entry to invalidate */ |
| 1130 | |
| 1131 | isync /* mark the entry invalid */ |
| 1132 | ld r11,0(r10) |
| 1133 | rldicl r11,r11,56,1 /* clear the valid bit */ |
| 1134 | rotldi r11,r11,8 |
| 1135 | std r11,0(r10) |
| 1136 | sync |
| 1137 | |
| 1138 | clrrdi r11,r11,28 /* Get the esid part of the ste */ |
| 1139 | slbie r11 |
| 1140 | |
| 1141 | 2: std r9,8(r10) /* Store the vsid part of the ste */ |
| 1142 | eieio |
| 1143 | |
| 1144 | mfspr r11,SPRN_DAR /* Get the new esid */ |
| 1145 | clrrdi r11,r11,28 /* Permits a full 32b of ESID */ |
| 1146 | ori r11,r11,0x90 /* Turn on valid and kp */ |
| 1147 | std r11,0(r10) /* Put new entry back into the stab */ |
| 1148 | |
| 1149 | sync |
| 1150 | |
| 1151 | /* All done -- return from exception. */ |
| 1152 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ |
| 1153 | ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */ |
| 1154 | |
| 1155 | andi. r10,r12,MSR_RI |
| 1156 | beq- unrecov_slb |
| 1157 | |
| 1158 | mtcrf 0x80,r9 /* restore CR */ |
| 1159 | |
| 1160 | mfmsr r10 |
| 1161 | clrrdi r10,r10,2 |
| 1162 | mtmsrd r10,1 |
| 1163 | |
| 1164 | mtspr SPRN_SRR0,r11 |
| 1165 | mtspr SPRN_SRR1,r12 |
| 1166 | ld r9,PACA_EXSLB+EX_R9(r13) |
| 1167 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 1168 | ld r11,PACA_EXSLB+EX_R11(r13) |
| 1169 | ld r12,PACA_EXSLB+EX_R12(r13) |
| 1170 | ld r13,PACA_EXSLB+EX_R13(r13) |
| 1171 | rfid |
| 1172 | b . /* prevent speculative execution */ |
| 1173 | |
Benjamin Herrenschmidt | ed79ba9 | 2011-09-19 17:45:04 +0000 | [diff] [blame] | 1174 | #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1175 | /* |
| 1176 | * Data area reserved for FWNMI option. |
| 1177 | * This address (0x7000) is fixed by the RPA. |
| 1178 | */ |
| 1179 | .= 0x7000 |
| 1180 | .globl fwnmi_data_area |
| 1181 | fwnmi_data_area: |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1182 | |
Benjamin Herrenschmidt | ed79ba9 | 2011-09-19 17:45:04 +0000 | [diff] [blame] | 1183 | /* pseries and powernv need to keep the whole page from |
| 1184 | * 0x7000 to 0x8000 free for use by the firmware |
| 1185 | */ |
Michael Neuling | 278a6cd | 2012-11-02 14:11:51 +1100 | [diff] [blame] | 1186 | . = 0x8000 |
Benjamin Herrenschmidt | ed79ba9 | 2011-09-19 17:45:04 +0000 | [diff] [blame] | 1187 | #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */ |
Benjamin Herrenschmidt | 8449380 | 2011-03-06 18:09:07 +0000 | [diff] [blame] | 1188 | |
Benjamin Herrenschmidt | 4f8cf36 | 2012-02-28 13:44:58 +1100 | [diff] [blame] | 1189 | /* Space for CPU0's segment table */ |
| 1190 | .balign 4096 |
Benjamin Herrenschmidt | 8449380 | 2011-03-06 18:09:07 +0000 | [diff] [blame] | 1191 | .globl initial_stab |
| 1192 | initial_stab: |
| 1193 | .space 4096 |
Benjamin Herrenschmidt | 4f8cf36 | 2012-02-28 13:44:58 +1100 | [diff] [blame] | 1194 | |
Benjamin Herrenschmidt | ed79ba9 | 2011-09-19 17:45:04 +0000 | [diff] [blame] | 1195 | #ifdef CONFIG_PPC_POWERNV |
| 1196 | _GLOBAL(opal_mc_secondary_handler) |
| 1197 | HMT_MEDIUM |
| 1198 | SET_SCRATCH0(r13) |
| 1199 | GET_PACA(r13) |
| 1200 | clrldi r3,r3,2 |
| 1201 | tovirt(r3,r3) |
| 1202 | std r3,PACA_OPAL_MC_EVT(r13) |
| 1203 | ld r13,OPAL_MC_SRR0(r3) |
| 1204 | mtspr SPRN_SRR0,r13 |
| 1205 | ld r13,OPAL_MC_SRR1(r3) |
| 1206 | mtspr SPRN_SRR1,r13 |
| 1207 | ld r3,OPAL_MC_GPR3(r3) |
| 1208 | GET_SCRATCH0(r13) |
| 1209 | b machine_check_pSeries |
| 1210 | #endif /* CONFIG_PPC_POWERNV */ |