Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Boot code and exception vectors for Book3E processors |
| 3 | * |
| 4 | * Copyright (C) 2007 Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/threads.h> |
| 13 | #include <asm/reg.h> |
| 14 | #include <asm/page.h> |
| 15 | #include <asm/ppc_asm.h> |
| 16 | #include <asm/asm-offsets.h> |
| 17 | #include <asm/cputable.h> |
| 18 | #include <asm/setup.h> |
| 19 | #include <asm/thread_info.h> |
Jack Miller | a0496d4 | 2011-04-14 22:32:08 +0000 | [diff] [blame] | 20 | #include <asm/reg_a2.h> |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 21 | #include <asm/exception-64e.h> |
| 22 | #include <asm/bug.h> |
| 23 | #include <asm/irqflags.h> |
| 24 | #include <asm/ptrace.h> |
| 25 | #include <asm/ppc-opcode.h> |
| 26 | #include <asm/mmu.h> |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 27 | #include <asm/hw_irq.h> |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 28 | #include <asm/kvm_asm.h> |
| 29 | #include <asm/kvm_booke_hv_asm.h> |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 30 | |
| 31 | /* XXX This will ultimately add space for a special exception save |
| 32 | * structure used to save things like SRR0/SRR1, SPRGs, MAS, etc... |
| 33 | * when taking special interrupts. For now we don't support that, |
| 34 | * special interrupts from within a non-standard level will probably |
| 35 | * blow you up |
| 36 | */ |
| 37 | #define SPECIAL_EXC_FRAME_SIZE INT_FRAME_SIZE |
| 38 | |
| 39 | /* Exception prolog code for all exceptions */ |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 40 | #define EXCEPTION_PROLOG(n, intnum, type, addition) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 41 | mtspr SPRN_SPRG_##type##_SCRATCH,r13; /* get spare registers */ \ |
| 42 | mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \ |
| 43 | std r10,PACA_EX##type+EX_R10(r13); \ |
| 44 | std r11,PACA_EX##type+EX_R11(r13); \ |
Mihai Caraman | 8b64a9d | 2012-08-06 03:27:07 +0000 | [diff] [blame^] | 45 | PROLOG_STORE_RESTORE_SCRATCH_##type; \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 46 | mfcr r10; /* save CR */ \ |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 47 | mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \ |
| 48 | DO_KVM intnum,SPRN_##type##_SRR1; /* KVM hook */ \ |
Mihai Caraman | 79b5c8d | 2012-08-06 03:27:06 +0000 | [diff] [blame] | 49 | stw r10,PACA_EX##type+EX_CR(r13); /* save old CR in the PACA */ \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 50 | addition; /* additional code for that exc. */ \ |
| 51 | std r1,PACA_EX##type+EX_R1(r13); /* save old r1 in the PACA */ \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 52 | type##_SET_KSTACK; /* get special stack if necessary */\ |
| 53 | andi. r10,r11,MSR_PR; /* save stack pointer */ \ |
| 54 | beq 1f; /* branch around if supervisor */ \ |
| 55 | ld r1,PACAKSAVE(r13); /* get kernel stack coming from usr */\ |
| 56 | 1: cmpdi cr1,r1,0; /* check if SP makes sense */ \ |
| 57 | bge- cr1,exc_##n##_bad_stack;/* bad stack (TODO: out of line) */ \ |
| 58 | mfspr r10,SPRN_##type##_SRR0; /* read SRR0 before touching stack */ |
| 59 | |
| 60 | /* Exception type-specific macros */ |
| 61 | #define GEN_SET_KSTACK \ |
| 62 | subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ |
| 63 | #define SPRN_GEN_SRR0 SPRN_SRR0 |
| 64 | #define SPRN_GEN_SRR1 SPRN_SRR1 |
| 65 | |
Mihai Caraman | 5473eb1 | 2012-08-06 03:27:04 +0000 | [diff] [blame] | 66 | #define GDBELL_SET_KSTACK GEN_SET_KSTACK |
| 67 | #define SPRN_GDBELL_SRR0 SPRN_GSRR0 |
| 68 | #define SPRN_GDBELL_SRR1 SPRN_GSRR1 |
| 69 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 70 | #define CRIT_SET_KSTACK \ |
| 71 | ld r1,PACA_CRIT_STACK(r13); \ |
| 72 | subi r1,r1,SPECIAL_EXC_FRAME_SIZE; |
| 73 | #define SPRN_CRIT_SRR0 SPRN_CSRR0 |
| 74 | #define SPRN_CRIT_SRR1 SPRN_CSRR1 |
| 75 | |
| 76 | #define DBG_SET_KSTACK \ |
| 77 | ld r1,PACA_DBG_STACK(r13); \ |
| 78 | subi r1,r1,SPECIAL_EXC_FRAME_SIZE; |
| 79 | #define SPRN_DBG_SRR0 SPRN_DSRR0 |
| 80 | #define SPRN_DBG_SRR1 SPRN_DSRR1 |
| 81 | |
| 82 | #define MC_SET_KSTACK \ |
| 83 | ld r1,PACA_MC_STACK(r13); \ |
| 84 | subi r1,r1,SPECIAL_EXC_FRAME_SIZE; |
| 85 | #define SPRN_MC_SRR0 SPRN_MCSRR0 |
| 86 | #define SPRN_MC_SRR1 SPRN_MCSRR1 |
| 87 | |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 88 | #define NORMAL_EXCEPTION_PROLOG(n, intnum, addition) \ |
| 89 | EXCEPTION_PROLOG(n, intnum, GEN, addition##_GEN(n)) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 90 | |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 91 | #define CRIT_EXCEPTION_PROLOG(n, intnum, addition) \ |
| 92 | EXCEPTION_PROLOG(n, intnum, CRIT, addition##_CRIT(n)) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 93 | |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 94 | #define DBG_EXCEPTION_PROLOG(n, intnum, addition) \ |
| 95 | EXCEPTION_PROLOG(n, intnum, DBG, addition##_DBG(n)) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 96 | |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 97 | #define MC_EXCEPTION_PROLOG(n, intnum, addition) \ |
| 98 | EXCEPTION_PROLOG(n, intnum, MC, addition##_MC(n)) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 99 | |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 100 | #define GDBELL_EXCEPTION_PROLOG(n, intnum, addition) \ |
| 101 | EXCEPTION_PROLOG(n, intnum, GDBELL, addition##_GDBELL(n)) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 102 | |
Mihai Caraman | 8b64a9d | 2012-08-06 03:27:07 +0000 | [diff] [blame^] | 103 | /* |
| 104 | * Store user-visible scratch in PACA exception slots and restore proper value |
| 105 | */ |
| 106 | #define PROLOG_STORE_RESTORE_SCRATCH_GEN |
| 107 | #define PROLOG_STORE_RESTORE_SCRATCH_GDBELL |
| 108 | #define PROLOG_STORE_RESTORE_SCRATCH_DBG |
| 109 | #define PROLOG_STORE_RESTORE_SCRATCH_MC |
| 110 | |
| 111 | #define PROLOG_STORE_RESTORE_SCRATCH_CRIT \ |
| 112 | mfspr r10,SPRN_SPRG_CRIT_SCRATCH; /* get r13 */ \ |
| 113 | std r10,PACA_EXCRIT+EX_R13(r13) |
| 114 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 115 | /* Variants of the "addition" argument for the prolog |
| 116 | */ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 117 | #define PROLOG_ADDITION_NONE_GEN(n) |
Mihai Caraman | 5473eb1 | 2012-08-06 03:27:04 +0000 | [diff] [blame] | 118 | #define PROLOG_ADDITION_NONE_GDBELL(n) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 119 | #define PROLOG_ADDITION_NONE_CRIT(n) |
| 120 | #define PROLOG_ADDITION_NONE_DBG(n) |
| 121 | #define PROLOG_ADDITION_NONE_MC(n) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 122 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 123 | #define PROLOG_ADDITION_MASKABLE_GEN(n) \ |
Mihai Caraman | 79b5c8d | 2012-08-06 03:27:06 +0000 | [diff] [blame] | 124 | lbz r10,PACASOFTIRQEN(r13); /* are irqs soft-disabled ? */ \ |
| 125 | cmpwi cr0,r10,0; /* yes -> go out of line */ \ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 126 | beq masked_interrupt_book3e_##n |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 127 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 128 | #define PROLOG_ADDITION_2REGS_GEN(n) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 129 | std r14,PACA_EXGEN+EX_R14(r13); \ |
| 130 | std r15,PACA_EXGEN+EX_R15(r13) |
| 131 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 132 | #define PROLOG_ADDITION_1REG_GEN(n) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 133 | std r14,PACA_EXGEN+EX_R14(r13); |
| 134 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 135 | #define PROLOG_ADDITION_2REGS_CRIT(n) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 136 | std r14,PACA_EXCRIT+EX_R14(r13); \ |
| 137 | std r15,PACA_EXCRIT+EX_R15(r13) |
| 138 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 139 | #define PROLOG_ADDITION_2REGS_DBG(n) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 140 | std r14,PACA_EXDBG+EX_R14(r13); \ |
| 141 | std r15,PACA_EXDBG+EX_R15(r13) |
| 142 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 143 | #define PROLOG_ADDITION_2REGS_MC(n) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 144 | std r14,PACA_EXMC+EX_R14(r13); \ |
| 145 | std r15,PACA_EXMC+EX_R15(r13) |
| 146 | |
Scott Wood | 3d97a61 | 2011-06-22 11:19:49 +0000 | [diff] [blame] | 147 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 148 | /* Core exception code for all exceptions except TLB misses. |
| 149 | * XXX: Needs to make SPRN_SPRG_GEN depend on exception type |
| 150 | */ |
| 151 | #define EXCEPTION_COMMON(n, excf, ints) \ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 152 | exc_##n##_common: \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 153 | std r0,GPR0(r1); /* save r0 in stackframe */ \ |
| 154 | std r2,GPR2(r1); /* save r2 in stackframe */ \ |
| 155 | SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ |
| 156 | SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ |
| 157 | std r9,GPR9(r1); /* save r9 in stackframe */ \ |
| 158 | std r10,_NIP(r1); /* save SRR0 to stackframe */ \ |
| 159 | std r11,_MSR(r1); /* save SRR1 to stackframe */ \ |
| 160 | ACCOUNT_CPU_USER_ENTRY(r10,r11);/* accounting (uses cr0+eq) */ \ |
| 161 | ld r3,excf+EX_R10(r13); /* get back r10 */ \ |
| 162 | ld r4,excf+EX_R11(r13); /* get back r11 */ \ |
| 163 | mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 */ \ |
| 164 | std r12,GPR12(r1); /* save r12 in stackframe */ \ |
| 165 | ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ |
| 166 | mflr r6; /* save LR in stackframe */ \ |
| 167 | mfctr r7; /* save CTR in stackframe */ \ |
| 168 | mfspr r8,SPRN_XER; /* save XER in stackframe */ \ |
| 169 | ld r9,excf+EX_R1(r13); /* load orig r1 back from PACA */ \ |
| 170 | lwz r10,excf+EX_CR(r13); /* load orig CR back from PACA */ \ |
| 171 | lbz r11,PACASOFTIRQEN(r13); /* get current IRQ softe */ \ |
| 172 | ld r12,exception_marker@toc(r2); \ |
| 173 | li r0,0; \ |
| 174 | std r3,GPR10(r1); /* save r10 to stackframe */ \ |
| 175 | std r4,GPR11(r1); /* save r11 to stackframe */ \ |
| 176 | std r5,GPR13(r1); /* save it to stackframe */ \ |
| 177 | std r6,_LINK(r1); \ |
| 178 | std r7,_CTR(r1); \ |
| 179 | std r8,_XER(r1); \ |
| 180 | li r3,(n)+1; /* indicate partial regs in trap */ \ |
| 181 | std r9,0(r1); /* store stack frame back link */ \ |
| 182 | std r10,_CCR(r1); /* store orig CR in stackframe */ \ |
| 183 | std r9,GPR1(r1); /* store stack frame back link */ \ |
| 184 | std r11,SOFTE(r1); /* and save it to stackframe */ \ |
| 185 | std r12,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ \ |
| 186 | std r3,_TRAP(r1); /* set trap number */ \ |
| 187 | std r0,RESULT(r1); /* clear regs->result */ \ |
| 188 | ints; |
| 189 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 190 | /* Variants for the "ints" argument. This one does nothing when we want |
| 191 | * to keep interrupts in their original state |
| 192 | */ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 193 | #define INTS_KEEP |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 194 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 195 | /* This second version is meant for exceptions that don't immediately |
| 196 | * hard-enable. We set a bit in paca->irq_happened to ensure that |
| 197 | * a subsequent call to arch_local_irq_restore() will properly |
| 198 | * hard-enable and avoid the fast-path |
| 199 | */ |
| 200 | #define INTS_DISABLE SOFT_DISABLE_INTS(r3,r4) |
| 201 | |
| 202 | /* This is called by exceptions that used INTS_KEEP (that did not touch |
| 203 | * irq indicators in the PACA). This will restore MSR:EE to it's previous |
| 204 | * value |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 205 | * |
| 206 | * XXX In the long run, we may want to open-code it in order to separate the |
| 207 | * load from the wrtee, thus limiting the latency caused by the dependency |
| 208 | * but at this point, I'll favor code clarity until we have a near to final |
| 209 | * implementation |
| 210 | */ |
| 211 | #define INTS_RESTORE_HARD \ |
| 212 | ld r11,_MSR(r1); \ |
| 213 | wrtee r11; |
| 214 | |
| 215 | /* XXX FIXME: Restore r14/r15 when necessary */ |
| 216 | #define BAD_STACK_TRAMPOLINE(n) \ |
| 217 | exc_##n##_bad_stack: \ |
| 218 | li r1,(n); /* get exception number */ \ |
| 219 | sth r1,PACA_TRAP_SAVE(r13); /* store trap */ \ |
| 220 | b bad_stack_book3e; /* bad stack error */ |
| 221 | |
Benjamin Herrenschmidt | ff82c31 | 2010-06-08 10:58:58 +1000 | [diff] [blame] | 222 | /* WARNING: If you change the layout of this stub, make sure you chcek |
| 223 | * the debug exception handler which handles single stepping |
| 224 | * into exceptions from userspace, and the MM code in |
| 225 | * arch/powerpc/mm/tlb_nohash.c which patches the branch here |
| 226 | * and would need to be updated if that branch is moved |
| 227 | */ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 228 | #define EXCEPTION_STUB(loc, label) \ |
| 229 | . = interrupt_base_book3e + loc; \ |
| 230 | nop; /* To make debug interrupts happy */ \ |
| 231 | b exc_##label##_book3e; |
| 232 | |
| 233 | #define ACK_NONE(r) |
| 234 | #define ACK_DEC(r) \ |
| 235 | lis r,TSR_DIS@h; \ |
| 236 | mtspr SPRN_TSR,r |
| 237 | #define ACK_FIT(r) \ |
| 238 | lis r,TSR_FIS@h; \ |
| 239 | mtspr SPRN_TSR,r |
| 240 | |
Benjamin Herrenschmidt | 34d97e0 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 241 | /* Used by asynchronous interrupt that may happen in the idle loop. |
| 242 | * |
| 243 | * This check if the thread was in the idle loop, and if yes, returns |
| 244 | * to the caller rather than the PC. This is to avoid a race if |
| 245 | * interrupts happen before the wait instruction. |
| 246 | */ |
| 247 | #define CHECK_NAPPING() \ |
Stuart Yoder | 9778b69 | 2012-07-05 04:41:35 +0000 | [diff] [blame] | 248 | CURRENT_THREAD_INFO(r11, r1); \ |
Benjamin Herrenschmidt | 34d97e0 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 249 | ld r10,TI_LOCAL_FLAGS(r11); \ |
| 250 | andi. r9,r10,_TLF_NAPPING; \ |
| 251 | beq+ 1f; \ |
| 252 | ld r8,_LINK(r1); \ |
| 253 | rlwinm r7,r10,0,~_TLF_NAPPING; \ |
| 254 | std r8,_NIP(r1); \ |
| 255 | std r7,TI_LOCAL_FLAGS(r11); \ |
| 256 | 1: |
| 257 | |
| 258 | |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 259 | #define MASKABLE_EXCEPTION(trapnum, intnum, label, hdlr, ack) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 260 | START_EXCEPTION(label); \ |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 261 | NORMAL_EXCEPTION_PROLOG(trapnum, intnum, PROLOG_ADDITION_MASKABLE)\ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 262 | EXCEPTION_COMMON(trapnum, PACA_EXGEN, INTS_DISABLE) \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 263 | ack(r8); \ |
Benjamin Herrenschmidt | 34d97e0 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 264 | CHECK_NAPPING(); \ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 265 | addi r3,r1,STACK_FRAME_OVERHEAD; \ |
| 266 | bl hdlr; \ |
| 267 | b .ret_from_except_lite; |
| 268 | |
| 269 | /* This value is used to mark exception frames on the stack. */ |
| 270 | .section ".toc","aw" |
| 271 | exception_marker: |
| 272 | .tc ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER |
| 273 | |
| 274 | |
| 275 | /* |
| 276 | * And here we have the exception vectors ! |
| 277 | */ |
| 278 | |
| 279 | .text |
| 280 | .balign 0x1000 |
| 281 | .globl interrupt_base_book3e |
| 282 | interrupt_base_book3e: /* fake trap */ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 283 | EXCEPTION_STUB(0x000, machine_check) /* 0x0200 */ |
| 284 | EXCEPTION_STUB(0x020, critical_input) /* 0x0580 */ |
| 285 | EXCEPTION_STUB(0x040, debug_crit) /* 0x0d00 */ |
| 286 | EXCEPTION_STUB(0x060, data_storage) /* 0x0300 */ |
| 287 | EXCEPTION_STUB(0x080, instruction_storage) /* 0x0400 */ |
| 288 | EXCEPTION_STUB(0x0a0, external_input) /* 0x0500 */ |
| 289 | EXCEPTION_STUB(0x0c0, alignment) /* 0x0600 */ |
| 290 | EXCEPTION_STUB(0x0e0, program) /* 0x0700 */ |
| 291 | EXCEPTION_STUB(0x100, fp_unavailable) /* 0x0800 */ |
| 292 | EXCEPTION_STUB(0x120, system_call) /* 0x0c00 */ |
| 293 | EXCEPTION_STUB(0x140, ap_unavailable) /* 0x0f20 */ |
| 294 | EXCEPTION_STUB(0x160, decrementer) /* 0x0900 */ |
| 295 | EXCEPTION_STUB(0x180, fixed_interval) /* 0x0980 */ |
| 296 | EXCEPTION_STUB(0x1a0, watchdog) /* 0x09f0 */ |
| 297 | EXCEPTION_STUB(0x1c0, data_tlb_miss) |
| 298 | EXCEPTION_STUB(0x1e0, instruction_tlb_miss) |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 299 | EXCEPTION_STUB(0x260, perfmon) |
Benjamin Herrenschmidt | 89c8179 | 2010-07-09 15:31:28 +1000 | [diff] [blame] | 300 | EXCEPTION_STUB(0x280, doorbell) |
| 301 | EXCEPTION_STUB(0x2a0, doorbell_crit) |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 302 | EXCEPTION_STUB(0x2c0, guest_doorbell) |
| 303 | EXCEPTION_STUB(0x2e0, guest_doorbell_crit) |
| 304 | EXCEPTION_STUB(0x300, hypercall) |
| 305 | EXCEPTION_STUB(0x320, ehpriv) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 306 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 307 | .globl interrupt_end_book3e |
| 308 | interrupt_end_book3e: |
| 309 | |
| 310 | /* Critical Input Interrupt */ |
| 311 | START_EXCEPTION(critical_input); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 312 | CRIT_EXCEPTION_PROLOG(0x100, BOOKE_INTERRUPT_CRITICAL, |
| 313 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 314 | // EXCEPTION_COMMON(0x100, PACA_EXCRIT, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 315 | // bl special_reg_save_crit |
Benjamin Herrenschmidt | 34d97e0 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 316 | // CHECK_NAPPING(); |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 317 | // addi r3,r1,STACK_FRAME_OVERHEAD |
| 318 | // bl .critical_exception |
| 319 | // b ret_from_crit_except |
| 320 | b . |
| 321 | |
| 322 | /* Machine Check Interrupt */ |
| 323 | START_EXCEPTION(machine_check); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 324 | MC_EXCEPTION_PROLOG(0x200, BOOKE_INTERRUPT_MACHINE_CHECK, |
| 325 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 326 | // EXCEPTION_COMMON(0x200, PACA_EXMC, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 327 | // bl special_reg_save_mc |
| 328 | // addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 34d97e0 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 329 | // CHECK_NAPPING(); |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 330 | // bl .machine_check_exception |
| 331 | // b ret_from_mc_except |
| 332 | b . |
| 333 | |
| 334 | /* Data Storage Interrupt */ |
| 335 | START_EXCEPTION(data_storage) |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 336 | NORMAL_EXCEPTION_PROLOG(0x300, BOOKE_INTERRUPT_DATA_STORAGE, |
| 337 | PROLOG_ADDITION_2REGS) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 338 | mfspr r14,SPRN_DEAR |
| 339 | mfspr r15,SPRN_ESR |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 340 | EXCEPTION_COMMON(0x300, PACA_EXGEN, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 341 | b storage_fault_common |
| 342 | |
| 343 | /* Instruction Storage Interrupt */ |
| 344 | START_EXCEPTION(instruction_storage); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 345 | NORMAL_EXCEPTION_PROLOG(0x400, BOOKE_INTERRUPT_INST_STORAGE, |
| 346 | PROLOG_ADDITION_2REGS) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 347 | li r15,0 |
| 348 | mr r14,r10 |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 349 | EXCEPTION_COMMON(0x400, PACA_EXGEN, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 350 | b storage_fault_common |
| 351 | |
| 352 | /* External Input Interrupt */ |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 353 | MASKABLE_EXCEPTION(0x500, BOOKE_INTERRUPT_EXTERNAL, |
| 354 | external_input, .do_IRQ, ACK_NONE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 355 | |
| 356 | /* Alignment */ |
| 357 | START_EXCEPTION(alignment); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 358 | NORMAL_EXCEPTION_PROLOG(0x600, BOOKE_INTERRUPT_ALIGNMENT, |
| 359 | PROLOG_ADDITION_2REGS) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 360 | mfspr r14,SPRN_DEAR |
| 361 | mfspr r15,SPRN_ESR |
| 362 | EXCEPTION_COMMON(0x600, PACA_EXGEN, INTS_KEEP) |
| 363 | b alignment_more /* no room, go out of line */ |
| 364 | |
| 365 | /* Program Interrupt */ |
| 366 | START_EXCEPTION(program); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 367 | NORMAL_EXCEPTION_PROLOG(0x700, BOOKE_INTERRUPT_PROGRAM, |
| 368 | PROLOG_ADDITION_1REG) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 369 | mfspr r14,SPRN_ESR |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 370 | EXCEPTION_COMMON(0x700, PACA_EXGEN, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 371 | std r14,_DSISR(r1) |
| 372 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 373 | ld r14,PACA_EXGEN+EX_R14(r13) |
| 374 | bl .save_nvgprs |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 375 | bl .program_check_exception |
| 376 | b .ret_from_except |
| 377 | |
| 378 | /* Floating Point Unavailable Interrupt */ |
| 379 | START_EXCEPTION(fp_unavailable); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 380 | NORMAL_EXCEPTION_PROLOG(0x800, BOOKE_INTERRUPT_FP_UNAVAIL, |
| 381 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 382 | /* we can probably do a shorter exception entry for that one... */ |
| 383 | EXCEPTION_COMMON(0x800, PACA_EXGEN, INTS_KEEP) |
Benjamin Herrenschmidt | 9424fab | 2012-03-05 10:55:04 +1100 | [diff] [blame] | 384 | ld r12,_MSR(r1) |
| 385 | andi. r0,r12,MSR_PR; |
| 386 | beq- 1f |
| 387 | bl .load_up_fpu |
| 388 | b fast_exception_return |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 389 | 1: INTS_DISABLE |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 390 | bl .save_nvgprs |
| 391 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 392 | bl .kernel_fp_unavailable_exception |
Benjamin Herrenschmidt | 9424fab | 2012-03-05 10:55:04 +1100 | [diff] [blame] | 393 | b .ret_from_except |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 394 | |
| 395 | /* Decrementer Interrupt */ |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 396 | MASKABLE_EXCEPTION(0x900, BOOKE_INTERRUPT_DECREMENTER, |
| 397 | decrementer, .timer_interrupt, ACK_DEC) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 398 | |
| 399 | /* Fixed Interval Timer Interrupt */ |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 400 | MASKABLE_EXCEPTION(0x980, BOOKE_INTERRUPT_FIT, |
| 401 | fixed_interval, .unknown_exception, ACK_FIT) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 402 | |
| 403 | /* Watchdog Timer Interrupt */ |
| 404 | START_EXCEPTION(watchdog); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 405 | CRIT_EXCEPTION_PROLOG(0x9f0, BOOKE_INTERRUPT_WATCHDOG, |
| 406 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 407 | // EXCEPTION_COMMON(0x9f0, PACA_EXCRIT, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 408 | // bl special_reg_save_crit |
Benjamin Herrenschmidt | 34d97e0 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 409 | // CHECK_NAPPING(); |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 410 | // addi r3,r1,STACK_FRAME_OVERHEAD |
| 411 | // bl .unknown_exception |
| 412 | // b ret_from_crit_except |
| 413 | b . |
| 414 | |
| 415 | /* System Call Interrupt */ |
| 416 | START_EXCEPTION(system_call) |
| 417 | mr r9,r13 /* keep a copy of userland r13 */ |
| 418 | mfspr r11,SPRN_SRR0 /* get return address */ |
| 419 | mfspr r12,SPRN_SRR1 /* get previous MSR */ |
| 420 | mfspr r13,SPRN_SPRG_PACA /* get our PACA */ |
| 421 | b system_call_common |
| 422 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 423 | /* Auxiliary Processor Unavailable Interrupt */ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 424 | START_EXCEPTION(ap_unavailable); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 425 | NORMAL_EXCEPTION_PROLOG(0xf20, BOOKE_INTERRUPT_AP_UNAVAIL, |
| 426 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 427 | EXCEPTION_COMMON(0xf20, PACA_EXGEN, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 428 | bl .save_nvgprs |
Benjamin Herrenschmidt | 9f2f79e | 2012-03-01 15:47:44 +1100 | [diff] [blame] | 429 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 430 | bl .unknown_exception |
| 431 | b .ret_from_except |
| 432 | |
| 433 | /* Debug exception as a critical interrupt*/ |
| 434 | START_EXCEPTION(debug_crit); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 435 | CRIT_EXCEPTION_PROLOG(0xd00, BOOKE_INTERRUPT_DEBUG, |
| 436 | PROLOG_ADDITION_2REGS) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 437 | |
| 438 | /* |
| 439 | * If there is a single step or branch-taken exception in an |
| 440 | * exception entry sequence, it was probably meant to apply to |
| 441 | * the code where the exception occurred (since exception entry |
| 442 | * doesn't turn off DE automatically). We simulate the effect |
| 443 | * of turning off DE on entry to an exception handler by turning |
| 444 | * off DE in the CSRR1 value and clearing the debug status. |
| 445 | */ |
| 446 | |
| 447 | mfspr r14,SPRN_DBSR /* check single-step/branch taken */ |
| 448 | andis. r15,r14,DBSR_IC@h |
| 449 | beq+ 1f |
| 450 | |
| 451 | LOAD_REG_IMMEDIATE(r14,interrupt_base_book3e) |
| 452 | LOAD_REG_IMMEDIATE(r15,interrupt_end_book3e) |
| 453 | cmpld cr0,r10,r14 |
| 454 | cmpld cr1,r10,r15 |
| 455 | blt+ cr0,1f |
| 456 | bge+ cr1,1f |
| 457 | |
| 458 | /* here it looks like we got an inappropriate debug exception. */ |
| 459 | lis r14,DBSR_IC@h /* clear the IC event */ |
| 460 | rlwinm r11,r11,0,~MSR_DE /* clear DE in the CSRR1 value */ |
| 461 | mtspr SPRN_DBSR,r14 |
| 462 | mtspr SPRN_CSRR1,r11 |
| 463 | lwz r10,PACA_EXCRIT+EX_CR(r13) /* restore registers */ |
| 464 | ld r1,PACA_EXCRIT+EX_R1(r13) |
| 465 | ld r14,PACA_EXCRIT+EX_R14(r13) |
| 466 | ld r15,PACA_EXCRIT+EX_R15(r13) |
| 467 | mtcr r10 |
| 468 | ld r10,PACA_EXCRIT+EX_R10(r13) /* restore registers */ |
| 469 | ld r11,PACA_EXCRIT+EX_R11(r13) |
Mihai Caraman | 8b64a9d | 2012-08-06 03:27:07 +0000 | [diff] [blame^] | 470 | ld r13,PACA_EXCRIT+EX_R13(r13) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 471 | rfci |
| 472 | |
| 473 | /* Normal debug exception */ |
| 474 | /* XXX We only handle coming from userspace for now since we can't |
| 475 | * quite save properly an interrupted kernel state yet |
| 476 | */ |
| 477 | 1: andi. r14,r11,MSR_PR; /* check for userspace again */ |
| 478 | beq kernel_dbg_exc; /* if from kernel mode */ |
| 479 | |
| 480 | /* Now we mash up things to make it look like we are coming on a |
| 481 | * normal exception |
| 482 | */ |
Mihai Caraman | 8b64a9d | 2012-08-06 03:27:07 +0000 | [diff] [blame^] | 483 | ld r15,PACA_EXCRIT+EX_R13(r13) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 484 | mtspr SPRN_SPRG_GEN_SCRATCH,r15 |
| 485 | mfspr r14,SPRN_DBSR |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 486 | EXCEPTION_COMMON(0xd00, PACA_EXCRIT, INTS_DISABLE) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 487 | std r14,_DSISR(r1) |
| 488 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 489 | mr r4,r14 |
| 490 | ld r14,PACA_EXCRIT+EX_R14(r13) |
| 491 | ld r15,PACA_EXCRIT+EX_R15(r13) |
| 492 | bl .save_nvgprs |
| 493 | bl .DebugException |
| 494 | b .ret_from_except |
| 495 | |
| 496 | kernel_dbg_exc: |
| 497 | b . /* NYI */ |
| 498 | |
Kumar Gala | d36b4c4 | 2011-04-06 00:18:48 -0500 | [diff] [blame] | 499 | /* Debug exception as a debug interrupt*/ |
| 500 | START_EXCEPTION(debug_debug); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 501 | DBG_EXCEPTION_PROLOG(0xd00, BOOKE_INTERRUPT_DEBUG, |
| 502 | PROLOG_ADDITION_2REGS) |
Kumar Gala | d36b4c4 | 2011-04-06 00:18:48 -0500 | [diff] [blame] | 503 | |
| 504 | /* |
| 505 | * If there is a single step or branch-taken exception in an |
| 506 | * exception entry sequence, it was probably meant to apply to |
| 507 | * the code where the exception occurred (since exception entry |
| 508 | * doesn't turn off DE automatically). We simulate the effect |
| 509 | * of turning off DE on entry to an exception handler by turning |
| 510 | * off DE in the DSRR1 value and clearing the debug status. |
| 511 | */ |
| 512 | |
| 513 | mfspr r14,SPRN_DBSR /* check single-step/branch taken */ |
| 514 | andis. r15,r14,DBSR_IC@h |
| 515 | beq+ 1f |
| 516 | |
| 517 | LOAD_REG_IMMEDIATE(r14,interrupt_base_book3e) |
| 518 | LOAD_REG_IMMEDIATE(r15,interrupt_end_book3e) |
| 519 | cmpld cr0,r10,r14 |
| 520 | cmpld cr1,r10,r15 |
| 521 | blt+ cr0,1f |
| 522 | bge+ cr1,1f |
| 523 | |
| 524 | /* here it looks like we got an inappropriate debug exception. */ |
| 525 | lis r14,DBSR_IC@h /* clear the IC event */ |
| 526 | rlwinm r11,r11,0,~MSR_DE /* clear DE in the DSRR1 value */ |
| 527 | mtspr SPRN_DBSR,r14 |
| 528 | mtspr SPRN_DSRR1,r11 |
| 529 | lwz r10,PACA_EXDBG+EX_CR(r13) /* restore registers */ |
| 530 | ld r1,PACA_EXDBG+EX_R1(r13) |
| 531 | ld r14,PACA_EXDBG+EX_R14(r13) |
| 532 | ld r15,PACA_EXDBG+EX_R15(r13) |
| 533 | mtcr r10 |
| 534 | ld r10,PACA_EXDBG+EX_R10(r13) /* restore registers */ |
| 535 | ld r11,PACA_EXDBG+EX_R11(r13) |
| 536 | mfspr r13,SPRN_SPRG_DBG_SCRATCH |
| 537 | rfdi |
| 538 | |
| 539 | /* Normal debug exception */ |
| 540 | /* XXX We only handle coming from userspace for now since we can't |
| 541 | * quite save properly an interrupted kernel state yet |
| 542 | */ |
| 543 | 1: andi. r14,r11,MSR_PR; /* check for userspace again */ |
| 544 | beq kernel_dbg_exc; /* if from kernel mode */ |
| 545 | |
| 546 | /* Now we mash up things to make it look like we are coming on a |
| 547 | * normal exception |
| 548 | */ |
| 549 | mfspr r15,SPRN_SPRG_DBG_SCRATCH |
| 550 | mtspr SPRN_SPRG_GEN_SCRATCH,r15 |
| 551 | mfspr r14,SPRN_DBSR |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 552 | EXCEPTION_COMMON(0xd08, PACA_EXDBG, INTS_DISABLE) |
Kumar Gala | d36b4c4 | 2011-04-06 00:18:48 -0500 | [diff] [blame] | 553 | std r14,_DSISR(r1) |
| 554 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 555 | mr r4,r14 |
| 556 | ld r14,PACA_EXDBG+EX_R14(r13) |
| 557 | ld r15,PACA_EXDBG+EX_R15(r13) |
| 558 | bl .save_nvgprs |
| 559 | bl .DebugException |
| 560 | b .ret_from_except |
| 561 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 562 | START_EXCEPTION(perfmon); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 563 | NORMAL_EXCEPTION_PROLOG(0x260, BOOKE_INTERRUPT_PERFORMANCE_MONITOR, |
| 564 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 565 | EXCEPTION_COMMON(0x260, PACA_EXGEN, INTS_DISABLE) |
| 566 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 567 | bl .performance_monitor_exception |
| 568 | b .ret_from_except_lite |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 569 | |
Benjamin Herrenschmidt | 89c8179 | 2010-07-09 15:31:28 +1000 | [diff] [blame] | 570 | /* Doorbell interrupt */ |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 571 | MASKABLE_EXCEPTION(0x280, BOOKE_INTERRUPT_DOORBELL, |
| 572 | doorbell, .doorbell_exception, ACK_NONE) |
Benjamin Herrenschmidt | 89c8179 | 2010-07-09 15:31:28 +1000 | [diff] [blame] | 573 | |
| 574 | /* Doorbell critical Interrupt */ |
| 575 | START_EXCEPTION(doorbell_crit); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 576 | CRIT_EXCEPTION_PROLOG(0x2a0, BOOKE_INTERRUPT_DOORBELL_CRITICAL, |
| 577 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 578 | // EXCEPTION_COMMON(0x2a0, PACA_EXCRIT, INTS_DISABLE) |
Benjamin Herrenschmidt | 89c8179 | 2010-07-09 15:31:28 +1000 | [diff] [blame] | 579 | // bl special_reg_save_crit |
Benjamin Herrenschmidt | 34d97e0 | 2010-07-14 14:12:16 +1000 | [diff] [blame] | 580 | // CHECK_NAPPING(); |
Benjamin Herrenschmidt | 89c8179 | 2010-07-09 15:31:28 +1000 | [diff] [blame] | 581 | // addi r3,r1,STACK_FRAME_OVERHEAD |
| 582 | // bl .doorbell_critical_exception |
| 583 | // b ret_from_crit_except |
| 584 | b . |
| 585 | |
Mihai Caraman | 5473eb1 | 2012-08-06 03:27:04 +0000 | [diff] [blame] | 586 | /* |
| 587 | * Guest doorbell interrupt |
| 588 | * This general exception use GSRRx save/restore registers |
| 589 | */ |
| 590 | START_EXCEPTION(guest_doorbell); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 591 | GDBELL_EXCEPTION_PROLOG(0x2c0, BOOKE_INTERRUPT_GUEST_DBELL, |
| 592 | PROLOG_ADDITION_NONE) |
Mihai Caraman | 5473eb1 | 2012-08-06 03:27:04 +0000 | [diff] [blame] | 593 | EXCEPTION_COMMON(0x2c0, PACA_EXGEN, INTS_KEEP) |
| 594 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 595 | bl .save_nvgprs |
| 596 | INTS_RESTORE_HARD |
| 597 | bl .unknown_exception |
| 598 | b .ret_from_except |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 599 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 600 | /* Guest Doorbell critical Interrupt */ |
| 601 | START_EXCEPTION(guest_doorbell_crit); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 602 | CRIT_EXCEPTION_PROLOG(0x2e0, BOOKE_INTERRUPT_GUEST_DBELL_CRIT, |
| 603 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 604 | // EXCEPTION_COMMON(0x2e0, PACA_EXCRIT, INTS_DISABLE) |
| 605 | // bl special_reg_save_crit |
| 606 | // CHECK_NAPPING(); |
| 607 | // addi r3,r1,STACK_FRAME_OVERHEAD |
| 608 | // bl .guest_doorbell_critical_exception |
| 609 | // b ret_from_crit_except |
| 610 | b . |
| 611 | |
| 612 | /* Hypervisor call */ |
| 613 | START_EXCEPTION(hypercall); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 614 | NORMAL_EXCEPTION_PROLOG(0x310, BOOKE_INTERRUPT_HV_SYSCALL, |
| 615 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 616 | EXCEPTION_COMMON(0x310, PACA_EXGEN, INTS_KEEP) |
| 617 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 618 | bl .save_nvgprs |
| 619 | INTS_RESTORE_HARD |
| 620 | bl .unknown_exception |
| 621 | b .ret_from_except |
| 622 | |
| 623 | /* Embedded Hypervisor priviledged */ |
| 624 | START_EXCEPTION(ehpriv); |
Mihai Caraman | fecff0f | 2012-08-06 03:27:05 +0000 | [diff] [blame] | 625 | NORMAL_EXCEPTION_PROLOG(0x320, BOOKE_INTERRUPT_HV_PRIV, |
| 626 | PROLOG_ADDITION_NONE) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 627 | EXCEPTION_COMMON(0x320, PACA_EXGEN, INTS_KEEP) |
| 628 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 629 | bl .save_nvgprs |
| 630 | INTS_RESTORE_HARD |
| 631 | bl .unknown_exception |
| 632 | b .ret_from_except |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 633 | |
| 634 | /* |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 635 | * An interrupt came in while soft-disabled; We mark paca->irq_happened |
| 636 | * accordingly and if the interrupt is level sensitive, we hard disable |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 637 | */ |
Scott Wood | 3d97a61 | 2011-06-22 11:19:49 +0000 | [diff] [blame] | 638 | |
Mihai Caraman | 79b5c8d | 2012-08-06 03:27:06 +0000 | [diff] [blame] | 639 | .macro masked_interrupt_book3e paca_irq full_mask |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 640 | lbz r10,PACAIRQHAPPENED(r13) |
Mihai Caraman | 79b5c8d | 2012-08-06 03:27:06 +0000 | [diff] [blame] | 641 | ori r10,r10,\paca_irq |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 642 | stb r10,PACAIRQHAPPENED(r13) |
Mihai Caraman | 79b5c8d | 2012-08-06 03:27:06 +0000 | [diff] [blame] | 643 | |
| 644 | .if \full_mask == 1 |
| 645 | rldicl r10,r11,48,1 /* clear MSR_EE */ |
| 646 | rotldi r11,r10,16 |
| 647 | mtspr SPRN_SRR1,r11 |
| 648 | .endif |
| 649 | |
| 650 | lwz r11,PACA_EXGEN+EX_CR(r13) |
| 651 | mtcr r11 |
| 652 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 653 | ld r11,PACA_EXGEN+EX_R11(r13) |
| 654 | mfspr r13,SPRN_SPRG_GEN_SCRATCH |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 655 | rfi |
| 656 | b . |
Mihai Caraman | 79b5c8d | 2012-08-06 03:27:06 +0000 | [diff] [blame] | 657 | .endm |
| 658 | |
| 659 | masked_interrupt_book3e_0x500: |
| 660 | // XXX When adding support for EPR, use PACA_IRQ_EE_EDGE |
| 661 | masked_interrupt_book3e PACA_IRQ_EE 1 |
| 662 | |
| 663 | masked_interrupt_book3e_0x900: |
| 664 | ACK_DEC(r10); |
| 665 | masked_interrupt_book3e PACA_IRQ_DEC 0 |
| 666 | |
| 667 | masked_interrupt_book3e_0x980: |
| 668 | ACK_FIT(r10); |
| 669 | masked_interrupt_book3e PACA_IRQ_DEC 0 |
| 670 | |
| 671 | masked_interrupt_book3e_0x280: |
| 672 | masked_interrupt_book3e_0x2c0: |
| 673 | masked_interrupt_book3e PACA_IRQ_DBELL 0 |
| 674 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 675 | /* |
| 676 | * Called from arch_local_irq_enable when an interrupt needs |
| 677 | * to be resent. r3 contains either 0x500,0x900,0x260 or 0x280 |
| 678 | * to indicate the kind of interrupt. MSR:EE is already off. |
| 679 | * We generate a stackframe like if a real interrupt had happened. |
| 680 | * |
| 681 | * Note: While MSR:EE is off, we need to make sure that _MSR |
| 682 | * in the generated frame has EE set to 1 or the exception |
| 683 | * handler will not properly re-enable them. |
| 684 | */ |
| 685 | _GLOBAL(__replay_interrupt) |
| 686 | /* We are going to jump to the exception common code which |
| 687 | * will retrieve various register values from the PACA which |
| 688 | * we don't give a damn about. |
| 689 | */ |
| 690 | mflr r10 |
| 691 | mfmsr r11 |
| 692 | mfcr r4 |
| 693 | mtspr SPRN_SPRG_GEN_SCRATCH,r13; |
| 694 | std r1,PACA_EXGEN+EX_R1(r13); |
| 695 | stw r4,PACA_EXGEN+EX_CR(r13); |
| 696 | ori r11,r11,MSR_EE |
| 697 | subi r1,r1,INT_FRAME_SIZE; |
| 698 | cmpwi cr0,r3,0x500 |
| 699 | beq exc_0x500_common |
| 700 | cmpwi cr0,r3,0x900 |
| 701 | beq exc_0x900_common |
| 702 | cmpwi cr0,r3,0x280 |
| 703 | beq exc_0x280_common |
| 704 | blr |
| 705 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 706 | |
| 707 | /* |
| 708 | * This is called from 0x300 and 0x400 handlers after the prologs with |
| 709 | * r14 and r15 containing the fault address and error code, with the |
| 710 | * original values stashed away in the PACA |
| 711 | */ |
| 712 | storage_fault_common: |
| 713 | std r14,_DAR(r1) |
| 714 | std r15,_DSISR(r1) |
| 715 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 716 | mr r4,r14 |
| 717 | mr r5,r15 |
| 718 | ld r14,PACA_EXGEN+EX_R14(r13) |
| 719 | ld r15,PACA_EXGEN+EX_R15(r13) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 720 | bl .do_page_fault |
| 721 | cmpdi r3,0 |
| 722 | bne- 1f |
| 723 | b .ret_from_except_lite |
| 724 | 1: bl .save_nvgprs |
| 725 | mr r5,r3 |
| 726 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 727 | ld r4,_DAR(r1) |
| 728 | bl .bad_page_fault |
| 729 | b .ret_from_except |
| 730 | |
| 731 | /* |
| 732 | * Alignment exception doesn't fit entirely in the 0x100 bytes so it |
| 733 | * continues here. |
| 734 | */ |
| 735 | alignment_more: |
| 736 | std r14,_DAR(r1) |
| 737 | std r15,_DSISR(r1) |
| 738 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 739 | ld r14,PACA_EXGEN+EX_R14(r13) |
| 740 | ld r15,PACA_EXGEN+EX_R15(r13) |
| 741 | bl .save_nvgprs |
| 742 | INTS_RESTORE_HARD |
| 743 | bl .alignment_exception |
| 744 | b .ret_from_except |
| 745 | |
| 746 | /* |
| 747 | * We branch here from entry_64.S for the last stage of the exception |
| 748 | * return code path. MSR:EE is expected to be off at that point |
| 749 | */ |
| 750 | _GLOBAL(exception_return_book3e) |
| 751 | b 1f |
| 752 | |
| 753 | /* This is the return from load_up_fpu fast path which could do with |
| 754 | * less GPR restores in fact, but for now we have a single return path |
| 755 | */ |
| 756 | .globl fast_exception_return |
| 757 | fast_exception_return: |
| 758 | wrteei 0 |
| 759 | 1: mr r0,r13 |
| 760 | ld r10,_MSR(r1) |
| 761 | REST_4GPRS(2, r1) |
| 762 | andi. r6,r10,MSR_PR |
| 763 | REST_2GPRS(6, r1) |
| 764 | beq 1f |
| 765 | ACCOUNT_CPU_USER_EXIT(r10, r11) |
| 766 | ld r0,GPR13(r1) |
| 767 | |
| 768 | 1: stdcx. r0,0,r1 /* to clear the reservation */ |
| 769 | |
| 770 | ld r8,_CCR(r1) |
| 771 | ld r9,_LINK(r1) |
| 772 | ld r10,_CTR(r1) |
| 773 | ld r11,_XER(r1) |
| 774 | mtcr r8 |
| 775 | mtlr r9 |
| 776 | mtctr r10 |
| 777 | mtxer r11 |
| 778 | REST_2GPRS(8, r1) |
| 779 | ld r10,GPR10(r1) |
| 780 | ld r11,GPR11(r1) |
| 781 | ld r12,GPR12(r1) |
| 782 | mtspr SPRN_SPRG_GEN_SCRATCH,r0 |
| 783 | |
| 784 | std r10,PACA_EXGEN+EX_R10(r13); |
| 785 | std r11,PACA_EXGEN+EX_R11(r13); |
| 786 | ld r10,_NIP(r1) |
| 787 | ld r11,_MSR(r1) |
| 788 | ld r0,GPR0(r1) |
| 789 | ld r1,GPR1(r1) |
| 790 | mtspr SPRN_SRR0,r10 |
| 791 | mtspr SPRN_SRR1,r11 |
| 792 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 793 | ld r11,PACA_EXGEN+EX_R11(r13) |
| 794 | mfspr r13,SPRN_SPRG_GEN_SCRATCH |
| 795 | rfi |
| 796 | |
| 797 | /* |
| 798 | * Trampolines used when spotting a bad kernel stack pointer in |
| 799 | * the exception entry code. |
| 800 | * |
| 801 | * TODO: move some bits like SRR0 read to trampoline, pass PACA |
| 802 | * index around, etc... to handle crit & mcheck |
| 803 | */ |
| 804 | BAD_STACK_TRAMPOLINE(0x000) |
| 805 | BAD_STACK_TRAMPOLINE(0x100) |
| 806 | BAD_STACK_TRAMPOLINE(0x200) |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 807 | BAD_STACK_TRAMPOLINE(0x260) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 808 | BAD_STACK_TRAMPOLINE(0x280) |
| 809 | BAD_STACK_TRAMPOLINE(0x2a0) |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 810 | BAD_STACK_TRAMPOLINE(0x2c0) |
| 811 | BAD_STACK_TRAMPOLINE(0x2e0) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 812 | BAD_STACK_TRAMPOLINE(0x300) |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 813 | BAD_STACK_TRAMPOLINE(0x310) |
| 814 | BAD_STACK_TRAMPOLINE(0x320) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 815 | BAD_STACK_TRAMPOLINE(0x400) |
| 816 | BAD_STACK_TRAMPOLINE(0x500) |
| 817 | BAD_STACK_TRAMPOLINE(0x600) |
| 818 | BAD_STACK_TRAMPOLINE(0x700) |
| 819 | BAD_STACK_TRAMPOLINE(0x800) |
| 820 | BAD_STACK_TRAMPOLINE(0x900) |
| 821 | BAD_STACK_TRAMPOLINE(0x980) |
| 822 | BAD_STACK_TRAMPOLINE(0x9f0) |
| 823 | BAD_STACK_TRAMPOLINE(0xa00) |
| 824 | BAD_STACK_TRAMPOLINE(0xb00) |
| 825 | BAD_STACK_TRAMPOLINE(0xc00) |
| 826 | BAD_STACK_TRAMPOLINE(0xd00) |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 827 | BAD_STACK_TRAMPOLINE(0xd08) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 828 | BAD_STACK_TRAMPOLINE(0xe00) |
| 829 | BAD_STACK_TRAMPOLINE(0xf00) |
| 830 | BAD_STACK_TRAMPOLINE(0xf20) |
| 831 | |
| 832 | .globl bad_stack_book3e |
| 833 | bad_stack_book3e: |
| 834 | /* XXX: Needs to make SPRN_SPRG_GEN depend on exception type */ |
| 835 | mfspr r10,SPRN_SRR0; /* read SRR0 before touching stack */ |
| 836 | ld r1,PACAEMERGSP(r13) |
| 837 | subi r1,r1,64+INT_FRAME_SIZE |
| 838 | std r10,_NIP(r1) |
| 839 | std r11,_MSR(r1) |
| 840 | ld r10,PACA_EXGEN+EX_R1(r13) /* FIXME for crit & mcheck */ |
| 841 | lwz r11,PACA_EXGEN+EX_CR(r13) /* FIXME for crit & mcheck */ |
| 842 | std r10,GPR1(r1) |
| 843 | std r11,_CCR(r1) |
| 844 | mfspr r10,SPRN_DEAR |
| 845 | mfspr r11,SPRN_ESR |
| 846 | std r10,_DAR(r1) |
| 847 | std r11,_DSISR(r1) |
| 848 | std r0,GPR0(r1); /* save r0 in stackframe */ \ |
| 849 | std r2,GPR2(r1); /* save r2 in stackframe */ \ |
| 850 | SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ |
| 851 | SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ |
| 852 | std r9,GPR9(r1); /* save r9 in stackframe */ \ |
| 853 | ld r3,PACA_EXGEN+EX_R10(r13);/* get back r10 */ \ |
| 854 | ld r4,PACA_EXGEN+EX_R11(r13);/* get back r11 */ \ |
| 855 | mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 XXX can be wrong */ \ |
| 856 | std r3,GPR10(r1); /* save r10 to stackframe */ \ |
| 857 | std r4,GPR11(r1); /* save r11 to stackframe */ \ |
| 858 | std r12,GPR12(r1); /* save r12 in stackframe */ \ |
| 859 | std r5,GPR13(r1); /* save it to stackframe */ \ |
| 860 | mflr r10 |
| 861 | mfctr r11 |
| 862 | mfxer r12 |
| 863 | std r10,_LINK(r1) |
| 864 | std r11,_CTR(r1) |
| 865 | std r12,_XER(r1) |
| 866 | SAVE_10GPRS(14,r1) |
| 867 | SAVE_8GPRS(24,r1) |
| 868 | lhz r12,PACA_TRAP_SAVE(r13) |
| 869 | std r12,_TRAP(r1) |
| 870 | addi r11,r1,INT_FRAME_SIZE |
| 871 | std r11,0(r1) |
| 872 | li r12,0 |
| 873 | std r12,0(r11) |
| 874 | ld r2,PACATOC(r13) |
| 875 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 876 | bl .kernel_bad_stack |
| 877 | b 1b |
| 878 | |
| 879 | /* |
| 880 | * Setup the initial TLB for a core. This current implementation |
| 881 | * assume that whatever we are running off will not conflict with |
| 882 | * the new mapping at PAGE_OFFSET. |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 883 | */ |
| 884 | _GLOBAL(initial_tlb_book3e) |
| 885 | |
Kumar Gala | bb1af71 | 2009-08-18 19:08:33 +0000 | [diff] [blame] | 886 | /* Look for the first TLB with IPROT set */ |
| 887 | mfspr r4,SPRN_TLB0CFG |
| 888 | andi. r3,r4,TLBnCFG_IPROT |
| 889 | lis r3,MAS0_TLBSEL(0)@h |
| 890 | bne found_iprot |
| 891 | |
| 892 | mfspr r4,SPRN_TLB1CFG |
| 893 | andi. r3,r4,TLBnCFG_IPROT |
| 894 | lis r3,MAS0_TLBSEL(1)@h |
| 895 | bne found_iprot |
| 896 | |
| 897 | mfspr r4,SPRN_TLB2CFG |
| 898 | andi. r3,r4,TLBnCFG_IPROT |
| 899 | lis r3,MAS0_TLBSEL(2)@h |
| 900 | bne found_iprot |
| 901 | |
| 902 | lis r3,MAS0_TLBSEL(3)@h |
| 903 | mfspr r4,SPRN_TLB3CFG |
| 904 | /* fall through */ |
| 905 | |
| 906 | found_iprot: |
| 907 | andi. r5,r4,TLBnCFG_HES |
| 908 | bne have_hes |
| 909 | |
| 910 | mflr r8 /* save LR */ |
| 911 | /* 1. Find the index of the entry we're executing in |
| 912 | * |
| 913 | * r3 = MAS0_TLBSEL (for the iprot array) |
| 914 | * r4 = SPRN_TLBnCFG |
| 915 | */ |
| 916 | bl invstr /* Find our address */ |
| 917 | invstr: mflr r6 /* Make it accessible */ |
| 918 | mfmsr r7 |
| 919 | rlwinm r5,r7,27,31,31 /* extract MSR[IS] */ |
| 920 | mfspr r7,SPRN_PID |
| 921 | slwi r7,r7,16 |
| 922 | or r7,r7,r5 |
| 923 | mtspr SPRN_MAS6,r7 |
| 924 | tlbsx 0,r6 /* search MSR[IS], SPID=PID */ |
| 925 | |
| 926 | mfspr r3,SPRN_MAS0 |
| 927 | rlwinm r5,r3,16,20,31 /* Extract MAS0(Entry) */ |
| 928 | |
| 929 | mfspr r7,SPRN_MAS1 /* Insure IPROT set */ |
| 930 | oris r7,r7,MAS1_IPROT@h |
| 931 | mtspr SPRN_MAS1,r7 |
| 932 | tlbwe |
| 933 | |
| 934 | /* 2. Invalidate all entries except the entry we're executing in |
| 935 | * |
| 936 | * r3 = MAS0 w/TLBSEL & ESEL for the entry we are running in |
| 937 | * r4 = SPRN_TLBnCFG |
| 938 | * r5 = ESEL of entry we are running in |
| 939 | */ |
| 940 | andi. r4,r4,TLBnCFG_N_ENTRY /* Extract # entries */ |
| 941 | li r6,0 /* Set Entry counter to 0 */ |
| 942 | 1: mr r7,r3 /* Set MAS0(TLBSEL) */ |
| 943 | rlwimi r7,r6,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r6) */ |
| 944 | mtspr SPRN_MAS0,r7 |
| 945 | tlbre |
| 946 | mfspr r7,SPRN_MAS1 |
| 947 | rlwinm r7,r7,0,2,31 /* Clear MAS1 Valid and IPROT */ |
| 948 | cmpw r5,r6 |
| 949 | beq skpinv /* Dont update the current execution TLB */ |
| 950 | mtspr SPRN_MAS1,r7 |
| 951 | tlbwe |
| 952 | isync |
| 953 | skpinv: addi r6,r6,1 /* Increment */ |
| 954 | cmpw r6,r4 /* Are we done? */ |
| 955 | bne 1b /* If not, repeat */ |
| 956 | |
| 957 | /* Invalidate all TLBs */ |
Michael Neuling | 962cffb | 2012-06-25 13:33:25 +0000 | [diff] [blame] | 958 | PPC_TLBILX_ALL(0,R0) |
Kumar Gala | bb1af71 | 2009-08-18 19:08:33 +0000 | [diff] [blame] | 959 | sync |
| 960 | isync |
| 961 | |
| 962 | /* 3. Setup a temp mapping and jump to it |
| 963 | * |
| 964 | * r3 = MAS0 w/TLBSEL & ESEL for the entry we are running in |
| 965 | * r5 = ESEL of entry we are running in |
| 966 | */ |
| 967 | andi. r7,r5,0x1 /* Find an entry not used and is non-zero */ |
| 968 | addi r7,r7,0x1 |
| 969 | mr r4,r3 /* Set MAS0(TLBSEL) = 1 */ |
| 970 | mtspr SPRN_MAS0,r4 |
| 971 | tlbre |
| 972 | |
| 973 | rlwimi r4,r7,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r7) */ |
| 974 | mtspr SPRN_MAS0,r4 |
| 975 | |
| 976 | mfspr r7,SPRN_MAS1 |
| 977 | xori r6,r7,MAS1_TS /* Setup TMP mapping in the other Address space */ |
| 978 | mtspr SPRN_MAS1,r6 |
| 979 | |
| 980 | tlbwe |
| 981 | |
| 982 | mfmsr r6 |
| 983 | xori r6,r6,MSR_IS |
| 984 | mtspr SPRN_SRR1,r6 |
| 985 | bl 1f /* Find our address */ |
| 986 | 1: mflr r6 |
| 987 | addi r6,r6,(2f - 1b) |
| 988 | mtspr SPRN_SRR0,r6 |
| 989 | rfi |
| 990 | 2: |
| 991 | |
| 992 | /* 4. Clear out PIDs & Search info |
| 993 | * |
| 994 | * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in |
| 995 | * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping |
| 996 | * r5 = MAS3 |
| 997 | */ |
| 998 | li r6,0 |
| 999 | mtspr SPRN_MAS6,r6 |
| 1000 | mtspr SPRN_PID,r6 |
| 1001 | |
| 1002 | /* 5. Invalidate mapping we started in |
| 1003 | * |
| 1004 | * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in |
| 1005 | * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping |
| 1006 | * r5 = MAS3 |
| 1007 | */ |
| 1008 | mtspr SPRN_MAS0,r3 |
| 1009 | tlbre |
| 1010 | mfspr r6,SPRN_MAS1 |
| 1011 | rlwinm r6,r6,0,2,0 /* clear IPROT */ |
| 1012 | mtspr SPRN_MAS1,r6 |
| 1013 | tlbwe |
| 1014 | |
| 1015 | /* Invalidate TLB1 */ |
Michael Neuling | 962cffb | 2012-06-25 13:33:25 +0000 | [diff] [blame] | 1016 | PPC_TLBILX_ALL(0,R0) |
Kumar Gala | bb1af71 | 2009-08-18 19:08:33 +0000 | [diff] [blame] | 1017 | sync |
| 1018 | isync |
| 1019 | |
| 1020 | /* The mapping only needs to be cache-coherent on SMP */ |
| 1021 | #ifdef CONFIG_SMP |
| 1022 | #define M_IF_SMP MAS2_M |
| 1023 | #else |
| 1024 | #define M_IF_SMP 0 |
| 1025 | #endif |
| 1026 | |
| 1027 | /* 6. Setup KERNELBASE mapping in TLB[0] |
| 1028 | * |
| 1029 | * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in |
| 1030 | * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping |
| 1031 | * r5 = MAS3 |
| 1032 | */ |
| 1033 | rlwinm r3,r3,0,16,3 /* clear ESEL */ |
| 1034 | mtspr SPRN_MAS0,r3 |
| 1035 | lis r6,(MAS1_VALID|MAS1_IPROT)@h |
| 1036 | ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_1GB))@l |
| 1037 | mtspr SPRN_MAS1,r6 |
| 1038 | |
| 1039 | LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET | M_IF_SMP) |
| 1040 | mtspr SPRN_MAS2,r6 |
| 1041 | |
| 1042 | rlwinm r5,r5,0,0,25 |
| 1043 | ori r5,r5,MAS3_SR | MAS3_SW | MAS3_SX |
| 1044 | mtspr SPRN_MAS3,r5 |
| 1045 | li r5,-1 |
| 1046 | rlwinm r5,r5,0,0,25 |
| 1047 | |
| 1048 | tlbwe |
| 1049 | |
| 1050 | /* 7. Jump to KERNELBASE mapping |
| 1051 | * |
| 1052 | * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping |
| 1053 | */ |
| 1054 | /* Now we branch the new virtual address mapped by this entry */ |
| 1055 | LOAD_REG_IMMEDIATE(r6,2f) |
| 1056 | lis r7,MSR_KERNEL@h |
| 1057 | ori r7,r7,MSR_KERNEL@l |
| 1058 | mtspr SPRN_SRR0,r6 |
| 1059 | mtspr SPRN_SRR1,r7 |
| 1060 | rfi /* start execution out of TLB1[0] entry */ |
| 1061 | 2: |
| 1062 | |
| 1063 | /* 8. Clear out the temp mapping |
| 1064 | * |
| 1065 | * r4 = MAS0 w/TLBSEL & ESEL for the entry we are running in |
| 1066 | */ |
| 1067 | mtspr SPRN_MAS0,r4 |
| 1068 | tlbre |
| 1069 | mfspr r5,SPRN_MAS1 |
| 1070 | rlwinm r5,r5,0,2,0 /* clear IPROT */ |
| 1071 | mtspr SPRN_MAS1,r5 |
| 1072 | tlbwe |
| 1073 | |
| 1074 | /* Invalidate TLB1 */ |
Michael Neuling | 962cffb | 2012-06-25 13:33:25 +0000 | [diff] [blame] | 1075 | PPC_TLBILX_ALL(0,R0) |
Kumar Gala | bb1af71 | 2009-08-18 19:08:33 +0000 | [diff] [blame] | 1076 | sync |
| 1077 | isync |
| 1078 | |
| 1079 | /* We translate LR and return */ |
| 1080 | tovirt(r8,r8) |
| 1081 | mtlr r8 |
| 1082 | blr |
| 1083 | |
| 1084 | have_hes: |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1085 | /* Setup MAS 0,1,2,3 and 7 for tlbwe of a 1G entry that maps the |
| 1086 | * kernel linear mapping. We also set MAS8 once for all here though |
| 1087 | * that will have to be made dependent on whether we are running under |
| 1088 | * a hypervisor I suppose. |
| 1089 | */ |
David Gibson | a1d0d98 | 2011-04-14 22:32:06 +0000 | [diff] [blame] | 1090 | |
| 1091 | /* BEWARE, MAGIC |
| 1092 | * This code is called as an ordinary function on the boot CPU. But to |
| 1093 | * avoid duplication, this code is also used in SCOM bringup of |
| 1094 | * secondary CPUs. We read the code between the initial_tlb_code_start |
| 1095 | * and initial_tlb_code_end labels one instruction at a time and RAM it |
| 1096 | * into the new core via SCOM. That doesn't process branches, so there |
| 1097 | * must be none between those two labels. It also means if this code |
| 1098 | * ever takes any parameters, the SCOM code must also be updated to |
| 1099 | * provide them. |
| 1100 | */ |
| 1101 | .globl a2_tlbinit_code_start |
| 1102 | a2_tlbinit_code_start: |
| 1103 | |
Benjamin Herrenschmidt | 1a51dde | 2011-04-14 22:32:04 +0000 | [diff] [blame] | 1104 | ori r11,r3,MAS0_WQ_ALLWAYS |
| 1105 | oris r11,r11,MAS0_ESEL(3)@h /* Use way 3: workaround A2 erratum 376 */ |
| 1106 | mtspr SPRN_MAS0,r11 |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1107 | lis r3,(MAS1_VALID | MAS1_IPROT)@h |
| 1108 | ori r3,r3,BOOK3E_PAGESZ_1GB << MAS1_TSIZE_SHIFT |
| 1109 | mtspr SPRN_MAS1,r3 |
| 1110 | LOAD_REG_IMMEDIATE(r3, PAGE_OFFSET | MAS2_M) |
| 1111 | mtspr SPRN_MAS2,r3 |
| 1112 | li r3,MAS3_SR | MAS3_SW | MAS3_SX |
| 1113 | mtspr SPRN_MAS7_MAS3,r3 |
| 1114 | li r3,0 |
| 1115 | mtspr SPRN_MAS8,r3 |
| 1116 | |
| 1117 | /* Write the TLB entry */ |
| 1118 | tlbwe |
| 1119 | |
David Gibson | a1d0d98 | 2011-04-14 22:32:06 +0000 | [diff] [blame] | 1120 | .globl a2_tlbinit_after_linear_map |
| 1121 | a2_tlbinit_after_linear_map: |
| 1122 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1123 | /* Now we branch the new virtual address mapped by this entry */ |
| 1124 | LOAD_REG_IMMEDIATE(r3,1f) |
| 1125 | mtctr r3 |
| 1126 | bctr |
| 1127 | |
| 1128 | 1: /* We are now running at PAGE_OFFSET, clean the TLB of everything |
Jack Miller | f0aae32 | 2011-04-14 22:32:05 +0000 | [diff] [blame] | 1129 | * else (including IPROTed things left by firmware) |
| 1130 | * r4 = TLBnCFG |
| 1131 | * r3 = current address (more or less) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1132 | */ |
Jack Miller | f0aae32 | 2011-04-14 22:32:05 +0000 | [diff] [blame] | 1133 | |
| 1134 | li r5,0 |
| 1135 | mtspr SPRN_MAS6,r5 |
| 1136 | tlbsx 0,r3 |
| 1137 | |
| 1138 | rlwinm r9,r4,0,TLBnCFG_N_ENTRY |
| 1139 | rlwinm r10,r4,8,0xff |
| 1140 | addi r10,r10,-1 /* Get inner loop mask */ |
| 1141 | |
| 1142 | li r3,1 |
| 1143 | |
| 1144 | mfspr r5,SPRN_MAS1 |
| 1145 | rlwinm r5,r5,0,(~(MAS1_VALID|MAS1_IPROT)) |
| 1146 | |
| 1147 | mfspr r6,SPRN_MAS2 |
| 1148 | rldicr r6,r6,0,51 /* Extract EPN */ |
| 1149 | |
| 1150 | mfspr r7,SPRN_MAS0 |
| 1151 | rlwinm r7,r7,0,0xffff0fff /* Clear HES and WQ */ |
| 1152 | |
| 1153 | rlwinm r8,r7,16,0xfff /* Extract ESEL */ |
| 1154 | |
| 1155 | 2: add r4,r3,r8 |
| 1156 | and r4,r4,r10 |
| 1157 | |
| 1158 | rlwimi r7,r4,16,MAS0_ESEL_MASK |
| 1159 | |
| 1160 | mtspr SPRN_MAS0,r7 |
| 1161 | mtspr SPRN_MAS1,r5 |
| 1162 | mtspr SPRN_MAS2,r6 |
| 1163 | tlbwe |
| 1164 | |
| 1165 | addi r3,r3,1 |
| 1166 | and. r4,r3,r10 |
| 1167 | |
| 1168 | bne 3f |
| 1169 | addis r6,r6,(1<<30)@h |
| 1170 | 3: |
| 1171 | cmpw r3,r9 |
| 1172 | blt 2b |
| 1173 | |
David Gibson | a1d0d98 | 2011-04-14 22:32:06 +0000 | [diff] [blame] | 1174 | .globl a2_tlbinit_after_iprot_flush |
| 1175 | a2_tlbinit_after_iprot_flush: |
| 1176 | |
Jack Miller | a0496d4 | 2011-04-14 22:32:08 +0000 | [diff] [blame] | 1177 | #ifdef CONFIG_PPC_EARLY_DEBUG_WSP |
| 1178 | /* Now establish early debug mappings if applicable */ |
| 1179 | /* Restore the MAS0 we used for linear mapping load */ |
| 1180 | mtspr SPRN_MAS0,r11 |
| 1181 | |
| 1182 | lis r3,(MAS1_VALID | MAS1_IPROT)@h |
| 1183 | ori r3,r3,(BOOK3E_PAGESZ_4K << MAS1_TSIZE_SHIFT) |
| 1184 | mtspr SPRN_MAS1,r3 |
| 1185 | LOAD_REG_IMMEDIATE(r3, WSP_UART_VIRT | MAS2_I | MAS2_G) |
| 1186 | mtspr SPRN_MAS2,r3 |
| 1187 | LOAD_REG_IMMEDIATE(r3, WSP_UART_PHYS | MAS3_SR | MAS3_SW) |
| 1188 | mtspr SPRN_MAS7_MAS3,r3 |
| 1189 | /* re-use the MAS8 value from the linear mapping */ |
| 1190 | tlbwe |
| 1191 | #endif /* CONFIG_PPC_EARLY_DEBUG_WSP */ |
| 1192 | |
Michael Neuling | 962cffb | 2012-06-25 13:33:25 +0000 | [diff] [blame] | 1193 | PPC_TLBILX(0,0,R0) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1194 | sync |
| 1195 | isync |
| 1196 | |
David Gibson | a1d0d98 | 2011-04-14 22:32:06 +0000 | [diff] [blame] | 1197 | .globl a2_tlbinit_code_end |
| 1198 | a2_tlbinit_code_end: |
| 1199 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1200 | /* We translate LR and return */ |
| 1201 | mflr r3 |
| 1202 | tovirt(r3,r3) |
| 1203 | mtlr r3 |
| 1204 | blr |
| 1205 | |
| 1206 | /* |
| 1207 | * Main entry (boot CPU, thread 0) |
| 1208 | * |
| 1209 | * We enter here from head_64.S, possibly after the prom_init trampoline |
| 1210 | * with r3 and r4 already saved to r31 and 30 respectively and in 64 bits |
| 1211 | * mode. Anything else is as it was left by the bootloader |
| 1212 | * |
| 1213 | * Initial requirements of this port: |
| 1214 | * |
| 1215 | * - Kernel loaded at 0 physical |
| 1216 | * - A good lump of memory mapped 0:0 by UTLB entry 0 |
| 1217 | * - MSR:IS & MSR:DS set to 0 |
| 1218 | * |
| 1219 | * Note that some of the above requirements will be relaxed in the future |
| 1220 | * as the kernel becomes smarter at dealing with different initial conditions |
| 1221 | * but for now you have to be careful |
| 1222 | */ |
| 1223 | _GLOBAL(start_initialization_book3e) |
| 1224 | mflr r28 |
| 1225 | |
| 1226 | /* First, we need to setup some initial TLBs to map the kernel |
| 1227 | * text, data and bss at PAGE_OFFSET. We don't have a real mode |
| 1228 | * and always use AS 0, so we just set it up to match our link |
| 1229 | * address and never use 0 based addresses. |
| 1230 | */ |
| 1231 | bl .initial_tlb_book3e |
| 1232 | |
| 1233 | /* Init global core bits */ |
| 1234 | bl .init_core_book3e |
| 1235 | |
| 1236 | /* Init per-thread bits */ |
| 1237 | bl .init_thread_book3e |
| 1238 | |
| 1239 | /* Return to common init code */ |
| 1240 | tovirt(r28,r28) |
| 1241 | mtlr r28 |
| 1242 | blr |
| 1243 | |
| 1244 | |
| 1245 | /* |
| 1246 | * Secondary core/processor entry |
| 1247 | * |
| 1248 | * This is entered for thread 0 of a secondary core, all other threads |
| 1249 | * are expected to be stopped. It's similar to start_initialization_book3e |
| 1250 | * except that it's generally entered from the holding loop in head_64.S |
| 1251 | * after CPUs have been gathered by Open Firmware. |
| 1252 | * |
| 1253 | * We assume we are in 32 bits mode running with whatever TLB entry was |
| 1254 | * set for us by the firmware or POR engine. |
| 1255 | */ |
| 1256 | _GLOBAL(book3e_secondary_core_init_tlb_set) |
| 1257 | li r4,1 |
| 1258 | b .generic_secondary_smp_init |
| 1259 | |
| 1260 | _GLOBAL(book3e_secondary_core_init) |
| 1261 | mflr r28 |
| 1262 | |
| 1263 | /* Do we need to setup initial TLB entry ? */ |
| 1264 | cmplwi r4,0 |
| 1265 | bne 2f |
| 1266 | |
| 1267 | /* Setup TLB for this core */ |
| 1268 | bl .initial_tlb_book3e |
| 1269 | |
| 1270 | /* We can return from the above running at a different |
| 1271 | * address, so recalculate r2 (TOC) |
| 1272 | */ |
| 1273 | bl .relative_toc |
| 1274 | |
| 1275 | /* Init global core bits */ |
| 1276 | 2: bl .init_core_book3e |
| 1277 | |
| 1278 | /* Init per-thread bits */ |
| 1279 | 3: bl .init_thread_book3e |
| 1280 | |
| 1281 | /* Return to common init code at proper virtual address. |
| 1282 | * |
| 1283 | * Due to various previous assumptions, we know we entered this |
| 1284 | * function at either the final PAGE_OFFSET mapping or using a |
| 1285 | * 1:1 mapping at 0, so we don't bother doing a complicated check |
| 1286 | * here, we just ensure the return address has the right top bits. |
| 1287 | * |
| 1288 | * Note that if we ever want to be smarter about where we can be |
| 1289 | * started from, we have to be careful that by the time we reach |
| 1290 | * the code below we may already be running at a different location |
| 1291 | * than the one we were called from since initial_tlb_book3e can |
| 1292 | * have moved us already. |
| 1293 | */ |
| 1294 | cmpdi cr0,r28,0 |
| 1295 | blt 1f |
| 1296 | lis r3,PAGE_OFFSET@highest |
| 1297 | sldi r3,r3,32 |
| 1298 | or r28,r28,r3 |
| 1299 | 1: mtlr r28 |
| 1300 | blr |
| 1301 | |
| 1302 | _GLOBAL(book3e_secondary_thread_init) |
| 1303 | mflr r28 |
| 1304 | b 3b |
| 1305 | |
| 1306 | _STATIC(init_core_book3e) |
| 1307 | /* Establish the interrupt vector base */ |
| 1308 | LOAD_REG_IMMEDIATE(r3, interrupt_base_book3e) |
| 1309 | mtspr SPRN_IVPR,r3 |
| 1310 | sync |
| 1311 | blr |
| 1312 | |
| 1313 | _STATIC(init_thread_book3e) |
| 1314 | lis r3,(SPRN_EPCR_ICM | SPRN_EPCR_GICM)@h |
| 1315 | mtspr SPRN_EPCR,r3 |
| 1316 | |
| 1317 | /* Make sure interrupts are off */ |
| 1318 | wrteei 0 |
| 1319 | |
Kumar Gala | 6c18882 | 2009-08-18 19:08:31 +0000 | [diff] [blame] | 1320 | /* disable all timers and clear out status */ |
| 1321 | li r3,0 |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1322 | mtspr SPRN_TCR,r3 |
Kumar Gala | 6c18882 | 2009-08-18 19:08:31 +0000 | [diff] [blame] | 1323 | mfspr r3,SPRN_TSR |
| 1324 | mtspr SPRN_TSR,r3 |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1325 | |
| 1326 | blr |
| 1327 | |
Kumar Gala | 4b98d9e | 2009-08-18 19:08:32 +0000 | [diff] [blame] | 1328 | _GLOBAL(__setup_base_ivors) |
| 1329 | SET_IVOR(0, 0x020) /* Critical Input */ |
| 1330 | SET_IVOR(1, 0x000) /* Machine Check */ |
| 1331 | SET_IVOR(2, 0x060) /* Data Storage */ |
| 1332 | SET_IVOR(3, 0x080) /* Instruction Storage */ |
| 1333 | SET_IVOR(4, 0x0a0) /* External Input */ |
| 1334 | SET_IVOR(5, 0x0c0) /* Alignment */ |
| 1335 | SET_IVOR(6, 0x0e0) /* Program */ |
| 1336 | SET_IVOR(7, 0x100) /* FP Unavailable */ |
| 1337 | SET_IVOR(8, 0x120) /* System Call */ |
| 1338 | SET_IVOR(9, 0x140) /* Auxiliary Processor Unavailable */ |
| 1339 | SET_IVOR(10, 0x160) /* Decrementer */ |
| 1340 | SET_IVOR(11, 0x180) /* Fixed Interval Timer */ |
| 1341 | SET_IVOR(12, 0x1a0) /* Watchdog Timer */ |
| 1342 | SET_IVOR(13, 0x1c0) /* Data TLB Error */ |
| 1343 | SET_IVOR(14, 0x1e0) /* Instruction TLB Error */ |
| 1344 | SET_IVOR(15, 0x040) /* Debug */ |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1345 | |
Kumar Gala | 4b98d9e | 2009-08-18 19:08:32 +0000 | [diff] [blame] | 1346 | sync |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 1347 | |
Kumar Gala | 4b98d9e | 2009-08-18 19:08:32 +0000 | [diff] [blame] | 1348 | blr |
Scott Wood | 3a6e9bd | 2011-05-09 16:26:00 -0500 | [diff] [blame] | 1349 | |
| 1350 | _GLOBAL(setup_perfmon_ivor) |
| 1351 | SET_IVOR(35, 0x260) /* Performance Monitor */ |
| 1352 | blr |
| 1353 | |
| 1354 | _GLOBAL(setup_doorbell_ivors) |
| 1355 | SET_IVOR(36, 0x280) /* Processor Doorbell */ |
| 1356 | SET_IVOR(37, 0x2a0) /* Processor Doorbell Crit */ |
| 1357 | |
| 1358 | /* Check MMUCFG[LPIDSIZE] to determine if we have category E.HV */ |
| 1359 | mfspr r10,SPRN_MMUCFG |
| 1360 | rlwinm. r10,r10,0,MMUCFG_LPIDSIZE |
| 1361 | beqlr |
| 1362 | |
| 1363 | SET_IVOR(38, 0x2c0) /* Guest Processor Doorbell */ |
| 1364 | SET_IVOR(39, 0x2e0) /* Guest Processor Doorbell Crit/MC */ |
| 1365 | blr |
| 1366 | |
| 1367 | _GLOBAL(setup_ehv_ivors) |
| 1368 | /* |
| 1369 | * We may be running as a guest and lack E.HV even on a chip |
| 1370 | * that normally has it. |
| 1371 | */ |
| 1372 | mfspr r10,SPRN_MMUCFG |
| 1373 | rlwinm. r10,r10,0,MMUCFG_LPIDSIZE |
| 1374 | beqlr |
| 1375 | |
| 1376 | SET_IVOR(40, 0x300) /* Embedded Hypervisor System Call */ |
| 1377 | SET_IVOR(41, 0x320) /* Embedded Hypervisor Privilege */ |
| 1378 | blr |