diff options
author | Mihai Caraman <mihai.caraman@freescale.com> | 2012-10-11 02:13:21 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-12-05 19:34:11 -0500 |
commit | e51f8f32d6b82f4a34dbb5781769c79b813e5694 (patch) | |
tree | 5596f43d7e8718875bd7099fea2b3dc804441384 /arch/powerpc/kvm/bookehv_interrupts.S | |
parent | ff594746845877c0a6402be23897df659188eacb (diff) |
KVM: PPC: bookehv64: Add support for interrupt handling
Add interrupt handling support for 64-bit bookehv hosts. Unify 32 and 64 bit
implementations using a common stack layout and a common execution flow starting
from kvm_handler_common macro. Update documentation for 64-bit input register
values. This patch only address the bolted TLB miss exception handlers version.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/bookehv_interrupts.S')
-rw-r--r-- | arch/powerpc/kvm/bookehv_interrupts.S | 138 |
1 files changed, 130 insertions, 8 deletions
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S index fa6d5529ebfb..e8ed7d659c55 100644 --- a/arch/powerpc/kvm/bookehv_interrupts.S +++ b/arch/powerpc/kvm/bookehv_interrupts.S | |||
@@ -16,6 +16,7 @@ | |||
16 | * | 16 | * |
17 | * Author: Varun Sethi <varun.sethi@freescale.com> | 17 | * Author: Varun Sethi <varun.sethi@freescale.com> |
18 | * Author: Scott Wood <scotwood@freescale.com> | 18 | * Author: Scott Wood <scotwood@freescale.com> |
19 | * Author: Mihai Caraman <mihai.caraman@freescale.com> | ||
19 | * | 20 | * |
20 | * This file is derived from arch/powerpc/kvm/booke_interrupts.S | 21 | * This file is derived from arch/powerpc/kvm/booke_interrupts.S |
21 | */ | 22 | */ |
@@ -30,28 +31,33 @@ | |||
30 | #include <asm/bitsperlong.h> | 31 | #include <asm/bitsperlong.h> |
31 | #include <asm/thread_info.h> | 32 | #include <asm/thread_info.h> |
32 | 33 | ||
34 | #ifdef CONFIG_64BIT | ||
35 | #include <asm/exception-64e.h> | ||
36 | #else | ||
33 | #include "../kernel/head_booke.h" /* for THREAD_NORMSAVE() */ | 37 | #include "../kernel/head_booke.h" /* for THREAD_NORMSAVE() */ |
38 | #endif | ||
34 | 39 | ||
35 | #define LONGBYTES (BITS_PER_LONG / 8) | 40 | #define LONGBYTES (BITS_PER_LONG / 8) |
36 | 41 | ||
37 | #define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES)) | 42 | #define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES)) |
38 | 43 | ||
39 | /* The host stack layout: */ | 44 | /* The host stack layout: */ |
40 | #define HOST_R1 (0 * LONGBYTES) /* Implied by stwu. */ | 45 | #define HOST_R1 0 /* Implied by stwu. */ |
41 | #define HOST_CALLEE_LR (1 * LONGBYTES) | 46 | #define HOST_CALLEE_LR PPC_LR_STKOFF |
42 | #define HOST_RUN (2 * LONGBYTES) /* struct kvm_run */ | 47 | #define HOST_RUN (HOST_CALLEE_LR + LONGBYTES) |
43 | /* | 48 | /* |
44 | * r2 is special: it holds 'current', and it made nonvolatile in the | 49 | * r2 is special: it holds 'current', and it made nonvolatile in the |
45 | * kernel with the -ffixed-r2 gcc option. | 50 | * kernel with the -ffixed-r2 gcc option. |
46 | */ | 51 | */ |
47 | #define HOST_R2 (3 * LONGBYTES) | 52 | #define HOST_R2 (HOST_RUN + LONGBYTES) |
48 | #define HOST_CR (4 * LONGBYTES) | 53 | #define HOST_CR (HOST_R2 + LONGBYTES) |
49 | #define HOST_NV_GPRS (5 * LONGBYTES) | 54 | #define HOST_NV_GPRS (HOST_CR + LONGBYTES) |
50 | #define __HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES)) | 55 | #define __HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES)) |
51 | #define HOST_NV_GPR(n) __HOST_NV_GPR(__REG_##n) | 56 | #define HOST_NV_GPR(n) __HOST_NV_GPR(__REG_##n) |
52 | #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + LONGBYTES) | 57 | #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + LONGBYTES) |
53 | #define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) & ~15) /* Align. */ | 58 | #define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) & ~15) /* Align. */ |
54 | #define HOST_STACK_LR (HOST_STACK_SIZE + LONGBYTES) /* In caller stack frame. */ | 59 | /* LR in caller stack frame. */ |
60 | #define HOST_STACK_LR (HOST_STACK_SIZE + PPC_LR_STKOFF) | ||
55 | 61 | ||
56 | #define NEED_EMU 0x00000001 /* emulation -- save nv regs */ | 62 | #define NEED_EMU 0x00000001 /* emulation -- save nv regs */ |
57 | #define NEED_DEAR 0x00000002 /* save faulting DEAR */ | 63 | #define NEED_DEAR 0x00000002 /* save faulting DEAR */ |
@@ -198,6 +204,122 @@ | |||
198 | b kvmppc_resume_host | 204 | b kvmppc_resume_host |
199 | .endm | 205 | .endm |
200 | 206 | ||
207 | #ifdef CONFIG_64BIT | ||
208 | /* Exception types */ | ||
209 | #define EX_GEN 1 | ||
210 | #define EX_GDBELL 2 | ||
211 | #define EX_DBG 3 | ||
212 | #define EX_MC 4 | ||
213 | #define EX_CRIT 5 | ||
214 | #define EX_TLB 6 | ||
215 | |||
216 | /* | ||
217 | * For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h | ||
218 | */ | ||
219 | .macro kvm_handler intno type scratch, paca_ex, ex_r10, ex_r11, srr0, srr1, flags | ||
220 | _GLOBAL(kvmppc_handler_\intno\()_\srr1) | ||
221 | mr r11, r4 | ||
222 | /* | ||
223 | * Get vcpu from Paca: paca->__current.thread->kvm_vcpu | ||
224 | */ | ||
225 | PPC_LL r4, PACACURRENT(r13) | ||
226 | PPC_LL r4, (THREAD + THREAD_KVM_VCPU)(r4) | ||
227 | stw r10, VCPU_CR(r4) | ||
228 | PPC_STL r11, VCPU_GPR(R4)(r4) | ||
229 | PPC_STL r5, VCPU_GPR(R5)(r4) | ||
230 | .if \type == EX_CRIT | ||
231 | PPC_LL r5, (\paca_ex + EX_R13)(r13) | ||
232 | .else | ||
233 | mfspr r5, \scratch | ||
234 | .endif | ||
235 | PPC_STL r6, VCPU_GPR(R6)(r4) | ||
236 | PPC_STL r8, VCPU_GPR(R8)(r4) | ||
237 | PPC_STL r9, VCPU_GPR(R9)(r4) | ||
238 | PPC_STL r5, VCPU_GPR(R13)(r4) | ||
239 | PPC_LL r6, (\paca_ex + \ex_r10)(r13) | ||
240 | PPC_LL r8, (\paca_ex + \ex_r11)(r13) | ||
241 | PPC_STL r3, VCPU_GPR(R3)(r4) | ||
242 | PPC_STL r7, VCPU_GPR(R7)(r4) | ||
243 | PPC_STL r12, VCPU_GPR(R12)(r4) | ||
244 | PPC_STL r6, VCPU_GPR(R10)(r4) | ||
245 | PPC_STL r8, VCPU_GPR(R11)(r4) | ||
246 | mfctr r5 | ||
247 | PPC_STL r5, VCPU_CTR(r4) | ||
248 | mfspr r5, \srr0 | ||
249 | mfspr r6, \srr1 | ||
250 | kvm_handler_common \intno, \srr0, \flags | ||
251 | .endm | ||
252 | |||
253 | #define EX_PARAMS(type) \ | ||
254 | EX_##type, \ | ||
255 | SPRN_SPRG_##type##_SCRATCH, \ | ||
256 | PACA_EX##type, \ | ||
257 | EX_R10, \ | ||
258 | EX_R11 | ||
259 | |||
260 | #define EX_PARAMS_TLB \ | ||
261 | EX_TLB, \ | ||
262 | SPRN_SPRG_GEN_SCRATCH, \ | ||
263 | PACA_EXTLB, \ | ||
264 | EX_TLB_R10, \ | ||
265 | EX_TLB_R11 | ||
266 | |||
267 | kvm_handler BOOKE_INTERRUPT_CRITICAL, EX_PARAMS(CRIT), \ | ||
268 | SPRN_CSRR0, SPRN_CSRR1, 0 | ||
269 | kvm_handler BOOKE_INTERRUPT_MACHINE_CHECK, EX_PARAMS(MC), \ | ||
270 | SPRN_MCSRR0, SPRN_MCSRR1, 0 | ||
271 | kvm_handler BOOKE_INTERRUPT_DATA_STORAGE, EX_PARAMS(GEN), \ | ||
272 | SPRN_SRR0, SPRN_SRR1,(NEED_EMU | NEED_DEAR | NEED_ESR) | ||
273 | kvm_handler BOOKE_INTERRUPT_INST_STORAGE, EX_PARAMS(GEN), \ | ||
274 | SPRN_SRR0, SPRN_SRR1, NEED_ESR | ||
275 | kvm_handler BOOKE_INTERRUPT_EXTERNAL, EX_PARAMS(GEN), \ | ||
276 | SPRN_SRR0, SPRN_SRR1, 0 | ||
277 | kvm_handler BOOKE_INTERRUPT_ALIGNMENT, EX_PARAMS(GEN), \ | ||
278 | SPRN_SRR0, SPRN_SRR1,(NEED_DEAR | NEED_ESR) | ||
279 | kvm_handler BOOKE_INTERRUPT_PROGRAM, EX_PARAMS(GEN), \ | ||
280 | SPRN_SRR0, SPRN_SRR1,NEED_ESR | ||
281 | kvm_handler BOOKE_INTERRUPT_FP_UNAVAIL, EX_PARAMS(GEN), \ | ||
282 | SPRN_SRR0, SPRN_SRR1, 0 | ||
283 | kvm_handler BOOKE_INTERRUPT_AP_UNAVAIL, EX_PARAMS(GEN), \ | ||
284 | SPRN_SRR0, SPRN_SRR1, 0 | ||
285 | kvm_handler BOOKE_INTERRUPT_DECREMENTER, EX_PARAMS(GEN), \ | ||
286 | SPRN_SRR0, SPRN_SRR1, 0 | ||
287 | kvm_handler BOOKE_INTERRUPT_FIT, EX_PARAMS(GEN), \ | ||
288 | SPRN_SRR0, SPRN_SRR1, 0 | ||
289 | kvm_handler BOOKE_INTERRUPT_WATCHDOG, EX_PARAMS(CRIT),\ | ||
290 | SPRN_CSRR0, SPRN_CSRR1, 0 | ||
291 | /* | ||
292 | * Only bolted TLB miss exception handlers are supported for now | ||
293 | */ | ||
294 | kvm_handler BOOKE_INTERRUPT_DTLB_MISS, EX_PARAMS_TLB, \ | ||
295 | SPRN_SRR0, SPRN_SRR1, (NEED_EMU | NEED_DEAR | NEED_ESR) | ||
296 | kvm_handler BOOKE_INTERRUPT_ITLB_MISS, EX_PARAMS_TLB, \ | ||
297 | SPRN_SRR0, SPRN_SRR1, 0 | ||
298 | kvm_handler BOOKE_INTERRUPT_SPE_UNAVAIL, EX_PARAMS(GEN), \ | ||
299 | SPRN_SRR0, SPRN_SRR1, 0 | ||
300 | kvm_handler BOOKE_INTERRUPT_SPE_FP_DATA, EX_PARAMS(GEN), \ | ||
301 | SPRN_SRR0, SPRN_SRR1, 0 | ||
302 | kvm_handler BOOKE_INTERRUPT_SPE_FP_ROUND, EX_PARAMS(GEN), \ | ||
303 | SPRN_SRR0, SPRN_SRR1, 0 | ||
304 | kvm_handler BOOKE_INTERRUPT_PERFORMANCE_MONITOR, EX_PARAMS(GEN), \ | ||
305 | SPRN_SRR0, SPRN_SRR1, 0 | ||
306 | kvm_handler BOOKE_INTERRUPT_DOORBELL, EX_PARAMS(GEN), \ | ||
307 | SPRN_SRR0, SPRN_SRR1, 0 | ||
308 | kvm_handler BOOKE_INTERRUPT_DOORBELL_CRITICAL, EX_PARAMS(CRIT), \ | ||
309 | SPRN_CSRR0, SPRN_CSRR1, 0 | ||
310 | kvm_handler BOOKE_INTERRUPT_HV_PRIV, EX_PARAMS(GEN), \ | ||
311 | SPRN_SRR0, SPRN_SRR1, NEED_EMU | ||
312 | kvm_handler BOOKE_INTERRUPT_HV_SYSCALL, EX_PARAMS(GEN), \ | ||
313 | SPRN_SRR0, SPRN_SRR1, 0 | ||
314 | kvm_handler BOOKE_INTERRUPT_GUEST_DBELL, EX_PARAMS(GDBELL), \ | ||
315 | SPRN_GSRR0, SPRN_GSRR1, 0 | ||
316 | kvm_handler BOOKE_INTERRUPT_GUEST_DBELL_CRIT, EX_PARAMS(CRIT), \ | ||
317 | SPRN_CSRR0, SPRN_CSRR1, 0 | ||
318 | kvm_handler BOOKE_INTERRUPT_DEBUG, EX_PARAMS(DBG), \ | ||
319 | SPRN_DSRR0, SPRN_DSRR1, 0 | ||
320 | kvm_handler BOOKE_INTERRUPT_DEBUG, EX_PARAMS(CRIT), \ | ||
321 | SPRN_CSRR0, SPRN_CSRR1, 0 | ||
322 | #else | ||
201 | /* | 323 | /* |
202 | * For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h | 324 | * For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h |
203 | */ | 325 | */ |
@@ -292,7 +414,7 @@ kvm_lvl_handler BOOKE_INTERRUPT_DEBUG, \ | |||
292 | SPRN_SPRG_RSCRATCH_CRIT, SPRN_CSRR0, SPRN_CSRR1, 0 | 414 | SPRN_SPRG_RSCRATCH_CRIT, SPRN_CSRR0, SPRN_CSRR1, 0 |
293 | kvm_lvl_handler BOOKE_INTERRUPT_DEBUG, \ | 415 | kvm_lvl_handler BOOKE_INTERRUPT_DEBUG, \ |
294 | SPRN_SPRG_RSCRATCH_DBG, SPRN_DSRR0, SPRN_DSRR1, 0 | 416 | SPRN_SPRG_RSCRATCH_DBG, SPRN_DSRR0, SPRN_DSRR1, 0 |
295 | 417 | #endif | |
296 | 418 | ||
297 | /* Registers: | 419 | /* Registers: |
298 | * SPRG_SCRATCH0: guest r10 | 420 | * SPRG_SCRATCH0: guest r10 |