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 | 8aa34ab | 2009-07-14 20:52:52 +0000 | [diff] [blame] | 15 | #include <asm/exception-64s.h> |
Stephen Rothwell | 46f5221 | 2010-11-18 15:06:17 +0000 | [diff] [blame] | 16 | #include <asm/ptrace.h> |
Benjamin Herrenschmidt | 8aa34ab | 2009-07-14 20:52:52 +0000 | [diff] [blame] | 17 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 18 | /* |
| 19 | * We layout physical memory as follows: |
| 20 | * 0x0000 - 0x00ff : Secondary processor spin code |
| 21 | * 0x0100 - 0x2fff : pSeries Interrupt prologs |
| 22 | * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs |
| 23 | * 0x6000 - 0x6fff : Initial (CPU0) segment table |
| 24 | * 0x7000 - 0x7fff : FWNMI data area |
| 25 | * 0x8000 - : Early init and support code |
| 26 | */ |
| 27 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 28 | /* |
| 29 | * This is the start of the interrupt handlers for pSeries |
| 30 | * This code runs with relocation off. |
| 31 | * Code from here to __end_interrupts gets copied down to real |
| 32 | * address 0x100 when we are running a relocatable kernel. |
| 33 | * Therefore any relative branches in this section must only |
| 34 | * branch to labels in this section. |
| 35 | */ |
| 36 | . = 0x100 |
| 37 | .globl __start_interrupts |
| 38 | __start_interrupts: |
| 39 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 40 | STD_EXCEPTION_PSERIES(0x100, 0x100, system_reset) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 41 | |
| 42 | . = 0x200 |
| 43 | _machine_check_pSeries: |
| 44 | HMT_MEDIUM |
Alexander Graf | 842f2fe | 2009-10-30 05:47:17 +0000 | [diff] [blame] | 45 | DO_KVM 0x200 |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 46 | mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 47 | EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common, EXC_STD) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 48 | |
| 49 | . = 0x300 |
| 50 | .globl data_access_pSeries |
| 51 | data_access_pSeries: |
| 52 | HMT_MEDIUM |
Alexander Graf | 842f2fe | 2009-10-30 05:47:17 +0000 | [diff] [blame] | 53 | DO_KVM 0x300 |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 54 | mtspr SPRN_SPRG_SCRATCH0,r13 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 55 | BEGIN_FTR_SECTION |
Benjamin Herrenschmidt | 2dd60d7 | 2011-01-20 17:50:21 +1100 | [diff] [blame] | 56 | GET_PACA(r13) |
Benjamin Herrenschmidt | c5a8c0c | 2009-07-16 19:36:57 +0000 | [diff] [blame] | 57 | std r9,PACA_EXSLB+EX_R9(r13) |
| 58 | std r10,PACA_EXSLB+EX_R10(r13) |
| 59 | mfspr r10,SPRN_DAR |
| 60 | mfspr r9,SPRN_DSISR |
| 61 | srdi r10,r10,60 |
| 62 | rlwimi r10,r9,16,0x20 |
| 63 | mfcr r9 |
| 64 | cmpwi r10,0x2c |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 65 | beq do_stab_bolted_pSeries |
Benjamin Herrenschmidt | c5a8c0c | 2009-07-16 19:36:57 +0000 | [diff] [blame] | 66 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 67 | std r11,PACA_EXGEN+EX_R11(r13) |
| 68 | ld r11,PACA_EXSLB+EX_R9(r13) |
| 69 | std r12,PACA_EXGEN+EX_R12(r13) |
| 70 | mfspr r12,SPRN_SPRG_SCRATCH0 |
| 71 | std r10,PACA_EXGEN+EX_R10(r13) |
| 72 | std r11,PACA_EXGEN+EX_R9(r13) |
| 73 | std r12,PACA_EXGEN+EX_R13(r13) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 74 | EXCEPTION_PROLOG_PSERIES_1(data_access_common, EXC_STD) |
Benjamin Herrenschmidt | c5a8c0c | 2009-07-16 19:36:57 +0000 | [diff] [blame] | 75 | FTR_SECTION_ELSE |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 76 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD) |
Benjamin Herrenschmidt | c5a8c0c | 2009-07-16 19:36:57 +0000 | [diff] [blame] | 77 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_SLB) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 78 | |
| 79 | . = 0x380 |
| 80 | .globl data_access_slb_pSeries |
| 81 | data_access_slb_pSeries: |
| 82 | HMT_MEDIUM |
Alexander Graf | 842f2fe | 2009-10-30 05:47:17 +0000 | [diff] [blame] | 83 | DO_KVM 0x380 |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 84 | mtspr SPRN_SPRG_SCRATCH0,r13 |
Benjamin Herrenschmidt | 2dd60d7 | 2011-01-20 17:50:21 +1100 | [diff] [blame] | 85 | GET_PACA(r13) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 86 | std r3,PACA_EXSLB+EX_R3(r13) |
| 87 | mfspr r3,SPRN_DAR |
| 88 | std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ |
| 89 | mfcr r9 |
| 90 | #ifdef __DISABLED__ |
| 91 | /* Keep that around for when we re-implement dynamic VSIDs */ |
| 92 | cmpdi r3,0 |
| 93 | bge slb_miss_user_pseries |
| 94 | #endif /* __DISABLED__ */ |
| 95 | std r10,PACA_EXSLB+EX_R10(r13) |
| 96 | std r11,PACA_EXSLB+EX_R11(r13) |
| 97 | std r12,PACA_EXSLB+EX_R12(r13) |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 98 | mfspr r10,SPRN_SPRG_SCRATCH0 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 99 | std r10,PACA_EXSLB+EX_R13(r13) |
| 100 | mfspr r12,SPRN_SRR1 /* and SRR1 */ |
| 101 | #ifndef CONFIG_RELOCATABLE |
| 102 | b .slb_miss_realmode |
| 103 | #else |
| 104 | /* |
| 105 | * We can't just use a direct branch to .slb_miss_realmode |
| 106 | * because the distance from here to there depends on where |
| 107 | * the kernel ends up being put. |
| 108 | */ |
| 109 | mfctr r11 |
| 110 | ld r10,PACAKBASE(r13) |
| 111 | LOAD_HANDLER(r10, .slb_miss_realmode) |
| 112 | mtctr r10 |
| 113 | bctr |
| 114 | #endif |
| 115 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 116 | STD_EXCEPTION_PSERIES(0x400, 0x400, instruction_access) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 117 | |
| 118 | . = 0x480 |
| 119 | .globl instruction_access_slb_pSeries |
| 120 | instruction_access_slb_pSeries: |
| 121 | HMT_MEDIUM |
Alexander Graf | 842f2fe | 2009-10-30 05:47:17 +0000 | [diff] [blame] | 122 | DO_KVM 0x480 |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 123 | mtspr SPRN_SPRG_SCRATCH0,r13 |
Benjamin Herrenschmidt | 2dd60d7 | 2011-01-20 17:50:21 +1100 | [diff] [blame] | 124 | GET_PACA(r13) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 125 | std r3,PACA_EXSLB+EX_R3(r13) |
| 126 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ |
| 127 | std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ |
| 128 | mfcr r9 |
| 129 | #ifdef __DISABLED__ |
| 130 | /* Keep that around for when we re-implement dynamic VSIDs */ |
| 131 | cmpdi r3,0 |
| 132 | bge slb_miss_user_pseries |
| 133 | #endif /* __DISABLED__ */ |
| 134 | std r10,PACA_EXSLB+EX_R10(r13) |
| 135 | std r11,PACA_EXSLB+EX_R11(r13) |
| 136 | std r12,PACA_EXSLB+EX_R12(r13) |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 137 | mfspr r10,SPRN_SPRG_SCRATCH0 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 138 | std r10,PACA_EXSLB+EX_R13(r13) |
| 139 | mfspr r12,SPRN_SRR1 /* and SRR1 */ |
| 140 | #ifndef CONFIG_RELOCATABLE |
| 141 | b .slb_miss_realmode |
| 142 | #else |
| 143 | mfctr r11 |
| 144 | ld r10,PACAKBASE(r13) |
| 145 | LOAD_HANDLER(r10, .slb_miss_realmode) |
| 146 | mtctr r10 |
| 147 | bctr |
| 148 | #endif |
| 149 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 150 | /* We open code these as we can't have a ". = x" (even with |
| 151 | * x = "." within a feature section |
| 152 | */ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 153 | . = 0x500; |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 154 | .globl hardware_interrupt_pSeries; |
| 155 | .globl hardware_interrupt_hv; |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 156 | hardware_interrupt_pSeries: |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 157 | hardware_interrupt_hv: |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 158 | BEGIN_FTR_SECTION |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 159 | _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 160 | FTR_SECTION_ELSE |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 161 | _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 162 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_HVMODE_206) |
| 163 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 164 | STD_EXCEPTION_PSERIES(0x600, 0x600, alignment) |
| 165 | STD_EXCEPTION_PSERIES(0x700, 0x700, program_check) |
| 166 | STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 167 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 168 | MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer) |
| 169 | MASKABLE_EXCEPTION_HV(0x980, 0x980, decrementer) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 170 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 171 | STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a) |
| 172 | STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 173 | |
| 174 | . = 0xc00 |
| 175 | .globl system_call_pSeries |
| 176 | system_call_pSeries: |
| 177 | HMT_MEDIUM |
Alexander Graf | 842f2fe | 2009-10-30 05:47:17 +0000 | [diff] [blame] | 178 | DO_KVM 0xc00 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 179 | BEGIN_FTR_SECTION |
| 180 | cmpdi r0,0x1ebe |
| 181 | beq- 1f |
| 182 | END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) |
| 183 | mr r9,r13 |
Benjamin Herrenschmidt | 2dd60d7 | 2011-01-20 17:50:21 +1100 | [diff] [blame] | 184 | GET_PACA(r13) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 185 | mfspr r11,SPRN_SRR0 |
| 186 | ld r12,PACAKBASE(r13) |
| 187 | ld r10,PACAKMSR(r13) |
| 188 | LOAD_HANDLER(r12, system_call_entry) |
| 189 | mtspr SPRN_SRR0,r12 |
| 190 | mfspr r12,SPRN_SRR1 |
| 191 | mtspr SPRN_SRR1,r10 |
| 192 | rfid |
| 193 | b . /* prevent speculative execution */ |
| 194 | |
| 195 | /* Fast LE/BE switch system call */ |
| 196 | 1: mfspr r12,SPRN_SRR1 |
| 197 | xori r12,r12,MSR_LE |
| 198 | mtspr SPRN_SRR1,r12 |
| 199 | rfid /* return to userspace */ |
| 200 | b . |
| 201 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 202 | STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step) |
| 203 | |
| 204 | /* At 0xe??? we have a bunch of hypervisor exceptions, we branch |
| 205 | * out of line to handle them |
| 206 | */ |
| 207 | . = 0xe00 |
| 208 | b h_data_storage_hv |
| 209 | . = 0xe20 |
| 210 | b h_instr_storage_hv |
| 211 | . = 0xe40 |
| 212 | b emulation_assist_hv |
| 213 | . = 0xe50 |
| 214 | b hmi_exception_hv |
| 215 | . = 0xe60 |
| 216 | b hmi_exception_hv |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 217 | |
| 218 | /* We need to deal with the Altivec unavailable exception |
| 219 | * here which is at 0xf20, thus in the middle of the |
| 220 | * prolog code of the PerformanceMonitor one. A little |
| 221 | * trickery is thus necessary |
| 222 | */ |
Anton Blanchard | c86e2ea | 2009-10-18 01:24:06 +0000 | [diff] [blame] | 223 | performance_monitor_pSeries_1: |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 224 | . = 0xf00 |
| 225 | b performance_monitor_pSeries |
| 226 | |
Anton Blanchard | c86e2ea | 2009-10-18 01:24:06 +0000 | [diff] [blame] | 227 | altivec_unavailable_pSeries_1: |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 228 | . = 0xf20 |
| 229 | b altivec_unavailable_pSeries |
| 230 | |
Anton Blanchard | c86e2ea | 2009-10-18 01:24:06 +0000 | [diff] [blame] | 231 | vsx_unavailable_pSeries_1: |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 232 | . = 0xf40 |
| 233 | b vsx_unavailable_pSeries |
| 234 | |
| 235 | #ifdef CONFIG_CBE_RAS |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 236 | STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 237 | #endif /* CONFIG_CBE_RAS */ |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 238 | STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 239 | #ifdef CONFIG_CBE_RAS |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 240 | STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 241 | #endif /* CONFIG_CBE_RAS */ |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 242 | STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 243 | #ifdef CONFIG_CBE_RAS |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 244 | STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 245 | #endif /* CONFIG_CBE_RAS */ |
| 246 | |
| 247 | . = 0x3000 |
| 248 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 249 | /*** Out of line interrupts support ***/ |
| 250 | |
| 251 | /* moved from 0xe00 */ |
| 252 | STD_EXCEPTION_HV(., 0xe00, h_data_storage) |
| 253 | STD_EXCEPTION_HV(., 0xe20, h_instr_storage) |
| 254 | STD_EXCEPTION_HV(., 0xe40, emulation_assist) |
| 255 | STD_EXCEPTION_HV(., 0xe60, hmi_exception) /* need to flush cache ? */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 256 | |
| 257 | /* moved from 0xf00 */ |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 258 | STD_EXCEPTION_PSERIES(., 0xf00, performance_monitor) |
| 259 | STD_EXCEPTION_PSERIES(., 0xf20, altivec_unavailable) |
| 260 | STD_EXCEPTION_PSERIES(., 0xf40, vsx_unavailable) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 261 | |
| 262 | /* |
| 263 | * An interrupt came in while soft-disabled; clear EE in SRR1, |
| 264 | * clear paca->hard_enabled and return. |
| 265 | */ |
| 266 | masked_interrupt: |
| 267 | stb r10,PACAHARDIRQEN(r13) |
| 268 | mtcrf 0x80,r9 |
| 269 | ld r9,PACA_EXGEN+EX_R9(r13) |
| 270 | mfspr r10,SPRN_SRR1 |
| 271 | rldicl r10,r10,48,1 /* clear MSR_EE */ |
| 272 | rotldi r10,r10,16 |
| 273 | mtspr SPRN_SRR1,r10 |
| 274 | ld r10,PACA_EXGEN+EX_R10(r13) |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 275 | mfspr r13,SPRN_SPRG_SCRATCH0 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 276 | rfid |
| 277 | b . |
| 278 | |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 279 | masked_Hinterrupt: |
| 280 | stb r10,PACAHARDIRQEN(r13) |
| 281 | mtcrf 0x80,r9 |
| 282 | ld r9,PACA_EXGEN+EX_R9(r13) |
| 283 | mfspr r10,SPRN_HSRR1 |
| 284 | rldicl r10,r10,48,1 /* clear MSR_EE */ |
| 285 | rotldi r10,r10,16 |
| 286 | mtspr SPRN_HSRR1,r10 |
| 287 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 288 | mfspr r13,SPRN_SPRG_HSCRATCH0 |
| 289 | hrfid |
| 290 | b . |
| 291 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 292 | .align 7 |
| 293 | do_stab_bolted_pSeries: |
Benjamin Herrenschmidt | c5a8c0c | 2009-07-16 19:36:57 +0000 | [diff] [blame] | 294 | std r11,PACA_EXSLB+EX_R11(r13) |
| 295 | std r12,PACA_EXSLB+EX_R12(r13) |
| 296 | mfspr r10,SPRN_SPRG_SCRATCH0 |
| 297 | std r10,PACA_EXSLB+EX_R13(r13) |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 298 | EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 299 | |
| 300 | #ifdef CONFIG_PPC_PSERIES |
| 301 | /* |
| 302 | * Vectors for the FWNMI option. Share common code. |
| 303 | */ |
| 304 | .globl system_reset_fwnmi |
| 305 | .align 7 |
| 306 | system_reset_fwnmi: |
| 307 | HMT_MEDIUM |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 308 | mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 309 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 310 | |
| 311 | .globl machine_check_fwnmi |
| 312 | .align 7 |
| 313 | machine_check_fwnmi: |
| 314 | HMT_MEDIUM |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 315 | mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 316 | EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common, EXC_STD) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 317 | |
| 318 | #endif /* CONFIG_PPC_PSERIES */ |
| 319 | |
| 320 | #ifdef __DISABLED__ |
| 321 | /* |
| 322 | * This is used for when the SLB miss handler has to go virtual, |
| 323 | * which doesn't happen for now anymore but will once we re-implement |
| 324 | * dynamic VSIDs for shared page tables |
| 325 | */ |
| 326 | slb_miss_user_pseries: |
| 327 | std r10,PACA_EXGEN+EX_R10(r13) |
| 328 | std r11,PACA_EXGEN+EX_R11(r13) |
| 329 | std r12,PACA_EXGEN+EX_R12(r13) |
Benjamin Herrenschmidt | ee43eb7 | 2009-07-14 20:52:54 +0000 | [diff] [blame] | 330 | mfspr r10,SPRG_SCRATCH0 |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 331 | ld r11,PACA_EXSLB+EX_R9(r13) |
| 332 | ld r12,PACA_EXSLB+EX_R3(r13) |
| 333 | std r10,PACA_EXGEN+EX_R13(r13) |
| 334 | std r11,PACA_EXGEN+EX_R9(r13) |
| 335 | std r12,PACA_EXGEN+EX_R3(r13) |
| 336 | clrrdi r12,r13,32 |
| 337 | mfmsr r10 |
| 338 | mfspr r11,SRR0 /* save SRR0 */ |
| 339 | ori r12,r12,slb_miss_user_common@l /* virt addr of handler */ |
| 340 | ori r10,r10,MSR_IR|MSR_DR|MSR_RI |
| 341 | mtspr SRR0,r12 |
| 342 | mfspr r12,SRR1 /* and SRR1 */ |
| 343 | mtspr SRR1,r10 |
| 344 | rfid |
| 345 | b . /* prevent spec. execution */ |
| 346 | #endif /* __DISABLED__ */ |
| 347 | |
Alexander Graf | a58ddea | 2010-07-29 15:04:22 +0200 | [diff] [blame] | 348 | /* KVM's trampoline code needs to be close to the interrupt handlers */ |
| 349 | |
| 350 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
| 351 | #include "../kvm/book3s_rmhandlers.S" |
| 352 | #endif |
| 353 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 354 | .align 7 |
| 355 | .globl __end_interrupts |
| 356 | __end_interrupts: |
| 357 | |
| 358 | /* |
| 359 | * Code from here down to __end_handlers is invoked from the |
| 360 | * exception prologs above. Because the prologs assemble the |
| 361 | * addresses of these handlers using the LOAD_HANDLER macro, |
| 362 | * which uses an addi instruction, these handlers must be in |
| 363 | * the first 32k of the kernel image. |
| 364 | */ |
| 365 | |
| 366 | /*** Common interrupt handlers ***/ |
| 367 | |
| 368 | STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception) |
| 369 | |
| 370 | /* |
| 371 | * Machine check is different because we use a different |
| 372 | * save area: PACA_EXMC instead of PACA_EXGEN. |
| 373 | */ |
| 374 | .align 7 |
| 375 | .globl machine_check_common |
| 376 | machine_check_common: |
| 377 | EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) |
| 378 | FINISH_NAP |
| 379 | DISABLE_INTS |
| 380 | bl .save_nvgprs |
| 381 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 382 | bl .machine_check_exception |
| 383 | b .ret_from_except |
| 384 | |
| 385 | STD_EXCEPTION_COMMON_LITE(0x900, decrementer, .timer_interrupt) |
| 386 | STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception) |
| 387 | STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) |
| 388 | STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) |
| 389 | STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception) |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 390 | STD_EXCEPTION_COMMON(0xe40, emulation_assist, .program_check_exception) |
| 391 | STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception) |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 392 | STD_EXCEPTION_COMMON_IDLE(0xf00, performance_monitor, .performance_monitor_exception) |
| 393 | STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception) |
| 394 | #ifdef CONFIG_ALTIVEC |
| 395 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception) |
| 396 | #else |
| 397 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception) |
| 398 | #endif |
| 399 | #ifdef CONFIG_CBE_RAS |
| 400 | STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception) |
| 401 | STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception) |
| 402 | STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception) |
| 403 | #endif /* CONFIG_CBE_RAS */ |
| 404 | |
| 405 | .align 7 |
| 406 | system_call_entry: |
| 407 | b system_call_common |
| 408 | |
| 409 | /* |
| 410 | * Here we have detected that the kernel stack pointer is bad. |
| 411 | * R9 contains the saved CR, r13 points to the paca, |
| 412 | * r10 contains the (bad) kernel stack pointer, |
| 413 | * r11 and r12 contain the saved SRR0 and SRR1. |
| 414 | * We switch to using an emergency stack, save the registers there, |
| 415 | * and call kernel_bad_stack(), which panics. |
| 416 | */ |
| 417 | bad_stack: |
| 418 | ld r1,PACAEMERGSP(r13) |
| 419 | subi r1,r1,64+INT_FRAME_SIZE |
| 420 | std r9,_CCR(r1) |
| 421 | std r10,GPR1(r1) |
| 422 | std r11,_NIP(r1) |
| 423 | std r12,_MSR(r1) |
| 424 | mfspr r11,SPRN_DAR |
| 425 | mfspr r12,SPRN_DSISR |
| 426 | std r11,_DAR(r1) |
| 427 | std r12,_DSISR(r1) |
| 428 | mflr r10 |
| 429 | mfctr r11 |
| 430 | mfxer r12 |
| 431 | std r10,_LINK(r1) |
| 432 | std r11,_CTR(r1) |
| 433 | std r12,_XER(r1) |
| 434 | SAVE_GPR(0,r1) |
| 435 | SAVE_GPR(2,r1) |
| 436 | SAVE_4GPRS(3,r1) |
| 437 | SAVE_2GPRS(7,r1) |
| 438 | SAVE_10GPRS(12,r1) |
| 439 | SAVE_10GPRS(22,r1) |
| 440 | lhz r12,PACA_TRAP_SAVE(r13) |
| 441 | std r12,_TRAP(r1) |
| 442 | addi r11,r1,INT_FRAME_SIZE |
| 443 | std r11,0(r1) |
| 444 | li r12,0 |
| 445 | std r12,0(r11) |
| 446 | ld r2,PACATOC(r13) |
| 447 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 448 | bl .kernel_bad_stack |
| 449 | b 1b |
| 450 | |
| 451 | /* |
| 452 | * Here r13 points to the paca, r9 contains the saved CR, |
| 453 | * SRR0 and SRR1 are saved in r11 and r12, |
| 454 | * r9 - r13 are saved in paca->exgen. |
| 455 | */ |
| 456 | .align 7 |
| 457 | .globl data_access_common |
| 458 | data_access_common: |
| 459 | mfspr r10,SPRN_DAR |
| 460 | std r10,PACA_EXGEN+EX_DAR(r13) |
| 461 | mfspr r10,SPRN_DSISR |
| 462 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 463 | EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN) |
| 464 | ld r3,PACA_EXGEN+EX_DAR(r13) |
| 465 | lwz r4,PACA_EXGEN+EX_DSISR(r13) |
| 466 | li r5,0x300 |
| 467 | b .do_hash_page /* Try to handle as hpte fault */ |
| 468 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 469 | .align 7 |
| 470 | .globl h_data_storage_common |
| 471 | h_data_storage_common: |
| 472 | mfspr r10,SPRN_HDAR |
| 473 | std r10,PACA_EXGEN+EX_DAR(r13) |
| 474 | mfspr r10,SPRN_HDSISR |
| 475 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 476 | EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN) |
| 477 | bl .save_nvgprs |
| 478 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 479 | bl .unknown_exception |
| 480 | b .ret_from_except |
| 481 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 482 | .align 7 |
| 483 | .globl instruction_access_common |
| 484 | instruction_access_common: |
| 485 | EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN) |
| 486 | ld r3,_NIP(r1) |
| 487 | andis. r4,r12,0x5820 |
| 488 | li r5,0x400 |
| 489 | b .do_hash_page /* Try to handle as hpte fault */ |
| 490 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame^] | 491 | STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception) |
| 492 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 493 | /* |
| 494 | * Here is the common SLB miss user that is used when going to virtual |
| 495 | * mode for SLB misses, that is currently not used |
| 496 | */ |
| 497 | #ifdef __DISABLED__ |
| 498 | .align 7 |
| 499 | .globl slb_miss_user_common |
| 500 | slb_miss_user_common: |
| 501 | mflr r10 |
| 502 | std r3,PACA_EXGEN+EX_DAR(r13) |
| 503 | stw r9,PACA_EXGEN+EX_CCR(r13) |
| 504 | std r10,PACA_EXGEN+EX_LR(r13) |
| 505 | std r11,PACA_EXGEN+EX_SRR0(r13) |
| 506 | bl .slb_allocate_user |
| 507 | |
| 508 | ld r10,PACA_EXGEN+EX_LR(r13) |
| 509 | ld r3,PACA_EXGEN+EX_R3(r13) |
| 510 | lwz r9,PACA_EXGEN+EX_CCR(r13) |
| 511 | ld r11,PACA_EXGEN+EX_SRR0(r13) |
| 512 | mtlr r10 |
| 513 | beq- slb_miss_fault |
| 514 | |
| 515 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ |
| 516 | beq- unrecov_user_slb |
| 517 | mfmsr r10 |
| 518 | |
| 519 | .machine push |
| 520 | .machine "power4" |
| 521 | mtcrf 0x80,r9 |
| 522 | .machine pop |
| 523 | |
| 524 | clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */ |
| 525 | mtmsrd r10,1 |
| 526 | |
| 527 | mtspr SRR0,r11 |
| 528 | mtspr SRR1,r12 |
| 529 | |
| 530 | ld r9,PACA_EXGEN+EX_R9(r13) |
| 531 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 532 | ld r11,PACA_EXGEN+EX_R11(r13) |
| 533 | ld r12,PACA_EXGEN+EX_R12(r13) |
| 534 | ld r13,PACA_EXGEN+EX_R13(r13) |
| 535 | rfid |
| 536 | b . |
| 537 | |
| 538 | slb_miss_fault: |
| 539 | EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN) |
| 540 | ld r4,PACA_EXGEN+EX_DAR(r13) |
| 541 | li r5,0 |
| 542 | std r4,_DAR(r1) |
| 543 | std r5,_DSISR(r1) |
| 544 | b handle_page_fault |
| 545 | |
| 546 | unrecov_user_slb: |
| 547 | EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN) |
| 548 | DISABLE_INTS |
| 549 | bl .save_nvgprs |
| 550 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 551 | bl .unrecoverable_exception |
| 552 | b 1b |
| 553 | |
| 554 | #endif /* __DISABLED__ */ |
| 555 | |
| 556 | |
| 557 | /* |
| 558 | * r13 points to the PACA, r9 contains the saved CR, |
| 559 | * r12 contain the saved SRR1, SRR0 is still ready for return |
| 560 | * r3 has the faulting address |
| 561 | * r9 - r13 are saved in paca->exslb. |
| 562 | * r3 is saved in paca->slb_r3 |
| 563 | * We assume we aren't going to take any exceptions during this procedure. |
| 564 | */ |
| 565 | _GLOBAL(slb_miss_realmode) |
| 566 | mflr r10 |
| 567 | #ifdef CONFIG_RELOCATABLE |
| 568 | mtctr r11 |
| 569 | #endif |
| 570 | |
| 571 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ |
| 572 | std r10,PACA_EXSLB+EX_LR(r13) /* save LR */ |
| 573 | |
| 574 | bl .slb_allocate_realmode |
| 575 | |
| 576 | /* All done -- return from exception. */ |
| 577 | |
| 578 | ld r10,PACA_EXSLB+EX_LR(r13) |
| 579 | ld r3,PACA_EXSLB+EX_R3(r13) |
| 580 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ |
| 581 | #ifdef CONFIG_PPC_ISERIES |
| 582 | BEGIN_FW_FTR_SECTION |
| 583 | ld r11,PACALPPACAPTR(r13) |
| 584 | ld r11,LPPACASRR0(r11) /* get SRR0 value */ |
| 585 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
| 586 | #endif /* CONFIG_PPC_ISERIES */ |
| 587 | |
| 588 | mtlr r10 |
| 589 | |
| 590 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ |
| 591 | beq- 2f |
| 592 | |
| 593 | .machine push |
| 594 | .machine "power4" |
| 595 | mtcrf 0x80,r9 |
| 596 | mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ |
| 597 | .machine pop |
| 598 | |
| 599 | #ifdef CONFIG_PPC_ISERIES |
| 600 | BEGIN_FW_FTR_SECTION |
| 601 | mtspr SPRN_SRR0,r11 |
| 602 | mtspr SPRN_SRR1,r12 |
| 603 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
| 604 | #endif /* CONFIG_PPC_ISERIES */ |
| 605 | ld r9,PACA_EXSLB+EX_R9(r13) |
| 606 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 607 | ld r11,PACA_EXSLB+EX_R11(r13) |
| 608 | ld r12,PACA_EXSLB+EX_R12(r13) |
| 609 | ld r13,PACA_EXSLB+EX_R13(r13) |
| 610 | rfid |
| 611 | b . /* prevent speculative execution */ |
| 612 | |
| 613 | 2: |
| 614 | #ifdef CONFIG_PPC_ISERIES |
| 615 | BEGIN_FW_FTR_SECTION |
| 616 | b unrecov_slb |
| 617 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
| 618 | #endif /* CONFIG_PPC_ISERIES */ |
| 619 | mfspr r11,SPRN_SRR0 |
| 620 | ld r10,PACAKBASE(r13) |
| 621 | LOAD_HANDLER(r10,unrecov_slb) |
| 622 | mtspr SPRN_SRR0,r10 |
| 623 | ld r10,PACAKMSR(r13) |
| 624 | mtspr SPRN_SRR1,r10 |
| 625 | rfid |
| 626 | b . |
| 627 | |
| 628 | unrecov_slb: |
| 629 | EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB) |
| 630 | DISABLE_INTS |
| 631 | bl .save_nvgprs |
| 632 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 633 | bl .unrecoverable_exception |
| 634 | b 1b |
| 635 | |
| 636 | .align 7 |
| 637 | .globl hardware_interrupt_common |
| 638 | .globl hardware_interrupt_entry |
| 639 | hardware_interrupt_common: |
| 640 | EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN) |
| 641 | FINISH_NAP |
| 642 | hardware_interrupt_entry: |
| 643 | DISABLE_INTS |
| 644 | BEGIN_FTR_SECTION |
| 645 | bl .ppc64_runlatch_on |
| 646 | END_FTR_SECTION_IFSET(CPU_FTR_CTRL) |
| 647 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 648 | bl .do_IRQ |
| 649 | b .ret_from_except_lite |
| 650 | |
| 651 | #ifdef CONFIG_PPC_970_NAP |
| 652 | power4_fixup_nap: |
| 653 | andc r9,r9,r10 |
| 654 | std r9,TI_LOCAL_FLAGS(r11) |
| 655 | ld r10,_LINK(r1) /* make idle task do the */ |
| 656 | std r10,_NIP(r1) /* equivalent of a blr */ |
| 657 | blr |
| 658 | #endif |
| 659 | |
| 660 | .align 7 |
| 661 | .globl alignment_common |
| 662 | alignment_common: |
| 663 | mfspr r10,SPRN_DAR |
| 664 | std r10,PACA_EXGEN+EX_DAR(r13) |
| 665 | mfspr r10,SPRN_DSISR |
| 666 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 667 | EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN) |
| 668 | ld r3,PACA_EXGEN+EX_DAR(r13) |
| 669 | lwz r4,PACA_EXGEN+EX_DSISR(r13) |
| 670 | std r3,_DAR(r1) |
| 671 | std r4,_DSISR(r1) |
| 672 | bl .save_nvgprs |
| 673 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 674 | ENABLE_INTS |
| 675 | bl .alignment_exception |
| 676 | b .ret_from_except |
| 677 | |
| 678 | .align 7 |
| 679 | .globl program_check_common |
| 680 | program_check_common: |
| 681 | EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) |
| 682 | bl .save_nvgprs |
| 683 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 684 | ENABLE_INTS |
| 685 | bl .program_check_exception |
| 686 | b .ret_from_except |
| 687 | |
| 688 | .align 7 |
| 689 | .globl fp_unavailable_common |
| 690 | fp_unavailable_common: |
| 691 | EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) |
| 692 | bne 1f /* if from user, just load it up */ |
| 693 | bl .save_nvgprs |
| 694 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 695 | ENABLE_INTS |
| 696 | bl .kernel_fp_unavailable_exception |
| 697 | BUG_OPCODE |
| 698 | 1: bl .load_up_fpu |
| 699 | b fast_exception_return |
| 700 | |
| 701 | .align 7 |
| 702 | .globl altivec_unavailable_common |
| 703 | altivec_unavailable_common: |
| 704 | EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN) |
| 705 | #ifdef CONFIG_ALTIVEC |
| 706 | BEGIN_FTR_SECTION |
| 707 | beq 1f |
| 708 | bl .load_up_altivec |
| 709 | b fast_exception_return |
| 710 | 1: |
| 711 | END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) |
| 712 | #endif |
| 713 | bl .save_nvgprs |
| 714 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 715 | ENABLE_INTS |
| 716 | bl .altivec_unavailable_exception |
| 717 | b .ret_from_except |
| 718 | |
| 719 | .align 7 |
| 720 | .globl vsx_unavailable_common |
| 721 | vsx_unavailable_common: |
| 722 | EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN) |
| 723 | #ifdef CONFIG_VSX |
| 724 | BEGIN_FTR_SECTION |
| 725 | bne .load_up_vsx |
| 726 | 1: |
| 727 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) |
| 728 | #endif |
| 729 | bl .save_nvgprs |
| 730 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 731 | ENABLE_INTS |
| 732 | bl .vsx_unavailable_exception |
| 733 | b .ret_from_except |
| 734 | |
| 735 | .align 7 |
| 736 | .globl __end_handlers |
| 737 | __end_handlers: |
| 738 | |
| 739 | /* |
| 740 | * Return from an exception with minimal checks. |
| 741 | * The caller is assumed to have done EXCEPTION_PROLOG_COMMON. |
| 742 | * If interrupts have been enabled, or anything has been |
| 743 | * done that might have changed the scheduling status of |
| 744 | * any task or sent any task a signal, you should use |
| 745 | * ret_from_except or ret_from_except_lite instead of this. |
| 746 | */ |
| 747 | fast_exc_return_irq: /* restores irq state too */ |
| 748 | ld r3,SOFTE(r1) |
| 749 | TRACE_AND_RESTORE_IRQ(r3); |
| 750 | ld r12,_MSR(r1) |
| 751 | rldicl r4,r12,49,63 /* get MSR_EE to LSB */ |
| 752 | stb r4,PACAHARDIRQEN(r13) /* restore paca->hard_enabled */ |
| 753 | b 1f |
| 754 | |
| 755 | .globl fast_exception_return |
| 756 | fast_exception_return: |
| 757 | ld r12,_MSR(r1) |
| 758 | 1: ld r11,_NIP(r1) |
| 759 | andi. r3,r12,MSR_RI /* check if RI is set */ |
| 760 | beq- unrecov_fer |
| 761 | |
| 762 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
| 763 | andi. r3,r12,MSR_PR |
| 764 | beq 2f |
| 765 | ACCOUNT_CPU_USER_EXIT(r3, r4) |
| 766 | 2: |
| 767 | #endif |
| 768 | |
| 769 | ld r3,_CCR(r1) |
| 770 | ld r4,_LINK(r1) |
| 771 | ld r5,_CTR(r1) |
| 772 | ld r6,_XER(r1) |
| 773 | mtcr r3 |
| 774 | mtlr r4 |
| 775 | mtctr r5 |
| 776 | mtxer r6 |
| 777 | REST_GPR(0, r1) |
| 778 | REST_8GPRS(2, r1) |
| 779 | |
| 780 | mfmsr r10 |
| 781 | rldicl r10,r10,48,1 /* clear EE */ |
| 782 | rldicr r10,r10,16,61 /* clear RI (LE is 0 already) */ |
| 783 | mtmsrd r10,1 |
| 784 | |
| 785 | mtspr SPRN_SRR1,r12 |
| 786 | mtspr SPRN_SRR0,r11 |
| 787 | REST_4GPRS(10, r1) |
| 788 | ld r1,GPR1(r1) |
| 789 | rfid |
| 790 | b . /* prevent speculative execution */ |
| 791 | |
| 792 | unrecov_fer: |
| 793 | bl .save_nvgprs |
| 794 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 795 | bl .unrecoverable_exception |
| 796 | b 1b |
| 797 | |
| 798 | |
| 799 | /* |
| 800 | * Hash table stuff |
| 801 | */ |
| 802 | .align 7 |
| 803 | _STATIC(do_hash_page) |
| 804 | std r3,_DAR(r1) |
| 805 | std r4,_DSISR(r1) |
| 806 | |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 807 | andis. r0,r4,0xa410 /* weird error? */ |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 808 | bne- handle_page_fault /* if not, try to insert a HPTE */ |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 809 | andis. r0,r4,DSISR_DABRMATCH@h |
| 810 | bne- handle_dabr_fault |
| 811 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 812 | BEGIN_FTR_SECTION |
| 813 | andis. r0,r4,0x0020 /* Is it a segment table fault? */ |
| 814 | bne- do_ste_alloc /* If so handle it */ |
| 815 | END_FTR_SECTION_IFCLR(CPU_FTR_SLB) |
| 816 | |
Paul Mackerras | 9c1e105 | 2009-08-17 15:17:54 +1000 | [diff] [blame] | 817 | clrrdi r11,r1,THREAD_SHIFT |
| 818 | lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */ |
| 819 | andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */ |
| 820 | bne 77f /* then don't call hash_page now */ |
| 821 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 822 | /* |
| 823 | * On iSeries, we soft-disable interrupts here, then |
| 824 | * hard-enable interrupts so that the hash_page code can spin on |
| 825 | * the hash_table_lock without problems on a shared processor. |
| 826 | */ |
| 827 | DISABLE_INTS |
| 828 | |
| 829 | /* |
| 830 | * Currently, trace_hardirqs_off() will be called by DISABLE_INTS |
| 831 | * and will clobber volatile registers when irq tracing is enabled |
| 832 | * so we need to reload them. It may be possible to be smarter here |
| 833 | * and move the irq tracing elsewhere but let's keep it simple for |
| 834 | * now |
| 835 | */ |
| 836 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 837 | ld r3,_DAR(r1) |
| 838 | ld r4,_DSISR(r1) |
| 839 | ld r5,_TRAP(r1) |
| 840 | ld r12,_MSR(r1) |
| 841 | clrrdi r5,r5,4 |
| 842 | #endif /* CONFIG_TRACE_IRQFLAGS */ |
| 843 | /* |
| 844 | * We need to set the _PAGE_USER bit if MSR_PR is set or if we are |
| 845 | * accessing a userspace segment (even from the kernel). We assume |
| 846 | * kernel addresses always have the high bit set. |
| 847 | */ |
| 848 | rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */ |
| 849 | rotldi r0,r3,15 /* Move high bit into MSR_PR posn */ |
| 850 | orc r0,r12,r0 /* MSR_PR | ~high_bit */ |
| 851 | rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */ |
| 852 | ori r4,r4,1 /* add _PAGE_PRESENT */ |
| 853 | rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */ |
| 854 | |
| 855 | /* |
| 856 | * r3 contains the faulting address |
| 857 | * r4 contains the required access permissions |
| 858 | * r5 contains the trap number |
| 859 | * |
| 860 | * at return r3 = 0 for success |
| 861 | */ |
| 862 | bl .hash_page /* build HPTE if possible */ |
| 863 | cmpdi r3,0 /* see if hash_page succeeded */ |
| 864 | |
| 865 | BEGIN_FW_FTR_SECTION |
| 866 | /* |
| 867 | * If we had interrupts soft-enabled at the point where the |
| 868 | * DSI/ISI occurred, and an interrupt came in during hash_page, |
| 869 | * handle it now. |
| 870 | * We jump to ret_from_except_lite rather than fast_exception_return |
| 871 | * because ret_from_except_lite will check for and handle pending |
| 872 | * interrupts if necessary. |
| 873 | */ |
| 874 | beq 13f |
| 875 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
| 876 | |
| 877 | BEGIN_FW_FTR_SECTION |
| 878 | /* |
| 879 | * Here we have interrupts hard-disabled, so it is sufficient |
| 880 | * to restore paca->{soft,hard}_enable and get out. |
| 881 | */ |
| 882 | beq fast_exc_return_irq /* Return from exception on success */ |
| 883 | END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES) |
| 884 | |
| 885 | /* For a hash failure, we don't bother re-enabling interrupts */ |
| 886 | ble- 12f |
| 887 | |
| 888 | /* |
| 889 | * hash_page couldn't handle it, set soft interrupt enable back |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 890 | * to what it was before the trap. Note that .arch_local_irq_restore |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 891 | * handles any interrupts pending at this point. |
| 892 | */ |
| 893 | ld r3,SOFTE(r1) |
| 894 | TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 895 | bl .arch_local_irq_restore |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 896 | b 11f |
| 897 | |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 898 | /* We have a data breakpoint exception - handle it */ |
| 899 | handle_dabr_fault: |
K.Prasad | 5aae8a5 | 2010-06-15 11:35:19 +0530 | [diff] [blame] | 900 | bl .save_nvgprs |
K.Prasad | 9c7cc23 | 2010-03-29 23:59:25 +0000 | [diff] [blame] | 901 | ld r4,_DAR(r1) |
| 902 | ld r5,_DSISR(r1) |
| 903 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 904 | bl .do_dabr |
| 905 | b .ret_from_except_lite |
| 906 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 907 | /* Here we have a page fault that hash_page can't handle. */ |
| 908 | handle_page_fault: |
| 909 | ENABLE_INTS |
| 910 | 11: ld r4,_DAR(r1) |
| 911 | ld r5,_DSISR(r1) |
| 912 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 913 | bl .do_page_fault |
| 914 | cmpdi r3,0 |
| 915 | beq+ 13f |
| 916 | bl .save_nvgprs |
| 917 | mr r5,r3 |
| 918 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 919 | lwz r4,_DAR(r1) |
| 920 | bl .bad_page_fault |
| 921 | b .ret_from_except |
| 922 | |
| 923 | 13: b .ret_from_except_lite |
| 924 | |
| 925 | /* We have a page fault that hash_page could handle but HV refused |
| 926 | * the PTE insertion |
| 927 | */ |
| 928 | 12: bl .save_nvgprs |
| 929 | mr r5,r3 |
| 930 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 931 | ld r4,_DAR(r1) |
| 932 | bl .low_hash_fault |
| 933 | b .ret_from_except |
| 934 | |
Paul Mackerras | 9c1e105 | 2009-08-17 15:17:54 +1000 | [diff] [blame] | 935 | /* |
| 936 | * We come here as a result of a DSI at a point where we don't want |
| 937 | * to call hash_page, such as when we are accessing memory (possibly |
| 938 | * user memory) inside a PMU interrupt that occurred while interrupts |
| 939 | * were soft-disabled. We want to invoke the exception handler for |
| 940 | * the access, or panic if there isn't a handler. |
| 941 | */ |
| 942 | 77: bl .save_nvgprs |
| 943 | mr r4,r3 |
| 944 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 945 | li r5,SIGSEGV |
| 946 | bl .bad_page_fault |
| 947 | b .ret_from_except |
| 948 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 949 | /* here we have a segment miss */ |
| 950 | do_ste_alloc: |
| 951 | bl .ste_allocate /* try to insert stab entry */ |
| 952 | cmpdi r3,0 |
| 953 | bne- handle_page_fault |
| 954 | b fast_exception_return |
| 955 | |
| 956 | /* |
| 957 | * r13 points to the PACA, r9 contains the saved CR, |
| 958 | * r11 and r12 contain the saved SRR0 and SRR1. |
| 959 | * r9 - r13 are saved in paca->exslb. |
| 960 | * We assume we aren't going to take any exceptions during this procedure. |
| 961 | * We assume (DAR >> 60) == 0xc. |
| 962 | */ |
| 963 | .align 7 |
| 964 | _GLOBAL(do_stab_bolted) |
| 965 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ |
| 966 | std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */ |
| 967 | |
| 968 | /* Hash to the primary group */ |
| 969 | ld r10,PACASTABVIRT(r13) |
| 970 | mfspr r11,SPRN_DAR |
| 971 | srdi r11,r11,28 |
| 972 | rldimi r10,r11,7,52 /* r10 = first ste of the group */ |
| 973 | |
| 974 | /* Calculate VSID */ |
| 975 | /* This is a kernel address, so protovsid = ESID */ |
| 976 | ASM_VSID_SCRAMBLE(r11, r9, 256M) |
| 977 | rldic r9,r11,12,16 /* r9 = vsid << 12 */ |
| 978 | |
| 979 | /* Search the primary group for a free entry */ |
| 980 | 1: ld r11,0(r10) /* Test valid bit of the current ste */ |
| 981 | andi. r11,r11,0x80 |
| 982 | beq 2f |
| 983 | addi r10,r10,16 |
| 984 | andi. r11,r10,0x70 |
| 985 | bne 1b |
| 986 | |
| 987 | /* Stick for only searching the primary group for now. */ |
| 988 | /* At least for now, we use a very simple random castout scheme */ |
| 989 | /* Use the TB as a random number ; OR in 1 to avoid entry 0 */ |
| 990 | mftb r11 |
| 991 | rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */ |
| 992 | ori r11,r11,0x10 |
| 993 | |
| 994 | /* r10 currently points to an ste one past the group of interest */ |
| 995 | /* make it point to the randomly selected entry */ |
| 996 | subi r10,r10,128 |
| 997 | or r10,r10,r11 /* r10 is the entry to invalidate */ |
| 998 | |
| 999 | isync /* mark the entry invalid */ |
| 1000 | ld r11,0(r10) |
| 1001 | rldicl r11,r11,56,1 /* clear the valid bit */ |
| 1002 | rotldi r11,r11,8 |
| 1003 | std r11,0(r10) |
| 1004 | sync |
| 1005 | |
| 1006 | clrrdi r11,r11,28 /* Get the esid part of the ste */ |
| 1007 | slbie r11 |
| 1008 | |
| 1009 | 2: std r9,8(r10) /* Store the vsid part of the ste */ |
| 1010 | eieio |
| 1011 | |
| 1012 | mfspr r11,SPRN_DAR /* Get the new esid */ |
| 1013 | clrrdi r11,r11,28 /* Permits a full 32b of ESID */ |
| 1014 | ori r11,r11,0x90 /* Turn on valid and kp */ |
| 1015 | std r11,0(r10) /* Put new entry back into the stab */ |
| 1016 | |
| 1017 | sync |
| 1018 | |
| 1019 | /* All done -- return from exception. */ |
| 1020 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ |
| 1021 | ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */ |
| 1022 | |
| 1023 | andi. r10,r12,MSR_RI |
| 1024 | beq- unrecov_slb |
| 1025 | |
| 1026 | mtcrf 0x80,r9 /* restore CR */ |
| 1027 | |
| 1028 | mfmsr r10 |
| 1029 | clrrdi r10,r10,2 |
| 1030 | mtmsrd r10,1 |
| 1031 | |
| 1032 | mtspr SPRN_SRR0,r11 |
| 1033 | mtspr SPRN_SRR1,r12 |
| 1034 | ld r9,PACA_EXSLB+EX_R9(r13) |
| 1035 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 1036 | ld r11,PACA_EXSLB+EX_R11(r13) |
| 1037 | ld r12,PACA_EXSLB+EX_R12(r13) |
| 1038 | ld r13,PACA_EXSLB+EX_R13(r13) |
| 1039 | rfid |
| 1040 | b . /* prevent speculative execution */ |
| 1041 | |
Benjamin Herrenschmidt | 0ebc4cd | 2009-06-02 21:17:38 +0000 | [diff] [blame] | 1042 | #ifdef CONFIG_PPC_PSERIES |
| 1043 | /* |
| 1044 | * Data area reserved for FWNMI option. |
| 1045 | * This address (0x7000) is fixed by the RPA. |
| 1046 | */ |
| 1047 | .= 0x7000 |
| 1048 | .globl fwnmi_data_area |
| 1049 | fwnmi_data_area: |
| 1050 | #endif /* CONFIG_PPC_PSERIES */ |
| 1051 | |
| 1052 | /* iSeries does not use the FWNMI stuff, so it is safe to put |
| 1053 | * this here, even if we later allow kernels that will boot on |
| 1054 | * both pSeries and iSeries */ |
| 1055 | #ifdef CONFIG_PPC_ISERIES |
| 1056 | . = LPARMAP_PHYS |
| 1057 | .globl xLparMap |
| 1058 | xLparMap: |
| 1059 | .quad HvEsidsToMap /* xNumberEsids */ |
| 1060 | .quad HvRangesToMap /* xNumberRanges */ |
| 1061 | .quad STAB0_PAGE /* xSegmentTableOffs */ |
| 1062 | .zero 40 /* xRsvd */ |
| 1063 | /* xEsids (HvEsidsToMap entries of 2 quads) */ |
| 1064 | .quad PAGE_OFFSET_ESID /* xKernelEsid */ |
| 1065 | .quad PAGE_OFFSET_VSID /* xKernelVsid */ |
| 1066 | .quad VMALLOC_START_ESID /* xKernelEsid */ |
| 1067 | .quad VMALLOC_START_VSID /* xKernelVsid */ |
| 1068 | /* xRanges (HvRangesToMap entries of 3 quads) */ |
| 1069 | .quad HvPagesToMap /* xPages */ |
| 1070 | .quad 0 /* xOffset */ |
| 1071 | .quad PAGE_OFFSET_VSID << (SID_SHIFT - HW_PAGE_SHIFT) /* xVPN */ |
| 1072 | |
| 1073 | #endif /* CONFIG_PPC_ISERIES */ |
| 1074 | |
| 1075 | #ifdef CONFIG_PPC_PSERIES |
| 1076 | . = 0x8000 |
| 1077 | #endif /* CONFIG_PPC_PSERIES */ |
Benjamin Herrenschmidt | 8449380 | 2011-03-06 18:09:07 +0000 | [diff] [blame] | 1078 | |
| 1079 | /* |
| 1080 | * Space for CPU0's segment table. |
| 1081 | * |
| 1082 | * On iSeries, the hypervisor must fill in at least one entry before |
| 1083 | * we get control (with relocate on). The address is given to the hv |
| 1084 | * as a page number (see xLparMap above), so this must be at a |
| 1085 | * fixed address (the linker can't compute (u64)&initial_stab >> |
| 1086 | * PAGE_SHIFT). |
| 1087 | */ |
| 1088 | . = STAB0_OFFSET /* 0x8000 */ |
| 1089 | .globl initial_stab |
| 1090 | initial_stab: |
| 1091 | .space 4096 |