diff options
Diffstat (limited to 'sys/riscv/vmm')
| -rw-r--r-- | sys/riscv/vmm/vmm.c | 9 | ||||
| -rw-r--r-- | sys/riscv/vmm/vmm_aplic.c | 10 | ||||
| -rw-r--r-- | sys/riscv/vmm/vmm_aplic.h | 1 | ||||
| -rw-r--r-- | sys/riscv/vmm/vmm_dev_machdep.c | 37 |
4 files changed, 27 insertions, 30 deletions
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c index 4c9b1fa53f7a..a9eb9d144336 100644 --- a/sys/riscv/vmm/vmm.c +++ b/sys/riscv/vmm/vmm.c @@ -319,10 +319,6 @@ vm_alloc_vcpu(struct vm *vm, int vcpuid) if (vcpuid < 0 || vcpuid >= vm_get_maxcpus(vm)) return (NULL); - /* Some interrupt controllers may have a CPU limit */ - if (vcpuid >= aplic_max_cpu_count(vm->cookie)) - return (NULL); - vcpu = (struct vcpu *) atomic_load_acq_ptr((uintptr_t *)&vm->vcpu[vcpuid]); if (__predict_true(vcpu != NULL)) @@ -954,8 +950,7 @@ vcpu_get_state(struct vcpu *vcpu, int *hostcpu) int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval) { - - if (reg >= VM_REG_LAST) + if (reg < 0 || reg >= VM_REG_LAST) return (EINVAL); return (vmmops_getreg(vcpu->cookie, reg, retval)); @@ -966,7 +961,7 @@ vm_set_register(struct vcpu *vcpu, int reg, uint64_t val) { int error; - if (reg >= VM_REG_LAST) + if (reg < 0 || reg >= VM_REG_LAST) return (EINVAL); error = vmmops_setreg(vcpu->cookie, reg, val); if (error || reg != VM_REG_GUEST_SEPC) diff --git a/sys/riscv/vmm/vmm_aplic.c b/sys/riscv/vmm/vmm_aplic.c index 4df41f2de1a5..74cb4fef4273 100644 --- a/sys/riscv/vmm/vmm_aplic.c +++ b/sys/riscv/vmm/vmm_aplic.c @@ -577,13 +577,3 @@ aplic_sync_hwstate(struct hypctx *hypctx) { } - -int -aplic_max_cpu_count(struct hyp *hyp) -{ - int16_t max_count; - - max_count = vm_get_maxcpus(hyp->vm); - - return (max_count); -} diff --git a/sys/riscv/vmm/vmm_aplic.h b/sys/riscv/vmm/vmm_aplic.h index 49510221b419..96018fe9adda 100644 --- a/sys/riscv/vmm/vmm_aplic.h +++ b/sys/riscv/vmm/vmm_aplic.h @@ -49,6 +49,5 @@ void aplic_cpuinit(struct hypctx *hypctx); void aplic_cpucleanup(struct hypctx *hypctx); void aplic_flush_hwstate(struct hypctx *hypctx); void aplic_sync_hwstate(struct hypctx *hypctx); -int aplic_max_cpu_count(struct hyp *hyp); #endif /* !_VMM_APLIC_H_ */ diff --git a/sys/riscv/vmm/vmm_dev_machdep.c b/sys/riscv/vmm/vmm_dev_machdep.c index ba15d8dcd79e..c736b10dc9c0 100644 --- a/sys/riscv/vmm/vmm_dev_machdep.c +++ b/sys/riscv/vmm/vmm_dev_machdep.c @@ -67,18 +67,13 @@ int vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, int fflag, struct thread *td) { - struct vm_run *vmrun; - struct vm_aplic_descr *aplic; - struct vm_irq *vi; - struct vm_exception *vmexc; - struct vm_gla2gpa *gg; - struct vm_msi *vmsi; int error; error = 0; switch (cmd) { case VM_RUN: { struct vm_exit *vme; + struct vm_run *vmrun; vmrun = (struct vm_run *)data; vme = vm_exitinfo(vcpu); @@ -90,34 +85,52 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, error = copyout(vme, vmrun->vm_exit, sizeof(*vme)); break; } - case VM_INJECT_EXCEPTION: + case VM_INJECT_EXCEPTION: { + struct vm_exception *vmexc; + vmexc = (struct vm_exception *)data; error = vm_inject_exception(vcpu, vmexc->scause); break; - case VM_GLA2GPA_NOFAULT: + } + case VM_GLA2GPA_NOFAULT: { + struct vm_gla2gpa *gg; + gg = (struct vm_gla2gpa *)data; error = vm_gla2gpa_nofault(vcpu, &gg->paging, gg->gla, gg->prot, &gg->gpa, &gg->fault); KASSERT(error == 0 || error == EFAULT, ("%s: vm_gla2gpa unknown error %d", __func__, error)); break; - case VM_ATTACH_APLIC: + } + case VM_ATTACH_APLIC: { + struct vm_aplic_descr *aplic; + aplic = (struct vm_aplic_descr *)data; error = vm_attach_aplic(vm, aplic); break; - case VM_RAISE_MSI: + } + case VM_RAISE_MSI: { + struct vm_msi *vmsi; + vmsi = (struct vm_msi *)data; error = vm_raise_msi(vm, vmsi->msg, vmsi->addr, vmsi->bus, vmsi->slot, vmsi->func); break; - case VM_ASSERT_IRQ: + } + case VM_ASSERT_IRQ: { + struct vm_irq *vi; + vi = (struct vm_irq *)data; error = vm_assert_irq(vm, vi->irq); break; - case VM_DEASSERT_IRQ: + } + case VM_DEASSERT_IRQ: { + struct vm_irq *vi; + vi = (struct vm_irq *)data; error = vm_deassert_irq(vm, vi->irq); break; + } default: error = ENOTTY; break; |
