Lines Matching +full:reserved +full:- +full:ipi +full:- +full:vectors

8  * Copyright (C) 2012  MIPS Technologies, Inc.  All rights reserved.
115 return !!(vcpu->arch.pending_exceptions); in kvm_arch_vcpu_runnable()
130 return kvm_mips_callbacks->enable_virtualization_cpu(); in kvm_arch_enable_virtualization_cpu()
135 kvm_mips_callbacks->disable_virtualization_cpu(); in kvm_arch_disable_virtualization_cpu()
147 return -EINVAL; in kvm_arch_init_vm()
150 /* Allocate page table to map GPA -> RPA */ in kvm_arch_init_vm()
151 kvm->arch.gpa_mm.pgd = kvm_pgd_alloc(); in kvm_arch_init_vm()
152 if (!kvm->arch.gpa_mm.pgd) in kvm_arch_init_vm()
153 return -ENOMEM; in kvm_arch_init_vm()
166 pgd_free(NULL, kvm->arch.gpa_mm.pgd); in kvm_mips_free_gpa_pt()
178 return -ENOIOCTLCMD; in kvm_arch_dev_ioctl()
196 spin_lock(&kvm->mmu_lock); in kvm_arch_flush_shadow_memslot()
198 kvm_mips_flush_gpa_pt(kvm, slot->base_gfn, in kvm_arch_flush_shadow_memslot()
199 slot->base_gfn + slot->npages - 1); in kvm_arch_flush_shadow_memslot()
201 spin_unlock(&kvm->mmu_lock); in kvm_arch_flush_shadow_memslot()
229 (!(old->flags & KVM_MEM_LOG_DIRTY_PAGES) && in kvm_arch_commit_memory_region()
230 new->flags & KVM_MEM_LOG_DIRTY_PAGES)) { in kvm_arch_commit_memory_region()
231 spin_lock(&kvm->mmu_lock); in kvm_arch_commit_memory_region()
233 needs_flush = kvm_mips_mkclean_gpa_pt(kvm, new->base_gfn, in kvm_arch_commit_memory_region()
234 new->base_gfn + new->npages - 1); in kvm_arch_commit_memory_region()
237 spin_unlock(&kvm->mmu_lock); in kvm_arch_commit_memory_region()
265 kvm_mips_callbacks->queue_timer_int(vcpu); in kvm_mips_comparecount_wakeup()
267 vcpu->arch.wait = 0; in kvm_mips_comparecount_wakeup()
268 rcuwait_wake_up(&vcpu->wait); in kvm_mips_comparecount_wakeup()
285 vcpu->kvm, vcpu->vcpu_id, vcpu); in kvm_arch_vcpu_create()
287 err = kvm_mips_callbacks->vcpu_init(vcpu); in kvm_arch_vcpu_create()
291 hrtimer_init(&vcpu->arch.comparecount_timer, CLOCK_MONOTONIC, in kvm_arch_vcpu_create()
293 vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup; in kvm_arch_vcpu_create()
307 err = -ENOMEM; in kvm_arch_vcpu_create()
321 err = -ENOMEM; in kvm_arch_vcpu_create()
326 vcpu->arch.guest_ebase = gebase; in kvm_arch_vcpu_create()
328 /* Build guest exception vectors dynamically in unmapped memory */ in kvm_arch_vcpu_create()
331 /* TLB refill (or XTLB refill on 64-bit VZ where KX=1) */ in kvm_arch_vcpu_create()
340 /* For vectored interrupts poke the exception code @ all offsets 0-7 */ in kvm_arch_vcpu_create()
353 vcpu->arch.vcpu_run = p; in kvm_arch_vcpu_create()
360 dump_handler("kvm_vcpu_run", vcpu->arch.vcpu_run, p); in kvm_arch_vcpu_create()
363 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run); in kvm_arch_vcpu_create()
370 vcpu->arch.last_sched_cpu = -1; in kvm_arch_vcpu_create()
371 vcpu->arch.last_exec_cpu = -1; in kvm_arch_vcpu_create()
374 err = kvm_mips_callbacks->vcpu_setup(vcpu); in kvm_arch_vcpu_create()
383 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_create()
389 hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_arch_vcpu_destroy()
394 kfree(vcpu->arch.guest_ebase); in kvm_arch_vcpu_destroy()
396 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_destroy()
402 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_guest_debug()
417 ret = kvm_mips_callbacks->vcpu_run(vcpu); in kvm_mips_vcpu_enter_exit()
425 int r = -EINTR; in kvm_arch_vcpu_ioctl_run()
431 if (vcpu->mmio_needed) { in kvm_arch_vcpu_ioctl_run()
432 if (!vcpu->mmio_is_write) in kvm_arch_vcpu_ioctl_run()
434 vcpu->mmio_needed = 0; in kvm_arch_vcpu_ioctl_run()
437 if (!vcpu->wants_to_run) in kvm_arch_vcpu_ioctl_run()
448 * reordered ahead of the write to vcpu->mode, or we could miss a TLB in kvm_arch_vcpu_ioctl_run()
450 * mode and not needing an IPI. in kvm_arch_vcpu_ioctl_run()
452 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in kvm_arch_vcpu_ioctl_run()
483 int intr = (int)irq->irq; in kvm_vcpu_ioctl_interrupt()
488 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_1]) || in kvm_vcpu_ioctl_interrupt()
489 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_2])) in kvm_vcpu_ioctl_interrupt()
490 kvm_debug("%s: CPU: %d, INTR: %d\n", __func__, irq->cpu, in kvm_vcpu_ioctl_interrupt()
493 if (irq->cpu == -1) in kvm_vcpu_ioctl_interrupt()
496 dvcpu = kvm_get_vcpu(vcpu->kvm, irq->cpu); in kvm_vcpu_ioctl_interrupt()
499 kvm_mips_callbacks->queue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
501 } else if (intr == -2 || intr == -3 || intr == -4 || intr == -6) { in kvm_vcpu_ioctl_interrupt()
502 kvm_mips_callbacks->dequeue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
505 irq->cpu, irq->irq); in kvm_vcpu_ioctl_interrupt()
506 return -EINVAL; in kvm_vcpu_ioctl_interrupt()
509 dvcpu->arch.wait = 0; in kvm_vcpu_ioctl_interrupt()
511 rcuwait_wake_up(&dvcpu->wait); in kvm_vcpu_ioctl_interrupt()
519 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_mpstate()
525 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_mpstate()
584 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_num_regs()
590 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) in kvm_mips_num_regs()
592 ret += kvm_mips_callbacks->num_regs(vcpu); in kvm_mips_num_regs()
604 return -EFAULT; in kvm_mips_copy_reg_indices()
607 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
610 return -EFAULT; in kvm_mips_copy_reg_indices()
616 return -EFAULT; in kvm_mips_copy_reg_indices()
625 return -EFAULT; in kvm_mips_copy_reg_indices()
630 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
633 return -EFAULT; in kvm_mips_copy_reg_indices()
639 return -EFAULT; in kvm_mips_copy_reg_indices()
644 return kvm_mips_callbacks->copy_reg_indices(vcpu, indices); in kvm_mips_copy_reg_indices()
650 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_mips_get_reg()
651 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_get_reg()
657 switch (reg->id) { in kvm_mips_get_reg()
660 v = (long)vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0]; in kvm_mips_get_reg()
664 v = (long)vcpu->arch.hi; in kvm_mips_get_reg()
667 v = (long)vcpu->arch.lo; in kvm_mips_get_reg()
671 v = (long)vcpu->arch.pc; in kvm_mips_get_reg()
676 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
677 return -EINVAL; in kvm_mips_get_reg()
678 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_get_reg()
681 v = get_fpr32(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
683 v = get_fpr32(&fpu->fpr[idx & ~1], idx & 1); in kvm_mips_get_reg()
686 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
687 return -EINVAL; in kvm_mips_get_reg()
688 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_get_reg()
691 return -EINVAL; in kvm_mips_get_reg()
692 v = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
695 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
696 return -EINVAL; in kvm_mips_get_reg()
700 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
701 return -EINVAL; in kvm_mips_get_reg()
702 v = fpu->fcr31; in kvm_mips_get_reg()
707 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
708 return -EINVAL; in kvm_mips_get_reg()
711 return -EINVAL; in kvm_mips_get_reg()
712 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_get_reg()
715 vs[0] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
716 vs[1] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
719 vs[0] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
720 vs[1] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
724 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
725 return -EINVAL; in kvm_mips_get_reg()
729 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
730 return -EINVAL; in kvm_mips_get_reg()
731 v = fpu->msacsr; in kvm_mips_get_reg()
736 ret = kvm_mips_callbacks->get_one_reg(vcpu, reg, &v); in kvm_mips_get_reg()
741 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_get_reg()
742 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_get_reg()
745 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_get_reg()
746 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_get_reg()
750 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_get_reg()
751 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_get_reg()
753 return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0; in kvm_mips_get_reg()
755 return -EINVAL; in kvm_mips_get_reg()
762 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_mips_set_reg()
763 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_set_reg()
768 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_set_reg()
769 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_set_reg()
772 return -EFAULT; in kvm_mips_set_reg()
773 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_set_reg()
774 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_set_reg()
778 return -EFAULT; in kvm_mips_set_reg()
780 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_set_reg()
781 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_set_reg()
783 return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0; in kvm_mips_set_reg()
785 return -EINVAL; in kvm_mips_set_reg()
788 switch (reg->id) { in kvm_mips_set_reg()
794 vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0] = v; in kvm_mips_set_reg()
798 vcpu->arch.hi = v; in kvm_mips_set_reg()
801 vcpu->arch.lo = v; in kvm_mips_set_reg()
805 vcpu->arch.pc = v; in kvm_mips_set_reg()
810 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
811 return -EINVAL; in kvm_mips_set_reg()
812 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_set_reg()
815 set_fpr32(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
817 set_fpr32(&fpu->fpr[idx & ~1], idx & 1, v); in kvm_mips_set_reg()
820 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
821 return -EINVAL; in kvm_mips_set_reg()
822 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_set_reg()
825 return -EINVAL; in kvm_mips_set_reg()
826 set_fpr64(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
829 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
830 return -EINVAL; in kvm_mips_set_reg()
831 /* Read-only */ in kvm_mips_set_reg()
834 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
835 return -EINVAL; in kvm_mips_set_reg()
836 fpu->fcr31 = v; in kvm_mips_set_reg()
841 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
842 return -EINVAL; in kvm_mips_set_reg()
843 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_set_reg()
846 set_fpr64(&fpu->fpr[idx], 0, vs[0]); in kvm_mips_set_reg()
847 set_fpr64(&fpu->fpr[idx], 1, vs[1]); in kvm_mips_set_reg()
850 set_fpr64(&fpu->fpr[idx], 1, vs[0]); in kvm_mips_set_reg()
851 set_fpr64(&fpu->fpr[idx], 0, vs[1]); in kvm_mips_set_reg()
855 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
856 return -EINVAL; in kvm_mips_set_reg()
857 /* Read-only */ in kvm_mips_set_reg()
860 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
861 return -EINVAL; in kvm_mips_set_reg()
862 fpu->msacsr = v; in kvm_mips_set_reg()
867 return kvm_mips_callbacks->set_one_reg(vcpu, reg, v); in kvm_mips_set_reg()
877 if (!kvm_vm_ioctl_check_extension(vcpu->kvm, cap->cap)) in kvm_vcpu_ioctl_enable_cap()
878 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
879 if (cap->flags) in kvm_vcpu_ioctl_enable_cap()
880 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
881 if (cap->args[0]) in kvm_vcpu_ioctl_enable_cap()
882 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
884 switch (cap->cap) { in kvm_vcpu_ioctl_enable_cap()
886 vcpu->arch.fpu_enabled = true; in kvm_vcpu_ioctl_enable_cap()
889 vcpu->arch.msa_enabled = true; in kvm_vcpu_ioctl_enable_cap()
892 r = -EINVAL; in kvm_vcpu_ioctl_enable_cap()
902 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_async_ioctl()
909 return -EFAULT; in kvm_arch_vcpu_async_ioctl()
910 kvm_debug("[%d] %s: irq: %d\n", vcpu->vcpu_id, __func__, in kvm_arch_vcpu_async_ioctl()
916 return -ENOIOCTLCMD; in kvm_arch_vcpu_async_ioctl()
922 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_ioctl()
933 r = -EFAULT; in kvm_arch_vcpu_ioctl()
947 r = -EFAULT; in kvm_arch_vcpu_ioctl()
954 r = -E2BIG; in kvm_arch_vcpu_ioctl()
957 r = kvm_mips_copy_reg_indices(vcpu, user_list->reg); in kvm_arch_vcpu_ioctl()
963 r = -EFAULT; in kvm_arch_vcpu_ioctl()
970 r = -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl()
984 kvm_mips_callbacks->prepare_flush_shadow(kvm); in kvm_arch_flush_remote_tlbs()
994 r = -ENOIOCTLCMD; in kvm_arch_vm_ioctl()
1003 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_sregs()
1009 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_sregs()
1018 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_fpu()
1023 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_fpu()
1072 r = kvm_mips_callbacks->check_extension(kvm, ext); in kvm_vm_ioctl_check_extension()
1081 kvm_read_c0_guest_cause(&vcpu->arch.cop0) & C_TI; in kvm_cpu_has_pending_timer()
1090 return -1; in kvm_arch_vcpu_dump_regs()
1093 kvm_debug("\tpc = 0x%08lx\n", vcpu->arch.pc); in kvm_arch_vcpu_dump_regs()
1094 kvm_debug("\texceptions: %08lx\n", vcpu->arch.pending_exceptions); in kvm_arch_vcpu_dump_regs()
1098 vcpu->arch.gprs[i], in kvm_arch_vcpu_dump_regs()
1099 vcpu->arch.gprs[i + 1], in kvm_arch_vcpu_dump_regs()
1100 vcpu->arch.gprs[i + 2], vcpu->arch.gprs[i + 3]); in kvm_arch_vcpu_dump_regs()
1102 kvm_debug("\thi: 0x%08lx\n", vcpu->arch.hi); in kvm_arch_vcpu_dump_regs()
1103 kvm_debug("\tlo: 0x%08lx\n", vcpu->arch.lo); in kvm_arch_vcpu_dump_regs()
1105 cop0 = &vcpu->arch.cop0; in kvm_arch_vcpu_dump_regs()
1121 for (i = 1; i < ARRAY_SIZE(vcpu->arch.gprs); i++) in kvm_arch_vcpu_ioctl_set_regs()
1122 vcpu->arch.gprs[i] = regs->gpr[i]; in kvm_arch_vcpu_ioctl_set_regs()
1123 vcpu->arch.gprs[0] = 0; /* zero is special, and cannot be set. */ in kvm_arch_vcpu_ioctl_set_regs()
1124 vcpu->arch.hi = regs->hi; in kvm_arch_vcpu_ioctl_set_regs()
1125 vcpu->arch.lo = regs->lo; in kvm_arch_vcpu_ioctl_set_regs()
1126 vcpu->arch.pc = regs->pc; in kvm_arch_vcpu_ioctl_set_regs()
1138 for (i = 0; i < ARRAY_SIZE(vcpu->arch.gprs); i++) in kvm_arch_vcpu_ioctl_get_regs()
1139 regs->gpr[i] = vcpu->arch.gprs[i]; in kvm_arch_vcpu_ioctl_get_regs()
1141 regs->hi = vcpu->arch.hi; in kvm_arch_vcpu_ioctl_get_regs()
1142 regs->lo = vcpu->arch.lo; in kvm_arch_vcpu_ioctl_get_regs()
1143 regs->pc = vcpu->arch.pc; in kvm_arch_vcpu_ioctl_get_regs()
1171 struct kvm_run *run = vcpu->run; in __kvm_mips_handle_exit()
1172 u32 cause = vcpu->arch.host_cp0_cause; in __kvm_mips_handle_exit()
1174 u32 __user *opc = (u32 __user *) vcpu->arch.pc; in __kvm_mips_handle_exit()
1175 unsigned long badvaddr = vcpu->arch.host_cp0_badvaddr; in __kvm_mips_handle_exit()
1180 vcpu->mode = OUTSIDE_GUEST_MODE; in __kvm_mips_handle_exit()
1183 run->exit_reason = KVM_EXIT_UNKNOWN; in __kvm_mips_handle_exit()
1184 run->ready_for_interrupt_injection = 1; in __kvm_mips_handle_exit()
1200 kvm_debug("[%d]EXCCODE_INT @ %p\n", vcpu->vcpu_id, opc); in __kvm_mips_handle_exit()
1202 ++vcpu->stat.int_exits; in __kvm_mips_handle_exit()
1213 ++vcpu->stat.cop_unusable_exits; in __kvm_mips_handle_exit()
1214 ret = kvm_mips_callbacks->handle_cop_unusable(vcpu); in __kvm_mips_handle_exit()
1216 if (run->exit_reason == KVM_EXIT_IRQ_WINDOW_OPEN) in __kvm_mips_handle_exit()
1221 ++vcpu->stat.tlbmod_exits; in __kvm_mips_handle_exit()
1222 ret = kvm_mips_callbacks->handle_tlb_mod(vcpu); in __kvm_mips_handle_exit()
1227 cause, kvm_read_c0_guest_status(&vcpu->arch.cop0), opc, in __kvm_mips_handle_exit()
1230 ++vcpu->stat.tlbmiss_st_exits; in __kvm_mips_handle_exit()
1231 ret = kvm_mips_callbacks->handle_tlb_st_miss(vcpu); in __kvm_mips_handle_exit()
1238 ++vcpu->stat.tlbmiss_ld_exits; in __kvm_mips_handle_exit()
1239 ret = kvm_mips_callbacks->handle_tlb_ld_miss(vcpu); in __kvm_mips_handle_exit()
1243 ++vcpu->stat.addrerr_st_exits; in __kvm_mips_handle_exit()
1244 ret = kvm_mips_callbacks->handle_addr_err_st(vcpu); in __kvm_mips_handle_exit()
1248 ++vcpu->stat.addrerr_ld_exits; in __kvm_mips_handle_exit()
1249 ret = kvm_mips_callbacks->handle_addr_err_ld(vcpu); in __kvm_mips_handle_exit()
1253 ++vcpu->stat.syscall_exits; in __kvm_mips_handle_exit()
1254 ret = kvm_mips_callbacks->handle_syscall(vcpu); in __kvm_mips_handle_exit()
1258 ++vcpu->stat.resvd_inst_exits; in __kvm_mips_handle_exit()
1259 ret = kvm_mips_callbacks->handle_res_inst(vcpu); in __kvm_mips_handle_exit()
1263 ++vcpu->stat.break_inst_exits; in __kvm_mips_handle_exit()
1264 ret = kvm_mips_callbacks->handle_break(vcpu); in __kvm_mips_handle_exit()
1268 ++vcpu->stat.trap_inst_exits; in __kvm_mips_handle_exit()
1269 ret = kvm_mips_callbacks->handle_trap(vcpu); in __kvm_mips_handle_exit()
1273 ++vcpu->stat.msa_fpe_exits; in __kvm_mips_handle_exit()
1274 ret = kvm_mips_callbacks->handle_msa_fpe(vcpu); in __kvm_mips_handle_exit()
1278 ++vcpu->stat.fpe_exits; in __kvm_mips_handle_exit()
1279 ret = kvm_mips_callbacks->handle_fpe(vcpu); in __kvm_mips_handle_exit()
1283 ++vcpu->stat.msa_disabled_exits; in __kvm_mips_handle_exit()
1284 ret = kvm_mips_callbacks->handle_msa_disabled(vcpu); in __kvm_mips_handle_exit()
1289 ret = kvm_mips_callbacks->handle_guest_exit(vcpu); in __kvm_mips_handle_exit()
1299 kvm_read_c0_guest_status(&vcpu->arch.cop0)); in __kvm_mips_handle_exit()
1301 run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in __kvm_mips_handle_exit()
1318 run->exit_reason = KVM_EXIT_INTR; in __kvm_mips_handle_exit()
1319 ret = (-EINTR << 2) | RESUME_HOST; in __kvm_mips_handle_exit()
1320 ++vcpu->stat.signal_exits; in __kvm_mips_handle_exit()
1330 * callback is not reordered ahead of the write to vcpu->mode, in __kvm_mips_handle_exit()
1332 * the VCPU as outside of guest mode and not needing an IPI. in __kvm_mips_handle_exit()
1334 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in __kvm_mips_handle_exit()
1336 kvm_mips_callbacks->vcpu_reenter(vcpu); in __kvm_mips_handle_exit()
1347 if (kvm_mips_guest_has_fpu(&vcpu->arch) && in __kvm_mips_handle_exit()
1349 __kvm_restore_fcsr(&vcpu->arch); in __kvm_mips_handle_exit()
1351 if (kvm_mips_guest_has_msa(&vcpu->arch) && in __kvm_mips_handle_exit()
1353 __kvm_restore_msacsr(&vcpu->arch); in __kvm_mips_handle_exit()
1372 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_own_fpu()
1381 * FR=0 FPU state, and we don't want to hit reserved instruction in kvm_own_fpu()
1386 vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) in kvm_own_fpu()
1401 if (!(vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU)) { in kvm_own_fpu()
1402 __kvm_restore_fpu(&vcpu->arch); in kvm_own_fpu()
1403 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_fpu()
1416 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_own_msa()
1425 if (kvm_mips_guest_has_fpu(&vcpu->arch)) { in kvm_own_msa()
1433 (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | in kvm_own_msa()
1448 switch (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA)) { in kvm_own_msa()
1453 __kvm_restore_msa_upper(&vcpu->arch); in kvm_own_msa()
1454 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1459 __kvm_restore_msa(&vcpu->arch); in kvm_own_msa()
1460 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1461 if (kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_own_msa()
1462 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_msa()
1479 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_drop_fpu()
1482 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_MSA; in kvm_drop_fpu()
1484 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_drop_fpu()
1487 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_drop_fpu()
1499 * This is why we explicitly re-enable the hardware before saving. in kvm_lose_fpu()
1503 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_lose_fpu()
1504 __kvm_save_msa(&vcpu->arch); in kvm_lose_fpu()
1509 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1513 vcpu->arch.aux_inuse &= ~(KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA); in kvm_lose_fpu()
1514 } else if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1515 __kvm_save_fpu(&vcpu->arch); in kvm_lose_fpu()
1516 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_lose_fpu()
1535 struct pt_regs *regs = args->regs; in kvm_mips_csr_die_notify()
1543 if (!(current->flags & PF_VCPU)) in kvm_mips_csr_die_notify()
1609 return -EOPNOTSUPP; in kvm_mips_init()