aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/kvm_emul.S
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2011-11-08 19:23:28 -0500
committerAvi Kivity <avi@redhat.com>2012-03-05 07:52:26 -0500
commit940b45ec18cf00046b8b28299d97066a2c43d559 (patch)
treea3a768ff3b6fcda9cbed00d93dac1bbf2b95f20c /arch/powerpc/kernel/kvm_emul.S
parent29ac26efbdc651303643025c83009ce5766c1676 (diff)
KVM: PPC: booke: Paravirtualize wrtee
Also fix wrteei 1 paravirt to check for a pending interrupt. Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kernel/kvm_emul.S')
-rw-r--r--arch/powerpc/kernel/kvm_emul.S96
1 files changed, 74 insertions, 22 deletions
diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index 3d64c5704fd5..801058dd74db 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -13,6 +13,7 @@
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 * 14 *
15 * Copyright SUSE Linux Products GmbH 2010 15 * Copyright SUSE Linux Products GmbH 2010
16 * Copyright 2010-2011 Freescale Semiconductor, Inc.
16 * 17 *
17 * Authors: Alexander Graf <agraf@suse.de> 18 * Authors: Alexander Graf <agraf@suse.de>
18 */ 19 */
@@ -208,24 +209,80 @@ kvm_emulate_mtmsr_orig_ins_offs:
208kvm_emulate_mtmsr_len: 209kvm_emulate_mtmsr_len:
209 .long (kvm_emulate_mtmsr_end - kvm_emulate_mtmsr) / 4 210 .long (kvm_emulate_mtmsr_end - kvm_emulate_mtmsr) / 4
210 211
212/* also used for wrteei 1 */
213.global kvm_emulate_wrtee
214kvm_emulate_wrtee:
211 215
216 SCRATCH_SAVE
217
218 /* Fetch old MSR in r31 */
219 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
212 220
213.global kvm_emulate_wrteei 221 /* Insert new MSR[EE] */
214kvm_emulate_wrteei: 222kvm_emulate_wrtee_reg:
223 ori r30, r0, 0
224 rlwimi r31, r30, 0, MSR_EE
225
226 /*
227 * If MSR[EE] is now set, check for a pending interrupt.
228 * We could skip this if MSR[EE] was already on, but that
229 * should be rare, so don't bother.
230 */
231 andi. r30, r30, MSR_EE
215 232
233 /* Put MSR into magic page because we don't call wrtee */
234 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
235
236 beq no_wrtee
237
238 /* Check if we have to fetch an interrupt */
239 lwz r30, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0)
240 cmpwi r30, 0
241 bne do_wrtee
242
243no_wrtee:
244 SCRATCH_RESTORE
245
246 /* Go back to caller */
247kvm_emulate_wrtee_branch:
248 b .
249
250do_wrtee:
251 SCRATCH_RESTORE
252
253 /* Just fire off the wrtee if it's critical */
254kvm_emulate_wrtee_orig_ins:
255 wrtee r0
256
257 b kvm_emulate_wrtee_branch
258
259kvm_emulate_wrtee_end:
260
261.global kvm_emulate_wrtee_branch_offs
262kvm_emulate_wrtee_branch_offs:
263 .long (kvm_emulate_wrtee_branch - kvm_emulate_wrtee) / 4
264
265.global kvm_emulate_wrtee_reg_offs
266kvm_emulate_wrtee_reg_offs:
267 .long (kvm_emulate_wrtee_reg - kvm_emulate_wrtee) / 4
268
269.global kvm_emulate_wrtee_orig_ins_offs
270kvm_emulate_wrtee_orig_ins_offs:
271 .long (kvm_emulate_wrtee_orig_ins - kvm_emulate_wrtee) / 4
272
273.global kvm_emulate_wrtee_len
274kvm_emulate_wrtee_len:
275 .long (kvm_emulate_wrtee_end - kvm_emulate_wrtee) / 4
276
277.global kvm_emulate_wrteei_0
278kvm_emulate_wrteei_0:
216 SCRATCH_SAVE 279 SCRATCH_SAVE
217 280
218 /* Fetch old MSR in r31 */ 281 /* Fetch old MSR in r31 */
219 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0) 282 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
220 283
221 /* Remove MSR_EE from old MSR */ 284 /* Remove MSR_EE from old MSR */
222 li r30, 0 285 rlwinm r31, r31, 0, ~MSR_EE
223 ori r30, r30, MSR_EE
224 andc r31, r31, r30
225
226 /* OR new MSR_EE onto the old MSR */
227kvm_emulate_wrteei_ee:
228 ori r31, r31, 0
229 286
230 /* Write new MSR value back */ 287 /* Write new MSR value back */
231 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0) 288 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
@@ -233,22 +290,17 @@ kvm_emulate_wrteei_ee:
233 SCRATCH_RESTORE 290 SCRATCH_RESTORE
234 291
235 /* Go back to caller */ 292 /* Go back to caller */
236kvm_emulate_wrteei_branch: 293kvm_emulate_wrteei_0_branch:
237 b . 294 b .
238kvm_emulate_wrteei_end: 295kvm_emulate_wrteei_0_end:
239
240.global kvm_emulate_wrteei_branch_offs
241kvm_emulate_wrteei_branch_offs:
242 .long (kvm_emulate_wrteei_branch - kvm_emulate_wrteei) / 4
243
244.global kvm_emulate_wrteei_ee_offs
245kvm_emulate_wrteei_ee_offs:
246 .long (kvm_emulate_wrteei_ee - kvm_emulate_wrteei) / 4
247 296
248.global kvm_emulate_wrteei_len 297.global kvm_emulate_wrteei_0_branch_offs
249kvm_emulate_wrteei_len: 298kvm_emulate_wrteei_0_branch_offs:
250 .long (kvm_emulate_wrteei_end - kvm_emulate_wrteei) / 4 299 .long (kvm_emulate_wrteei_0_branch - kvm_emulate_wrteei_0) / 4
251 300
301.global kvm_emulate_wrteei_0_len
302kvm_emulate_wrteei_0_len:
303 .long (kvm_emulate_wrteei_0_end - kvm_emulate_wrteei_0) / 4
252 304
253.global kvm_emulate_mtsrin 305.global kvm_emulate_mtsrin
254kvm_emulate_mtsrin: 306kvm_emulate_mtsrin: