KVM: PPC: Use PACA backed shadow vcpu
[deliverable/linux.git] / arch / powerpc / kvm / book3s_64_rmhandlers.S
CommitLineData
c862125c
AG
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 *
15 * Copyright SUSE Linux Products GmbH 2009
16 *
17 * Authors: Alexander Graf <agraf@suse.de>
18 */
19
20#include <asm/ppc_asm.h>
21#include <asm/kvm_asm.h>
22#include <asm/reg.h>
23#include <asm/page.h>
24#include <asm/asm-offsets.h>
25#include <asm/exception-64s.h>
26
27/*****************************************************************************
28 * *
29 * Real Mode handlers that need to be in low physical memory *
30 * *
31 ****************************************************************************/
32
33
34.macro INTERRUPT_TRAMPOLINE intno
35
36.global kvmppc_trampoline_\intno
37kvmppc_trampoline_\intno:
38
39 mtspr SPRN_SPRG_SCRATCH0, r13 /* Save r13 */
40
41 /*
42 * First thing to do is to find out if we're coming
43 * from a KVM guest or a Linux process.
44 *
45 * To distinguish, we check a magic byte in the PACA
46 */
47 mfspr r13, SPRN_SPRG_PACA /* r13 = PACA */
7e57cba0 48 std r12, PACA_KVM_SCRATCH0(r13)
c862125c 49 mfcr r12
7e57cba0 50 stw r12, PACA_KVM_SCRATCH1(r13)
c862125c
AG
51 lbz r12, PACA_KVM_IN_GUEST(r13)
52 cmpwi r12, 0
53 bne ..kvmppc_handler_hasmagic_\intno
54 /* No KVM guest? Then jump back to the Linux handler! */
7e57cba0 55 lwz r12, PACA_KVM_SCRATCH1(r13)
c862125c 56 mtcr r12
7e57cba0 57 ld r12, PACA_KVM_SCRATCH0(r13)
c862125c
AG
58 mfspr r13, SPRN_SPRG_SCRATCH0 /* r13 = original r13 */
59 b kvmppc_resume_\intno /* Get back original handler */
60
61 /* Now we know we're handling a KVM guest */
62..kvmppc_handler_hasmagic_\intno:
c862125c
AG
63 /* Let's store which interrupt we're handling */
64 li r12, \intno
65
66 /* Jump into the SLB exit code that goes to the highmem handler */
67 b kvmppc_handler_trampoline_exit
68
69.endm
70
71INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_SYSTEM_RESET
72INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_MACHINE_CHECK
73INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_DATA_STORAGE
74INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_DATA_SEGMENT
75INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_INST_STORAGE
76INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_INST_SEGMENT
77INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_EXTERNAL
78INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_ALIGNMENT
79INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_PROGRAM
80INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_FP_UNAVAIL
81INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_DECREMENTER
82INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_SYSCALL
83INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_TRACE
84INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_PERFMON
85INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_ALTIVEC
86INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_VSX
87
88/*
89 * This trampoline brings us back to a real mode handler
90 *
91 * Input Registers:
92 *
7e57cba0
AG
93 * R5 = SRR0
94 * R6 = SRR1
c862125c
AG
95 * LR = real-mode IP
96 *
97 */
98.global kvmppc_handler_lowmem_trampoline
99kvmppc_handler_lowmem_trampoline:
100
7e57cba0
AG
101 mtsrr0 r5
102 mtsrr1 r6
c862125c
AG
103 blr
104kvmppc_handler_lowmem_trampoline_end:
105
106.global kvmppc_trampoline_lowmem
107kvmppc_trampoline_lowmem:
108 .long kvmppc_handler_lowmem_trampoline - _stext
109
110.global kvmppc_trampoline_enter
111kvmppc_trampoline_enter:
112 .long kvmppc_handler_trampoline_enter - _stext
113
114#include "book3s_64_slb.S"
115
This page took 0.048503 seconds and 5 git commands to generate.