aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/book3s_64_slb.S
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-01-07 20:58:04 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2010-03-01 10:35:48 -0500
commitb4433a7cceed59714b0778e1ace624befdd15ded (patch)
tree745f0477d7368155cddc363fed6e8f3dc28f83cd /arch/powerpc/kvm/book3s_64_slb.S
parent7e57cba06074da84d7c24d8c3f44040d2d8c88ac (diff)
KVM: PPC: Implement 'skip instruction' mode
To fetch the last instruction we were interrupted on, we enable DR in early exit code, where we are still in a very transitional phase between guest and host state. Most of the time this seemed to work, but another CPU can easily flush our TLB and HTAB which makes us go in the Linux page fault handler which totally breaks because we still use the guest's SLB entries. To work around that, let's introduce a second KVM guest mode that defines that whenever we get a trap, we don't call the Linux handler or go into the KVM exit code, but just jump over the faulting instruction. That way a potentially bad lwz doesn't trigger any faults and we can later on interpret the invalid instruction we fetched as "fetch didn't work". Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm/book3s_64_slb.S')
-rw-r--r--arch/powerpc/kvm/book3s_64_slb.S16
1 files changed, 11 insertions, 5 deletions
diff --git a/arch/powerpc/kvm/book3s_64_slb.S b/arch/powerpc/kvm/book3s_64_slb.S
index 7188c11ed7d1..d07b88617b2c 100644
--- a/arch/powerpc/kvm/book3s_64_slb.S
+++ b/arch/powerpc/kvm/book3s_64_slb.S
@@ -212,10 +212,6 @@ kvmppc_handler_trampoline_exit:
212 mfdar r5 212 mfdar r5
213 mfdsisr r6 213 mfdsisr r6
214 214
215 /* Unset guest state */
216 li r9, 0
217 stb r9, PACA_KVM_IN_GUEST(r13)
218
219 /* 215 /*
220 * In order for us to easily get the last instruction, 216 * In order for us to easily get the last instruction,
221 * we got the #vmexit at, we exploit the fact that the 217 * we got the #vmexit at, we exploit the fact that the
@@ -233,18 +229,28 @@ kvmppc_handler_trampoline_exit:
233 229
234ld_last_inst: 230ld_last_inst:
235 /* Save off the guest instruction we're at */ 231 /* Save off the guest instruction we're at */
232
233 /* Set guest mode to 'jump over instruction' so if lwz faults
234 * we'll just continue at the next IP. */
235 li r9, KVM_GUEST_MODE_SKIP
236 stb r9, PACA_KVM_IN_GUEST(r13)
237
236 /* 1) enable paging for data */ 238 /* 1) enable paging for data */
237 mfmsr r9 239 mfmsr r9
238 ori r11, r9, MSR_DR /* Enable paging for data */ 240 ori r11, r9, MSR_DR /* Enable paging for data */
239 mtmsr r11 241 mtmsr r11
240 /* 2) fetch the instruction */ 242 /* 2) fetch the instruction */
241 /* XXX implement PACA_KVM_IN_GUEST=2 path to safely jump over this */ 243 li r0, KVM_INST_FETCH_FAILED /* In case lwz faults */
242 lwz r0, 0(r3) 244 lwz r0, 0(r3)
243 /* 3) disable paging again */ 245 /* 3) disable paging again */
244 mtmsr r9 246 mtmsr r9
245 247
246no_ld_last_inst: 248no_ld_last_inst:
247 249
250 /* Unset guest mode */
251 li r9, KVM_GUEST_MODE_NONE
252 stb r9, PACA_KVM_IN_GUEST(r13)
253
248 /* Restore bolted entries from the shadow and fix it along the way */ 254 /* Restore bolted entries from the shadow and fix it along the way */
249 255
250 /* We don't store anything in entry 0, so we don't need to take care of it */ 256 /* We don't store anything in entry 0, so we don't need to take care of it */