diff options
author | James Hogan <james.hogan@imgtec.com> | 2016-11-28 18:15:53 -0500 |
---|---|---|
committer | James Hogan <james.hogan@imgtec.com> | 2017-02-03 10:21:13 -0500 |
commit | 5207ce144a25aef89dd12b8fc3ccaa53aba4f2bd (patch) | |
tree | 34a878c2607d1681ea2e4406f658dfc7f2eff7bc | |
parent | 4b21e8abf959ca66c27f0656bf294fe69d3f2254 (diff) |
KVM: MIPS/MMU: Use lockless GVA helpers for get_inst()
Use the lockless GVA helpers to implement the reading of guest
instructions for emulation. This will allow it to handle asynchronous
TLB flushes when they are implemented.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
-rw-r--r-- | arch/mips/kvm/mmu.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c index 32c317de6c0a..b3da473e1569 100644 --- a/arch/mips/kvm/mmu.c +++ b/arch/mips/kvm/mmu.c | |||
@@ -787,11 +787,26 @@ int kvm_get_inst(u32 *opc, struct kvm_vcpu *vcpu, u32 *out) | |||
787 | { | 787 | { |
788 | int err; | 788 | int err; |
789 | 789 | ||
790 | retry: | ||
791 | kvm_trap_emul_gva_lockless_begin(vcpu); | ||
790 | err = get_user(*out, opc); | 792 | err = get_user(*out, opc); |
793 | kvm_trap_emul_gva_lockless_end(vcpu); | ||
794 | |||
791 | if (unlikely(err)) { | 795 | if (unlikely(err)) { |
792 | kvm_err("%s: illegal address: %p\n", __func__, opc); | 796 | /* |
793 | return -EFAULT; | 797 | * Try to handle the fault, maybe we just raced with a GVA |
794 | } | 798 | * invalidation. |
799 | */ | ||
800 | err = kvm_trap_emul_gva_fault(vcpu, (unsigned long)opc, | ||
801 | false); | ||
802 | if (unlikely(err)) { | ||
803 | kvm_err("%s: illegal address: %p\n", | ||
804 | __func__, opc); | ||
805 | return -EFAULT; | ||
806 | } | ||
795 | 807 | ||
808 | /* Hopefully it'll work now */ | ||
809 | goto retry; | ||
810 | } | ||
796 | return 0; | 811 | return 0; |
797 | } | 812 | } |