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_setup(&vcpu->arch.comparecount_timer, kvm_mips_comparecount_wakeup, CLOCK_MONOTONIC, in kvm_arch_vcpu_create()
306 err = -ENOMEM; in kvm_arch_vcpu_create()
320 err = -ENOMEM; in kvm_arch_vcpu_create()
325 vcpu->arch.guest_ebase = gebase; in kvm_arch_vcpu_create()
327 /* Build guest exception vectors dynamically in unmapped memory */ in kvm_arch_vcpu_create()
330 /* TLB refill (or XTLB refill on 64-bit VZ where KX=1) */ in kvm_arch_vcpu_create()
339 /* For vectored interrupts poke the exception code @ all offsets 0-7 */ in kvm_arch_vcpu_create()
352 vcpu->arch.vcpu_run = p; in kvm_arch_vcpu_create()
359 dump_handler("kvm_vcpu_run", vcpu->arch.vcpu_run, p); in kvm_arch_vcpu_create()
362 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run); in kvm_arch_vcpu_create()
369 vcpu->arch.last_sched_cpu = -1; in kvm_arch_vcpu_create()
370 vcpu->arch.last_exec_cpu = -1; in kvm_arch_vcpu_create()
373 err = kvm_mips_callbacks->vcpu_setup(vcpu); in kvm_arch_vcpu_create()
382 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_create()
388 hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_arch_vcpu_destroy()
393 kfree(vcpu->arch.guest_ebase); in kvm_arch_vcpu_destroy()
395 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_destroy()
401 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_guest_debug()
416 ret = kvm_mips_callbacks->vcpu_run(vcpu); in kvm_mips_vcpu_enter_exit()
424 int r = -EINTR; in kvm_arch_vcpu_ioctl_run()
430 if (vcpu->mmio_needed) { in kvm_arch_vcpu_ioctl_run()
431 if (!vcpu->mmio_is_write) in kvm_arch_vcpu_ioctl_run()
433 vcpu->mmio_needed = 0; in kvm_arch_vcpu_ioctl_run()
436 if (!vcpu->wants_to_run) in kvm_arch_vcpu_ioctl_run()
447 * reordered ahead of the write to vcpu->mode, or we could miss a TLB in kvm_arch_vcpu_ioctl_run()
449 * mode and not needing an IPI. in kvm_arch_vcpu_ioctl_run()
451 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in kvm_arch_vcpu_ioctl_run()
482 int intr = (int)irq->irq; in kvm_vcpu_ioctl_interrupt()
487 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_1]) || in kvm_vcpu_ioctl_interrupt()
488 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_2])) in kvm_vcpu_ioctl_interrupt()
489 kvm_debug("%s: CPU: %d, INTR: %d\n", __func__, irq->cpu, in kvm_vcpu_ioctl_interrupt()
492 if (irq->cpu == -1) in kvm_vcpu_ioctl_interrupt()
495 dvcpu = kvm_get_vcpu(vcpu->kvm, irq->cpu); in kvm_vcpu_ioctl_interrupt()
498 kvm_mips_callbacks->queue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
500 } else if (intr == -2 || intr == -3 || intr == -4 || intr == -6) { in kvm_vcpu_ioctl_interrupt()
501 kvm_mips_callbacks->dequeue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
504 irq->cpu, irq->irq); in kvm_vcpu_ioctl_interrupt()
505 return -EINVAL; in kvm_vcpu_ioctl_interrupt()
508 dvcpu->arch.wait = 0; in kvm_vcpu_ioctl_interrupt()
510 rcuwait_wake_up(&dvcpu->wait); in kvm_vcpu_ioctl_interrupt()
518 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_mpstate()
524 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_mpstate()
583 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_num_regs()
589 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) in kvm_mips_num_regs()
591 ret += kvm_mips_callbacks->num_regs(vcpu); in kvm_mips_num_regs()
603 return -EFAULT; in kvm_mips_copy_reg_indices()
606 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
609 return -EFAULT; in kvm_mips_copy_reg_indices()
615 return -EFAULT; in kvm_mips_copy_reg_indices()
624 return -EFAULT; in kvm_mips_copy_reg_indices()
629 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
632 return -EFAULT; in kvm_mips_copy_reg_indices()
638 return -EFAULT; in kvm_mips_copy_reg_indices()
643 return kvm_mips_callbacks->copy_reg_indices(vcpu, indices); in kvm_mips_copy_reg_indices()
649 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_mips_get_reg()
650 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_get_reg()
656 switch (reg->id) { in kvm_mips_get_reg()
659 v = (long)vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0]; in kvm_mips_get_reg()
663 v = (long)vcpu->arch.hi; in kvm_mips_get_reg()
666 v = (long)vcpu->arch.lo; in kvm_mips_get_reg()
670 v = (long)vcpu->arch.pc; in kvm_mips_get_reg()
675 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
676 return -EINVAL; in kvm_mips_get_reg()
677 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_get_reg()
680 v = get_fpr32(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
682 v = get_fpr32(&fpu->fpr[idx & ~1], idx & 1); in kvm_mips_get_reg()
685 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
686 return -EINVAL; in kvm_mips_get_reg()
687 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_get_reg()
690 return -EINVAL; in kvm_mips_get_reg()
691 v = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
694 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
695 return -EINVAL; in kvm_mips_get_reg()
699 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
700 return -EINVAL; in kvm_mips_get_reg()
701 v = fpu->fcr31; in kvm_mips_get_reg()
706 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
707 return -EINVAL; in kvm_mips_get_reg()
710 return -EINVAL; in kvm_mips_get_reg()
711 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_get_reg()
714 vs[0] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
715 vs[1] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
718 vs[0] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
719 vs[1] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
723 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
724 return -EINVAL; in kvm_mips_get_reg()
728 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
729 return -EINVAL; in kvm_mips_get_reg()
730 v = fpu->msacsr; in kvm_mips_get_reg()
735 ret = kvm_mips_callbacks->get_one_reg(vcpu, reg, &v); in kvm_mips_get_reg()
740 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_get_reg()
741 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_get_reg()
744 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_get_reg()
745 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_get_reg()
749 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_get_reg()
750 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_get_reg()
752 return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0; in kvm_mips_get_reg()
754 return -EINVAL; in kvm_mips_get_reg()
761 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_mips_set_reg()
762 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_set_reg()
767 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_set_reg()
768 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_set_reg()
771 return -EFAULT; in kvm_mips_set_reg()
772 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_set_reg()
773 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_set_reg()
777 return -EFAULT; in kvm_mips_set_reg()
779 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_set_reg()
780 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_set_reg()
782 return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0; in kvm_mips_set_reg()
784 return -EINVAL; in kvm_mips_set_reg()
787 switch (reg->id) { in kvm_mips_set_reg()
793 vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0] = v; in kvm_mips_set_reg()
797 vcpu->arch.hi = v; in kvm_mips_set_reg()
800 vcpu->arch.lo = v; in kvm_mips_set_reg()
804 vcpu->arch.pc = v; in kvm_mips_set_reg()
809 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
810 return -EINVAL; in kvm_mips_set_reg()
811 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_set_reg()
814 set_fpr32(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
816 set_fpr32(&fpu->fpr[idx & ~1], idx & 1, v); in kvm_mips_set_reg()
819 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
820 return -EINVAL; in kvm_mips_set_reg()
821 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_set_reg()
824 return -EINVAL; in kvm_mips_set_reg()
825 set_fpr64(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
828 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
829 return -EINVAL; in kvm_mips_set_reg()
830 /* Read-only */ in kvm_mips_set_reg()
833 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
834 return -EINVAL; in kvm_mips_set_reg()
835 fpu->fcr31 = v; in kvm_mips_set_reg()
840 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
841 return -EINVAL; in kvm_mips_set_reg()
842 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_set_reg()
845 set_fpr64(&fpu->fpr[idx], 0, vs[0]); in kvm_mips_set_reg()
846 set_fpr64(&fpu->fpr[idx], 1, vs[1]); in kvm_mips_set_reg()
849 set_fpr64(&fpu->fpr[idx], 1, vs[0]); in kvm_mips_set_reg()
850 set_fpr64(&fpu->fpr[idx], 0, vs[1]); in kvm_mips_set_reg()
854 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
855 return -EINVAL; in kvm_mips_set_reg()
856 /* Read-only */ in kvm_mips_set_reg()
859 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
860 return -EINVAL; in kvm_mips_set_reg()
861 fpu->msacsr = v; in kvm_mips_set_reg()
866 return kvm_mips_callbacks->set_one_reg(vcpu, reg, v); in kvm_mips_set_reg()
876 if (!kvm_vm_ioctl_check_extension(vcpu->kvm, cap->cap)) in kvm_vcpu_ioctl_enable_cap()
877 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
878 if (cap->flags) in kvm_vcpu_ioctl_enable_cap()
879 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
880 if (cap->args[0]) in kvm_vcpu_ioctl_enable_cap()
881 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
883 switch (cap->cap) { in kvm_vcpu_ioctl_enable_cap()
885 vcpu->arch.fpu_enabled = true; in kvm_vcpu_ioctl_enable_cap()
888 vcpu->arch.msa_enabled = true; in kvm_vcpu_ioctl_enable_cap()
891 r = -EINVAL; in kvm_vcpu_ioctl_enable_cap()
901 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_async_ioctl()
908 return -EFAULT; in kvm_arch_vcpu_async_ioctl()
909 kvm_debug("[%d] %s: irq: %d\n", vcpu->vcpu_id, __func__, in kvm_arch_vcpu_async_ioctl()
915 return -ENOIOCTLCMD; in kvm_arch_vcpu_async_ioctl()
921 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_ioctl()
932 r = -EFAULT; in kvm_arch_vcpu_ioctl()
946 r = -EFAULT; in kvm_arch_vcpu_ioctl()
953 r = -E2BIG; in kvm_arch_vcpu_ioctl()
956 r = kvm_mips_copy_reg_indices(vcpu, user_list->reg); in kvm_arch_vcpu_ioctl()
962 r = -EFAULT; in kvm_arch_vcpu_ioctl()
969 r = -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl()
983 kvm_mips_callbacks->prepare_flush_shadow(kvm); in kvm_arch_flush_remote_tlbs()
993 r = -ENOIOCTLCMD; in kvm_arch_vm_ioctl()
1002 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_sregs()
1008 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_sregs()
1017 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_fpu()
1022 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_fpu()
1071 r = kvm_mips_callbacks->check_extension(kvm, ext); in kvm_vm_ioctl_check_extension()
1080 kvm_read_c0_guest_cause(&vcpu->arch.cop0) & C_TI; in kvm_cpu_has_pending_timer()
1089 return -1; in kvm_arch_vcpu_dump_regs()
1092 kvm_debug("\tpc = 0x%08lx\n", vcpu->arch.pc); in kvm_arch_vcpu_dump_regs()
1093 kvm_debug("\texceptions: %08lx\n", vcpu->arch.pending_exceptions); in kvm_arch_vcpu_dump_regs()
1097 vcpu->arch.gprs[i], in kvm_arch_vcpu_dump_regs()
1098 vcpu->arch.gprs[i + 1], in kvm_arch_vcpu_dump_regs()
1099 vcpu->arch.gprs[i + 2], vcpu->arch.gprs[i + 3]); in kvm_arch_vcpu_dump_regs()
1101 kvm_debug("\thi: 0x%08lx\n", vcpu->arch.hi); in kvm_arch_vcpu_dump_regs()
1102 kvm_debug("\tlo: 0x%08lx\n", vcpu->arch.lo); in kvm_arch_vcpu_dump_regs()
1104 cop0 = &vcpu->arch.cop0; in kvm_arch_vcpu_dump_regs()
1120 for (i = 1; i < ARRAY_SIZE(vcpu->arch.gprs); i++) in kvm_arch_vcpu_ioctl_set_regs()
1121 vcpu->arch.gprs[i] = regs->gpr[i]; in kvm_arch_vcpu_ioctl_set_regs()
1122 vcpu->arch.gprs[0] = 0; /* zero is special, and cannot be set. */ in kvm_arch_vcpu_ioctl_set_regs()
1123 vcpu->arch.hi = regs->hi; in kvm_arch_vcpu_ioctl_set_regs()
1124 vcpu->arch.lo = regs->lo; in kvm_arch_vcpu_ioctl_set_regs()
1125 vcpu->arch.pc = regs->pc; in kvm_arch_vcpu_ioctl_set_regs()
1137 for (i = 0; i < ARRAY_SIZE(vcpu->arch.gprs); i++) in kvm_arch_vcpu_ioctl_get_regs()
1138 regs->gpr[i] = vcpu->arch.gprs[i]; in kvm_arch_vcpu_ioctl_get_regs()
1140 regs->hi = vcpu->arch.hi; in kvm_arch_vcpu_ioctl_get_regs()
1141 regs->lo = vcpu->arch.lo; in kvm_arch_vcpu_ioctl_get_regs()
1142 regs->pc = vcpu->arch.pc; in kvm_arch_vcpu_ioctl_get_regs()
1170 struct kvm_run *run = vcpu->run; in __kvm_mips_handle_exit()
1171 u32 cause = vcpu->arch.host_cp0_cause; in __kvm_mips_handle_exit()
1173 u32 __user *opc = (u32 __user *) vcpu->arch.pc; in __kvm_mips_handle_exit()
1174 unsigned long badvaddr = vcpu->arch.host_cp0_badvaddr; in __kvm_mips_handle_exit()
1179 vcpu->mode = OUTSIDE_GUEST_MODE; in __kvm_mips_handle_exit()
1182 run->exit_reason = KVM_EXIT_UNKNOWN; in __kvm_mips_handle_exit()
1183 run->ready_for_interrupt_injection = 1; in __kvm_mips_handle_exit()
1199 kvm_debug("[%d]EXCCODE_INT @ %p\n", vcpu->vcpu_id, opc); in __kvm_mips_handle_exit()
1201 ++vcpu->stat.int_exits; in __kvm_mips_handle_exit()
1212 ++vcpu->stat.cop_unusable_exits; in __kvm_mips_handle_exit()
1213 ret = kvm_mips_callbacks->handle_cop_unusable(vcpu); in __kvm_mips_handle_exit()
1215 if (run->exit_reason == KVM_EXIT_IRQ_WINDOW_OPEN) in __kvm_mips_handle_exit()
1220 ++vcpu->stat.tlbmod_exits; in __kvm_mips_handle_exit()
1221 ret = kvm_mips_callbacks->handle_tlb_mod(vcpu); in __kvm_mips_handle_exit()
1226 cause, kvm_read_c0_guest_status(&vcpu->arch.cop0), opc, in __kvm_mips_handle_exit()
1229 ++vcpu->stat.tlbmiss_st_exits; in __kvm_mips_handle_exit()
1230 ret = kvm_mips_callbacks->handle_tlb_st_miss(vcpu); in __kvm_mips_handle_exit()
1237 ++vcpu->stat.tlbmiss_ld_exits; in __kvm_mips_handle_exit()
1238 ret = kvm_mips_callbacks->handle_tlb_ld_miss(vcpu); in __kvm_mips_handle_exit()
1242 ++vcpu->stat.addrerr_st_exits; in __kvm_mips_handle_exit()
1243 ret = kvm_mips_callbacks->handle_addr_err_st(vcpu); in __kvm_mips_handle_exit()
1247 ++vcpu->stat.addrerr_ld_exits; in __kvm_mips_handle_exit()
1248 ret = kvm_mips_callbacks->handle_addr_err_ld(vcpu); in __kvm_mips_handle_exit()
1252 ++vcpu->stat.syscall_exits; in __kvm_mips_handle_exit()
1253 ret = kvm_mips_callbacks->handle_syscall(vcpu); in __kvm_mips_handle_exit()
1257 ++vcpu->stat.resvd_inst_exits; in __kvm_mips_handle_exit()
1258 ret = kvm_mips_callbacks->handle_res_inst(vcpu); in __kvm_mips_handle_exit()
1262 ++vcpu->stat.break_inst_exits; in __kvm_mips_handle_exit()
1263 ret = kvm_mips_callbacks->handle_break(vcpu); in __kvm_mips_handle_exit()
1267 ++vcpu->stat.trap_inst_exits; in __kvm_mips_handle_exit()
1268 ret = kvm_mips_callbacks->handle_trap(vcpu); in __kvm_mips_handle_exit()
1272 ++vcpu->stat.msa_fpe_exits; in __kvm_mips_handle_exit()
1273 ret = kvm_mips_callbacks->handle_msa_fpe(vcpu); in __kvm_mips_handle_exit()
1277 ++vcpu->stat.fpe_exits; in __kvm_mips_handle_exit()
1278 ret = kvm_mips_callbacks->handle_fpe(vcpu); in __kvm_mips_handle_exit()
1282 ++vcpu->stat.msa_disabled_exits; in __kvm_mips_handle_exit()
1283 ret = kvm_mips_callbacks->handle_msa_disabled(vcpu); in __kvm_mips_handle_exit()
1288 ret = kvm_mips_callbacks->handle_guest_exit(vcpu); in __kvm_mips_handle_exit()
1298 kvm_read_c0_guest_status(&vcpu->arch.cop0)); in __kvm_mips_handle_exit()
1300 run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in __kvm_mips_handle_exit()
1317 run->exit_reason = KVM_EXIT_INTR; in __kvm_mips_handle_exit()
1318 ret = (-EINTR << 2) | RESUME_HOST; in __kvm_mips_handle_exit()
1319 ++vcpu->stat.signal_exits; in __kvm_mips_handle_exit()
1329 * callback is not reordered ahead of the write to vcpu->mode, in __kvm_mips_handle_exit()
1331 * the VCPU as outside of guest mode and not needing an IPI. in __kvm_mips_handle_exit()
1333 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in __kvm_mips_handle_exit()
1335 kvm_mips_callbacks->vcpu_reenter(vcpu); in __kvm_mips_handle_exit()
1346 if (kvm_mips_guest_has_fpu(&vcpu->arch) && in __kvm_mips_handle_exit()
1348 __kvm_restore_fcsr(&vcpu->arch); in __kvm_mips_handle_exit()
1350 if (kvm_mips_guest_has_msa(&vcpu->arch) && in __kvm_mips_handle_exit()
1352 __kvm_restore_msacsr(&vcpu->arch); in __kvm_mips_handle_exit()
1371 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_own_fpu()
1380 * FR=0 FPU state, and we don't want to hit reserved instruction in kvm_own_fpu()
1385 vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) in kvm_own_fpu()
1400 if (!(vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU)) { in kvm_own_fpu()
1401 __kvm_restore_fpu(&vcpu->arch); in kvm_own_fpu()
1402 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_fpu()
1415 struct mips_coproc *cop0 = &vcpu->arch.cop0; in kvm_own_msa()
1424 if (kvm_mips_guest_has_fpu(&vcpu->arch)) { in kvm_own_msa()
1432 (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | in kvm_own_msa()
1447 switch (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA)) { in kvm_own_msa()
1452 __kvm_restore_msa_upper(&vcpu->arch); in kvm_own_msa()
1453 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1458 __kvm_restore_msa(&vcpu->arch); in kvm_own_msa()
1459 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1460 if (kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_own_msa()
1461 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_msa()
1478 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_drop_fpu()
1481 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_MSA; in kvm_drop_fpu()
1483 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_drop_fpu()
1486 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_drop_fpu()
1498 * This is why we explicitly re-enable the hardware before saving. in kvm_lose_fpu()
1502 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_lose_fpu()
1503 __kvm_save_msa(&vcpu->arch); in kvm_lose_fpu()
1508 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1512 vcpu->arch.aux_inuse &= ~(KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA); in kvm_lose_fpu()
1513 } else if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1514 __kvm_save_fpu(&vcpu->arch); in kvm_lose_fpu()
1515 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_lose_fpu()
1534 struct pt_regs *regs = args->regs; in kvm_mips_csr_die_notify()
1542 if (!(current->flags & PF_VCPU)) in kvm_mips_csr_die_notify()
1608 return -EOPNOTSUPP; in kvm_mips_init()