1
2
3
4
5
6
7
8
9
10
11
12 #include <asm/ppc_asm.h>
13 #include <asm/kvm_asm.h>
14 #include <asm/reg.h>
15 #include <asm/page.h>
16 #include <asm/asm-offsets.h>
17 #include <asm/exception-64s.h>
18 #include <asm/ppc-opcode.h>
19 #include <asm/asm-compat.h>
20 #include <asm/feature-fixups.h>
21
22
23
24
25
26
27
28
29
30
31 _GLOBAL(__kvmppc_vcore_entry)
32
33
34 mflr r0
35 std r0,PPC_LR_STKOFF(r1)
36
37
38 stdu r1, -SWITCH_FRAME_SIZE(r1)
39
40
41 SAVE_NVGPRS(r1)
42 mfcr r3
43 std r3, _CCR(r1)
44
45
46 mfspr r3, SPRN_DSCR
47 std r3, HSTATE_DSCR(r13)
48
49 BEGIN_FTR_SECTION
50
51 mfspr r3, SPRN_DABR
52 std r3, HSTATE_DABR(r13)
53 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
54
55
56 bl kvmhv_save_host_pmu
57
58
59
60
61
62 BEGIN_FTR_SECTION
63 ld r5, HSTATE_KVM_VCORE(r13)
64 ld r6, VCORE_KVM(r5)
65 ld r9, KVM_HOST_LPCR(r6)
66 andis. r9, r9, LPCR_LD@h
67 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
68 mfspr r8,SPRN_DEC
69 mftb r7
70 BEGIN_FTR_SECTION
71
72 bne 32f
73 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
74 extsw r8,r8
75 32: mtspr SPRN_HDEC,r8
76 add r8,r8,r7
77 std r8,HSTATE_DECEXP(r13)
78
79
80 bl kvmppc_hv_entry_trampoline
81 nop
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 REST_NVGPRS(r1)
101 ld r4, _CCR(r1)
102 mtcr r4
103
104 addi r1, r1, SWITCH_FRAME_SIZE
105 ld r0, PPC_LR_STKOFF(r1)
106 mtlr r0
107 blr
108
109 _GLOBAL(kvmhv_save_host_pmu)
110 BEGIN_FTR_SECTION
111
112 li r3, -1
113 clrrdi r3, r3, 10
114 mfspr r8, SPRN_MMCR2
115 mtspr SPRN_MMCR2, r3
116 isync
117 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
118 li r3, 1
119 sldi r3, r3, 31
120 mfspr r7, SPRN_MMCR0
121 mtspr SPRN_MMCR0, r3
122 mfspr r6, SPRN_MMCRA
123
124 li r5, 0
125 mtspr SPRN_MMCRA, r5
126 isync
127 lbz r5, PACA_PMCINUSE(r13)
128 cmpwi r5, 0
129 beq 31f
130 mfspr r5, SPRN_MMCR1
131 mfspr r9, SPRN_SIAR
132 mfspr r10, SPRN_SDAR
133 std r7, HSTATE_MMCR0(r13)
134 std r5, HSTATE_MMCR1(r13)
135 std r6, HSTATE_MMCRA(r13)
136 std r9, HSTATE_SIAR(r13)
137 std r10, HSTATE_SDAR(r13)
138 BEGIN_FTR_SECTION
139 mfspr r9, SPRN_SIER
140 std r8, HSTATE_MMCR2(r13)
141 std r9, HSTATE_SIER(r13)
142 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
143 mfspr r3, SPRN_PMC1
144 mfspr r5, SPRN_PMC2
145 mfspr r6, SPRN_PMC3
146 mfspr r7, SPRN_PMC4
147 mfspr r8, SPRN_PMC5
148 mfspr r9, SPRN_PMC6
149 stw r3, HSTATE_PMC1(r13)
150 stw r5, HSTATE_PMC2(r13)
151 stw r6, HSTATE_PMC3(r13)
152 stw r7, HSTATE_PMC4(r13)
153 stw r8, HSTATE_PMC5(r13)
154 stw r9, HSTATE_PMC6(r13)
155 31: blr