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

8  * Copyright (C) 2012  MIPS Technologies, Inc.  All rights reserved.
102 return !!(vcpu->arch.pending_exceptions); in kvm_arch_vcpu_runnable()
117 return kvm_mips_callbacks->hardware_enable(); in kvm_arch_hardware_enable()
122 kvm_mips_callbacks->hardware_disable(); in kvm_arch_hardware_disable()
150 return -EINVAL; in kvm_arch_init_vm()
153 /* Allocate page table to map GPA -> RPA */ in kvm_arch_init_vm()
154 kvm->arch.gpa_mm.pgd = kvm_pgd_alloc(); in kvm_arch_init_vm()
155 if (!kvm->arch.gpa_mm.pgd) in kvm_arch_init_vm()
156 return -ENOMEM; in kvm_arch_init_vm()
174 mutex_lock(&kvm->lock); in kvm_mips_free_vcpus()
176 for (i = 0; i < atomic_read(&kvm->online_vcpus); i++) in kvm_mips_free_vcpus()
177 kvm->vcpus[i] = NULL; in kvm_mips_free_vcpus()
179 atomic_set(&kvm->online_vcpus, 0); in kvm_mips_free_vcpus()
181 mutex_unlock(&kvm->lock); in kvm_mips_free_vcpus()
188 pgd_free(NULL, kvm->arch.gpa_mm.pgd); in kvm_mips_free_gpa_pt()
200 return -ENOIOCTLCMD; in kvm_arch_dev_ioctl()
209 kvm_mips_callbacks->flush_shadow_all(kvm); in kvm_arch_flush_shadow_all()
220 spin_lock(&kvm->mmu_lock); in kvm_arch_flush_shadow_memslot()
222 kvm_mips_flush_gpa_pt(kvm, slot->base_gfn, in kvm_arch_flush_shadow_memslot()
223 slot->base_gfn + slot->npages - 1); in kvm_arch_flush_shadow_memslot()
225 kvm_mips_callbacks->flush_shadow_memslot(kvm, slot); in kvm_arch_flush_shadow_memslot()
226 spin_unlock(&kvm->mmu_lock); in kvm_arch_flush_shadow_memslot()
246 __func__, kvm, mem->slot, mem->guest_phys_addr, in kvm_arch_commit_memory_region()
247 mem->memory_size, mem->userspace_addr); in kvm_arch_commit_memory_region()
259 (!(old->flags & KVM_MEM_LOG_DIRTY_PAGES) && in kvm_arch_commit_memory_region()
260 new->flags & KVM_MEM_LOG_DIRTY_PAGES)) { in kvm_arch_commit_memory_region()
261 spin_lock(&kvm->mmu_lock); in kvm_arch_commit_memory_region()
263 needs_flush = kvm_mips_mkclean_gpa_pt(kvm, new->base_gfn, in kvm_arch_commit_memory_region()
264 new->base_gfn + new->npages - 1); in kvm_arch_commit_memory_region()
267 kvm_mips_callbacks->flush_shadow_memslot(kvm, new); in kvm_arch_commit_memory_region()
268 spin_unlock(&kvm->mmu_lock); in kvm_arch_commit_memory_region()
296 kvm_mips_callbacks->queue_timer_int(vcpu); in kvm_mips_comparecount_wakeup()
298 vcpu->arch.wait = 0; in kvm_mips_comparecount_wakeup()
299 rcuwait_wake_up(&vcpu->wait); in kvm_mips_comparecount_wakeup()
316 vcpu->kvm, vcpu->vcpu_id, vcpu); in kvm_arch_vcpu_create()
318 err = kvm_mips_callbacks->vcpu_init(vcpu); in kvm_arch_vcpu_create()
322 hrtimer_init(&vcpu->arch.comparecount_timer, CLOCK_MONOTONIC, in kvm_arch_vcpu_create()
324 vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup; in kvm_arch_vcpu_create()
338 err = -ENOMEM; in kvm_arch_vcpu_create()
352 err = -ENOMEM; in kvm_arch_vcpu_create()
357 vcpu->arch.guest_ebase = gebase; in kvm_arch_vcpu_create()
359 /* Build guest exception vectors dynamically in unmapped memory */ in kvm_arch_vcpu_create()
362 /* TLB refill (or XTLB refill on 64-bit VZ where KX=1) */ in kvm_arch_vcpu_create()
371 /* For vectored interrupts poke the exception code @ all offsets 0-7 */ in kvm_arch_vcpu_create()
384 vcpu->arch.vcpu_run = p; in kvm_arch_vcpu_create()
391 dump_handler("kvm_vcpu_run", vcpu->arch.vcpu_run, p); in kvm_arch_vcpu_create()
394 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run); in kvm_arch_vcpu_create()
401 * Allocate comm page for guest kernel, a TLB will be reserved for in kvm_arch_vcpu_create()
404 vcpu->arch.kseg0_commpage = kzalloc(PAGE_SIZE << 1, GFP_KERNEL); in kvm_arch_vcpu_create()
406 if (!vcpu->arch.kseg0_commpage) { in kvm_arch_vcpu_create()
407 err = -ENOMEM; in kvm_arch_vcpu_create()
411 kvm_debug("Allocated COMM page @ %p\n", vcpu->arch.kseg0_commpage); in kvm_arch_vcpu_create()
415 vcpu->arch.last_sched_cpu = -1; in kvm_arch_vcpu_create()
416 vcpu->arch.last_exec_cpu = -1; in kvm_arch_vcpu_create()
419 err = kvm_mips_callbacks->vcpu_setup(vcpu); in kvm_arch_vcpu_create()
426 kfree(vcpu->arch.kseg0_commpage); in kvm_arch_vcpu_create()
430 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_create()
436 hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_arch_vcpu_destroy()
441 kfree(vcpu->arch.guest_ebase); in kvm_arch_vcpu_destroy()
442 kfree(vcpu->arch.kseg0_commpage); in kvm_arch_vcpu_destroy()
444 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_destroy()
450 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_guest_debug()
455 int r = -EINTR; in kvm_arch_vcpu_ioctl_run()
461 if (vcpu->mmio_needed) { in kvm_arch_vcpu_ioctl_run()
462 if (!vcpu->mmio_is_write) in kvm_arch_vcpu_ioctl_run()
464 vcpu->mmio_needed = 0; in kvm_arch_vcpu_ioctl_run()
467 if (vcpu->run->immediate_exit) in kvm_arch_vcpu_ioctl_run()
478 * reordered ahead of the write to vcpu->mode, or we could miss a TLB in kvm_arch_vcpu_ioctl_run()
480 * mode and not needing an IPI. in kvm_arch_vcpu_ioctl_run()
482 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in kvm_arch_vcpu_ioctl_run()
484 r = kvm_mips_callbacks->vcpu_run(vcpu); in kvm_arch_vcpu_ioctl_run()
500 int intr = (int)irq->irq; in kvm_vcpu_ioctl_interrupt()
505 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_1]) || in kvm_vcpu_ioctl_interrupt()
506 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_2])) in kvm_vcpu_ioctl_interrupt()
507 kvm_debug("%s: CPU: %d, INTR: %d\n", __func__, irq->cpu, in kvm_vcpu_ioctl_interrupt()
510 if (irq->cpu == -1) in kvm_vcpu_ioctl_interrupt()
513 dvcpu = vcpu->kvm->vcpus[irq->cpu]; in kvm_vcpu_ioctl_interrupt()
516 kvm_mips_callbacks->queue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
518 } else if (intr == -2 || intr == -3 || intr == -4 || intr == -6) { in kvm_vcpu_ioctl_interrupt()
519 kvm_mips_callbacks->dequeue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
522 irq->cpu, irq->irq); in kvm_vcpu_ioctl_interrupt()
523 return -EINVAL; in kvm_vcpu_ioctl_interrupt()
526 dvcpu->arch.wait = 0; in kvm_vcpu_ioctl_interrupt()
528 rcuwait_wake_up(&dvcpu->wait); in kvm_vcpu_ioctl_interrupt()
536 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_mpstate()
542 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_mpstate()
601 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_num_regs()
607 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) in kvm_mips_num_regs()
609 ret += kvm_mips_callbacks->num_regs(vcpu); in kvm_mips_num_regs()
621 return -EFAULT; in kvm_mips_copy_reg_indices()
624 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
627 return -EFAULT; in kvm_mips_copy_reg_indices()
633 return -EFAULT; in kvm_mips_copy_reg_indices()
642 return -EFAULT; in kvm_mips_copy_reg_indices()
647 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
650 return -EFAULT; in kvm_mips_copy_reg_indices()
656 return -EFAULT; in kvm_mips_copy_reg_indices()
661 return kvm_mips_callbacks->copy_reg_indices(vcpu, indices); in kvm_mips_copy_reg_indices()
667 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_get_reg()
668 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_get_reg()
674 switch (reg->id) { in kvm_mips_get_reg()
677 v = (long)vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0]; in kvm_mips_get_reg()
681 v = (long)vcpu->arch.hi; in kvm_mips_get_reg()
684 v = (long)vcpu->arch.lo; in kvm_mips_get_reg()
688 v = (long)vcpu->arch.pc; in kvm_mips_get_reg()
693 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
694 return -EINVAL; in kvm_mips_get_reg()
695 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_get_reg()
698 v = get_fpr32(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
700 v = get_fpr32(&fpu->fpr[idx & ~1], idx & 1); in kvm_mips_get_reg()
703 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
704 return -EINVAL; in kvm_mips_get_reg()
705 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_get_reg()
708 return -EINVAL; in kvm_mips_get_reg()
709 v = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
712 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
713 return -EINVAL; in kvm_mips_get_reg()
717 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
718 return -EINVAL; in kvm_mips_get_reg()
719 v = fpu->fcr31; 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()
728 return -EINVAL; in kvm_mips_get_reg()
729 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_get_reg()
732 vs[0] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
733 vs[1] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
736 vs[0] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
737 vs[1] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
741 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
742 return -EINVAL; in kvm_mips_get_reg()
746 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
747 return -EINVAL; in kvm_mips_get_reg()
748 v = fpu->msacsr; in kvm_mips_get_reg()
753 ret = kvm_mips_callbacks->get_one_reg(vcpu, reg, &v); in kvm_mips_get_reg()
758 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_get_reg()
759 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_get_reg()
762 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_get_reg()
763 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_get_reg()
767 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_get_reg()
768 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_get_reg()
770 return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0; in kvm_mips_get_reg()
772 return -EINVAL; in kvm_mips_get_reg()
779 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_set_reg()
780 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_set_reg()
785 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_set_reg()
786 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_set_reg()
789 return -EFAULT; in kvm_mips_set_reg()
790 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_set_reg()
791 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_set_reg()
795 return -EFAULT; in kvm_mips_set_reg()
797 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_set_reg()
798 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_set_reg()
800 return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0; in kvm_mips_set_reg()
802 return -EINVAL; in kvm_mips_set_reg()
805 switch (reg->id) { in kvm_mips_set_reg()
811 vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0] = v; in kvm_mips_set_reg()
815 vcpu->arch.hi = v; in kvm_mips_set_reg()
818 vcpu->arch.lo = v; in kvm_mips_set_reg()
822 vcpu->arch.pc = v; in kvm_mips_set_reg()
827 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
828 return -EINVAL; in kvm_mips_set_reg()
829 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_set_reg()
832 set_fpr32(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
834 set_fpr32(&fpu->fpr[idx & ~1], idx & 1, v); in kvm_mips_set_reg()
837 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
838 return -EINVAL; in kvm_mips_set_reg()
839 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_set_reg()
842 return -EINVAL; in kvm_mips_set_reg()
843 set_fpr64(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
846 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
847 return -EINVAL; in kvm_mips_set_reg()
848 /* Read-only */ in kvm_mips_set_reg()
851 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
852 return -EINVAL; in kvm_mips_set_reg()
853 fpu->fcr31 = v; in kvm_mips_set_reg()
858 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
859 return -EINVAL; in kvm_mips_set_reg()
860 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_set_reg()
863 set_fpr64(&fpu->fpr[idx], 0, vs[0]); in kvm_mips_set_reg()
864 set_fpr64(&fpu->fpr[idx], 1, vs[1]); in kvm_mips_set_reg()
867 set_fpr64(&fpu->fpr[idx], 1, vs[0]); in kvm_mips_set_reg()
868 set_fpr64(&fpu->fpr[idx], 0, vs[1]); in kvm_mips_set_reg()
872 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
873 return -EINVAL; in kvm_mips_set_reg()
874 /* Read-only */ in kvm_mips_set_reg()
877 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
878 return -EINVAL; in kvm_mips_set_reg()
879 fpu->msacsr = v; in kvm_mips_set_reg()
884 return kvm_mips_callbacks->set_one_reg(vcpu, reg, v); in kvm_mips_set_reg()
894 if (!kvm_vm_ioctl_check_extension(vcpu->kvm, cap->cap)) in kvm_vcpu_ioctl_enable_cap()
895 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
896 if (cap->flags) in kvm_vcpu_ioctl_enable_cap()
897 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
898 if (cap->args[0]) in kvm_vcpu_ioctl_enable_cap()
899 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
901 switch (cap->cap) { in kvm_vcpu_ioctl_enable_cap()
903 vcpu->arch.fpu_enabled = true; in kvm_vcpu_ioctl_enable_cap()
906 vcpu->arch.msa_enabled = true; in kvm_vcpu_ioctl_enable_cap()
909 r = -EINVAL; in kvm_vcpu_ioctl_enable_cap()
919 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_async_ioctl()
926 return -EFAULT; in kvm_arch_vcpu_async_ioctl()
927 kvm_debug("[%d] %s: irq: %d\n", vcpu->vcpu_id, __func__, in kvm_arch_vcpu_async_ioctl()
933 return -ENOIOCTLCMD; in kvm_arch_vcpu_async_ioctl()
939 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_ioctl()
950 r = -EFAULT; in kvm_arch_vcpu_ioctl()
964 r = -EFAULT; in kvm_arch_vcpu_ioctl()
971 r = -E2BIG; in kvm_arch_vcpu_ioctl()
974 r = kvm_mips_copy_reg_indices(vcpu, user_list->reg); in kvm_arch_vcpu_ioctl()
980 r = -EFAULT; in kvm_arch_vcpu_ioctl()
987 r = -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl()
1003 kvm_mips_callbacks->flush_shadow_memslot(kvm, memslot); in kvm_arch_flush_remote_tlbs_memslot()
1012 r = -ENOIOCTLCMD; in kvm_arch_vm_ioctl()
1022 return -EEXIST; in kvm_arch_init()
1036 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_sregs()
1042 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_sregs()
1051 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_fpu()
1056 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_fpu()
1105 r = kvm_mips_callbacks->check_extension(kvm, ext); in kvm_vm_ioctl_check_extension()
1114 kvm_read_c0_guest_cause(vcpu->arch.cop0) & C_TI; in kvm_cpu_has_pending_timer()
1123 return -1; in kvm_arch_vcpu_dump_regs()
1126 kvm_debug("\tpc = 0x%08lx\n", vcpu->arch.pc); in kvm_arch_vcpu_dump_regs()
1127 kvm_debug("\texceptions: %08lx\n", vcpu->arch.pending_exceptions); in kvm_arch_vcpu_dump_regs()
1131 vcpu->arch.gprs[i], in kvm_arch_vcpu_dump_regs()
1132 vcpu->arch.gprs[i + 1], in kvm_arch_vcpu_dump_regs()
1133 vcpu->arch.gprs[i + 2], vcpu->arch.gprs[i + 3]); in kvm_arch_vcpu_dump_regs()
1135 kvm_debug("\thi: 0x%08lx\n", vcpu->arch.hi); in kvm_arch_vcpu_dump_regs()
1136 kvm_debug("\tlo: 0x%08lx\n", vcpu->arch.lo); in kvm_arch_vcpu_dump_regs()
1138 cop0 = vcpu->arch.cop0; in kvm_arch_vcpu_dump_regs()
1154 for (i = 1; i < ARRAY_SIZE(vcpu->arch.gprs); i++) in kvm_arch_vcpu_ioctl_set_regs()
1155 vcpu->arch.gprs[i] = regs->gpr[i]; in kvm_arch_vcpu_ioctl_set_regs()
1156 vcpu->arch.gprs[0] = 0; /* zero is special, and cannot be set. */ in kvm_arch_vcpu_ioctl_set_regs()
1157 vcpu->arch.hi = regs->hi; in kvm_arch_vcpu_ioctl_set_regs()
1158 vcpu->arch.lo = regs->lo; in kvm_arch_vcpu_ioctl_set_regs()
1159 vcpu->arch.pc = regs->pc; in kvm_arch_vcpu_ioctl_set_regs()
1171 for (i = 0; i < ARRAY_SIZE(vcpu->arch.gprs); i++) in kvm_arch_vcpu_ioctl_get_regs()
1172 regs->gpr[i] = vcpu->arch.gprs[i]; in kvm_arch_vcpu_ioctl_get_regs()
1174 regs->hi = vcpu->arch.hi; in kvm_arch_vcpu_ioctl_get_regs()
1175 regs->lo = vcpu->arch.lo; in kvm_arch_vcpu_ioctl_get_regs()
1176 regs->pc = vcpu->arch.pc; in kvm_arch_vcpu_ioctl_get_regs()
1204 struct kvm_run *run = vcpu->run; in kvm_mips_handle_exit()
1205 u32 cause = vcpu->arch.host_cp0_cause; in kvm_mips_handle_exit()
1207 u32 __user *opc = (u32 __user *) vcpu->arch.pc; in kvm_mips_handle_exit()
1208 unsigned long badvaddr = vcpu->arch.host_cp0_badvaddr; in kvm_mips_handle_exit()
1213 vcpu->mode = OUTSIDE_GUEST_MODE; in kvm_mips_handle_exit()
1215 /* re-enable HTW before enabling interrupts */ in kvm_mips_handle_exit()
1220 run->exit_reason = KVM_EXIT_UNKNOWN; in kvm_mips_handle_exit()
1221 run->ready_for_interrupt_injection = 1; in kvm_mips_handle_exit()
1245 run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in kvm_mips_handle_exit()
1253 kvm_debug("[%d]EXCCODE_INT @ %p\n", vcpu->vcpu_id, opc); in kvm_mips_handle_exit()
1255 ++vcpu->stat.int_exits; in kvm_mips_handle_exit()
1266 ++vcpu->stat.cop_unusable_exits; in kvm_mips_handle_exit()
1267 ret = kvm_mips_callbacks->handle_cop_unusable(vcpu); in kvm_mips_handle_exit()
1269 if (run->exit_reason == KVM_EXIT_IRQ_WINDOW_OPEN) in kvm_mips_handle_exit()
1274 ++vcpu->stat.tlbmod_exits; in kvm_mips_handle_exit()
1275 ret = kvm_mips_callbacks->handle_tlb_mod(vcpu); in kvm_mips_handle_exit()
1280 cause, kvm_read_c0_guest_status(vcpu->arch.cop0), opc, in kvm_mips_handle_exit()
1283 ++vcpu->stat.tlbmiss_st_exits; in kvm_mips_handle_exit()
1284 ret = kvm_mips_callbacks->handle_tlb_st_miss(vcpu); in kvm_mips_handle_exit()
1291 ++vcpu->stat.tlbmiss_ld_exits; in kvm_mips_handle_exit()
1292 ret = kvm_mips_callbacks->handle_tlb_ld_miss(vcpu); in kvm_mips_handle_exit()
1296 ++vcpu->stat.addrerr_st_exits; in kvm_mips_handle_exit()
1297 ret = kvm_mips_callbacks->handle_addr_err_st(vcpu); in kvm_mips_handle_exit()
1301 ++vcpu->stat.addrerr_ld_exits; in kvm_mips_handle_exit()
1302 ret = kvm_mips_callbacks->handle_addr_err_ld(vcpu); in kvm_mips_handle_exit()
1306 ++vcpu->stat.syscall_exits; in kvm_mips_handle_exit()
1307 ret = kvm_mips_callbacks->handle_syscall(vcpu); in kvm_mips_handle_exit()
1311 ++vcpu->stat.resvd_inst_exits; in kvm_mips_handle_exit()
1312 ret = kvm_mips_callbacks->handle_res_inst(vcpu); in kvm_mips_handle_exit()
1316 ++vcpu->stat.break_inst_exits; in kvm_mips_handle_exit()
1317 ret = kvm_mips_callbacks->handle_break(vcpu); in kvm_mips_handle_exit()
1321 ++vcpu->stat.trap_inst_exits; in kvm_mips_handle_exit()
1322 ret = kvm_mips_callbacks->handle_trap(vcpu); in kvm_mips_handle_exit()
1326 ++vcpu->stat.msa_fpe_exits; in kvm_mips_handle_exit()
1327 ret = kvm_mips_callbacks->handle_msa_fpe(vcpu); in kvm_mips_handle_exit()
1331 ++vcpu->stat.fpe_exits; in kvm_mips_handle_exit()
1332 ret = kvm_mips_callbacks->handle_fpe(vcpu); in kvm_mips_handle_exit()
1336 ++vcpu->stat.msa_disabled_exits; in kvm_mips_handle_exit()
1337 ret = kvm_mips_callbacks->handle_msa_disabled(vcpu); in kvm_mips_handle_exit()
1342 ret = kvm_mips_callbacks->handle_guest_exit(vcpu); in kvm_mips_handle_exit()
1352 kvm_read_c0_guest_status(vcpu->arch.cop0)); in kvm_mips_handle_exit()
1354 run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in kvm_mips_handle_exit()
1372 run->exit_reason = KVM_EXIT_INTR; in kvm_mips_handle_exit()
1373 ret = (-EINTR << 2) | RESUME_HOST; in kvm_mips_handle_exit()
1374 ++vcpu->stat.signal_exits; in kvm_mips_handle_exit()
1384 * callback is not reordered ahead of the write to vcpu->mode, in kvm_mips_handle_exit()
1386 * the VCPU as outside of guest mode and not needing an IPI. in kvm_mips_handle_exit()
1388 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in kvm_mips_handle_exit()
1390 kvm_mips_callbacks->vcpu_reenter(vcpu); in kvm_mips_handle_exit()
1401 if (kvm_mips_guest_has_fpu(&vcpu->arch) && in kvm_mips_handle_exit()
1403 __kvm_restore_fcsr(&vcpu->arch); in kvm_mips_handle_exit()
1405 if (kvm_mips_guest_has_msa(&vcpu->arch) && in kvm_mips_handle_exit()
1407 __kvm_restore_msacsr(&vcpu->arch); in kvm_mips_handle_exit()
1420 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_own_fpu()
1429 * FR=0 FPU state, and we don't want to hit reserved instruction in kvm_own_fpu()
1438 vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) in kvm_own_fpu()
1453 if (!(vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU)) { in kvm_own_fpu()
1454 __kvm_restore_fpu(&vcpu->arch); in kvm_own_fpu()
1455 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_fpu()
1468 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_own_msa()
1477 if (kvm_mips_guest_has_fpu(&vcpu->arch)) { in kvm_own_msa()
1485 (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | in kvm_own_msa()
1500 switch (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA)) { in kvm_own_msa()
1505 __kvm_restore_msa_upper(&vcpu->arch); in kvm_own_msa()
1506 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1511 __kvm_restore_msa(&vcpu->arch); in kvm_own_msa()
1512 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1513 if (kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_own_msa()
1514 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_msa()
1531 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_drop_fpu()
1534 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_MSA; in kvm_drop_fpu()
1536 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_drop_fpu()
1539 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_drop_fpu()
1551 * This is why we explicitly re-enable the hardware before saving. in kvm_lose_fpu()
1555 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_lose_fpu()
1561 __kvm_save_msa(&vcpu->arch); in kvm_lose_fpu()
1566 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1570 vcpu->arch.aux_inuse &= ~(KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA); in kvm_lose_fpu()
1571 } else if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1577 __kvm_save_fpu(&vcpu->arch); in kvm_lose_fpu()
1578 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_lose_fpu()
1597 struct pt_regs *regs = args->regs; in kvm_mips_csr_die_notify()
1605 if (!(current->flags & PF_VCPU)) in kvm_mips_csr_die_notify()
1671 return -EOPNOTSUPP; in kvm_mips_init()