1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <asm/ppc_asm.h>
24#include <asm/kvm_asm.h>
25#include <asm/reg.h>
26#include <asm/page.h>
27#include <asm/asm-offsets.h>
28#include <asm/exception-64s.h>
29#include <asm/ppc-opcode.h>
30
31
32
33
34
35
36
37
38
39
40_GLOBAL(__kvmppc_vcore_entry)
41
42
43 mflr r0
44 std r0,PPC_LR_STKOFF(r1)
45
46
47 stdu r1, -SWITCH_FRAME_SIZE(r1)
48
49
50 SAVE_NVGPRS(r1)
51 mfcr r3
52 std r3, _CCR(r1)
53
54
55BEGIN_FTR_SECTION
56 mfspr r3, SPRN_DSCR
57 std r3, HSTATE_DSCR(r13)
58END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
59
60
61 mfspr r3, SPRN_DABR
62 std r3, HSTATE_DABR(r13)
63
64
65 mfmsr r10
66 std r10, HSTATE_HOST_MSR(r13)
67 rldicl r10,r10,48,1
68 rotldi r10,r10,16
69 mtmsrd r10,1
70
71
72
73 li r3, 1
74 sldi r3, r3, 31
75 mfspr r7, SPRN_MMCR0
76 mtspr SPRN_MMCR0, r3
77 mfspr r6, SPRN_MMCRA
78BEGIN_FTR_SECTION
79
80 li r5, 0
81 mtspr SPRN_MMCRA, r5
82END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
83 isync
84 ld r3, PACALPPACAPTR(r13)
85 lbz r5, LPPACA_PMCINUSE(r3)
86 cmpwi r5, 0
87 beq 31f
88 mfspr r5, SPRN_MMCR1
89 std r7, HSTATE_MMCR(r13)
90 std r5, HSTATE_MMCR + 8(r13)
91 std r6, HSTATE_MMCR + 16(r13)
92 mfspr r3, SPRN_PMC1
93 mfspr r5, SPRN_PMC2
94 mfspr r6, SPRN_PMC3
95 mfspr r7, SPRN_PMC4
96 mfspr r8, SPRN_PMC5
97 mfspr r9, SPRN_PMC6
98BEGIN_FTR_SECTION
99 mfspr r10, SPRN_PMC7
100 mfspr r11, SPRN_PMC8
101END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
102 stw r3, HSTATE_PMC(r13)
103 stw r5, HSTATE_PMC + 4(r13)
104 stw r6, HSTATE_PMC + 8(r13)
105 stw r7, HSTATE_PMC + 12(r13)
106 stw r8, HSTATE_PMC + 16(r13)
107 stw r9, HSTATE_PMC + 20(r13)
108BEGIN_FTR_SECTION
109 stw r10, HSTATE_PMC + 24(r13)
110 stw r11, HSTATE_PMC + 28(r13)
111END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
11231:
113
114
115
116
117
118 mfspr r8,SPRN_DEC
119 mftb r7
120 mtspr SPRN_HDEC,r8
121 extsw r8,r8
122 add r8,r8,r7
123 std r8,HSTATE_DECEXP(r13)
124
125#ifdef CONFIG_SMP
126
127
128
129
130
131
132
133
134
135
136BEGIN_FTR_SECTION
137 ld r0, VCPU_PENDING_EXC(r4)
138 li r7, (1 << BOOK3S_IRQPRIO_EXTERNAL)
139 oris r7, r7, (1 << BOOK3S_IRQPRIO_EXTERNAL_LEVEL)@h
140 and. r0, r0, r7
141 beq 32f
142 mr r31, r4
143 lhz r3, PACAPACAINDEX(r13)
144 bl smp_send_reschedule
145 nop
146 mr r4, r31
14732:
148END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
149#endif
150
151
152 bl .kvmppc_hv_entry_trampoline
153 nop
154
155
156
157
158
159
160
161.global kvmppc_handler_highmem
162kvmppc_handler_highmem:
163
164
165
166
167
168
169
170
171
172
173
174 REST_NVGPRS(r1)
175 ld r4, _CCR(r1)
176 mtcr r4
177
178 addi r1, r1, SWITCH_FRAME_SIZE
179 ld r0, PPC_LR_STKOFF(r1)
180 mtlr r0
181 blr
182