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 #define EXCEPTION_PROLOG_COMMON_1() \ 327 std r9,_CCR(r1); /* save CR in stackframe */ \ 328 std r11,_NIP(r1); /* save SRR0 in stackframe */ \ 329 std r12,_MSR(r1); /* save SRR1 in stackframe */ \ 330 std r10,0(r1); /* make stack chain pointer */ \ 331 std r0,GPR0(r1); /* save r0 in stackframe */ \ 332 std r10,GPR1(r1); /* save r1 in stackframe */ \ 333 334 335 /* 336 * The common exception prolog is used for all except a few exceptions 337 * such as a segment miss on a kernel address. We have to be prepared 338 * to take another exception from the point where we first touch the 339 * kernel stack onwards. 340 * 341 * On entry r13 points to the paca, r9-r13 are saved in the paca, 342 * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and 343 * SRR1, and relocation is on. 344 */ 345 #define EXCEPTION_PROLOG_COMMON(n, area) \ 346 andi. r10,r12,MSR_PR; /* See if coming from user */ \ 347 mr r10,r1; /* Save r1 */ \ 348 subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \ 349 beq- 1f; \ 350 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ 351 1: cmpdi cr1,r1,-INT_FRAME_SIZE; /* check if r1 is in userspace */ \ 352 blt+ cr1,3f; /* abort if it is */ \ 353 li r1,(n); /* will be reloaded later */ \ 354 sth r1,PACA_TRAP_SAVE(r13); \ 355 std r3,area+EX_R3(r13); \ 356 addi r3,r13,area; /* r3 -> where regs are saved*/ \ 357 RESTORE_CTR(r1, area); \ 358 b bad_stack; \ 359 3: EXCEPTION_PROLOG_COMMON_1(); \ 360 beq 4f; /* if from kernel mode */ \ 361 ACCOUNT_CPU_USER_ENTRY(r13, r9, r10); \ 362 SAVE_PPR(area, r9, r10); \ 363 4: EXCEPTION_PROLOG_COMMON_2(area) \ 364 EXCEPTION_PROLOG_COMMON_3(n) \ 365 ACCOUNT_STOLEN_TIME 366 367 /* Save original regs values from save area to stack frame. */ 368 #define EXCEPTION_PROLOG_COMMON_2(area) \ 369 ld r9,area+EX_R9(r13); /* move r9, r10 to stackframe */ \ 370 ld r10,area+EX_R10(r13); \ 371 std r9,GPR9(r1); \ 372 std r10,GPR10(r1); \ 373 ld r9,area+EX_R11(r13); /* move r11 - r13 to stackframe */ \ 374 ld r10,area+EX_R12(r13); \ 375 ld r11,area+EX_R13(r13); \ 376 std r9,GPR11(r1); \ 377 std r10,GPR12(r1); \ 378 std r11,GPR13(r1); \ 379 BEGIN_FTR_SECTION_NESTED(66); \ 380 ld r10,area+EX_CFAR(r13); \ 381 std r10,ORIG_GPR3(r1); \ 382 END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \ 383 GET_CTR(r10, area); \ 384 std r10,_CTR(r1); 385 386 #define EXCEPTION_PROLOG_COMMON_3(n) \ 387 std r2,GPR2(r1); /* save r2 in stackframe */ \ 388 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ 389 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ 390 mflr r9; /* Get LR, later save to stack */ \ 391 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ 392 std r9,_LINK(r1); \ 393 lbz r10,PACASOFTIRQEN(r13); \ 394 mfspr r11,SPRN_XER; /* save XER in stackframe */ \ 395 std r10,SOFTE(r1); \ 396 std r11,_XER(r1); \ 397 li r9,(n)+1; \ 398 std r9,_TRAP(r1); /* set trap number */ \ 399 li r10,0; \ 400 ld r11,exception_marker@toc(r2); \ 401 std r10,RESULT(r1); /* clear regs->result */ \ 402 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ 403 404 /* 405 * Exception vectors. 406 */ 407 #define STD_EXCEPTION_PSERIES(vec, label) \ 408 SET_SCRATCH0(r13); /* save r13 */ \ 409 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 410 EXC_STD, KVMTEST_PR, vec); \ 411 412 /* Version of above for when we have to branch out-of-line */ 413 #define __OOL_EXCEPTION(vec, label, hdlr) \ 414 SET_SCRATCH0(r13) \ 415 EXCEPTION_PROLOG_0(PACA_EXGEN) \ 416 b hdlr; 417 418 #define STD_EXCEPTION_PSERIES_OOL(vec, label) \ 419 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, vec); \ 420 EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 421 422 #define STD_EXCEPTION_HV(loc, vec, label) \ 423 SET_SCRATCH0(r13); /* save r13 */ \ 424 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 425 EXC_HV, KVMTEST_HV, vec); 426 427 #define STD_EXCEPTION_HV_OOL(vec, label) \ 428 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 429 EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 430 431 #define STD_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 432 /* No guest interrupts come through here */ \ 433 SET_SCRATCH0(r13); /* save r13 */ \ 434 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, EXC_STD, NOTEST, vec); 435 436 #define STD_RELON_EXCEPTION_PSERIES_OOL(vec, label) \ 437 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \ 438 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_STD) 439 440 #define STD_RELON_EXCEPTION_HV(loc, vec, label) \ 441 SET_SCRATCH0(r13); /* save r13 */ \ 442 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, \ 443 EXC_HV, KVMTEST_HV, vec); 444 445 #define STD_RELON_EXCEPTION_HV_OOL(vec, label) \ 446 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 447 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 448 449 /* This associate vector numbers with bits in paca->irq_happened */ 450 #define SOFTEN_VALUE_0x500 PACA_IRQ_EE 451 #define SOFTEN_VALUE_0x900 PACA_IRQ_DEC 452 #define SOFTEN_VALUE_0x980 PACA_IRQ_DEC 453 #define SOFTEN_VALUE_0xa00 PACA_IRQ_DBELL 454 #define SOFTEN_VALUE_0xe80 PACA_IRQ_DBELL 455 #define SOFTEN_VALUE_0xe60 PACA_IRQ_HMI 456 #define SOFTEN_VALUE_0xea0 PACA_IRQ_EE 457 458 #define __SOFTEN_TEST(h, vec) \ 459 lbz r10,PACASOFTIRQEN(r13); \ 460 cmpwi r10,0; \ 461 li r10,SOFTEN_VALUE_##vec; \ 462 beq masked_##h##interrupt 463 464 #define _SOFTEN_TEST(h, vec) __SOFTEN_TEST(h, vec) 465 466 #define SOFTEN_TEST_PR(vec) \ 467 KVMTEST(EXC_STD, vec); \ 468 _SOFTEN_TEST(EXC_STD, vec) 469 470 #define SOFTEN_TEST_HV(vec) \ 471 KVMTEST(EXC_HV, vec); \ 472 _SOFTEN_TEST(EXC_HV, vec) 473 474 #define KVMTEST_PR(vec) \ 475 KVMTEST(EXC_STD, vec) 476 477 #define KVMTEST_HV(vec) \ 478 KVMTEST(EXC_HV, vec) 479 480 #define SOFTEN_NOTEST_PR(vec) _SOFTEN_TEST(EXC_STD, vec) 481 #define SOFTEN_NOTEST_HV(vec) _SOFTEN_TEST(EXC_HV, vec) 482 483 #define __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 484 SET_SCRATCH0(r13); /* save r13 */ \ 485 EXCEPTION_PROLOG_0(PACA_EXGEN); \ 486 __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 487 EXCEPTION_PROLOG_PSERIES_1(label, h); 488 489 #define _MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 490 __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) 491 492 #define MASKABLE_EXCEPTION_PSERIES(loc, vec, label) \ 493 _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 494 EXC_STD, SOFTEN_TEST_PR) 495 496 #define MASKABLE_EXCEPTION_PSERIES_OOL(vec, label) \ 497 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_PR, vec); \ 498 EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 499 500 #define MASKABLE_EXCEPTION_HV(loc, vec, label) \ 501 _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 502 EXC_HV, SOFTEN_TEST_HV) 503 504 #define MASKABLE_EXCEPTION_HV_OOL(vec, label) \ 505 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 506 EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 507 508 #define __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 509 SET_SCRATCH0(r13); /* save r13 */ \ 510 EXCEPTION_PROLOG_0(PACA_EXGEN); \ 511 __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 512 EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) 513 514 #define _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 515 __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) 516 517 #define MASKABLE_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 518 _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 519 EXC_STD, SOFTEN_NOTEST_PR) 520 521 #define MASKABLE_RELON_EXCEPTION_HV(loc, vec, label) \ 522 _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 523 EXC_HV, SOFTEN_TEST_HV) 524 525 #define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label) \ 526 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 527 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 528 529 /* 530 * Our exception common code can be passed various "additions" 531 * to specify the behaviour of interrupts, whether to kick the 532 * runlatch, etc... 533 */ 534 535 /* 536 * This addition reconciles our actual IRQ state with the various software 537 * flags that track it. This may call C code. 538 */ 539 #define ADD_RECONCILE RECONCILE_IRQ_STATE(r10,r11) 540 541 #define ADD_NVGPRS \ 542 bl save_nvgprs 543 544 #define RUNLATCH_ON \ 545 BEGIN_FTR_SECTION \ 546 CURRENT_THREAD_INFO(r3, r1); \ 547 ld r4,TI_LOCAL_FLAGS(r3); \ 548 andi. r0,r4,_TLF_RUNLATCH; \ 549 beql ppc64_runlatch_on_trampoline; \ 550 END_FTR_SECTION_IFSET(CPU_FTR_CTRL) 551 552 #define EXCEPTION_COMMON(trap, label, hdlr, ret, additions) \ 553 EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \ 554 /* Volatile regs are potentially clobbered here */ \ 555 additions; \ 556 addi r3,r1,STACK_FRAME_OVERHEAD; \ 557 bl hdlr; \ 558 b ret 559 560 #define STD_EXCEPTION_COMMON(trap, label, hdlr) \ 561 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except, \ 562 ADD_NVGPRS;ADD_RECONCILE) 563 564 /* 565 * Like STD_EXCEPTION_COMMON, but for exceptions that can occur 566 * in the idle task and therefore need the special idle handling 567 * (finish nap and runlatch) 568 */ 569 #define STD_EXCEPTION_COMMON_ASYNC(trap, label, hdlr) \ 570 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except_lite, \ 571 FINISH_NAP;ADD_RECONCILE;RUNLATCH_ON) 572 573 /* 574 * When the idle code in power4_idle puts the CPU into NAP mode, 575 * it has to do so in a loop, and relies on the external interrupt 576 * and decrementer interrupt entry code to get it out of the loop. 577 * It sets the _TLF_NAPPING bit in current_thread_info()->local_flags 578 * to signal that it is in the loop and needs help to get out. 579 */ 580 #ifdef CONFIG_PPC_970_NAP 581 #define FINISH_NAP \ 582 BEGIN_FTR_SECTION \ 583 CURRENT_THREAD_INFO(r11, r1); \ 584 ld r9,TI_LOCAL_FLAGS(r11); \ 585 andi. r10,r9,_TLF_NAPPING; \ 586 bnel power4_fixup_nap; \ 587 END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) 588 #else 589 #define FINISH_NAP 590 #endif 591 592 #endif /* _ASM_POWERPC_EXCEPTION_H */ 593