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->hardware_enable(); in kvm_arch_hardware_enable()
135 kvm_mips_callbacks->hardware_disable(); in kvm_arch_hardware_disable()
159 return -EINVAL; in kvm_arch_init_vm()
162 /* Allocate page table to map GPA -> RPA */ in kvm_arch_init_vm()
163 kvm->arch.gpa_mm.pgd = kvm_pgd_alloc(); in kvm_arch_init_vm()
164 if (!kvm->arch.gpa_mm.pgd) in kvm_arch_init_vm()
165 return -ENOMEM; in kvm_arch_init_vm()
178 pgd_free(NULL, kvm->arch.gpa_mm.pgd); in kvm_mips_free_gpa_pt()
190 return -ENOIOCTLCMD; in kvm_arch_dev_ioctl()
208 spin_lock(&kvm->mmu_lock); in kvm_arch_flush_shadow_memslot()
210 kvm_mips_flush_gpa_pt(kvm, slot->base_gfn, in kvm_arch_flush_shadow_memslot()
211 slot->base_gfn + slot->npages - 1); in kvm_arch_flush_shadow_memslot()
213 spin_unlock(&kvm->mmu_lock); in kvm_arch_flush_shadow_memslot()
241 (!(old->flags & KVM_MEM_LOG_DIRTY_PAGES) && in kvm_arch_commit_memory_region()
242 new->flags & KVM_MEM_LOG_DIRTY_PAGES)) { in kvm_arch_commit_memory_region()
243 spin_lock(&kvm->mmu_lock); in kvm_arch_commit_memory_region()
245 needs_flush = kvm_mips_mkclean_gpa_pt(kvm, new->base_gfn, in kvm_arch_commit_memory_region()
246 new->base_gfn + new->npages - 1); in kvm_arch_commit_memory_region()
249 spin_unlock(&kvm->mmu_lock); in kvm_arch_commit_memory_region()
277 kvm_mips_callbacks->queue_timer_int(vcpu); in kvm_mips_comparecount_wakeup()
279 vcpu->arch.wait = 0; in kvm_mips_comparecount_wakeup()
280 rcuwait_wake_up(&vcpu->wait); in kvm_mips_comparecount_wakeup()
297 vcpu->kvm, vcpu->vcpu_id, vcpu); in kvm_arch_vcpu_create()
299 err = kvm_mips_callbacks->vcpu_init(vcpu); in kvm_arch_vcpu_create()
303 hrtimer_init(&vcpu->arch.comparecount_timer, CLOCK_MONOTONIC, in kvm_arch_vcpu_create()
305 vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup; in kvm_arch_vcpu_create()
319 err = -ENOMEM; in kvm_arch_vcpu_create()
333 err = -ENOMEM; in kvm_arch_vcpu_create()
338 vcpu->arch.guest_ebase = gebase; in kvm_arch_vcpu_create()
340 /* Build guest exception vectors dynamically in unmapped memory */ in kvm_arch_vcpu_create()
343 /* TLB refill (or XTLB refill on 64-bit VZ where KX=1) */ in kvm_arch_vcpu_create()
352 /* For vectored interrupts poke the exception code @ all offsets 0-7 */ in kvm_arch_vcpu_create()
365 vcpu->arch.vcpu_run = p; in kvm_arch_vcpu_create()
372 dump_handler("kvm_vcpu_run", vcpu->arch.vcpu_run, p); in kvm_arch_vcpu_create()
375 dump_handler("kvm_exit", gebase + 0x2000, vcpu->arch.vcpu_run); in kvm_arch_vcpu_create()
382 vcpu->arch.last_sched_cpu = -1; in kvm_arch_vcpu_create()
383 vcpu->arch.last_exec_cpu = -1; in kvm_arch_vcpu_create()
386 err = kvm_mips_callbacks->vcpu_setup(vcpu); in kvm_arch_vcpu_create()
395 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_create()
401 hrtimer_cancel(&vcpu->arch.comparecount_timer); in kvm_arch_vcpu_destroy()
406 kfree(vcpu->arch.guest_ebase); in kvm_arch_vcpu_destroy()
408 kvm_mips_callbacks->vcpu_uninit(vcpu); in kvm_arch_vcpu_destroy()
414 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_guest_debug()
429 ret = kvm_mips_callbacks->vcpu_run(vcpu); in kvm_mips_vcpu_enter_exit()
437 int r = -EINTR; in kvm_arch_vcpu_ioctl_run()
443 if (vcpu->mmio_needed) { in kvm_arch_vcpu_ioctl_run()
444 if (!vcpu->mmio_is_write) in kvm_arch_vcpu_ioctl_run()
446 vcpu->mmio_needed = 0; in kvm_arch_vcpu_ioctl_run()
449 if (vcpu->run->immediate_exit) in kvm_arch_vcpu_ioctl_run()
460 * reordered ahead of the write to vcpu->mode, or we could miss a TLB in kvm_arch_vcpu_ioctl_run()
462 * mode and not needing an IPI. in kvm_arch_vcpu_ioctl_run()
464 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in kvm_arch_vcpu_ioctl_run()
495 int intr = (int)irq->irq; in kvm_vcpu_ioctl_interrupt()
500 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_1]) || in kvm_vcpu_ioctl_interrupt()
501 intr == (-kvm_priority_to_irq[MIPS_EXC_INT_IPI_2])) in kvm_vcpu_ioctl_interrupt()
502 kvm_debug("%s: CPU: %d, INTR: %d\n", __func__, irq->cpu, in kvm_vcpu_ioctl_interrupt()
505 if (irq->cpu == -1) in kvm_vcpu_ioctl_interrupt()
508 dvcpu = kvm_get_vcpu(vcpu->kvm, irq->cpu); in kvm_vcpu_ioctl_interrupt()
511 kvm_mips_callbacks->queue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
513 } else if (intr == -2 || intr == -3 || intr == -4 || intr == -6) { in kvm_vcpu_ioctl_interrupt()
514 kvm_mips_callbacks->dequeue_io_int(dvcpu, irq); in kvm_vcpu_ioctl_interrupt()
517 irq->cpu, irq->irq); in kvm_vcpu_ioctl_interrupt()
518 return -EINVAL; in kvm_vcpu_ioctl_interrupt()
521 dvcpu->arch.wait = 0; in kvm_vcpu_ioctl_interrupt()
523 rcuwait_wake_up(&dvcpu->wait); in kvm_vcpu_ioctl_interrupt()
531 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_get_mpstate()
537 return -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl_set_mpstate()
596 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_num_regs()
602 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) in kvm_mips_num_regs()
604 ret += kvm_mips_callbacks->num_regs(vcpu); in kvm_mips_num_regs()
616 return -EFAULT; in kvm_mips_copy_reg_indices()
619 if (kvm_mips_guest_can_have_fpu(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
622 return -EFAULT; in kvm_mips_copy_reg_indices()
628 return -EFAULT; in kvm_mips_copy_reg_indices()
637 return -EFAULT; in kvm_mips_copy_reg_indices()
642 if (kvm_mips_guest_can_have_msa(&vcpu->arch)) { in kvm_mips_copy_reg_indices()
645 return -EFAULT; in kvm_mips_copy_reg_indices()
651 return -EFAULT; in kvm_mips_copy_reg_indices()
656 return kvm_mips_callbacks->copy_reg_indices(vcpu, indices); in kvm_mips_copy_reg_indices()
662 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_get_reg()
663 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_get_reg()
669 switch (reg->id) { in kvm_mips_get_reg()
672 v = (long)vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0]; in kvm_mips_get_reg()
676 v = (long)vcpu->arch.hi; in kvm_mips_get_reg()
679 v = (long)vcpu->arch.lo; in kvm_mips_get_reg()
683 v = (long)vcpu->arch.pc; in kvm_mips_get_reg()
688 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
689 return -EINVAL; in kvm_mips_get_reg()
690 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_get_reg()
693 v = get_fpr32(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
695 v = get_fpr32(&fpu->fpr[idx & ~1], idx & 1); in kvm_mips_get_reg()
698 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
699 return -EINVAL; in kvm_mips_get_reg()
700 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_get_reg()
703 return -EINVAL; in kvm_mips_get_reg()
704 v = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
707 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_get_reg()
708 return -EINVAL; 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()
714 v = fpu->fcr31; in kvm_mips_get_reg()
719 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
720 return -EINVAL; in kvm_mips_get_reg()
723 return -EINVAL; in kvm_mips_get_reg()
724 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_get_reg()
727 vs[0] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
728 vs[1] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
731 vs[0] = get_fpr64(&fpu->fpr[idx], 1); in kvm_mips_get_reg()
732 vs[1] = get_fpr64(&fpu->fpr[idx], 0); in kvm_mips_get_reg()
736 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_get_reg()
737 return -EINVAL; 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()
743 v = fpu->msacsr; in kvm_mips_get_reg()
748 ret = kvm_mips_callbacks->get_one_reg(vcpu, reg, &v); in kvm_mips_get_reg()
753 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_get_reg()
754 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_get_reg()
757 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_get_reg()
758 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_get_reg()
762 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_get_reg()
763 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_get_reg()
765 return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0; in kvm_mips_get_reg()
767 return -EINVAL; in kvm_mips_get_reg()
774 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_mips_set_reg()
775 struct mips_fpu_struct *fpu = &vcpu->arch.fpu; in kvm_mips_set_reg()
780 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) { in kvm_mips_set_reg()
781 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr; in kvm_mips_set_reg()
784 return -EFAULT; in kvm_mips_set_reg()
785 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) { in kvm_mips_set_reg()
786 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr; in kvm_mips_set_reg()
790 return -EFAULT; in kvm_mips_set_reg()
792 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) { in kvm_mips_set_reg()
793 void __user *uaddr = (void __user *)(long)reg->addr; in kvm_mips_set_reg()
795 return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0; in kvm_mips_set_reg()
797 return -EINVAL; in kvm_mips_set_reg()
800 switch (reg->id) { in kvm_mips_set_reg()
806 vcpu->arch.gprs[reg->id - KVM_REG_MIPS_R0] = v; in kvm_mips_set_reg()
810 vcpu->arch.hi = v; in kvm_mips_set_reg()
813 vcpu->arch.lo = v; in kvm_mips_set_reg()
817 vcpu->arch.pc = v; in kvm_mips_set_reg()
822 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
823 return -EINVAL; in kvm_mips_set_reg()
824 idx = reg->id - KVM_REG_MIPS_FPR_32(0); in kvm_mips_set_reg()
827 set_fpr32(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
829 set_fpr32(&fpu->fpr[idx & ~1], idx & 1, v); in kvm_mips_set_reg()
832 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
833 return -EINVAL; in kvm_mips_set_reg()
834 idx = reg->id - KVM_REG_MIPS_FPR_64(0); in kvm_mips_set_reg()
837 return -EINVAL; in kvm_mips_set_reg()
838 set_fpr64(&fpu->fpr[idx], 0, v); in kvm_mips_set_reg()
841 if (!kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_mips_set_reg()
842 return -EINVAL; in kvm_mips_set_reg()
843 /* Read-only */ 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 fpu->fcr31 = v; in kvm_mips_set_reg()
853 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
854 return -EINVAL; in kvm_mips_set_reg()
855 idx = reg->id - KVM_REG_MIPS_VEC_128(0); in kvm_mips_set_reg()
858 set_fpr64(&fpu->fpr[idx], 0, vs[0]); in kvm_mips_set_reg()
859 set_fpr64(&fpu->fpr[idx], 1, vs[1]); in kvm_mips_set_reg()
862 set_fpr64(&fpu->fpr[idx], 1, vs[0]); in kvm_mips_set_reg()
863 set_fpr64(&fpu->fpr[idx], 0, vs[1]); in kvm_mips_set_reg()
867 if (!kvm_mips_guest_has_msa(&vcpu->arch)) in kvm_mips_set_reg()
868 return -EINVAL; in kvm_mips_set_reg()
869 /* Read-only */ 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 fpu->msacsr = v; in kvm_mips_set_reg()
879 return kvm_mips_callbacks->set_one_reg(vcpu, reg, v); in kvm_mips_set_reg()
889 if (!kvm_vm_ioctl_check_extension(vcpu->kvm, cap->cap)) in kvm_vcpu_ioctl_enable_cap()
890 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
891 if (cap->flags) in kvm_vcpu_ioctl_enable_cap()
892 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
893 if (cap->args[0]) in kvm_vcpu_ioctl_enable_cap()
894 return -EINVAL; in kvm_vcpu_ioctl_enable_cap()
896 switch (cap->cap) { in kvm_vcpu_ioctl_enable_cap()
898 vcpu->arch.fpu_enabled = true; in kvm_vcpu_ioctl_enable_cap()
901 vcpu->arch.msa_enabled = true; in kvm_vcpu_ioctl_enable_cap()
904 r = -EINVAL; in kvm_vcpu_ioctl_enable_cap()
914 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_async_ioctl()
921 return -EFAULT; in kvm_arch_vcpu_async_ioctl()
922 kvm_debug("[%d] %s: irq: %d\n", vcpu->vcpu_id, __func__, in kvm_arch_vcpu_async_ioctl()
928 return -ENOIOCTLCMD; in kvm_arch_vcpu_async_ioctl()
934 struct kvm_vcpu *vcpu = filp->private_data; in kvm_arch_vcpu_ioctl()
945 r = -EFAULT; in kvm_arch_vcpu_ioctl()
959 r = -EFAULT; in kvm_arch_vcpu_ioctl()
966 r = -E2BIG; in kvm_arch_vcpu_ioctl()
969 r = kvm_mips_copy_reg_indices(vcpu, user_list->reg); in kvm_arch_vcpu_ioctl()
975 r = -EFAULT; in kvm_arch_vcpu_ioctl()
982 r = -ENOIOCTLCMD; in kvm_arch_vcpu_ioctl()
996 kvm_mips_callbacks->prepare_flush_shadow(kvm); in kvm_arch_flush_remote_tlb()
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()
1216 run->exit_reason = KVM_EXIT_UNKNOWN; in __kvm_mips_handle_exit()
1217 run->ready_for_interrupt_injection = 1; in __kvm_mips_handle_exit()
1233 kvm_debug("[%d]EXCCODE_INT @ %p\n", vcpu->vcpu_id, opc); in __kvm_mips_handle_exit()
1235 ++vcpu->stat.int_exits; in __kvm_mips_handle_exit()
1246 ++vcpu->stat.cop_unusable_exits; in __kvm_mips_handle_exit()
1247 ret = kvm_mips_callbacks->handle_cop_unusable(vcpu); in __kvm_mips_handle_exit()
1249 if (run->exit_reason == KVM_EXIT_IRQ_WINDOW_OPEN) in __kvm_mips_handle_exit()
1254 ++vcpu->stat.tlbmod_exits; in __kvm_mips_handle_exit()
1255 ret = kvm_mips_callbacks->handle_tlb_mod(vcpu); in __kvm_mips_handle_exit()
1260 cause, kvm_read_c0_guest_status(vcpu->arch.cop0), opc, in __kvm_mips_handle_exit()
1263 ++vcpu->stat.tlbmiss_st_exits; in __kvm_mips_handle_exit()
1264 ret = kvm_mips_callbacks->handle_tlb_st_miss(vcpu); in __kvm_mips_handle_exit()
1271 ++vcpu->stat.tlbmiss_ld_exits; in __kvm_mips_handle_exit()
1272 ret = kvm_mips_callbacks->handle_tlb_ld_miss(vcpu); in __kvm_mips_handle_exit()
1276 ++vcpu->stat.addrerr_st_exits; in __kvm_mips_handle_exit()
1277 ret = kvm_mips_callbacks->handle_addr_err_st(vcpu); in __kvm_mips_handle_exit()
1281 ++vcpu->stat.addrerr_ld_exits; in __kvm_mips_handle_exit()
1282 ret = kvm_mips_callbacks->handle_addr_err_ld(vcpu); in __kvm_mips_handle_exit()
1286 ++vcpu->stat.syscall_exits; in __kvm_mips_handle_exit()
1287 ret = kvm_mips_callbacks->handle_syscall(vcpu); in __kvm_mips_handle_exit()
1291 ++vcpu->stat.resvd_inst_exits; in __kvm_mips_handle_exit()
1292 ret = kvm_mips_callbacks->handle_res_inst(vcpu); in __kvm_mips_handle_exit()
1296 ++vcpu->stat.break_inst_exits; in __kvm_mips_handle_exit()
1297 ret = kvm_mips_callbacks->handle_break(vcpu); in __kvm_mips_handle_exit()
1301 ++vcpu->stat.trap_inst_exits; in __kvm_mips_handle_exit()
1302 ret = kvm_mips_callbacks->handle_trap(vcpu); in __kvm_mips_handle_exit()
1306 ++vcpu->stat.msa_fpe_exits; in __kvm_mips_handle_exit()
1307 ret = kvm_mips_callbacks->handle_msa_fpe(vcpu); in __kvm_mips_handle_exit()
1311 ++vcpu->stat.fpe_exits; in __kvm_mips_handle_exit()
1312 ret = kvm_mips_callbacks->handle_fpe(vcpu); in __kvm_mips_handle_exit()
1316 ++vcpu->stat.msa_disabled_exits; in __kvm_mips_handle_exit()
1317 ret = kvm_mips_callbacks->handle_msa_disabled(vcpu); in __kvm_mips_handle_exit()
1322 ret = kvm_mips_callbacks->handle_guest_exit(vcpu); in __kvm_mips_handle_exit()
1332 kvm_read_c0_guest_status(vcpu->arch.cop0)); in __kvm_mips_handle_exit()
1334 run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in __kvm_mips_handle_exit()
1351 run->exit_reason = KVM_EXIT_INTR; in __kvm_mips_handle_exit()
1352 ret = (-EINTR << 2) | RESUME_HOST; in __kvm_mips_handle_exit()
1353 ++vcpu->stat.signal_exits; in __kvm_mips_handle_exit()
1363 * callback is not reordered ahead of the write to vcpu->mode, in __kvm_mips_handle_exit()
1365 * the VCPU as outside of guest mode and not needing an IPI. in __kvm_mips_handle_exit()
1367 smp_store_mb(vcpu->mode, IN_GUEST_MODE); in __kvm_mips_handle_exit()
1369 kvm_mips_callbacks->vcpu_reenter(vcpu); in __kvm_mips_handle_exit()
1380 if (kvm_mips_guest_has_fpu(&vcpu->arch) && in __kvm_mips_handle_exit()
1382 __kvm_restore_fcsr(&vcpu->arch); in __kvm_mips_handle_exit()
1384 if (kvm_mips_guest_has_msa(&vcpu->arch) && in __kvm_mips_handle_exit()
1386 __kvm_restore_msacsr(&vcpu->arch); in __kvm_mips_handle_exit()
1405 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_own_fpu()
1414 * FR=0 FPU state, and we don't want to hit reserved instruction in kvm_own_fpu()
1419 vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) in kvm_own_fpu()
1434 if (!(vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU)) { in kvm_own_fpu()
1435 __kvm_restore_fpu(&vcpu->arch); in kvm_own_fpu()
1436 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_fpu()
1449 struct mips_coproc *cop0 = vcpu->arch.cop0; in kvm_own_msa()
1458 if (kvm_mips_guest_has_fpu(&vcpu->arch)) { in kvm_own_msa()
1466 (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | in kvm_own_msa()
1481 switch (vcpu->arch.aux_inuse & (KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA)) { in kvm_own_msa()
1486 __kvm_restore_msa_upper(&vcpu->arch); in kvm_own_msa()
1487 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1492 __kvm_restore_msa(&vcpu->arch); in kvm_own_msa()
1493 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_MSA; in kvm_own_msa()
1494 if (kvm_mips_guest_has_fpu(&vcpu->arch)) in kvm_own_msa()
1495 vcpu->arch.aux_inuse |= KVM_MIPS_AUX_FPU; in kvm_own_msa()
1512 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_drop_fpu()
1515 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_MSA; in kvm_drop_fpu()
1517 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_drop_fpu()
1520 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_drop_fpu()
1532 * This is why we explicitly re-enable the hardware before saving. in kvm_lose_fpu()
1536 if (cpu_has_msa && vcpu->arch.aux_inuse & KVM_MIPS_AUX_MSA) { in kvm_lose_fpu()
1537 __kvm_save_msa(&vcpu->arch); in kvm_lose_fpu()
1542 if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1546 vcpu->arch.aux_inuse &= ~(KVM_MIPS_AUX_FPU | KVM_MIPS_AUX_MSA); in kvm_lose_fpu()
1547 } else if (vcpu->arch.aux_inuse & KVM_MIPS_AUX_FPU) { in kvm_lose_fpu()
1548 __kvm_save_fpu(&vcpu->arch); in kvm_lose_fpu()
1549 vcpu->arch.aux_inuse &= ~KVM_MIPS_AUX_FPU; in kvm_lose_fpu()
1568 struct pt_regs *regs = args->regs; in kvm_mips_csr_die_notify()
1576 if (!(current->flags & PF_VCPU)) in kvm_mips_csr_die_notify()
1642 return -EOPNOTSUPP; in kvm_mips_init()