Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 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 | */ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 37 | #include <asm/head-64.h> |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 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 |
Paul Mackerras | 48404f2 | 2011-05-01 19:48:20 +0000 | [diff] [blame] | 50 | #define EX_CFAR 80 |
Haren Myneni | a09688c | 2012-12-06 21:48:26 +0000 | [diff] [blame] | 51 | #define EX_PPR 88 /* SMT thread status register (priority) */ |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 52 | #define EX_CTR 96 |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 53 | |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 54 | #ifdef CONFIG_RELOCATABLE |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 55 | #define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 56 | mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ |
| 57 | LOAD_HANDLER(r12,label); \ |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 58 | mtctr r12; \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 59 | mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ |
| 60 | li r10,MSR_RI; \ |
| 61 | mtmsrd r10,1; /* Set RI (EE=0) */ \ |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 62 | bctr; |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 63 | #else |
| 64 | /* If not relocatable, we can jump directly -- and save messing with LR */ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 65 | #define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 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 |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 72 | #define EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ |
| 73 | __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 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) \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 81 | EXCEPTION_PROLOG_0(area); \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 82 | EXCEPTION_PROLOG_1(area, extra, vec); \ |
| 83 | EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) |
| 84 | |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 85 | /* |
| 86 | * We're short on space and time in the exception prolog, so we can't |
Michael Ellerman | 2751023 | 2016-07-26 15:29:29 +1000 | [diff] [blame] | 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. |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 91 | */ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 92 | #define LOAD_HANDLER(reg, label) \ |
Michael Ellerman | d8d42b0 | 2016-07-26 15:29:30 +1000 | [diff] [blame] | 93 | ld reg,PACAKBASE(r13); /* get high part of &label */ \ |
Hugh Dickins | e6740ae | 2016-11-07 22:28:21 -0800 | [diff] [blame] | 94 | ori reg,reg,FIXED_SYMBOL_ABS_ADDR(label); |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 95 | |
Nicholas Piggin | fb479e4 | 2016-10-13 13:17:14 +1100 | [diff] [blame] | 96 | #define __LOAD_HANDLER(reg, label) \ |
| 97 | ld reg,PACAKBASE(r13); \ |
| 98 | ori reg,reg,(ABS_ADDR(label))@l; |
| 99 | |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 100 | /* Exception register prefixes */ |
| 101 | #define EXC_HV H |
| 102 | #define EXC_STD |
| 103 | |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 104 | #if defined(CONFIG_RELOCATABLE) |
| 105 | /* |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 106 | * If we support interrupts with relocation on AND we're a relocatable kernel, |
| 107 | * we need to use CTR to get to the 2nd level handler. So, save/restore it |
| 108 | * when required. |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 109 | */ |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 110 | #define SAVE_CTR(reg, area) mfctr reg ; std reg,area+EX_CTR(r13) |
| 111 | #define GET_CTR(reg, area) ld reg,area+EX_CTR(r13) |
| 112 | #define RESTORE_CTR(reg, area) ld reg,area+EX_CTR(r13) ; mtctr reg |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 113 | #else |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 114 | /* ...else CTR is unused and in register. */ |
| 115 | #define SAVE_CTR(reg, area) |
| 116 | #define GET_CTR(reg, area) mfctr reg |
| 117 | #define RESTORE_CTR(reg, area) |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 118 | #endif |
| 119 | |
Haren Myneni | 13e7a8e | 2012-12-06 21:50:32 +0000 | [diff] [blame] | 120 | /* |
| 121 | * PPR save/restore macros used in exceptions_64s.S |
| 122 | * Used for P7 or later processors |
| 123 | */ |
| 124 | #define SAVE_PPR(area, ra, rb) \ |
| 125 | BEGIN_FTR_SECTION_NESTED(940) \ |
| 126 | ld ra,PACACURRENT(r13); \ |
| 127 | ld rb,area+EX_PPR(r13); /* Read PPR from paca */ \ |
| 128 | std rb,TASKTHREADPPR(ra); \ |
| 129 | END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,940) |
| 130 | |
| 131 | #define RESTORE_PPR_PACA(area, ra) \ |
| 132 | BEGIN_FTR_SECTION_NESTED(941) \ |
| 133 | ld ra,area+EX_PPR(r13); \ |
| 134 | mtspr SPRN_PPR,ra; \ |
| 135 | END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,941) |
| 136 | |
| 137 | /* |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 138 | * Get an SPR into a register if the CPU has the given feature |
Haren Myneni | 13e7a8e | 2012-12-06 21:50:32 +0000 | [diff] [blame] | 139 | */ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 140 | #define OPT_GET_SPR(ra, spr, ftr) \ |
Haren Myneni | 13e7a8e | 2012-12-06 21:50:32 +0000 | [diff] [blame] | 141 | BEGIN_FTR_SECTION_NESTED(943) \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 142 | mfspr ra,spr; \ |
| 143 | END_FTR_SECTION_NESTED(ftr,ftr,943) |
Haren Myneni | 13e7a8e | 2012-12-06 21:50:32 +0000 | [diff] [blame] | 144 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 145 | /* |
Mahesh Salgaonkar | d410ae2 | 2014-03-11 10:56:18 +0530 | [diff] [blame] | 146 | * Set an SPR from a register if the CPU has the given feature |
| 147 | */ |
| 148 | #define OPT_SET_SPR(ra, spr, ftr) \ |
| 149 | BEGIN_FTR_SECTION_NESTED(943) \ |
| 150 | mtspr spr,ra; \ |
| 151 | END_FTR_SECTION_NESTED(ftr,ftr,943) |
| 152 | |
| 153 | /* |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 154 | * Save a register to the PACA if the CPU has the given feature |
| 155 | */ |
| 156 | #define OPT_SAVE_REG_TO_PACA(offset, ra, ftr) \ |
| 157 | BEGIN_FTR_SECTION_NESTED(943) \ |
| 158 | std ra,offset(r13); \ |
| 159 | END_FTR_SECTION_NESTED(ftr,ftr,943) |
| 160 | |
Nicholas Piggin | f23ed16 | 2016-11-02 17:57:01 +1100 | [diff] [blame] | 161 | #define EXCEPTION_PROLOG_0_PACA(area) \ |
Haren Myneni | 44e9309 | 2012-12-06 21:51:04 +0000 | [diff] [blame] | 162 | std r9,area+EX_R9(r13); /* save r9 */ \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 163 | OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR); \ |
| 164 | HMT_MEDIUM; \ |
Haren Myneni | 44e9309 | 2012-12-06 21:51:04 +0000 | [diff] [blame] | 165 | std r10,area+EX_R10(r13); /* save r10 - r12 */ \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 166 | OPT_GET_SPR(r10, SPRN_CFAR, CPU_FTR_CFAR) |
| 167 | |
Nicholas Piggin | f23ed16 | 2016-11-02 17:57:01 +1100 | [diff] [blame] | 168 | #define EXCEPTION_PROLOG_0(area) \ |
| 169 | GET_PACA(r13); \ |
| 170 | EXCEPTION_PROLOG_0_PACA(area) |
| 171 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 172 | #define __EXCEPTION_PROLOG_1(area, extra, vec) \ |
| 173 | OPT_SAVE_REG_TO_PACA(area+EX_PPR, r9, CPU_FTR_HAS_PPR); \ |
| 174 | OPT_SAVE_REG_TO_PACA(area+EX_CFAR, r10, CPU_FTR_CFAR); \ |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 175 | SAVE_CTR(r10, area); \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 176 | mfcr r9; \ |
| 177 | extra(vec); \ |
| 178 | std r11,area+EX_R11(r13); \ |
| 179 | std r12,area+EX_R12(r13); \ |
| 180 | GET_SCRATCH0(r10); \ |
| 181 | std r10,area+EX_R13(r13) |
| 182 | #define EXCEPTION_PROLOG_1(area, extra, vec) \ |
| 183 | __EXCEPTION_PROLOG_1(area, extra, vec) |
Stephen Rothwell | 7180e3e | 2007-08-22 13:48:37 +1000 | [diff] [blame] | 184 | |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 185 | #define __EXCEPTION_PROLOG_PSERIES_1(label, h) \ |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 186 | ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 187 | mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 188 | LOAD_HANDLER(r12,label) \ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 189 | mtspr SPRN_##h##SRR0,r12; \ |
| 190 | mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ |
| 191 | mtspr SPRN_##h##SRR1,r10; \ |
| 192 | h##rfid; \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 193 | b . /* prevent speculative execution */ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 194 | #define EXCEPTION_PROLOG_PSERIES_1(label, h) \ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 195 | __EXCEPTION_PROLOG_PSERIES_1(label, h) |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 196 | |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 197 | #define EXCEPTION_PROLOG_PSERIES(area, label, h, extra, vec) \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 198 | EXCEPTION_PROLOG_0(area); \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 199 | EXCEPTION_PROLOG_1(area, extra, vec); \ |
Benjamin Herrenschmidt | a5d4f3a | 2011-04-05 14:20:31 +1000 | [diff] [blame] | 200 | EXCEPTION_PROLOG_PSERIES_1(label, h); |
Benjamin Herrenschmidt | c5a8c0c | 2009-07-16 19:36:57 +0000 | [diff] [blame] | 201 | |
Nicholas Piggin | f23ed16 | 2016-11-02 17:57:01 +1100 | [diff] [blame] | 202 | /* Have the PACA in r13 already */ |
| 203 | #define EXCEPTION_PROLOG_PSERIES_PACA(area, label, h, extra, vec) \ |
| 204 | EXCEPTION_PROLOG_0_PACA(area); \ |
| 205 | EXCEPTION_PROLOG_1(area, extra, vec); \ |
| 206 | EXCEPTION_PROLOG_PSERIES_1(label, h); |
| 207 | |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 208 | #define __KVMTEST(h, n) \ |
| 209 | lbz r10,HSTATE_IN_GUEST(r13); \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 210 | cmpwi r10,0; \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 211 | bne do_kvm_##h##n |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 212 | |
Aneesh Kumar K.V | dd96b2c | 2013-10-07 22:17:55 +0530 | [diff] [blame] | 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 | |
Nicholas Piggin | fb479e4 | 2016-10-13 13:17:14 +1100 | [diff] [blame] | 224 | #ifdef CONFIG_RELOCATABLE |
| 225 | #define BRANCH_TO_COMMON(reg, label) \ |
| 226 | __LOAD_HANDLER(reg, label); \ |
| 227 | mtctr reg; \ |
| 228 | bctr |
| 229 | |
| 230 | #else |
| 231 | #define BRANCH_TO_COMMON(reg, label) \ |
| 232 | b label |
| 233 | |
| 234 | #endif |
| 235 | |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 236 | #define __KVM_HANDLER_PROLOG(area, n) \ |
Paul Mackerras | 0acb911 | 2013-02-04 18:10:51 +0000 | [diff] [blame] | 237 | BEGIN_FTR_SECTION_NESTED(947) \ |
| 238 | ld r10,area+EX_CFAR(r13); \ |
| 239 | std r10,HSTATE_CFAR(r13); \ |
| 240 | END_FTR_SECTION_NESTED(CPU_FTR_CFAR,CPU_FTR_CFAR,947); \ |
Paul Mackerras | 4b8473c | 2013-09-20 14:52:39 +1000 | [diff] [blame] | 241 | BEGIN_FTR_SECTION_NESTED(948) \ |
| 242 | ld r10,area+EX_PPR(r13); \ |
| 243 | std r10,HSTATE_PPR(r13); \ |
| 244 | END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 245 | ld r10,area+EX_R10(r13); \ |
Paul Mackerras | 0acb911 | 2013-02-04 18:10:51 +0000 | [diff] [blame] | 246 | stw r9,HSTATE_SCRATCH1(r13); \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 247 | ld r9,area+EX_R9(r13); \ |
Paul Mackerras | 0acb911 | 2013-02-04 18:10:51 +0000 | [diff] [blame] | 248 | std r12,HSTATE_SCRATCH0(r13); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 249 | |
| 250 | #define __KVM_HANDLER(area, h, n) \ |
| 251 | __KVM_HANDLER_PROLOG(area, n) \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 252 | li r12,n; \ |
| 253 | b kvmppc_interrupt |
| 254 | |
| 255 | #define __KVM_HANDLER_SKIP(area, h, n) \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 256 | cmpwi r10,KVM_GUEST_MODE_SKIP; \ |
| 257 | ld r10,area+EX_R10(r13); \ |
| 258 | beq 89f; \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 259 | stw r9,HSTATE_SCRATCH1(r13); \ |
Paul Mackerras | 4b8473c | 2013-09-20 14:52:39 +1000 | [diff] [blame] | 260 | BEGIN_FTR_SECTION_NESTED(948) \ |
| 261 | ld r9,area+EX_PPR(r13); \ |
| 262 | std r9,HSTATE_PPR(r13); \ |
| 263 | END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 264 | ld r9,area+EX_R9(r13); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 265 | std r12,HSTATE_SCRATCH0(r13); \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 266 | li r12,n; \ |
| 267 | b kvmppc_interrupt; \ |
| 268 | 89: mtocrf 0x80,r9; \ |
| 269 | ld r9,area+EX_R9(r13); \ |
| 270 | b kvmppc_skip_##h##interrupt |
| 271 | |
| 272 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 273 | #define KVMTEST(h, n) __KVMTEST(h, n) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 274 | #define KVM_HANDLER(area, h, n) __KVM_HANDLER(area, h, n) |
| 275 | #define KVM_HANDLER_SKIP(area, h, n) __KVM_HANDLER_SKIP(area, h, n) |
| 276 | |
| 277 | #else |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 278 | #define KVMTEST(h, n) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 279 | #define KVM_HANDLER(area, h, n) |
| 280 | #define KVM_HANDLER_SKIP(area, h, n) |
| 281 | #endif |
| 282 | |
| 283 | #define NOTEST(n) |
| 284 | |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 285 | /* |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 286 | * The common exception prolog is used for all except a few exceptions |
| 287 | * such as a segment miss on a kernel address. We have to be prepared |
| 288 | * to take another exception from the point where we first touch the |
| 289 | * kernel stack onwards. |
| 290 | * |
| 291 | * On entry r13 points to the paca, r9-r13 are saved in the paca, |
| 292 | * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and |
| 293 | * SRR1, and relocation is on. |
| 294 | */ |
| 295 | #define EXCEPTION_PROLOG_COMMON(n, area) \ |
| 296 | andi. r10,r12,MSR_PR; /* See if coming from user */ \ |
| 297 | mr r10,r1; /* Save r1 */ \ |
| 298 | subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \ |
| 299 | beq- 1f; \ |
| 300 | ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ |
Michael Neuling | 90ff5d6 | 2013-12-16 15:12:43 +1100 | [diff] [blame] | 301 | 1: cmpdi cr1,r1,-INT_FRAME_SIZE; /* check if r1 is in userspace */ \ |
Paul Mackerras | 1977b50 | 2011-05-01 19:46:44 +0000 | [diff] [blame] | 302 | blt+ cr1,3f; /* abort if it is */ \ |
| 303 | li r1,(n); /* will be reloaded later */ \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 304 | sth r1,PACA_TRAP_SAVE(r13); \ |
Paul Mackerras | 1977b50 | 2011-05-01 19:46:44 +0000 | [diff] [blame] | 305 | std r3,area+EX_R3(r13); \ |
| 306 | addi r3,r13,area; /* r3 -> where regs are saved*/ \ |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 307 | RESTORE_CTR(r1, area); \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 308 | b bad_stack; \ |
| 309 | 3: std r9,_CCR(r1); /* save CR in stackframe */ \ |
| 310 | std r11,_NIP(r1); /* save SRR0 in stackframe */ \ |
| 311 | std r12,_MSR(r1); /* save SRR1 in stackframe */ \ |
| 312 | std r10,0(r1); /* make stack chain pointer */ \ |
| 313 | std r0,GPR0(r1); /* save r0 in stackframe */ \ |
| 314 | std r10,GPR1(r1); /* save r1 in stackframe */ \ |
Haren Myneni | 5d75b26 | 2012-12-06 21:46:37 +0000 | [diff] [blame] | 315 | beq 4f; /* if from kernel mode */ \ |
Christophe Leroy | c223c90 | 2016-05-17 08:33:46 +0200 | [diff] [blame] | 316 | ACCOUNT_CPU_USER_ENTRY(r13, r9, r10); \ |
Haren Myneni | 44e9309 | 2012-12-06 21:51:04 +0000 | [diff] [blame] | 317 | SAVE_PPR(area, r9, r10); \ |
Mahesh Salgaonkar | b14a7253 | 2013-10-30 20:03:51 +0530 | [diff] [blame] | 318 | 4: EXCEPTION_PROLOG_COMMON_2(area) \ |
| 319 | EXCEPTION_PROLOG_COMMON_3(n) \ |
| 320 | ACCOUNT_STOLEN_TIME |
| 321 | |
| 322 | /* Save original regs values from save area to stack frame. */ |
| 323 | #define EXCEPTION_PROLOG_COMMON_2(area) \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 324 | ld r9,area+EX_R9(r13); /* move r9, r10 to stackframe */ \ |
| 325 | ld r10,area+EX_R10(r13); \ |
| 326 | std r9,GPR9(r1); \ |
| 327 | std r10,GPR10(r1); \ |
| 328 | ld r9,area+EX_R11(r13); /* move r11 - r13 to stackframe */ \ |
| 329 | ld r10,area+EX_R12(r13); \ |
| 330 | ld r11,area+EX_R13(r13); \ |
| 331 | std r9,GPR11(r1); \ |
| 332 | std r10,GPR12(r1); \ |
| 333 | std r11,GPR13(r1); \ |
Paul Mackerras | 48404f2 | 2011-05-01 19:48:20 +0000 | [diff] [blame] | 334 | BEGIN_FTR_SECTION_NESTED(66); \ |
| 335 | ld r10,area+EX_CFAR(r13); \ |
| 336 | std r10,ORIG_GPR3(r1); \ |
| 337 | END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \ |
Mahesh Salgaonkar | b14a7253 | 2013-10-30 20:03:51 +0530 | [diff] [blame] | 338 | GET_CTR(r10, area); \ |
| 339 | std r10,_CTR(r1); |
| 340 | |
| 341 | #define EXCEPTION_PROLOG_COMMON_3(n) \ |
| 342 | std r2,GPR2(r1); /* save r2 in stackframe */ \ |
| 343 | SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ |
| 344 | SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ |
Michael Neuling | bc2e6c6 | 2013-08-13 15:54:52 +1000 | [diff] [blame] | 345 | mflr r9; /* Get LR, later save to stack */ \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 346 | ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 347 | std r9,_LINK(r1); \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 348 | lbz r10,PACASOFTIRQEN(r13); \ |
| 349 | mfspr r11,SPRN_XER; /* save XER in stackframe */ \ |
| 350 | std r10,SOFTE(r1); \ |
| 351 | std r11,_XER(r1); \ |
| 352 | li r9,(n)+1; \ |
| 353 | std r9,_TRAP(r1); /* set trap number */ \ |
| 354 | li r10,0; \ |
| 355 | ld r11,exception_marker@toc(r2); \ |
| 356 | std r10,RESULT(r1); /* clear regs->result */ \ |
Mahesh Salgaonkar | b14a7253 | 2013-10-30 20:03:51 +0530 | [diff] [blame] | 357 | std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 358 | |
| 359 | /* |
| 360 | * Exception vectors. |
| 361 | */ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 362 | #define STD_EXCEPTION_PSERIES(vec, label) \ |
Paul Mackerras | 673b189 | 2011-04-05 13:59:58 +1000 | [diff] [blame] | 363 | SET_SCRATCH0(r13); /* save r13 */ \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 364 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ |
| 365 | EXC_STD, KVMTEST_PR, vec); \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 366 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 367 | /* Version of above for when we have to branch out-of-line */ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 368 | #define __OOL_EXCEPTION(vec, label, hdlr) \ |
| 369 | SET_SCRATCH0(r13) \ |
| 370 | EXCEPTION_PROLOG_0(PACA_EXGEN) \ |
| 371 | b hdlr; |
| 372 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 373 | #define STD_EXCEPTION_PSERIES_OOL(vec, label) \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 374 | EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, vec); \ |
| 375 | EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 376 | |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 377 | #define STD_EXCEPTION_HV(loc, vec, label) \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 378 | SET_SCRATCH0(r13); /* save r13 */ \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 379 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ |
| 380 | EXC_HV, KVMTEST_HV, vec); |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 381 | |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 382 | #define STD_EXCEPTION_HV_OOL(vec, label) \ |
| 383 | EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ |
| 384 | EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 385 | |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 386 | #define STD_RELON_EXCEPTION_PSERIES(loc, vec, label) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 387 | /* No guest interrupts come through here */ \ |
| 388 | SET_SCRATCH0(r13); /* save r13 */ \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 389 | EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, EXC_STD, NOTEST, vec); |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 390 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 391 | #define STD_RELON_EXCEPTION_PSERIES_OOL(vec, label) \ |
Michael Ellerman | c9f6951 | 2013-06-25 17:47:55 +1000 | [diff] [blame] | 392 | EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 393 | EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_STD) |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 394 | |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 395 | #define STD_RELON_EXCEPTION_HV(loc, vec, label) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 396 | /* No guest interrupts come through here */ \ |
| 397 | SET_SCRATCH0(r13); /* save r13 */ \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 398 | EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, EXC_HV, NOTEST, vec); |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 399 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 400 | #define STD_RELON_EXCEPTION_HV_OOL(vec, label) \ |
Michael Ellerman | c9f6951 | 2013-06-25 17:47:55 +1000 | [diff] [blame] | 401 | EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 402 | EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 403 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 404 | /* This associate vector numbers with bits in paca->irq_happened */ |
| 405 | #define SOFTEN_VALUE_0x500 PACA_IRQ_EE |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 406 | #define SOFTEN_VALUE_0x900 PACA_IRQ_DEC |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 407 | #define SOFTEN_VALUE_0x980 PACA_IRQ_DEC |
Ian Munsie | 1dbdafe | 2012-11-14 18:49:46 +0000 | [diff] [blame] | 408 | #define SOFTEN_VALUE_0xa00 PACA_IRQ_DBELL |
Ian Munsie | 655bb3f | 2012-11-14 18:49:45 +0000 | [diff] [blame] | 409 | #define SOFTEN_VALUE_0xe80 PACA_IRQ_DBELL |
Mahesh Salgaonkar | 0869b6f | 2014-07-29 18:40:01 +0530 | [diff] [blame] | 410 | #define SOFTEN_VALUE_0xe60 PACA_IRQ_HMI |
Benjamin Herrenschmidt | 9baaef0a | 2016-07-08 16:37:06 +1000 | [diff] [blame] | 411 | #define SOFTEN_VALUE_0xea0 PACA_IRQ_EE |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 412 | |
| 413 | #define __SOFTEN_TEST(h, vec) \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 414 | lbz r10,PACASOFTIRQEN(r13); \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 415 | cmpwi r10,0; \ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 416 | li r10,SOFTEN_VALUE_##vec; \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 417 | beq masked_##h##interrupt |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 418 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 419 | #define _SOFTEN_TEST(h, vec) __SOFTEN_TEST(h, vec) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 420 | |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 421 | #define SOFTEN_TEST_PR(vec) \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 422 | KVMTEST(EXC_STD, vec); \ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 423 | _SOFTEN_TEST(EXC_STD, vec) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 424 | |
| 425 | #define SOFTEN_TEST_HV(vec) \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 426 | KVMTEST(EXC_HV, vec); \ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 427 | _SOFTEN_TEST(EXC_HV, vec) |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 428 | |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 429 | #define KVMTEST_PR(vec) \ |
| 430 | KVMTEST(EXC_STD, vec) |
| 431 | |
| 432 | #define KVMTEST_HV(vec) \ |
| 433 | KVMTEST(EXC_HV, vec) |
| 434 | |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 435 | #define SOFTEN_NOTEST_PR(vec) _SOFTEN_TEST(EXC_STD, vec) |
| 436 | #define SOFTEN_NOTEST_HV(vec) _SOFTEN_TEST(EXC_HV, vec) |
| 437 | |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 438 | #define __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 439 | SET_SCRATCH0(r13); /* save r13 */ \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 440 | EXCEPTION_PROLOG_0(PACA_EXGEN); \ |
| 441 | __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 442 | EXCEPTION_PROLOG_PSERIES_1(label, h); |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 443 | |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 444 | #define _MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ |
| 445 | __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 446 | |
| 447 | #define MASKABLE_EXCEPTION_PSERIES(loc, vec, label) \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 448 | _MASKABLE_EXCEPTION_PSERIES(vec, label, \ |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 449 | EXC_STD, SOFTEN_TEST_PR) |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 450 | |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 451 | #define MASKABLE_EXCEPTION_PSERIES_OOL(vec, label) \ |
| 452 | EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_PR, vec); \ |
| 453 | EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) |
| 454 | |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 455 | #define MASKABLE_EXCEPTION_HV(loc, vec, label) \ |
Paul Mackerras | b01c8b5 | 2011-06-29 00:18:26 +0000 | [diff] [blame] | 456 | _MASKABLE_EXCEPTION_PSERIES(vec, label, \ |
| 457 | EXC_HV, SOFTEN_TEST_HV) |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 458 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 459 | #define MASKABLE_EXCEPTION_HV_OOL(vec, label) \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 460 | EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 461 | EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 462 | |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 463 | #define __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 464 | SET_SCRATCH0(r13); /* save r13 */ \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 465 | EXCEPTION_PROLOG_0(PACA_EXGEN); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 466 | __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ |
| 467 | EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) |
| 468 | |
| 469 | #define _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 470 | __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) |
| 471 | |
| 472 | #define MASKABLE_RELON_EXCEPTION_PSERIES(loc, vec, label) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 473 | _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ |
| 474 | EXC_STD, SOFTEN_NOTEST_PR) |
| 475 | |
| 476 | #define MASKABLE_RELON_EXCEPTION_HV(loc, vec, label) \ |
Michael Neuling | 4700dfa | 2012-11-02 17:21:28 +1100 | [diff] [blame] | 477 | _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ |
| 478 | EXC_HV, SOFTEN_NOTEST_HV) |
| 479 | |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 480 | #define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label) \ |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 481 | EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_NOTEST_HV, vec); \ |
Michael Ellerman | da2bc46 | 2016-09-30 19:43:18 +1000 | [diff] [blame] | 482 | EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) |
Paul Mackerras | 1707dd1 | 2013-02-04 18:10:15 +0000 | [diff] [blame] | 483 | |
Benjamin Herrenschmidt | 1b70117 | 2012-03-01 15:42:56 +1100 | [diff] [blame] | 484 | /* |
| 485 | * Our exception common code can be passed various "additions" |
| 486 | * to specify the behaviour of interrupts, whether to kick the |
| 487 | * runlatch, etc... |
| 488 | */ |
| 489 | |
Michael Ellerman | 9daf112 | 2014-07-15 21:15:38 +1000 | [diff] [blame] | 490 | /* |
| 491 | * This addition reconciles our actual IRQ state with the various software |
| 492 | * flags that track it. This may call C code. |
| 493 | */ |
| 494 | #define ADD_RECONCILE RECONCILE_IRQ_STATE(r10,r11) |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 495 | |
Benjamin Herrenschmidt | fe1952f | 2012-03-01 12:45:27 +1100 | [diff] [blame] | 496 | #define ADD_NVGPRS \ |
Anton Blanchard | b1576fe | 2014-02-04 16:04:35 +1100 | [diff] [blame] | 497 | bl save_nvgprs |
Benjamin Herrenschmidt | fe1952f | 2012-03-01 12:45:27 +1100 | [diff] [blame] | 498 | |
| 499 | #define RUNLATCH_ON \ |
| 500 | BEGIN_FTR_SECTION \ |
Stuart Yoder | 9778b69 | 2012-07-05 04:41:35 +0000 | [diff] [blame] | 501 | CURRENT_THREAD_INFO(r3, r1); \ |
Benjamin Herrenschmidt | fe1952f | 2012-03-01 12:45:27 +1100 | [diff] [blame] | 502 | ld r4,TI_LOCAL_FLAGS(r3); \ |
| 503 | andi. r0,r4,_TLF_RUNLATCH; \ |
| 504 | beql ppc64_runlatch_on_trampoline; \ |
| 505 | END_FTR_SECTION_IFSET(CPU_FTR_CTRL) |
| 506 | |
| 507 | #define EXCEPTION_COMMON(trap, label, hdlr, ret, additions) \ |
Benjamin Herrenschmidt | fe1952f | 2012-03-01 12:45:27 +1100 | [diff] [blame] | 508 | EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \ |
Michael Ellerman | a1d711c | 2014-07-15 21:15:37 +1000 | [diff] [blame] | 509 | /* Volatile regs are potentially clobbered here */ \ |
Benjamin Herrenschmidt | fe1952f | 2012-03-01 12:45:27 +1100 | [diff] [blame] | 510 | additions; \ |
| 511 | addi r3,r1,STACK_FRAME_OVERHEAD; \ |
| 512 | bl hdlr; \ |
| 513 | b ret |
| 514 | |
| 515 | #define STD_EXCEPTION_COMMON(trap, label, hdlr) \ |
| 516 | EXCEPTION_COMMON(trap, label, hdlr, ret_from_except, \ |
Michael Ellerman | 9daf112 | 2014-07-15 21:15:38 +1000 | [diff] [blame] | 517 | ADD_NVGPRS;ADD_RECONCILE) |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 518 | |
| 519 | /* |
| 520 | * Like STD_EXCEPTION_COMMON, but for exceptions that can occur |
Benjamin Herrenschmidt | 7450f6f | 2012-03-01 10:52:01 +1100 | [diff] [blame] | 521 | * in the idle task and therefore need the special idle handling |
| 522 | * (finish nap and runlatch) |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 523 | */ |
Benjamin Herrenschmidt | fe1952f | 2012-03-01 12:45:27 +1100 | [diff] [blame] | 524 | #define STD_EXCEPTION_COMMON_ASYNC(trap, label, hdlr) \ |
| 525 | EXCEPTION_COMMON(trap, label, hdlr, ret_from_except_lite, \ |
Michael Ellerman | 9daf112 | 2014-07-15 21:15:38 +1000 | [diff] [blame] | 526 | FINISH_NAP;ADD_RECONCILE;RUNLATCH_ON) |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 527 | |
| 528 | /* |
| 529 | * When the idle code in power4_idle puts the CPU into NAP mode, |
| 530 | * it has to do so in a loop, and relies on the external interrupt |
| 531 | * and decrementer interrupt entry code to get it out of the loop. |
| 532 | * It sets the _TLF_NAPPING bit in current_thread_info()->local_flags |
| 533 | * to signal that it is in the loop and needs help to get out. |
| 534 | */ |
| 535 | #ifdef CONFIG_PPC_970_NAP |
| 536 | #define FINISH_NAP \ |
| 537 | BEGIN_FTR_SECTION \ |
Stuart Yoder | 9778b69 | 2012-07-05 04:41:35 +0000 | [diff] [blame] | 538 | CURRENT_THREAD_INFO(r11, r1); \ |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 539 | ld r9,TI_LOCAL_FLAGS(r11); \ |
| 540 | andi. r10,r9,_TLF_NAPPING; \ |
| 541 | bnel power4_fixup_nap; \ |
| 542 | END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) |
| 543 | #else |
| 544 | #define FINISH_NAP |
| 545 | #endif |
| 546 | |
| 547 | #endif /* _ASM_POWERPC_EXCEPTION_H */ |