• Home
  • Raw
  • Download

Lines Matching refs:vcpu

41 static int kvm_compute_return_epc(struct kvm_vcpu *vcpu, unsigned long instpc,  in kvm_compute_return_epc()  argument
46 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_compute_return_epc()
57 err = kvm_get_badinstrp((u32 *)epc, vcpu, &insn.word); in kvm_compute_return_epc()
244 enum emulation_result update_pc(struct kvm_vcpu *vcpu, u32 cause) in update_pc() argument
249 err = kvm_compute_return_epc(vcpu, vcpu->arch.pc, in update_pc()
250 &vcpu->arch.pc); in update_pc()
254 vcpu->arch.pc += 4; in update_pc()
257 kvm_debug("update_pc(): New PC: %#lx\n", vcpu->arch.pc); in update_pc()
273 int kvm_get_badinstr(u32 *opc, struct kvm_vcpu *vcpu, u32 *out) in kvm_get_badinstr() argument
276 *out = vcpu->arch.host_cp0_badinstr; in kvm_get_badinstr()
279 return kvm_get_inst(opc, vcpu, out); in kvm_get_badinstr()
294 int kvm_get_badinstrp(u32 *opc, struct kvm_vcpu *vcpu, u32 *out) in kvm_get_badinstrp() argument
297 *out = vcpu->arch.host_cp0_badinstrp; in kvm_get_badinstrp()
300 return kvm_get_inst(opc, vcpu, out); in kvm_get_badinstrp()
312 int kvm_mips_count_disabled(struct kvm_vcpu *vcpu) in kvm_mips_count_disabled() argument
314 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_count_disabled()
316 return (vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC) || in kvm_mips_count_disabled()
327 static u32 kvm_mips_ktime_to_count(struct kvm_vcpu *vcpu, ktime_t now) in kvm_mips_ktime_to_count() argument
333 delta = now_ns + vcpu->arch.count_dyn_bias; in kvm_mips_ktime_to_count()
335 if (delta >= vcpu->arch.count_period) { in kvm_mips_ktime_to_count()
337 periods = div64_s64(now_ns, vcpu->arch.count_period); in kvm_mips_ktime_to_count()
338 vcpu->arch.count_dyn_bias = -periods * vcpu->arch.count_period; in kvm_mips_ktime_to_count()
340 delta = now_ns + vcpu->arch.count_dyn_bias; in kvm_mips_ktime_to_count()
353 return div_u64(delta * vcpu->arch.count_hz, NSEC_PER_SEC); in kvm_mips_ktime_to_count()
366 static inline ktime_t kvm_mips_count_time(struct kvm_vcpu *vcpu) in kvm_mips_count_time() argument
368 if (unlikely(vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC)) in kvm_mips_count_time()
369 return vcpu->arch.count_resume; in kvm_mips_count_time()
384 static u32 kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now) in kvm_mips_read_count_running() argument
386 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_read_count_running()
392 count = vcpu->arch.count_bias + kvm_mips_ktime_to_count(vcpu, now); in kvm_mips_read_count_running()
408 expires = hrtimer_get_expires(&vcpu->arch.comparecount_timer); in kvm_mips_read_count_running()
409 threshold = ktime_add_ns(now, vcpu->arch.count_period / 4); in kvm_mips_read_count_running()
415 running = hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_mips_read_count_running()
418 kvm_mips_callbacks->queue_timer_int(vcpu); in kvm_mips_read_count_running()
426 vcpu->arch.count_period); in kvm_mips_read_count_running()
427 hrtimer_start(&vcpu->arch.comparecount_timer, expires, in kvm_mips_read_count_running()
444 u32 kvm_mips_read_count(struct kvm_vcpu *vcpu) in kvm_mips_read_count() argument
446 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_read_count()
449 if (kvm_mips_count_disabled(vcpu)) in kvm_mips_read_count()
452 return kvm_mips_read_count_running(vcpu, ktime_get()); in kvm_mips_read_count()
471 ktime_t kvm_mips_freeze_hrtimer(struct kvm_vcpu *vcpu, u32 *count) in kvm_mips_freeze_hrtimer() argument
476 hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_mips_freeze_hrtimer()
480 *count = kvm_mips_read_count_running(vcpu, now); in kvm_mips_freeze_hrtimer()
501 static void kvm_mips_resume_hrtimer(struct kvm_vcpu *vcpu, in kvm_mips_resume_hrtimer() argument
504 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_resume_hrtimer()
512 delta = div_u64(delta * NSEC_PER_SEC, vcpu->arch.count_hz); in kvm_mips_resume_hrtimer()
516 hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_mips_resume_hrtimer()
517 hrtimer_start(&vcpu->arch.comparecount_timer, expire, HRTIMER_MODE_ABS); in kvm_mips_resume_hrtimer()
542 int kvm_mips_restore_hrtimer(struct kvm_vcpu *vcpu, ktime_t before, in kvm_mips_restore_hrtimer() argument
551 before_count = vcpu->arch.count_bias + in kvm_mips_restore_hrtimer()
552 kvm_mips_ktime_to_count(vcpu, before); in kvm_mips_restore_hrtimer()
564 vcpu->arch.count_bias += drift; in kvm_mips_restore_hrtimer()
571 now_count = vcpu->arch.count_bias + kvm_mips_ktime_to_count(vcpu, now); in kvm_mips_restore_hrtimer()
580 vcpu->arch.count_bias += drift; in kvm_mips_restore_hrtimer()
587 delta = div_u64(delta * NSEC_PER_SEC, vcpu->arch.count_hz); in kvm_mips_restore_hrtimer()
592 kvm_mips_resume_hrtimer(vcpu, count_time, count); in kvm_mips_restore_hrtimer()
603 void kvm_mips_write_count(struct kvm_vcpu *vcpu, u32 count) in kvm_mips_write_count() argument
605 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_write_count()
609 now = kvm_mips_count_time(vcpu); in kvm_mips_write_count()
610 vcpu->arch.count_bias = count - kvm_mips_ktime_to_count(vcpu, now); in kvm_mips_write_count()
612 if (kvm_mips_count_disabled(vcpu)) in kvm_mips_write_count()
617 kvm_mips_resume_hrtimer(vcpu, now, count); in kvm_mips_write_count()
628 void kvm_mips_init_count(struct kvm_vcpu *vcpu, unsigned long count_hz) in kvm_mips_init_count() argument
630 vcpu->arch.count_hz = count_hz; in kvm_mips_init_count()
631 vcpu->arch.count_period = div_u64((u64)NSEC_PER_SEC << 32, count_hz); in kvm_mips_init_count()
632 vcpu->arch.count_dyn_bias = 0; in kvm_mips_init_count()
635 kvm_mips_write_count(vcpu, 0); in kvm_mips_init_count()
649 int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz) in kvm_mips_set_count_hz() argument
651 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_set_count_hz()
660 if (vcpu->arch.count_hz == count_hz) in kvm_mips_set_count_hz()
664 dc = kvm_mips_count_disabled(vcpu); in kvm_mips_set_count_hz()
666 now = kvm_mips_count_time(vcpu); in kvm_mips_set_count_hz()
669 now = kvm_mips_freeze_hrtimer(vcpu, &count); in kvm_mips_set_count_hz()
673 vcpu->arch.count_hz = count_hz; in kvm_mips_set_count_hz()
674 vcpu->arch.count_period = div_u64((u64)NSEC_PER_SEC << 32, count_hz); in kvm_mips_set_count_hz()
675 vcpu->arch.count_dyn_bias = 0; in kvm_mips_set_count_hz()
678 vcpu->arch.count_bias = count - kvm_mips_ktime_to_count(vcpu, now); in kvm_mips_set_count_hz()
682 kvm_mips_resume_hrtimer(vcpu, now, count); in kvm_mips_set_count_hz()
696 void kvm_mips_write_compare(struct kvm_vcpu *vcpu, u32 compare, bool ack) in kvm_mips_write_compare() argument
698 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_write_compare()
710 kvm_mips_callbacks->dequeue_timer_int(vcpu); in kvm_mips_write_compare()
731 dc = kvm_mips_count_disabled(vcpu); in kvm_mips_write_compare()
733 now = kvm_mips_freeze_hrtimer(vcpu, &count); in kvm_mips_write_compare()
736 kvm_mips_callbacks->dequeue_timer_int(vcpu); in kvm_mips_write_compare()
758 kvm_mips_resume_hrtimer(vcpu, now, count); in kvm_mips_write_compare()
781 static ktime_t kvm_mips_count_disable(struct kvm_vcpu *vcpu) in kvm_mips_count_disable() argument
783 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_count_disable()
788 hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_mips_count_disable()
792 count = kvm_mips_read_count_running(vcpu, now); in kvm_mips_count_disable()
808 void kvm_mips_count_disable_cause(struct kvm_vcpu *vcpu) in kvm_mips_count_disable_cause() argument
810 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_count_disable_cause()
813 if (!(vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC)) in kvm_mips_count_disable_cause()
814 kvm_mips_count_disable(vcpu); in kvm_mips_count_disable_cause()
828 void kvm_mips_count_enable_cause(struct kvm_vcpu *vcpu) in kvm_mips_count_enable_cause() argument
830 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_count_enable_cause()
841 kvm_mips_write_count(vcpu, count); in kvm_mips_count_enable_cause()
854 int kvm_mips_set_count_ctl(struct kvm_vcpu *vcpu, s64 count_ctl) in kvm_mips_set_count_ctl() argument
856 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_set_count_ctl()
857 s64 changed = count_ctl ^ vcpu->arch.count_ctl; in kvm_mips_set_count_ctl()
867 vcpu->arch.count_ctl = count_ctl; in kvm_mips_set_count_ctl()
875 vcpu->arch.count_resume = ktime_get(); in kvm_mips_set_count_ctl()
878 vcpu->arch.count_resume = kvm_mips_count_disable(vcpu); in kvm_mips_set_count_ctl()
888 vcpu->arch.count_hz); in kvm_mips_set_count_ctl()
889 expire = ktime_add_ns(vcpu->arch.count_resume, delta); in kvm_mips_set_count_ctl()
895 kvm_mips_callbacks->queue_timer_int(vcpu); in kvm_mips_set_count_ctl()
898 count = kvm_mips_read_count_running(vcpu, now); in kvm_mips_set_count_ctl()
899 kvm_mips_resume_hrtimer(vcpu, now, count); in kvm_mips_set_count_ctl()
916 int kvm_mips_set_count_resume(struct kvm_vcpu *vcpu, s64 count_resume) in kvm_mips_set_count_resume() argument
926 vcpu->arch.count_resume = ns_to_ktime(count_resume); in kvm_mips_set_count_resume()
938 enum hrtimer_restart kvm_mips_count_timeout(struct kvm_vcpu *vcpu) in kvm_mips_count_timeout() argument
941 hrtimer_add_expires_ns(&vcpu->arch.comparecount_timer, in kvm_mips_count_timeout()
942 vcpu->arch.count_period); in kvm_mips_count_timeout()
946 enum emulation_result kvm_mips_emul_eret(struct kvm_vcpu *vcpu) in kvm_mips_emul_eret() argument
948 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emul_eret()
953 vcpu->arch.pc = kvm_read_c0_guest_errorepc(cop0); in kvm_mips_emul_eret()
955 kvm_debug("[%#lx] ERET to %#lx\n", vcpu->arch.pc, in kvm_mips_emul_eret()
958 vcpu->arch.pc = kvm_read_c0_guest_epc(cop0); in kvm_mips_emul_eret()
962 vcpu->arch.pc); in kvm_mips_emul_eret()
969 enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu) in kvm_mips_emul_wait() argument
971 kvm_debug("[%#lx] !!!WAIT!!! (%#lx)\n", vcpu->arch.pc, in kvm_mips_emul_wait()
972 vcpu->arch.pending_exceptions); in kvm_mips_emul_wait()
974 ++vcpu->stat.wait_exits; in kvm_mips_emul_wait()
975 trace_kvm_exit(vcpu, KVM_TRACE_EXIT_WAIT); in kvm_mips_emul_wait()
976 if (!vcpu->arch.pending_exceptions) { in kvm_mips_emul_wait()
977 kvm_vz_lose_htimer(vcpu); in kvm_mips_emul_wait()
978 vcpu->arch.wait = 1; in kvm_mips_emul_wait()
979 kvm_vcpu_block(vcpu); in kvm_mips_emul_wait()
985 if (kvm_check_request(KVM_REQ_UNHALT, vcpu)) { in kvm_mips_emul_wait()
986 kvm_clear_request(KVM_REQ_UNHALT, vcpu); in kvm_mips_emul_wait()
987 vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN; in kvm_mips_emul_wait()
994 static void kvm_mips_change_entryhi(struct kvm_vcpu *vcpu, in kvm_mips_change_entryhi() argument
997 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_change_entryhi()
998 struct mm_struct *kern_mm = &vcpu->arch.guest_kernel_mm; in kvm_mips_change_entryhi()
1003 trace_kvm_asid_change(vcpu, kvm_read_c0_guest_entryhi(cop0) & in kvm_mips_change_entryhi()
1029 enum emulation_result kvm_mips_emul_tlbr(struct kvm_vcpu *vcpu) in kvm_mips_emul_tlbr() argument
1031 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emul_tlbr()
1033 unsigned long pc = vcpu->arch.pc; in kvm_mips_emul_tlbr()
1043 tlb = &vcpu->arch.guest_tlb[index]; in kvm_mips_emul_tlbr()
1047 kvm_mips_change_entryhi(vcpu, tlb->tlb_hi); in kvm_mips_emul_tlbr()
1060 static void kvm_mips_invalidate_guest_tlb(struct kvm_vcpu *vcpu, in kvm_mips_invalidate_guest_tlb() argument
1063 struct mm_struct *kern_mm = &vcpu->arch.guest_kernel_mm; in kvm_mips_invalidate_guest_tlb()
1064 struct mm_struct *user_mm = &vcpu->arch.guest_user_mm; in kvm_mips_invalidate_guest_tlb()
1080 kvm_trap_emul_invalidate_gva(vcpu, tlb->tlb_hi & VPN2_MASK, user); in kvm_mips_invalidate_guest_tlb()
1086 kvm_mips_host_tlb_inv(vcpu, tlb->tlb_hi, user, true); in kvm_mips_invalidate_guest_tlb()
1102 enum emulation_result kvm_mips_emul_tlbwi(struct kvm_vcpu *vcpu) in kvm_mips_emul_tlbwi() argument
1104 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emul_tlbwi()
1107 unsigned long pc = vcpu->arch.pc; in kvm_mips_emul_tlbwi()
1119 tlb = &vcpu->arch.guest_tlb[index]; in kvm_mips_emul_tlbwi()
1121 kvm_mips_invalidate_guest_tlb(vcpu, tlb); in kvm_mips_emul_tlbwi()
1138 enum emulation_result kvm_mips_emul_tlbwr(struct kvm_vcpu *vcpu) in kvm_mips_emul_tlbwr() argument
1140 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emul_tlbwr()
1142 unsigned long pc = vcpu->arch.pc; in kvm_mips_emul_tlbwr()
1146 tlb = &vcpu->arch.guest_tlb[index]; in kvm_mips_emul_tlbwr()
1148 kvm_mips_invalidate_guest_tlb(vcpu, tlb); in kvm_mips_emul_tlbwr()
1163 enum emulation_result kvm_mips_emul_tlbp(struct kvm_vcpu *vcpu) in kvm_mips_emul_tlbp() argument
1165 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emul_tlbp()
1167 unsigned long pc = vcpu->arch.pc; in kvm_mips_emul_tlbp()
1170 index = kvm_mips_guest_tlb_lookup(vcpu, entryhi); in kvm_mips_emul_tlbp()
1187 unsigned int kvm_mips_config1_wrmask(struct kvm_vcpu *vcpu) in kvm_mips_config1_wrmask() argument
1192 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) in kvm_mips_config1_wrmask()
1205 unsigned int kvm_mips_config3_wrmask(struct kvm_vcpu *vcpu) in kvm_mips_config3_wrmask() argument
1211 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) in kvm_mips_config3_wrmask()
1224 unsigned int kvm_mips_config4_wrmask(struct kvm_vcpu *vcpu) in kvm_mips_config4_wrmask() argument
1242 unsigned int kvm_mips_config5_wrmask(struct kvm_vcpu *vcpu) in kvm_mips_config5_wrmask() argument
1247 if (kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_config5_wrmask()
1254 if (kvm_mips_guest_has_fpu(&vcpu->arch)) { in kvm_mips_config5_wrmask()
1265 struct kvm_vcpu *vcpu) in kvm_mips_emulate_CP0() argument
1267 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_CP0()
1276 curr_pc = vcpu->arch.pc; in kvm_mips_emulate_CP0()
1277 er = update_pc(vcpu, cause); in kvm_mips_emulate_CP0()
1284 er = kvm_mips_emul_tlbr(vcpu); in kvm_mips_emulate_CP0()
1287 er = kvm_mips_emul_tlbwi(vcpu); in kvm_mips_emulate_CP0()
1290 er = kvm_mips_emul_tlbwr(vcpu); in kvm_mips_emulate_CP0()
1293 er = kvm_mips_emul_tlbp(vcpu); in kvm_mips_emulate_CP0()
1299 er = kvm_mips_emul_eret(vcpu); in kvm_mips_emulate_CP0()
1302 er = kvm_mips_emul_wait(vcpu); in kvm_mips_emulate_CP0()
1305 er = kvm_mips_emul_hypcall(vcpu, inst); in kvm_mips_emulate_CP0()
1320 vcpu->arch.gprs[rt] = in kvm_mips_emulate_CP0()
1321 (s32)kvm_mips_read_count(vcpu); in kvm_mips_emulate_CP0()
1323 vcpu->arch.gprs[rt] = 0x0; in kvm_mips_emulate_CP0()
1325 kvm_mips_trans_mfc0(inst, opc, vcpu); in kvm_mips_emulate_CP0()
1328 vcpu->arch.gprs[rt] = (s32)cop0->reg[rd][sel]; in kvm_mips_emulate_CP0()
1331 kvm_mips_trans_mfc0(inst, opc, vcpu); in kvm_mips_emulate_CP0()
1335 trace_kvm_hwr(vcpu, KVM_TRACE_MFC0, in kvm_mips_emulate_CP0()
1337 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1341 vcpu->arch.gprs[rt] = cop0->reg[rd][sel]; in kvm_mips_emulate_CP0()
1343 trace_kvm_hwr(vcpu, KVM_TRACE_DMFC0, in kvm_mips_emulate_CP0()
1345 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1352 trace_kvm_hwr(vcpu, KVM_TRACE_MTC0, in kvm_mips_emulate_CP0()
1354 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1357 && (vcpu->arch.gprs[rt] >= in kvm_mips_emulate_CP0()
1360 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1370 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1372 kvm_mips_change_entryhi(vcpu, in kvm_mips_emulate_CP0()
1373 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1377 kvm_mips_write_count(vcpu, vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1382 kvm_mips_write_compare(vcpu, in kvm_mips_emulate_CP0()
1383 vcpu->arch.gprs[rt], in kvm_mips_emulate_CP0()
1389 val = vcpu->arch.gprs[rt]; in kvm_mips_emulate_CP0()
1400 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_emulate_CP0()
1420 kvm_drop_fpu(vcpu); in kvm_mips_emulate_CP0()
1431 vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) in kvm_mips_emulate_CP0()
1432 kvm_lose_fpu(vcpu); in kvm_mips_emulate_CP0()
1442 vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) in kvm_mips_emulate_CP0()
1454 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_emulate_CP0()
1455 kvm_mips_trans_mtc0(inst, opc, vcpu); in kvm_mips_emulate_CP0()
1461 val = vcpu->arch.gprs[rt]; in kvm_mips_emulate_CP0()
1464 wrmask = kvm_mips_config5_wrmask(vcpu); in kvm_mips_emulate_CP0()
1477 vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) in kvm_mips_emulate_CP0()
1487 vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) in kvm_mips_emulate_CP0()
1498 new_cause = vcpu->arch.gprs[rt]; in kvm_mips_emulate_CP0()
1505 kvm_mips_count_disable_cause(vcpu); in kvm_mips_emulate_CP0()
1507 kvm_mips_count_enable_cause(vcpu); in kvm_mips_emulate_CP0()
1518 cop0->reg[rd][sel] = vcpu->arch.gprs[rt] & mask; in kvm_mips_emulate_CP0()
1520 cop0->reg[rd][sel] = vcpu->arch.gprs[rt]; in kvm_mips_emulate_CP0()
1522 kvm_mips_trans_mtc0(inst, opc, vcpu); in kvm_mips_emulate_CP0()
1529 vcpu->arch.pc, rt, rd, sel); in kvm_mips_emulate_CP0()
1530 trace_kvm_hwr(vcpu, KVM_TRACE_DMTC0, in kvm_mips_emulate_CP0()
1532 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1541 vcpu->arch.gprs[rt] = in kvm_mips_emulate_CP0()
1546 vcpu->arch.pc); in kvm_mips_emulate_CP0()
1550 vcpu->arch.pc); in kvm_mips_emulate_CP0()
1570 vcpu->arch.gprs[rt]); in kvm_mips_emulate_CP0()
1571 vcpu->arch.gprs[rd] = vcpu->arch.gprs[rt]; in kvm_mips_emulate_CP0()
1576 vcpu->arch.pc, inst.c0r_format.rs); in kvm_mips_emulate_CP0()
1585 vcpu->arch.pc = curr_pc; in kvm_mips_emulate_CP0()
1599 struct kvm_vcpu *vcpu) in kvm_mips_emulate_store() argument
1604 struct kvm_run *run = vcpu->run; in kvm_mips_emulate_store()
1613 curr_pc = vcpu->arch.pc; in kvm_mips_emulate_store()
1614 er = update_pc(vcpu, cause); in kvm_mips_emulate_store()
1621 vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_store()
1629 *(u64 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1632 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1633 vcpu->arch.gprs[rt], *(u64 *)data); in kvm_mips_emulate_store()
1639 *(u32 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1642 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1643 vcpu->arch.gprs[rt], *(u32 *)data); in kvm_mips_emulate_store()
1648 *(u16 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1651 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1652 vcpu->arch.gprs[rt], *(u16 *)data); in kvm_mips_emulate_store()
1657 *(u8 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1660 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1661 vcpu->arch.gprs[rt], *(u8 *)data); in kvm_mips_emulate_store()
1666 vcpu->arch.host_cp0_badvaddr) & (~0x3); in kvm_mips_emulate_store()
1668 imme = vcpu->arch.host_cp0_badvaddr & 0x3; in kvm_mips_emulate_store()
1672 (vcpu->arch.gprs[rt] >> 24); in kvm_mips_emulate_store()
1676 (vcpu->arch.gprs[rt] >> 16); in kvm_mips_emulate_store()
1680 (vcpu->arch.gprs[rt] >> 8); in kvm_mips_emulate_store()
1683 *(u32 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1690 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1691 vcpu->arch.gprs[rt], *(u32 *)data); in kvm_mips_emulate_store()
1696 vcpu->arch.host_cp0_badvaddr) & (~0x3); in kvm_mips_emulate_store()
1698 imme = vcpu->arch.host_cp0_badvaddr & 0x3; in kvm_mips_emulate_store()
1701 *(u32 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1705 (vcpu->arch.gprs[rt] << 8); in kvm_mips_emulate_store()
1709 (vcpu->arch.gprs[rt] << 16); in kvm_mips_emulate_store()
1713 (vcpu->arch.gprs[rt] << 24); in kvm_mips_emulate_store()
1720 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1721 vcpu->arch.gprs[rt], *(u32 *)data); in kvm_mips_emulate_store()
1727 vcpu->arch.host_cp0_badvaddr) & (~0x7); in kvm_mips_emulate_store()
1730 imme = vcpu->arch.host_cp0_badvaddr & 0x7; in kvm_mips_emulate_store()
1734 ((vcpu->arch.gprs[rt] >> 56) & 0xff); in kvm_mips_emulate_store()
1738 ((vcpu->arch.gprs[rt] >> 48) & 0xffff); in kvm_mips_emulate_store()
1742 ((vcpu->arch.gprs[rt] >> 40) & 0xffffff); in kvm_mips_emulate_store()
1746 ((vcpu->arch.gprs[rt] >> 32) & 0xffffffff); in kvm_mips_emulate_store()
1750 ((vcpu->arch.gprs[rt] >> 24) & 0xffffffffff); in kvm_mips_emulate_store()
1754 ((vcpu->arch.gprs[rt] >> 16) & 0xffffffffffff); in kvm_mips_emulate_store()
1758 ((vcpu->arch.gprs[rt] >> 8) & 0xffffffffffffff); in kvm_mips_emulate_store()
1761 *(u64 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1768 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1769 vcpu->arch.gprs[rt], *(u64 *)data); in kvm_mips_emulate_store()
1774 vcpu->arch.host_cp0_badvaddr) & (~0x7); in kvm_mips_emulate_store()
1777 imme = vcpu->arch.host_cp0_badvaddr & 0x7; in kvm_mips_emulate_store()
1780 *(u64 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1784 (vcpu->arch.gprs[rt] << 8); in kvm_mips_emulate_store()
1788 (vcpu->arch.gprs[rt] << 16); in kvm_mips_emulate_store()
1792 (vcpu->arch.gprs[rt] << 24); in kvm_mips_emulate_store()
1796 (vcpu->arch.gprs[rt] << 32); in kvm_mips_emulate_store()
1800 (vcpu->arch.gprs[rt] << 40); in kvm_mips_emulate_store()
1804 (vcpu->arch.gprs[rt] << 48); in kvm_mips_emulate_store()
1808 (vcpu->arch.gprs[rt] << 56); in kvm_mips_emulate_store()
1815 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1816 vcpu->arch.gprs[rt], *(u64 *)data); in kvm_mips_emulate_store()
1834 *(u8 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1837 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1838 vcpu->arch.gprs[rt], *(u8 *)data); in kvm_mips_emulate_store()
1842 *(u16 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1845 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1846 vcpu->arch.gprs[rt], *(u16 *)data); in kvm_mips_emulate_store()
1850 *(u32 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1853 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1854 vcpu->arch.gprs[rt], *(u32 *)data); in kvm_mips_emulate_store()
1858 *(u64 *)data = vcpu->arch.gprs[rt]; in kvm_mips_emulate_store()
1861 vcpu->arch.pc, vcpu->arch.host_cp0_badvaddr, in kvm_mips_emulate_store()
1862 vcpu->arch.gprs[rt], *(u64 *)data); in kvm_mips_emulate_store()
1877 vcpu->mmio_needed = 1; in kvm_mips_emulate_store()
1879 vcpu->mmio_is_write = 1; in kvm_mips_emulate_store()
1881 r = kvm_io_bus_write(vcpu, KVM_MMIO_BUS, in kvm_mips_emulate_store()
1885 vcpu->mmio_needed = 0; in kvm_mips_emulate_store()
1893 vcpu->arch.pc = curr_pc; in kvm_mips_emulate_store()
1898 u32 cause, struct kvm_vcpu *vcpu) in kvm_mips_emulate_load() argument
1900 struct kvm_run *run = vcpu->run; in kvm_mips_emulate_load()
1915 curr_pc = vcpu->arch.pc; in kvm_mips_emulate_load()
1916 er = update_pc(vcpu, cause); in kvm_mips_emulate_load()
1919 vcpu->arch.io_pc = vcpu->arch.pc; in kvm_mips_emulate_load()
1920 vcpu->arch.pc = curr_pc; in kvm_mips_emulate_load()
1922 vcpu->arch.io_gpr = rt; in kvm_mips_emulate_load()
1925 vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_load()
1929 vcpu->mmio_needed = 2; /* signed */ in kvm_mips_emulate_load()
1937 vcpu->mmio_needed = 1; /* unsigned */ in kvm_mips_emulate_load()
1945 vcpu->mmio_needed = 1; /* unsigned */ in kvm_mips_emulate_load()
1952 vcpu->mmio_needed = 1; /* unsigned */ in kvm_mips_emulate_load()
1960 vcpu->arch.host_cp0_badvaddr) & (~0x3); in kvm_mips_emulate_load()
1963 imme = vcpu->arch.host_cp0_badvaddr & 0x3; in kvm_mips_emulate_load()
1966 vcpu->mmio_needed = 3; /* 1 byte */ in kvm_mips_emulate_load()
1969 vcpu->mmio_needed = 4; /* 2 bytes */ in kvm_mips_emulate_load()
1972 vcpu->mmio_needed = 5; /* 3 bytes */ in kvm_mips_emulate_load()
1975 vcpu->mmio_needed = 6; /* 4 bytes */ in kvm_mips_emulate_load()
1984 vcpu->arch.host_cp0_badvaddr) & (~0x3); in kvm_mips_emulate_load()
1987 imme = vcpu->arch.host_cp0_badvaddr & 0x3; in kvm_mips_emulate_load()
1990 vcpu->mmio_needed = 7; /* 4 bytes */ in kvm_mips_emulate_load()
1993 vcpu->mmio_needed = 8; /* 3 bytes */ in kvm_mips_emulate_load()
1996 vcpu->mmio_needed = 9; /* 2 bytes */ in kvm_mips_emulate_load()
1999 vcpu->mmio_needed = 10; /* 1 byte */ in kvm_mips_emulate_load()
2009 vcpu->arch.host_cp0_badvaddr) & (~0x7); in kvm_mips_emulate_load()
2012 imme = vcpu->arch.host_cp0_badvaddr & 0x7; in kvm_mips_emulate_load()
2015 vcpu->mmio_needed = 11; /* 1 byte */ in kvm_mips_emulate_load()
2018 vcpu->mmio_needed = 12; /* 2 bytes */ in kvm_mips_emulate_load()
2021 vcpu->mmio_needed = 13; /* 3 bytes */ in kvm_mips_emulate_load()
2024 vcpu->mmio_needed = 14; /* 4 bytes */ in kvm_mips_emulate_load()
2027 vcpu->mmio_needed = 15; /* 5 bytes */ in kvm_mips_emulate_load()
2030 vcpu->mmio_needed = 16; /* 6 bytes */ in kvm_mips_emulate_load()
2033 vcpu->mmio_needed = 17; /* 7 bytes */ in kvm_mips_emulate_load()
2036 vcpu->mmio_needed = 18; /* 8 bytes */ in kvm_mips_emulate_load()
2045 vcpu->arch.host_cp0_badvaddr) & (~0x7); in kvm_mips_emulate_load()
2048 imme = vcpu->arch.host_cp0_badvaddr & 0x7; in kvm_mips_emulate_load()
2051 vcpu->mmio_needed = 19; /* 8 bytes */ in kvm_mips_emulate_load()
2054 vcpu->mmio_needed = 20; /* 7 bytes */ in kvm_mips_emulate_load()
2057 vcpu->mmio_needed = 21; /* 6 bytes */ in kvm_mips_emulate_load()
2060 vcpu->mmio_needed = 22; /* 5 bytes */ in kvm_mips_emulate_load()
2063 vcpu->mmio_needed = 23; /* 4 bytes */ in kvm_mips_emulate_load()
2066 vcpu->mmio_needed = 24; /* 3 bytes */ in kvm_mips_emulate_load()
2069 vcpu->mmio_needed = 25; /* 2 bytes */ in kvm_mips_emulate_load()
2072 vcpu->mmio_needed = 26; /* 1 byte */ in kvm_mips_emulate_load()
2094 vcpu->mmio_needed = 27; /* signed */ in kvm_mips_emulate_load()
2098 vcpu->mmio_needed = 28; /* signed */ in kvm_mips_emulate_load()
2102 vcpu->mmio_needed = 29; /* signed */ in kvm_mips_emulate_load()
2106 vcpu->mmio_needed = 30; /* signed */ in kvm_mips_emulate_load()
2119 vcpu->mmio_needed = 0; in kvm_mips_emulate_load()
2124 vcpu->mmio_is_write = 0; in kvm_mips_emulate_load()
2126 r = kvm_io_bus_read(vcpu, KVM_MMIO_BUS, in kvm_mips_emulate_load()
2130 kvm_mips_complete_mmio_load(vcpu); in kvm_mips_emulate_load()
2131 vcpu->mmio_needed = 0; in kvm_mips_emulate_load()
2142 struct kvm_vcpu *vcpu, in kvm_mips_guest_cache_op() argument
2149 kvm_trap_emul_gva_lockless_begin(vcpu); in kvm_mips_guest_cache_op()
2151 kvm_trap_emul_gva_lockless_end(vcpu); in kvm_mips_guest_cache_op()
2160 switch (kvm_trap_emul_gva_fault(vcpu, addr, false)) { in kvm_mips_guest_cache_op()
2167 vcpu->arch.host_cp0_badvaddr = addr; in kvm_mips_guest_cache_op()
2168 vcpu->arch.pc = curr_pc; in kvm_mips_guest_cache_op()
2169 kvm_mips_emulate_tlbmiss_ld(cause, NULL, vcpu); in kvm_mips_guest_cache_op()
2173 vcpu->arch.host_cp0_badvaddr = addr; in kvm_mips_guest_cache_op()
2174 vcpu->arch.pc = curr_pc; in kvm_mips_guest_cache_op()
2175 kvm_mips_emulate_tlbinv_ld(cause, NULL, vcpu); in kvm_mips_guest_cache_op()
2185 struct kvm_vcpu *vcpu) in kvm_mips_emulate_cache() argument
2190 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_cache()
2198 curr_pc = vcpu->arch.pc; in kvm_mips_emulate_cache()
2199 er = update_pc(vcpu, cause); in kvm_mips_emulate_cache()
2224 vcpu->arch.pc, vcpu->arch.gprs[31], cache, op, base, in kvm_mips_emulate_cache()
2262 kvm_mips_trans_cache_index(inst, opc, vcpu); in kvm_mips_emulate_cache()
2274 curr_pc, va, vcpu, cause); in kvm_mips_emulate_cache()
2282 kvm_mips_trans_cache_va(inst, opc, vcpu); in kvm_mips_emulate_cache()
2287 curr_pc, va, vcpu, cause); in kvm_mips_emulate_cache()
2291 curr_pc, va, vcpu, cause); in kvm_mips_emulate_cache()
2297 kvm_mips_trans_cache_va(inst, opc, vcpu); in kvm_mips_emulate_cache()
2308 vcpu->arch.pc = curr_pc; in kvm_mips_emulate_cache()
2317 struct kvm_vcpu *vcpu) in kvm_mips_emulate_inst() argument
2326 err = kvm_get_badinstr(opc, vcpu, &inst.word); in kvm_mips_emulate_inst()
2332 er = kvm_mips_emulate_CP0(inst, opc, cause, vcpu); in kvm_mips_emulate_inst()
2337 ++vcpu->stat.cache_exits; in kvm_mips_emulate_inst()
2338 trace_kvm_exit(vcpu, KVM_TRACE_EXIT_CACHE); in kvm_mips_emulate_inst()
2339 er = kvm_mips_emulate_cache(inst, opc, cause, vcpu); in kvm_mips_emulate_inst()
2345 ++vcpu->stat.cache_exits; in kvm_mips_emulate_inst()
2346 trace_kvm_exit(vcpu, KVM_TRACE_EXIT_CACHE); in kvm_mips_emulate_inst()
2348 vcpu); in kvm_mips_emulate_inst()
2360 kvm_arch_vcpu_dump_regs(vcpu); in kvm_mips_emulate_inst()
2375 long kvm_mips_guest_exception_base(struct kvm_vcpu *vcpu) in kvm_mips_guest_exception_base() argument
2377 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_guest_exception_base()
2387 struct kvm_vcpu *vcpu) in kvm_mips_emulate_syscall() argument
2389 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_syscall()
2390 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_syscall()
2409 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_syscall()
2421 struct kvm_vcpu *vcpu) in kvm_mips_emulate_tlbmiss_ld() argument
2423 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_tlbmiss_ld()
2424 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_tlbmiss_ld()
2425 unsigned long entryhi = (vcpu->arch. host_cp0_badvaddr & VPN2_MASK) | in kvm_mips_emulate_tlbmiss_ld()
2442 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x0; in kvm_mips_emulate_tlbmiss_ld()
2448 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_tlbmiss_ld()
2455 kvm_write_c0_guest_badvaddr(cop0, vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_tlbmiss_ld()
2464 struct kvm_vcpu *vcpu) in kvm_mips_emulate_tlbinv_ld() argument
2466 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_tlbinv_ld()
2467 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_tlbinv_ld()
2469 (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | in kvm_mips_emulate_tlbinv_ld()
2490 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_tlbinv_ld()
2496 kvm_write_c0_guest_badvaddr(cop0, vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_tlbinv_ld()
2505 struct kvm_vcpu *vcpu) in kvm_mips_emulate_tlbmiss_st() argument
2507 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_tlbmiss_st()
2508 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_tlbmiss_st()
2509 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | in kvm_mips_emulate_tlbmiss_st()
2526 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x0; in kvm_mips_emulate_tlbmiss_st()
2530 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_tlbmiss_st()
2537 kvm_write_c0_guest_badvaddr(cop0, vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_tlbmiss_st()
2546 struct kvm_vcpu *vcpu) in kvm_mips_emulate_tlbinv_st() argument
2548 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_tlbinv_st()
2549 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_tlbinv_st()
2550 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | in kvm_mips_emulate_tlbinv_st()
2571 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_tlbinv_st()
2577 kvm_write_c0_guest_badvaddr(cop0, vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_tlbinv_st()
2586 struct kvm_vcpu *vcpu) in kvm_mips_emulate_tlbmod() argument
2588 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_tlbmod()
2589 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | in kvm_mips_emulate_tlbmod()
2591 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_tlbmod()
2610 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_tlbmod()
2616 kvm_write_c0_guest_badvaddr(cop0, vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_tlbmod()
2625 struct kvm_vcpu *vcpu) in kvm_mips_emulate_fpu_exc() argument
2627 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_fpu_exc()
2628 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_fpu_exc()
2642 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_fpu_exc()
2653 struct kvm_vcpu *vcpu) in kvm_mips_emulate_ri_exc() argument
2655 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_ri_exc()
2656 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_ri_exc()
2675 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_ri_exc()
2687 struct kvm_vcpu *vcpu) in kvm_mips_emulate_bp_exc() argument
2689 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_bp_exc()
2690 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_bp_exc()
2709 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_bp_exc()
2721 struct kvm_vcpu *vcpu) in kvm_mips_emulate_trap_exc() argument
2723 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_trap_exc()
2724 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_trap_exc()
2743 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_trap_exc()
2755 struct kvm_vcpu *vcpu) in kvm_mips_emulate_msafpe_exc() argument
2757 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_msafpe_exc()
2758 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_msafpe_exc()
2777 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_msafpe_exc()
2789 struct kvm_vcpu *vcpu) in kvm_mips_emulate_fpe_exc() argument
2791 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_fpe_exc()
2792 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_fpe_exc()
2811 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_fpe_exc()
2823 struct kvm_vcpu *vcpu) in kvm_mips_emulate_msadis_exc() argument
2825 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_msadis_exc()
2826 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_msadis_exc()
2845 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_msadis_exc()
2856 struct kvm_vcpu *vcpu) in kvm_mips_handle_ri() argument
2858 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_handle_ri()
2859 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_handle_ri()
2869 curr_pc = vcpu->arch.pc; in kvm_mips_handle_ri()
2870 er = update_pc(vcpu, cause); in kvm_mips_handle_ri()
2877 err = kvm_get_badinstr(opc, vcpu, &inst.word); in kvm_mips_handle_ri()
2887 int usermode = !KVM_GUEST_KERNEL_MODE(vcpu); in kvm_mips_handle_ri()
2900 arch->gprs[rt] = vcpu->vcpu_id; in kvm_mips_handle_ri()
2907 arch->gprs[rt] = (s32)kvm_mips_read_count(vcpu); in kvm_mips_handle_ri()
2928 trace_kvm_hwr(vcpu, KVM_TRACE_RDHWR, KVM_TRACE_HWR(rd, sel), in kvm_mips_handle_ri()
2929 vcpu->arch.gprs[rt]); in kvm_mips_handle_ri()
2943 vcpu->arch.pc = curr_pc; in kvm_mips_handle_ri()
2944 return kvm_mips_emulate_ri_exc(cause, opc, vcpu); in kvm_mips_handle_ri()
2947 enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu) in kvm_mips_complete_mmio_load() argument
2949 struct kvm_run *run = vcpu->run; in kvm_mips_complete_mmio_load()
2950 unsigned long *gpr = &vcpu->arch.gprs[vcpu->arch.io_gpr]; in kvm_mips_complete_mmio_load()
2960 vcpu->arch.pc = vcpu->arch.io_pc; in kvm_mips_complete_mmio_load()
2964 switch (vcpu->mmio_needed) { in kvm_mips_complete_mmio_load()
2966 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffffffffff) | in kvm_mips_complete_mmio_load()
2970 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffffffff) | in kvm_mips_complete_mmio_load()
2974 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffffff) | in kvm_mips_complete_mmio_load()
2978 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffff) | in kvm_mips_complete_mmio_load()
2982 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffff) | in kvm_mips_complete_mmio_load()
2986 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffff) | in kvm_mips_complete_mmio_load()
2990 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xff) | in kvm_mips_complete_mmio_load()
2998 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xff00000000000000) | in kvm_mips_complete_mmio_load()
3002 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffff000000000000) | in kvm_mips_complete_mmio_load()
3006 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffff0000000000) | in kvm_mips_complete_mmio_load()
3010 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffff00000000) | in kvm_mips_complete_mmio_load()
3014 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffffff000000) | in kvm_mips_complete_mmio_load()
3018 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffffffff0000) | in kvm_mips_complete_mmio_load()
3022 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffffffffffff00) | in kvm_mips_complete_mmio_load()
3031 switch (vcpu->mmio_needed) { in kvm_mips_complete_mmio_load()
3039 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffff) | in kvm_mips_complete_mmio_load()
3043 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffff) | in kvm_mips_complete_mmio_load()
3047 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xff) | in kvm_mips_complete_mmio_load()
3055 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xff000000) | in kvm_mips_complete_mmio_load()
3059 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffff0000) | in kvm_mips_complete_mmio_load()
3063 *gpr = (vcpu->arch.gprs[vcpu->arch.io_gpr] & 0xffffff00) | in kvm_mips_complete_mmio_load()
3072 if (vcpu->mmio_needed == 1) in kvm_mips_complete_mmio_load()
3079 if (vcpu->mmio_needed == 1) in kvm_mips_complete_mmio_load()
3092 struct kvm_vcpu *vcpu) in kvm_mips_emulate_exc() argument
3095 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_emulate_exc()
3096 struct kvm_vcpu_arch *arch = &vcpu->arch; in kvm_mips_emulate_exc()
3113 arch->pc = kvm_mips_guest_exception_base(vcpu) + 0x180; in kvm_mips_emulate_exc()
3114 kvm_write_c0_guest_badvaddr(cop0, vcpu->arch.host_cp0_badvaddr); in kvm_mips_emulate_exc()
3129 struct kvm_vcpu *vcpu) in kvm_mips_check_privilege() argument
3133 unsigned long badvaddr = vcpu->arch.host_cp0_badvaddr; in kvm_mips_check_privilege()
3135 int usermode = !KVM_GUEST_KERNEL_MODE(vcpu); in kvm_mips_check_privilege()
3210 kvm_mips_emulate_exc(cause, opc, vcpu); in kvm_mips_check_privilege()
3224 struct kvm_vcpu *vcpu, in kvm_mips_handle_tlbmiss() argument
3229 unsigned long va = vcpu->arch.host_cp0_badvaddr; in kvm_mips_handle_tlbmiss()
3233 vcpu->arch.host_cp0_badvaddr); in kvm_mips_handle_tlbmiss()
3241 index = kvm_mips_guest_tlb_lookup(vcpu, in kvm_mips_handle_tlbmiss()
3243 (kvm_read_c0_guest_entryhi(vcpu->arch.cop0) & in kvm_mips_handle_tlbmiss()
3247 er = kvm_mips_emulate_tlbmiss_ld(cause, opc, vcpu); in kvm_mips_handle_tlbmiss()
3249 er = kvm_mips_emulate_tlbmiss_st(cause, opc, vcpu); in kvm_mips_handle_tlbmiss()
3256 struct kvm_mips_tlb *tlb = &vcpu->arch.guest_tlb[index]; in kvm_mips_handle_tlbmiss()
3265 vcpu); in kvm_mips_handle_tlbmiss()
3268 vcpu); in kvm_mips_handle_tlbmiss()
3281 if (kvm_mips_handle_mapped_seg_tlb_fault(vcpu, tlb, va, in kvm_mips_handle_tlbmiss()
3284 __func__, va, index, vcpu, in kvm_mips_handle_tlbmiss()