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 #define EXCEPTION_PROLOG_PSERIES(area, label, h, extra, vec) \ 204 EXCEPTION_PROLOG_0(area); \ 205 EXCEPTION_PROLOG_1(area, extra, vec); \ 206 EXCEPTION_PROLOG_PSERIES_1(label, h); 207 208 #define __KVMTEST(h, n) \ 209 lbz r10,HSTATE_IN_GUEST(r13); \ 210 cmpwi r10,0; \ 211 bne do_kvm_##h##n 212 213 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 214 /* 215 * If hv is possible, interrupts come into to the hv version 216 * of the kvmppc_interrupt code, which then jumps to the PR handler, 217 * kvmppc_interrupt_pr, if the guest is a PR guest. 218 */ 219 #define kvmppc_interrupt kvmppc_interrupt_hv 220 #else 221 #define kvmppc_interrupt kvmppc_interrupt_pr 222 #endif 223 224 #ifdef CONFIG_RELOCATABLE 225 #define BRANCH_TO_COMMON(reg, label) \ 226 __LOAD_HANDLER(reg, label); \ 227 mtctr reg; \ 228 bctr 229 230 #define BRANCH_LINK_TO_FAR(reg, label) \ 231 __LOAD_FAR_HANDLER(reg, label); \ 232 mtctr reg; \ 233 bctrl 234 235 /* 236 * KVM requires __LOAD_FAR_HANDLER. 237 * 238 * __BRANCH_TO_KVM_EXIT branches are also a special case because they 239 * explicitly use r9 then reload it from PACA before branching. Hence 240 * the double-underscore. 241 */ 242 #define __BRANCH_TO_KVM_EXIT(area, label) \ 243 mfctr r9; \ 244 std r9,HSTATE_SCRATCH1(r13); \ 245 __LOAD_FAR_HANDLER(r9, label); \ 246 mtctr r9; \ 247 ld r9,area+EX_R9(r13); \ 248 bctr 249 250 #else 251 #define BRANCH_TO_COMMON(reg, label) \ 252 b label 253 254 #define BRANCH_LINK_TO_FAR(reg, label) \ 255 bl label 256 257 #define __BRANCH_TO_KVM_EXIT(area, label) \ 258 ld r9,area+EX_R9(r13); \ 259 b label 260 261 #endif 262 263 264 #define __KVM_HANDLER(area, h, n) \ 265 BEGIN_FTR_SECTION_NESTED(947) \ 266 ld r10,area+EX_CFAR(r13); \ 267 std r10,HSTATE_CFAR(r13); \ 268 END_FTR_SECTION_NESTED(CPU_FTR_CFAR,CPU_FTR_CFAR,947); \ 269 BEGIN_FTR_SECTION_NESTED(948) \ 270 ld r10,area+EX_PPR(r13); \ 271 std r10,HSTATE_PPR(r13); \ 272 END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ 273 ld r10,area+EX_R10(r13); \ 274 std r12,HSTATE_SCRATCH0(r13); \ 275 sldi r12,r9,32; \ 276 ori r12,r12,(n); \ 277 /* This reloads r9 before branching to kvmppc_interrupt */ \ 278 __BRANCH_TO_KVM_EXIT(area, kvmppc_interrupt) 279 280 #define __KVM_HANDLER_SKIP(area, h, n) \ 281 cmpwi r10,KVM_GUEST_MODE_SKIP; \ 282 beq 89f; \ 283 BEGIN_FTR_SECTION_NESTED(948) \ 284 ld r10,area+EX_PPR(r13); \ 285 std r10,HSTATE_PPR(r13); \ 286 END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ 287 ld r10,area+EX_R10(r13); \ 288 std r12,HSTATE_SCRATCH0(r13); \ 289 sldi r12,r9,32; \ 290 ori r12,r12,(n); \ 291 /* This reloads r9 before branching to kvmppc_interrupt */ \ 292 __BRANCH_TO_KVM_EXIT(area, kvmppc_interrupt); \ 293 89: mtocrf 0x80,r9; \ 294 ld r9,area+EX_R9(r13); \ 295 ld r10,area+EX_R10(r13); \ 296 b kvmppc_skip_##h##interrupt 297 298 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER 299 #define KVMTEST(h, n) __KVMTEST(h, n) 300 #define KVM_HANDLER(area, h, n) __KVM_HANDLER(area, h, n) 301 #define KVM_HANDLER_SKIP(area, h, n) __KVM_HANDLER_SKIP(area, h, n) 302 303 #else 304 #define KVMTEST(h, n) 305 #define KVM_HANDLER(area, h, n) 306 #define KVM_HANDLER_SKIP(area, h, n) 307 #endif 308 309 #define NOTEST(n) 310 311 /* 312 * The common exception prolog is used for all except a few exceptions 313 * such as a segment miss on a kernel address. We have to be prepared 314 * to take another exception from the point where we first touch the 315 * kernel stack onwards. 316 * 317 * On entry r13 points to the paca, r9-r13 are saved in the paca, 318 * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and 319 * SRR1, and relocation is on. 320 */ 321 #define EXCEPTION_PROLOG_COMMON(n, area) \ 322 andi. r10,r12,MSR_PR; /* See if coming from user */ \ 323 mr r10,r1; /* Save r1 */ \ 324 subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \ 325 beq- 1f; \ 326 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ 327 1: cmpdi cr1,r1,-INT_FRAME_SIZE; /* check if r1 is in userspace */ \ 328 blt+ cr1,3f; /* abort if it is */ \ 329 li r1,(n); /* will be reloaded later */ \ 330 sth r1,PACA_TRAP_SAVE(r13); \ 331 std r3,area+EX_R3(r13); \ 332 addi r3,r13,area; /* r3 -> where regs are saved*/ \ 333 RESTORE_CTR(r1, area); \ 334 b bad_stack; \ 335 3: std r9,_CCR(r1); /* save CR in stackframe */ \ 336 std r11,_NIP(r1); /* save SRR0 in stackframe */ \ 337 std r12,_MSR(r1); /* save SRR1 in stackframe */ \ 338 std r10,0(r1); /* make stack chain pointer */ \ 339 std r0,GPR0(r1); /* save r0 in stackframe */ \ 340 std r10,GPR1(r1); /* save r1 in stackframe */ \ 341 beq 4f; /* if from kernel mode */ \ 342 ACCOUNT_CPU_USER_ENTRY(r13, r9, r10); \ 343 SAVE_PPR(area, r9, r10); \ 344 4: EXCEPTION_PROLOG_COMMON_2(area) \ 345 EXCEPTION_PROLOG_COMMON_3(n) \ 346 ACCOUNT_STOLEN_TIME 347 348 /* Save original regs values from save area to stack frame. */ 349 #define EXCEPTION_PROLOG_COMMON_2(area) \ 350 ld r9,area+EX_R9(r13); /* move r9, r10 to stackframe */ \ 351 ld r10,area+EX_R10(r13); \ 352 std r9,GPR9(r1); \ 353 std r10,GPR10(r1); \ 354 ld r9,area+EX_R11(r13); /* move r11 - r13 to stackframe */ \ 355 ld r10,area+EX_R12(r13); \ 356 ld r11,area+EX_R13(r13); \ 357 std r9,GPR11(r1); \ 358 std r10,GPR12(r1); \ 359 std r11,GPR13(r1); \ 360 BEGIN_FTR_SECTION_NESTED(66); \ 361 ld r10,area+EX_CFAR(r13); \ 362 std r10,ORIG_GPR3(r1); \ 363 END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \ 364 GET_CTR(r10, area); \ 365 std r10,_CTR(r1); 366 367 #define EXCEPTION_PROLOG_COMMON_3(n) \ 368 std r2,GPR2(r1); /* save r2 in stackframe */ \ 369 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ 370 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ 371 mflr r9; /* Get LR, later save to stack */ \ 372 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ 373 std r9,_LINK(r1); \ 374 lbz r10,PACASOFTIRQEN(r13); \ 375 mfspr r11,SPRN_XER; /* save XER in stackframe */ \ 376 std r10,SOFTE(r1); \ 377 std r11,_XER(r1); \ 378 li r9,(n)+1; \ 379 std r9,_TRAP(r1); /* set trap number */ \ 380 li r10,0; \ 381 ld r11,exception_marker@toc(r2); \ 382 std r10,RESULT(r1); /* clear regs->result */ \ 383 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ 384 385 /* 386 * Exception vectors. 387 */ 388 #define STD_EXCEPTION_PSERIES(vec, label) \ 389 SET_SCRATCH0(r13); /* save r13 */ \ 390 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 391 EXC_STD, KVMTEST_PR, vec); \ 392 393 /* Version of above for when we have to branch out-of-line */ 394 #define __OOL_EXCEPTION(vec, label, hdlr) \ 395 SET_SCRATCH0(r13) \ 396 EXCEPTION_PROLOG_0(PACA_EXGEN) \ 397 b hdlr; 398 399 #define STD_EXCEPTION_PSERIES_OOL(vec, label) \ 400 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, vec); \ 401 EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 402 403 #define STD_EXCEPTION_HV(loc, vec, label) \ 404 SET_SCRATCH0(r13); /* save r13 */ \ 405 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 406 EXC_HV, KVMTEST_HV, vec); 407 408 #define STD_EXCEPTION_HV_OOL(vec, label) \ 409 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 410 EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 411 412 #define STD_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 413 /* No guest interrupts come through here */ \ 414 SET_SCRATCH0(r13); /* save r13 */ \ 415 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, EXC_STD, NOTEST, vec); 416 417 #define STD_RELON_EXCEPTION_PSERIES_OOL(vec, label) \ 418 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \ 419 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_STD) 420 421 #define STD_RELON_EXCEPTION_HV(loc, vec, label) \ 422 SET_SCRATCH0(r13); /* save r13 */ \ 423 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, \ 424 EXC_HV, KVMTEST_HV, vec); 425 426 #define STD_RELON_EXCEPTION_HV_OOL(vec, label) \ 427 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 428 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 429 430 /* This associate vector numbers with bits in paca->irq_happened */ 431 #define SOFTEN_VALUE_0x500 PACA_IRQ_EE 432 #define SOFTEN_VALUE_0x900 PACA_IRQ_DEC 433 #define SOFTEN_VALUE_0x980 PACA_IRQ_DEC 434 #define SOFTEN_VALUE_0xa00 PACA_IRQ_DBELL 435 #define SOFTEN_VALUE_0xe80 PACA_IRQ_DBELL 436 #define SOFTEN_VALUE_0xe60 PACA_IRQ_HMI 437 #define SOFTEN_VALUE_0xea0 PACA_IRQ_EE 438 439 #define __SOFTEN_TEST(h, vec) \ 440 lbz r10,PACASOFTIRQEN(r13); \ 441 cmpwi r10,0; \ 442 li r10,SOFTEN_VALUE_##vec; \ 443 beq masked_##h##interrupt 444 445 #define _SOFTEN_TEST(h, vec) __SOFTEN_TEST(h, vec) 446 447 #define SOFTEN_TEST_PR(vec) \ 448 KVMTEST(EXC_STD, vec); \ 449 _SOFTEN_TEST(EXC_STD, vec) 450 451 #define SOFTEN_TEST_HV(vec) \ 452 KVMTEST(EXC_HV, vec); \ 453 _SOFTEN_TEST(EXC_HV, vec) 454 455 #define KVMTEST_PR(vec) \ 456 KVMTEST(EXC_STD, vec) 457 458 #define KVMTEST_HV(vec) \ 459 KVMTEST(EXC_HV, vec) 460 461 #define SOFTEN_NOTEST_PR(vec) _SOFTEN_TEST(EXC_STD, vec) 462 #define SOFTEN_NOTEST_HV(vec) _SOFTEN_TEST(EXC_HV, vec) 463 464 #define __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 465 SET_SCRATCH0(r13); /* save r13 */ \ 466 EXCEPTION_PROLOG_0(PACA_EXGEN); \ 467 __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 468 EXCEPTION_PROLOG_PSERIES_1(label, h); 469 470 #define _MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 471 __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) 472 473 #define MASKABLE_EXCEPTION_PSERIES(loc, vec, label) \ 474 _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 475 EXC_STD, SOFTEN_TEST_PR) 476 477 #define MASKABLE_EXCEPTION_PSERIES_OOL(vec, label) \ 478 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_PR, vec); \ 479 EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 480 481 #define MASKABLE_EXCEPTION_HV(loc, vec, label) \ 482 _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 483 EXC_HV, SOFTEN_TEST_HV) 484 485 #define MASKABLE_EXCEPTION_HV_OOL(vec, label) \ 486 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 487 EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 488 489 #define __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 490 SET_SCRATCH0(r13); /* save r13 */ \ 491 EXCEPTION_PROLOG_0(PACA_EXGEN); \ 492 __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 493 EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) 494 495 #define _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 496 __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) 497 498 #define MASKABLE_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 499 _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 500 EXC_STD, SOFTEN_NOTEST_PR) 501 502 #define MASKABLE_RELON_EXCEPTION_HV(loc, vec, label) \ 503 _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 504 EXC_HV, SOFTEN_TEST_HV) 505 506 #define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label) \ 507 EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 508 EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 509 510 /* 511 * Our exception common code can be passed various "additions" 512 * to specify the behaviour of interrupts, whether to kick the 513 * runlatch, etc... 514 */ 515 516 /* 517 * This addition reconciles our actual IRQ state with the various software 518 * flags that track it. This may call C code. 519 */ 520 #define ADD_RECONCILE RECONCILE_IRQ_STATE(r10,r11) 521 522 #define ADD_NVGPRS \ 523 bl save_nvgprs 524 525 #define RUNLATCH_ON \ 526 BEGIN_FTR_SECTION \ 527 CURRENT_THREAD_INFO(r3, r1); \ 528 ld r4,TI_LOCAL_FLAGS(r3); \ 529 andi. r0,r4,_TLF_RUNLATCH; \ 530 beql ppc64_runlatch_on_trampoline; \ 531 END_FTR_SECTION_IFSET(CPU_FTR_CTRL) 532 533 #define EXCEPTION_COMMON(trap, label, hdlr, ret, additions) \ 534 EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \ 535 /* Volatile regs are potentially clobbered here */ \ 536 additions; \ 537 addi r3,r1,STACK_FRAME_OVERHEAD; \ 538 bl hdlr; \ 539 b ret 540 541 #define STD_EXCEPTION_COMMON(trap, label, hdlr) \ 542 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except, \ 543 ADD_NVGPRS;ADD_RECONCILE) 544 545 /* 546 * Like STD_EXCEPTION_COMMON, but for exceptions that can occur 547 * in the idle task and therefore need the special idle handling 548 * (finish nap and runlatch) 549 */ 550 #define STD_EXCEPTION_COMMON_ASYNC(trap, label, hdlr) \ 551 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except_lite, \ 552 FINISH_NAP;ADD_RECONCILE;RUNLATCH_ON) 553 554 /* 555 * When the idle code in power4_idle puts the CPU into NAP mode, 556 * it has to do so in a loop, and relies on the external interrupt 557 * and decrementer interrupt entry code to get it out of the loop. 558 * It sets the _TLF_NAPPING bit in current_thread_info()->local_flags 559 * to signal that it is in the loop and needs help to get out. 560 */ 561 #ifdef CONFIG_PPC_970_NAP 562 #define FINISH_NAP \ 563 BEGIN_FTR_SECTION \ 564 CURRENT_THREAD_INFO(r11, r1); \ 565 ld r9,TI_LOCAL_FLAGS(r11); \ 566 andi. r10,r9,_TLF_NAPPING; \ 567 bnel power4_fixup_nap; \ 568 END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) 569 #else 570 #define FINISH_NAP 571 #endif 572 573 #endif /* _ASM_POWERPC_EXCEPTION_H */ 574