1
2
3
4
5
6
7
8
9 #include <asm/ppc_asm.h>
10 #include <asm/kvm_asm.h>
11 #include <asm/reg.h>
12 #include <asm/mmu.h>
13 #include <asm/page.h>
14 #include <asm/asm-offsets.h>
15 #include <asm/asm-compat.h>
16
17 #ifdef CONFIG_PPC_BOOK3S_64
18 #include <asm/exception-64s.h>
19 #endif
20
21
22
23
24
25
26
27 #if defined(CONFIG_PPC_BOOK3S_64)
28
29 #ifdef PPC64_ELF_ABI_v2
30 #define FUNC(name) name
31 #else
32 #define FUNC(name) GLUE(.,name)
33 #endif
34
35 #elif defined(CONFIG_PPC_BOOK3S_32)
36
37 #define FUNC(name) name
38
39 #define RFI_TO_KERNEL RFI
40 #define RFI_TO_GUEST RFI
41
42 .macro INTERRUPT_TRAMPOLINE intno
43
44 .global kvmppc_trampoline_\intno
45 kvmppc_trampoline_\intno:
46
47 mtspr SPRN_SPRG_SCRATCH0, r13
48
49
50
51
52
53
54
55 mfspr r13, SPRN_SPRG_THREAD
56 lwz r13, THREAD_KVM_SVCPU(r13)
57
58 mtspr SPRN_SPRG_SCRATCH1, r12
59 mfcr r12
60 cmpwi r13, 0
61 bne 1f
62 2: mtcr r12
63 mfspr r12, SPRN_SPRG_SCRATCH1
64 mfspr r13, SPRN_SPRG_SCRATCH0
65 b kvmppc_resume_\intno
66
67 1: tophys(r13, r13)
68 stw r12, HSTATE_SCRATCH1(r13)
69 mfspr r12, SPRN_SPRG_SCRATCH1
70 stw r12, HSTATE_SCRATCH0(r13)
71 lbz r12, HSTATE_IN_GUEST(r13)
72 cmpwi r12, KVM_GUEST_MODE_NONE
73 bne ..kvmppc_handler_hasmagic_\intno
74
75 lwz r12, HSTATE_SCRATCH1(r13)
76 b 2b
77
78
79 ..kvmppc_handler_hasmagic_\intno:
80
81
82 cmpwi r12, KVM_GUEST_MODE_SKIP
83 beq kvmppc_handler_skip_ins
84
85
86 li r12, \intno
87
88
89 b kvmppc_handler_trampoline_exit
90
91 .endm
92
93 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_SYSTEM_RESET
94 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_MACHINE_CHECK
95 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_DATA_STORAGE
96 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_INST_STORAGE
97 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_EXTERNAL
98 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_ALIGNMENT
99 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_PROGRAM
100 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_FP_UNAVAIL
101 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_DECREMENTER
102 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_SYSCALL
103 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_TRACE
104 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_PERFMON
105 INTERRUPT_TRAMPOLINE BOOK3S_INTERRUPT_ALTIVEC
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 kvmppc_handler_skip_ins:
124
125
126 mfsrr0 r12
127 addi r12, r12, 4
128 mtsrr0 r12
129
130
131 lwz r12, HSTATE_SCRATCH1(r13)
132 mtcr r12
133 PPC_LL r12, HSTATE_SCRATCH0(r13)
134 GET_SCRATCH0(r13)
135
136
137 RFI_TO_KERNEL
138 #endif
139
140
141
142
143
144
145
146 _GLOBAL_TOC(kvmppc_entry_trampoline)
147 mfmsr r5
148 LOAD_REG_ADDR(r7, kvmppc_handler_trampoline_enter)
149 toreal(r7)
150
151 li r6, MSR_IR | MSR_DR
152 andc r6, r5, r6
153
154
155
156
157 ori r5, r5, MSR_EE
158 mtsrr0 r7
159 mtsrr1 r6
160 RFI_TO_KERNEL
161
162 #include "book3s_segment.S"