1 #ifndef _ASM_POWERPC_EXCEPTION_H 2 #define _ASM_POWERPC_EXCEPTION_H 3 /* 4 * Extracted from head_64.S 5 * 6 * PowerPC version 7 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 8 * 9 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP 10 * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu> 11 * Adapted for Power Macintosh by Paul Mackerras. 12 * Low-level exception handlers and MMU support 13 * rewritten by Paul Mackerras. 14 * Copyright (C) 1996 Paul Mackerras. 15 * 16 * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and 17 * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com 18 * 19 * This file contains the low-level support and setup for the 20 * PowerPC-64 platform, including trap and interrupt dispatch. 21 * 22 * This program is free software; you can redistribute it and/or 23 * modify it under the terms of the GNU General Public License 24 * as published by the Free Software Foundation; either version 25 * 2 of the License, or (at your option) any later version. 26 */ 27 /* 28 * The following macros define the code that appears as 29 * the prologue to each of the exception handlers. They 30 * are split into two parts to allow a single kernel binary 31 * to be used for pSeries and iSeries. 32 * 33 * We make as much of the exception code common between native 34 * exception handlers (including pSeries LPAR) and iSeries LPAR 35 * implementations as possible. 36 */ 37 #include <asm/head-64.h> 38 39 #define EX_R9 0 40 #define EX_R10 8 41 #define EX_R11 16 42 #define EX_R12 24 43 #define EX_R13 32 44 #define EX_SRR0 40 45 #define EX_DAR 48 46 #define EX_DSISR 56 47 #define EX_CCR 60 48 #define EX_R3 64 49 #define EX_LR 72 50 #define EX_CFAR 80 51 #define EX_PPR 88 /* SMT thread status register (priority) */ 52 #define EX_CTR 96 53 54 #ifdef CONFIG_RELOCATABLE 55 #define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 56 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 57 LOAD_HANDLER(r12,label); \ 58 mtctr r12; \ 59 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 60 li r10,MSR_RI; \ 61 mtmsrd r10,1; /* Set RI (EE=0) */ \ 62 bctr; 63 #else 64 /* If not relocatable, we can jump directly -- and save messing with LR */ 65 #define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 66 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 67 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 68 li r10,MSR_RI; \ 69 mtmsrd r10,1; /* Set RI (EE=0) */ \ 70 b label; 71 #endif 72 #define EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 73 __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 74 75 /* 76 * As EXCEPTION_PROLOG_PSERIES(), except we've already got relocation on 77 * so no need to rfid. Save lr in case we're CONFIG_RELOCATABLE, in which 78 * case EXCEPTION_RELON_PROLOG_PSERIES_1 will be using lr. 79 */ 80 #define EXCEPTION_RELON_PROLOG_PSERIES(area, label, h, extra, vec) \ 81 EXCEPTION_PROLOG_0(area); \ 82 EXCEPTION_PROLOG_1(area, extra, vec); \ 83 EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) 84 85 /* 86 * We're short on space and time in the exception prolog, so we can't 87 * use the normal LOAD_REG_IMMEDIATE macro to load the address of label. 88 * Instead we get the base of the kernel from paca->kernelbase and or in the low 89 * part of label. This requires that the label be within 64KB of kernelbase, and 90 * that kernelbase be 64K aligned. 91 */ 92 #define LOAD_HANDLER(reg, label) \ 93 ld reg,PACAKBASE(r13); /* get high part of &label */ \ 94 ori reg,reg,FIXED_SYMBOL_ABS_ADDR(label); 95 96 #define __LOAD_HANDLER(reg, label) \ 97 ld reg,PACAKBASE(r13); \ 98 ori reg,reg,(ABS_ADDR(label))@l; 99 100 /* 101 * Branches from unrelocated code (e.g., interrupts) to labels outside 102 * head-y require >64K offsets. 103 */ 104 #define __LOAD_FAR_HANDLER(reg, label) \ 105 ld reg,PACAKBASE(r13); \ 106 ori reg,reg,(ABS_ADDR(label))@l; \ 107 addis reg,reg,(ABS_ADDR(label))@h; 108 109 /* Exception register prefixes */ 110 #define EXC_HV H 111 #define EXC_STD 112 113 #if defined(CONFIG_RELOCATABLE) 114 /* 115 * If we support interrupts with relocation on AND we're a relocatable kernel, 116 * we need to use CTR to get to the 2nd level handler. So, save/restore it 117 * when required. 118 */ 119 #define SAVE_CTR(reg, area) mfctr reg ; std reg,area+EX_CTR(r13) 120 #define GET_CTR(reg, area) ld reg,area+EX_CTR(r13) 121 #define RESTORE_CTR(reg, area) ld reg,area+EX_CTR(r13) ; mtctr reg 122 #else 123 /* ...else CTR is unused and in register. */ 124 #define SAVE_CTR(reg, area) 125 #define GET_CTR(reg, area) mfctr reg 126 #define RESTORE_CTR(reg, area) 127 #endif 128 129 /* 130 * PPR save/restore macros used in exceptions_64s.S 131 * Used for P7 or later processors 132 */ 133 #define SAVE_PPR(area, ra, rb) \ 134 BEGIN_FTR_SECTION_NESTED(940) \ 135 ld ra,PACACURRENT(r13); \ 136 ld rb,area+EX_PPR(r13); /* Read PPR from paca */ \ 137 std rb,TASKTHREADPPR(ra); \ 138 END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,940) 139 140 #define RESTORE_PPR_PACA(area, ra) \ 141 BEGIN_FTR_SECTION_NESTED(941) \ 142 ld ra,area+EX_PPR(r13); \ 143 mtspr SPRN_PPR,ra; \ 144 END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,941) 145 146 /* 147 * Get an SPR into a register if the CPU has the given feature 148 */ 149 #define OPT_GET_SPR(ra, spr, ftr) \ 150 BEGIN_FTR_SECTION_NESTED(943) \ 151 mfspr ra,spr; \ 152 END_FTR_SECTION_NESTED(ftr,ftr,943) 153 154 /* 155 * Set an SPR from a register if the CPU has the given feature 156 */ 157 #define OPT_SET_SPR(ra, spr, ftr) \ 158 BEGIN_FTR_SECTION_NESTED(943) \ 159 mtspr spr,ra; \ 160 END_FTR_SECTION_NESTED(ftr,ftr,943) 161 162 /* 163 * Save a register to the PACA if the CPU has the given feature 164 */ 165 #define OPT_SAVE_REG_TO_PACA(offset, ra, ftr) \ 166 BEGIN_FTR_SECTION_NESTED(943) \ 167 std ra,offset(r13); \ 168 END_FTR_SECTION_NESTED(ftr,ftr,943) 169 170 #define EXCEPTION_PROLOG_0(area) \ 171 GET_PACA(r13); \ 172 std r9,area+EX_R9(r13); /* save r9 */ \ 173 OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR); \ 174 HMT_MEDIUM; \ 175 std r10,area+EX_R10(r13); /* save r10 - r12 */ \ 176 OPT_GET_SPR(r10, SPRN_CFAR, CPU_FTR_CFAR) 177 178 #define __EXCEPTION_PROLOG_1(area, extra, vec) \ 179 OPT_SAVE_REG_TO_PACA(area+EX_PPR, r9, CPU_FTR_HAS_PPR); \ 180 OPT_SAVE_REG_TO_PACA(area+EX_CFAR, r10, CPU_FTR_CFAR); \ 181 SAVE_CTR(r10, area); \ 182 mfcr r9; \ 183 extra(vec); \ 184 std r11,area+EX_R11(r13); \ 185 std r12,area+EX_R12(r13); \ 186 GET_SCRATCH0(r10); \ 187 std r10,area+EX_R13(r13) 188 #define EXCEPTION_PROLOG_1(area, extra, vec) \ 189 __EXCEPTION_PROLOG_1(area, extra, vec) 190 191 #define __EXCEPTION_PROLOG_PSERIES_1(label, h) \ 192 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ 193 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 194 LOAD_HANDLER(r12,label) \ 195 mtspr SPRN_##h##SRR0,r12; \ 196 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 197 mtspr SPRN_##h##SRR1,r10; \ 198 h##rfid; \ 199 b . /* prevent speculative execution */ 200 #define EXCEPTION_PROLOG_PSERIES_1(label, h) \ 201 __EXCEPTION_PROLOG_PSERIES_1(label, h) 202 203 /* _NORI variant keeps MSR_RI clear */ 204 #define __EXCEPTION_PROLOG_PSERIES_1_NORI(label, h) \ 205 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ 206 xori r10,r10,MSR_RI; /* Clear MSR_RI */ \ 207 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 208 LOAD_HANDLER(r12,label) \ 209 mtspr SPRN_##h##SRR0,r12; \ 210 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 211 mtspr SPRN_##h##SRR1,r10; \ 212 h##rfid; \ 213 b . /* prevent speculative execution */ 214 215 #define EXCEPTION_PROLOG_PSERIES_1_NORI(label, h) \ 216 __EXCEPTION_PROLOG_PSERIES_1_NORI(label, h) 217 218 #define EXCEPTION_PROLOG_PSERIES(area, label, h, extra, vec) \ 219 EXCEPTION_PROLOG_0(area); \ 220 EXCEPTION_PROLOG_1(area, extra, vec); \ 221 EXCEPTION_PROLOG_PSERIES_1(label, h); 222 223 #define __KVMTEST(h, n) \ 224 lbz r10,HSTATE_IN_GUEST(r13); \ 225 cmpwi r10,0; \ 226 bne do_kvm_##h##n 227 228 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 229 /* 230 * If hv is possible, interrupts come into to the hv version 231 * of the kvmppc_interrupt code, which then jumps to the PR handler, 232 * kvmppc_interrupt_pr, if the guest is a PR guest. 233 */ 234 #define kvmppc_interrupt kvmppc_interrupt_hv 235 #else 236 #define kvmppc_interrupt kvmppc_interrupt_pr 237 #endif 238 239 #ifdef CONFIG_RELOCATABLE 240 #define BRANCH_TO_COMMON(reg, label) \ 241 __LOAD_HANDLER(reg, label); \ 242 mtctr reg; \ 243 bctr 244 245 #define BRANCH_LINK_TO_FAR(reg, label) \ 246 __LOAD_FAR_HANDLER(reg, label); \ 247 mtctr reg; \ 248 bctrl 249 250 /* 251 * KVM requires __LOAD_FAR_HANDLER. 252 * 253 * __BRANCH_TO_KVM_EXIT branches are also a special case because they 254 * explicitly use r9 then reload it from PACA before branching. Hence 255 * the double-underscore. 256 */ 257 #define __BRANCH_TO_KVM_EXIT(area, label) \ 258 mfctr r9; \ 259 std r9,HSTATE_SCRATCH1(r13); \ 260 __LOAD_FAR_HANDLER(r9, label); \ 261 mtctr r9; \ 262 ld r9,area+EX_R9(r13); \ 263 bctr 264 265 #else 266 #define BRANCH_TO_COMMON(reg, label) \ 267 b label 268 269 #define BRANCH_LINK_TO_FAR(reg, label) \ 270 bl label 271 272 #define __BRANCH_TO_KVM_EXIT(area, label) \ 273 ld r9,area+EX_R9(r13); \ 274 b label 275 276 #endif 277 278 279 #define __KVM_HANDLER(area, h, n) \ 280 BEGIN_FTR_SECTION_NESTED(947) \ 281 ld r10,area+EX_CFAR(r13); \ 282 std r10,HSTATE_CFAR(r13); \ 283 END_FTR_SECTION_NESTED(CPU_FTR_CFAR,CPU_FTR_CFAR,947); \ 284 BEGIN_FTR_SECTION_NESTED(948) \ 285 ld r10,area+EX_PPR(r13); \ 286 std r10,HSTATE_PPR(r13); \ 287 END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ 288 ld r10,area+EX_R10(r13); \ 289 std r12,HSTATE_SCRATCH0(r13); \ 290 sldi r12,r9,32; \ 291 ori r12,r12,(n); \ 292 /* This reloads r9 before branching to kvmppc_interrupt */ \ 293 __BRANCH_TO_KVM_EXIT(area, kvmppc_interrupt) 294 295 #define __KVM_HANDLER_SKIP(area, h, n) \ 296 cmpwi r10,KVM_GUEST_MODE_SKIP; \ 297 beq 89f; \ 298 BEGIN_FTR_SECTION_NESTED(948) \ 299 ld r10,area+EX_PPR(r13); \ 300 std r10,HSTATE_PPR(r13); \ 301 END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ 302 ld r10,area+EX_R10(r13); \ 303 std r12,HSTATE_SCRATCH0(r13); \ 304 sldi r12,r9,32; \ 305 ori r12,r12,(n); \ 306 /* This reloads r9 before branching to kvmppc_interrupt */ \ 307 __BRANCH_TO_KVM_EXIT(area, kvmppc_interrupt); \ 308 89: mtocrf 0x80,r9; \ 309 ld r9,area+EX_R9(r13); \ 310 ld r10,area+EX_R10(r13); \ 311 b kvmppc_skip_##h##interrupt 312 313 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER 314 #define KVMTEST(h, n) __KVMTEST(h, n) 315 #define KVM_HANDLER(area, h, n) __KVM_HANDLER(area, h, n) 316 #define KVM_HANDLER_SKIP(area, h, n) __KVM_HANDLER_SKIP(area, h, n) 317 318 #else 319 #define KVMTEST(h, n) 320 #define KVM_HANDLER(area, h, n) 321 #define KVM_HANDLER_SKIP(area, h, n) 322 #endif 323 324 #define NOTEST(n) 325 326 /* 327 * The common exception prolog is used for all except a few exceptions 328 * such as a segment miss on a kernel address. We have to be prepared 329 * to take another exception from the point where we first touch the 330 * kernel stack onwards. 331 * 332 * On entry r13 points to the paca, r9-r13 are saved in the paca, 333 * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and 334 * SRR1, and relocation is on. 335 */ 336 #define EXCEPTION_PROLOG_COMMON(n, area) \ 337 andi. r10,r12,MSR_PR; /* See if coming from user */ \ 338 mr r10,r1; /* Save r1 */ \ 339 subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \ 340 beq- 1f; \ 341 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ 342 1: cmpdi cr1,r1,-INT_FRAME_SIZE; /* check if r1 is in userspace */ \ 343 blt+ cr1,3f; /* abort if it is */ \ 344 li r1,(n); /* will be reloaded later */ \ 345 sth r1,PACA_TRAP_SAVE(r13); \ 346 std r3,area+EX_R3(r13); \ 347 addi r3,r13,area; /* r3 -> where regs are saved*/ \ 348 RESTORE_CTR(r1, area); \ 349 b bad_stack; \ 350 3: std r9,_CCR(r1); /* save CR in stackframe */ \ 351 std r11,_NIP(r1); /* save SRR0 in stackframe */ \ 352 std r12,_MSR(r1); /* save SRR1 in stackframe */ \ 353 std r10,0(r1); /* make stack chain pointer */ \ 354 std r0,GPR0(r1); /* save r0 in stackframe */ \ 355 std r10,GPR1(r1); /* save r1 in stackframe */ \ 356 beq 4f; /* if from kernel mode */ \ 357 ACCOUNT_CPU_USER_ENTRY(r13, r9, r10); \ 358 SAVE_PPR(area, r9, r10); \ 359 4: EXCEPTION_PROLOG_COMMON_2(area) \ 360 EXCEPTION_PROLOG_COMMON_3(n) \ 361 ACCOUNT_STOLEN_TIME 362 363 /* Save original regs values from save area to stack frame. */ 364 #define EXCEPTION_PROLOG_COMMON_2(area) \ 365 ld r9,area+EX_R9(r13); /* move r9, r10 to stackframe */ \ 366 ld r10,area+EX_R10(r13); \ 367 std r9,GPR9(r1); \ 368 std r10,GPR10(r1); \ 369 ld r9,area+EX_R11(r13); /* move r11 - r13 to stackframe */ \ 370 ld r10,area+EX_R12(r13); \ 371 ld r11,area+EX_R13(r13); \ 372 std r9,GPR11(r1); \ 373 std r10,GPR12(r1); \ 374 std r11,GPR13(r1); \ 375 BEGIN_FTR_SECTION_NESTED(66); \ 376 ld r10,area+EX_CFAR(r13); \ 377 std r10,ORIG_GPR3(r1); \ 378 END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \ 379 GET_CTR(r10, area); \ 380 std r10,_CTR(r1); 381 382 #define EXCEPTION_PROLOG_COMMON_3(n) \ 383 std r2,GPR2(r1); /* save r2 in stackframe */ \ 384 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ 385 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ 386 mflr r9; /* Get LR, later save to stack */ \ 387 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ 388 std r9,_LINK(r1); \ 389 lbz r10,PACASOFTIRQEN(r13); \ 390 mfspr r11,SPRN_XER; /* save XER in stackframe */ \ 391 std r10,SOFTE(r1); \ 392 std r11,_XER(r1); \ 393 li r9,(n)+1; \ 394 std r9,_TRAP(r1); /* set trap number */ \ 395 li r10,0; \ 396 ld r11,exception_marker@toc(r2); \ 397 std r10,RESULT(r1); /* clear regs->result */ \ 398 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ 399 400 /* 401 * Exception vectors. 402 */ 403 #define STD_EXCEPTION_PSERIES(vec, label) \ 404 SET_SCRATCH0(r13); /* save r13 */ \ 405 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 406 EXC_STD, KVMTEST_PR, vec); \ 407 408 /* Version of above for when we have to branch out-of-line */ 409 #define __OOL_EXCEPTION(vec, label, hdlr) \ 410 SET_SCRATCH0(r13) \ 411 EXCEPTION_PROLOG_0(PACA_EXGEN) \ 412 b hdlr; 413 414 #define STD_EXCEPTION_PSERIES_OOL(vec, label) \ 415 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, vec); \ 416 EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 417 418 #define STD_EXCEPTION_HV(loc, vec, label) \ 419 SET_SCRATCH0(r13); /* save r13 */ \ 420 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 421 EXC_HV, KVMTEST_HV, vec); 422 423 #define STD_EXCEPTION_HV_OOL(vec, label) \ 424 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 425 EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 426 427 #define STD_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 428 /* No guest interrupts come through here */ \ 429 SET_SCRATCH0(r13); /* save r13 */ \ 430 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, EXC_STD, NOTEST, vec); 431 432 #define STD_RELON_EXCEPTION_PSERIES_OOL(vec, label) \ 433 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \ 434 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_STD) 435 436 #define STD_RELON_EXCEPTION_HV(loc, vec, label) \ 437 SET_SCRATCH0(r13); /* save r13 */ \ 438 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, \ 439 EXC_HV, KVMTEST_HV, vec); 440 441 #define STD_RELON_EXCEPTION_HV_OOL(vec, label) \ 442 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 443 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 444 445 /* This associate vector numbers with bits in paca->irq_happened */ 446 #define SOFTEN_VALUE_0x500 PACA_IRQ_EE 447 #define SOFTEN_VALUE_0x900 PACA_IRQ_DEC 448 #define SOFTEN_VALUE_0x980 PACA_IRQ_DEC 449 #define SOFTEN_VALUE_0xa00 PACA_IRQ_DBELL 450 #define SOFTEN_VALUE_0xe80 PACA_IRQ_DBELL 451 #define SOFTEN_VALUE_0xe60 PACA_IRQ_HMI 452 #define SOFTEN_VALUE_0xea0 PACA_IRQ_EE 453 454 #define __SOFTEN_TEST(h, vec) \ 455 lbz r10,PACASOFTIRQEN(r13); \ 456 cmpwi r10,0; \ 457 li r10,SOFTEN_VALUE_##vec; \ 458 beq masked_##h##interrupt 459 460 #define _SOFTEN_TEST(h, vec) __SOFTEN_TEST(h, vec) 461 462 #define SOFTEN_TEST_PR(vec) \ 463 KVMTEST(EXC_STD, vec); \ 464 _SOFTEN_TEST(EXC_STD, vec) 465 466 #define SOFTEN_TEST_HV(vec) \ 467 KVMTEST(EXC_HV, vec); \ 468 _SOFTEN_TEST(EXC_HV, vec) 469 470 #define KVMTEST_PR(vec) \ 471 KVMTEST(EXC_STD, vec) 472 473 #define KVMTEST_HV(vec) \ 474 KVMTEST(EXC_HV, vec) 475 476 #define SOFTEN_NOTEST_PR(vec) _SOFTEN_TEST(EXC_STD, vec) 477 #define SOFTEN_NOTEST_HV(vec) _SOFTEN_TEST(EXC_HV, vec) 478 479 #define __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 480 SET_SCRATCH0(r13); /* save r13 */ \ 481 EXCEPTION_PROLOG_0(PACA_EXGEN); \ 482 __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 483 EXCEPTION_PROLOG_PSERIES_1(label, h); 484 485 #define _MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 486 __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) 487 488 #define MASKABLE_EXCEPTION_PSERIES(loc, vec, label) \ 489 _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 490 EXC_STD, SOFTEN_TEST_PR) 491 492 #define MASKABLE_EXCEPTION_PSERIES_OOL(vec, label) \ 493 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_PR, vec); \ 494 EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 495 496 #define MASKABLE_EXCEPTION_HV(loc, vec, label) \ 497 _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 498 EXC_HV, SOFTEN_TEST_HV) 499 500 #define MASKABLE_EXCEPTION_HV_OOL(vec, label) \ 501 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 502 EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 503 504 #define __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 505 SET_SCRATCH0(r13); /* save r13 */ \ 506 EXCEPTION_PROLOG_0(PACA_EXGEN); \ 507 __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 508 EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) 509 510 #define _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 511 __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) 512 513 #define MASKABLE_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 514 _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 515 EXC_STD, SOFTEN_NOTEST_PR) 516 517 #define MASKABLE_RELON_EXCEPTION_HV(loc, vec, label) \ 518 _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 519 EXC_HV, SOFTEN_TEST_HV) 520 521 #define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label) \ 522 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 523 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 524 525 /* 526 * Our exception common code can be passed various "additions" 527 * to specify the behaviour of interrupts, whether to kick the 528 * runlatch, etc... 529 */ 530 531 /* 532 * This addition reconciles our actual IRQ state with the various software 533 * flags that track it. This may call C code. 534 */ 535 #define ADD_RECONCILE RECONCILE_IRQ_STATE(r10,r11) 536 537 #define ADD_NVGPRS \ 538 bl save_nvgprs 539 540 #define RUNLATCH_ON \ 541 BEGIN_FTR_SECTION \ 542 CURRENT_THREAD_INFO(r3, r1); \ 543 ld r4,TI_LOCAL_FLAGS(r3); \ 544 andi. r0,r4,_TLF_RUNLATCH; \ 545 beql ppc64_runlatch_on_trampoline; \ 546 END_FTR_SECTION_IFSET(CPU_FTR_CTRL) 547 548 #define EXCEPTION_COMMON(trap, label, hdlr, ret, additions) \ 549 EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \ 550 /* Volatile regs are potentially clobbered here */ \ 551 additions; \ 552 addi r3,r1,STACK_FRAME_OVERHEAD; \ 553 bl hdlr; \ 554 b ret 555 556 #define STD_EXCEPTION_COMMON(trap, label, hdlr) \ 557 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except, \ 558 ADD_NVGPRS;ADD_RECONCILE) 559 560 /* 561 * Like STD_EXCEPTION_COMMON, but for exceptions that can occur 562 * in the idle task and therefore need the special idle handling 563 * (finish nap and runlatch) 564 */ 565 #define STD_EXCEPTION_COMMON_ASYNC(trap, label, hdlr) \ 566 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except_lite, \ 567 FINISH_NAP;ADD_RECONCILE;RUNLATCH_ON) 568 569 /* 570 * When the idle code in power4_idle puts the CPU into NAP mode, 571 * it has to do so in a loop, and relies on the external interrupt 572 * and decrementer interrupt entry code to get it out of the loop. 573 * It sets the _TLF_NAPPING bit in current_thread_info()->local_flags 574 * to signal that it is in the loop and needs help to get out. 575 */ 576 #ifdef CONFIG_PPC_970_NAP 577 #define FINISH_NAP \ 578 BEGIN_FTR_SECTION \ 579 CURRENT_THREAD_INFO(r11, r1); \ 580 ld r9,TI_LOCAL_FLAGS(r11); \ 581 andi. r10,r9,_TLF_NAPPING; \ 582 bnel power4_fixup_nap; \ 583 END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) 584 #else 585 #define FINISH_NAP 586 #endif 587 588 #endif /* _ASM_POWERPC_EXCEPTION_H */ 589