diff options
author | Alexander Graf <agraf@suse.de> | 2014-06-20 08:17:30 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-07-28 10:33:54 -0400 |
commit | c45c551403f0a7b152e56c53735b954faa36c54c (patch) | |
tree | 294f61feb278b3d6574b1d9c979a78b02b9b733c /arch/powerpc | |
parent | 9897e88a79e1c6a3c5bbe74eccd64c4ba32a3b19 (diff) |
KVM: PPC: Use kvm_read_guest in kvmppc_ld
We have a nice and handy helper to read from guest physical address space,
so we should make use of it in kvmppc_ld as we already do for its counterpart
in kvmppc_st.
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 3d59730a7802..be40886e8f0a 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -309,19 +309,6 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) | |||
309 | } | 309 | } |
310 | EXPORT_SYMBOL_GPL(kvmppc_emulate_mmio); | 310 | EXPORT_SYMBOL_GPL(kvmppc_emulate_mmio); |
311 | 311 | ||
312 | static hva_t kvmppc_pte_to_hva(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte) | ||
313 | { | ||
314 | hva_t hpage; | ||
315 | |||
316 | hpage = gfn_to_hva(vcpu->kvm, pte->raddr >> PAGE_SHIFT); | ||
317 | if (kvm_is_error_hva(hpage)) | ||
318 | goto err; | ||
319 | |||
320 | return hpage | (pte->raddr & ~PAGE_MASK); | ||
321 | err: | ||
322 | return KVM_HVA_ERR_BAD; | ||
323 | } | ||
324 | |||
325 | int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, | 312 | int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, |
326 | bool data) | 313 | bool data) |
327 | { | 314 | { |
@@ -351,7 +338,6 @@ int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, | |||
351 | bool data) | 338 | bool data) |
352 | { | 339 | { |
353 | struct kvmppc_pte pte; | 340 | struct kvmppc_pte pte; |
354 | hva_t hva = *eaddr; | ||
355 | int rc; | 341 | int rc; |
356 | 342 | ||
357 | vcpu->stat.ld++; | 343 | vcpu->stat.ld++; |
@@ -369,19 +355,10 @@ int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, | |||
369 | if (!data && !pte.may_execute) | 355 | if (!data && !pte.may_execute) |
370 | return -ENOEXEC; | 356 | return -ENOEXEC; |
371 | 357 | ||
372 | hva = kvmppc_pte_to_hva(vcpu, &pte); | 358 | if (kvm_read_guest(vcpu->kvm, pte.raddr, ptr, size)) |
373 | if (kvm_is_error_hva(hva)) | 359 | return EMULATE_DO_MMIO; |
374 | goto mmio; | ||
375 | |||
376 | if (copy_from_user(ptr, (void __user *)hva, size)) { | ||
377 | printk(KERN_INFO "kvmppc_ld at 0x%lx failed\n", hva); | ||
378 | goto mmio; | ||
379 | } | ||
380 | 360 | ||
381 | return EMULATE_DONE; | 361 | return EMULATE_DONE; |
382 | |||
383 | mmio: | ||
384 | return EMULATE_DO_MMIO; | ||
385 | } | 362 | } |
386 | EXPORT_SYMBOL_GPL(kvmppc_ld); | 363 | EXPORT_SYMBOL_GPL(kvmppc_ld); |
387 | 364 | ||