aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kvm
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2016-06-09 09:19:21 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2016-06-14 05:02:48 -0400
commit35fec26242bd3ff5a770789185852d27b44ffaec (patch)
tree2770f9dd675283b0837cdaea107662b9a0ed5917 /arch/mips/kvm
parent3b08aec549a0314b8c3788bdc2a21096d53225e1 (diff)
MIPS: KVM: Use va in kvm_get_inst()
Like other functions, make use of a local unsigned long va, for the virtual address of the PC. This reduces the amount of verbose casting of the opc pointer to an unsigned long. 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 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/mips/kvm')
-rw-r--r--arch/mips/kvm/mmu.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
index ad3125fa9c61..208f70409ccb 100644
--- a/arch/mips/kvm/mmu.c
+++ b/arch/mips/kvm/mmu.c
@@ -327,17 +327,18 @@ u32 kvm_get_inst(u32 *opc, struct kvm_vcpu *vcpu)
327{ 327{
328 struct mips_coproc *cop0 = vcpu->arch.cop0; 328 struct mips_coproc *cop0 = vcpu->arch.cop0;
329 unsigned long paddr, flags, vpn2, asid; 329 unsigned long paddr, flags, vpn2, asid;
330 unsigned long va = (unsigned long)opc;
330 u32 inst; 331 u32 inst;
331 int index; 332 int index;
332 333
333 if (KVM_GUEST_KSEGX((unsigned long) opc) < KVM_GUEST_KSEG0 || 334 if (KVM_GUEST_KSEGX(va) < KVM_GUEST_KSEG0 ||
334 KVM_GUEST_KSEGX((unsigned long) opc) == KVM_GUEST_KSEG23) { 335 KVM_GUEST_KSEGX(va) == KVM_GUEST_KSEG23) {
335 local_irq_save(flags); 336 local_irq_save(flags);
336 index = kvm_mips_host_tlb_lookup(vcpu, (unsigned long) opc); 337 index = kvm_mips_host_tlb_lookup(vcpu, va);
337 if (index >= 0) { 338 if (index >= 0) {
338 inst = *(opc); 339 inst = *(opc);
339 } else { 340 } else {
340 vpn2 = (unsigned long) opc & VPN2_MASK; 341 vpn2 = va & VPN2_MASK;
341 asid = kvm_read_c0_guest_entryhi(cop0) & 342 asid = kvm_read_c0_guest_entryhi(cop0) &
342 KVM_ENTRYHI_ASID; 343 KVM_ENTRYHI_ASID;
343 index = kvm_mips_guest_tlb_lookup(vcpu, vpn2 | asid); 344 index = kvm_mips_guest_tlb_lookup(vcpu, vpn2 | asid);
@@ -354,10 +355,8 @@ u32 kvm_get_inst(u32 *opc, struct kvm_vcpu *vcpu)
354 inst = *(opc); 355 inst = *(opc);
355 } 356 }
356 local_irq_restore(flags); 357 local_irq_restore(flags);
357 } else if (KVM_GUEST_KSEGX(opc) == KVM_GUEST_KSEG0) { 358 } else if (KVM_GUEST_KSEGX(va) == KVM_GUEST_KSEG0) {
358 paddr = 359 paddr = kvm_mips_translate_guest_kseg0_to_hpa(vcpu, va);
359 kvm_mips_translate_guest_kseg0_to_hpa(vcpu,
360 (unsigned long) opc);
361 inst = *(u32 *) CKSEG0ADDR(paddr); 360 inst = *(u32 *) CKSEG0ADDR(paddr);
362 } else { 361 } else {
363 kvm_err("%s: illegal address: %p\n", __func__, opc); 362 kvm_err("%s: illegal address: %p\n", __func__, opc);