diff options
Diffstat (limited to 'sys/arm64/vmm')
| -rw-r--r-- | sys/arm64/vmm/arm64.h | 31 | ||||
| -rw-r--r-- | sys/arm64/vmm/io/vgic_v3.c | 1 | ||||
| -rw-r--r-- | sys/arm64/vmm/io/vtimer.c | 1 | ||||
| -rw-r--r-- | sys/arm64/vmm/vmm.c | 47 | ||||
| -rw-r--r-- | sys/arm64/vmm/vmm_arm64.c | 1 | ||||
| -rw-r--r-- | sys/arm64/vmm/vmm_dev_machdep.c | 43 | ||||
| -rw-r--r-- | sys/arm64/vmm/vmm_hyp.c | 1 | ||||
| -rw-r--r-- | sys/arm64/vmm/vmm_reset.c | 1 | 
8 files changed, 45 insertions, 81 deletions
| diff --git a/sys/arm64/vmm/arm64.h b/sys/arm64/vmm/arm64.h index f9b74aef7188..f530dab05331 100644 --- a/sys/arm64/vmm/arm64.h +++ b/sys/arm64/vmm/arm64.h @@ -136,37 +136,6 @@ struct hyp {  	struct hypctx	*ctx[];  }; -#define	DEFINE_VMMOPS_IFUNC(ret_type, opname, args)			\ -	ret_type vmmops_##opname args; - -DEFINE_VMMOPS_IFUNC(int, modinit, (int ipinum)) -DEFINE_VMMOPS_IFUNC(int, modcleanup, (void)) -DEFINE_VMMOPS_IFUNC(void *, init, (struct vm *vm, struct pmap *pmap)) -DEFINE_VMMOPS_IFUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging, -    uint64_t gla, int prot, uint64_t *gpa, int *is_fault)) -DEFINE_VMMOPS_IFUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap, -    struct vm_eventinfo *info)) -DEFINE_VMMOPS_IFUNC(void, cleanup, (void *vmi)) -DEFINE_VMMOPS_IFUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, -    int vcpu_id)) -DEFINE_VMMOPS_IFUNC(void, vcpu_cleanup, (void *vcpui)) -DEFINE_VMMOPS_IFUNC(int, exception, (void *vcpui, uint64_t esr, uint64_t far)) -DEFINE_VMMOPS_IFUNC(int, getreg, (void *vcpui, int num, uint64_t *retval)) -DEFINE_VMMOPS_IFUNC(int, setreg, (void *vcpui, int num, uint64_t val)) -DEFINE_VMMOPS_IFUNC(int, getcap, (void *vcpui, int num, int *retval)) -DEFINE_VMMOPS_IFUNC(int, setcap, (void *vcpui, int num, int val)) -DEFINE_VMMOPS_IFUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min, -    vm_offset_t max)) -DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace)) -#ifdef notyet -#ifdef BHYVE_SNAPSHOT -DEFINE_VMMOPS_IFUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta)) -DEFINE_VMMOPS_IFUNC(int, vcpu_snapshot, (void *vcpui, -    struct vm_snapshot_meta *meta)) -DEFINE_VMMOPS_IFUNC(int, restore_tsc, (void *vcpui, uint64_t now)) -#endif -#endif -  uint64_t	vmm_call_hyp(uint64_t, ...);  #if 0 diff --git a/sys/arm64/vmm/io/vgic_v3.c b/sys/arm64/vmm/io/vgic_v3.c index 67afb3374815..023406c64182 100644 --- a/sys/arm64/vmm/io/vgic_v3.c +++ b/sys/arm64/vmm/io/vgic_v3.c @@ -47,7 +47,6 @@  #include <dev/ofw/openfirm.h> -#include <machine/armreg.h>  #include <machine/atomic.h>  #include <machine/bus.h>  #include <machine/cpufunc.h> diff --git a/sys/arm64/vmm/io/vtimer.c b/sys/arm64/vmm/io/vtimer.c index da0f0d96c431..7c7fbb49e691 100644 --- a/sys/arm64/vmm/io/vtimer.c +++ b/sys/arm64/vmm/io/vtimer.c @@ -44,7 +44,6 @@  #include <machine/bus.h>  #include <machine/machdep.h>  #include <machine/vmm.h> -#include <machine/armreg.h>  #include <arm64/vmm/arm64.h> diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c index a551a2807183..e7b2b5d8c360 100644 --- a/sys/arm64/vmm/vmm.c +++ b/sys/arm64/vmm/vmm.c @@ -51,7 +51,6 @@  #include <vm/vm_extern.h>  #include <vm/vm_param.h> -#include <machine/armreg.h>  #include <machine/cpu.h>  #include <machine/fpu.h>  #include <machine/machdep.h> @@ -88,7 +87,6 @@ struct vcpu {  	struct vfpstate	*guestfpu;	/* (a,i) guest fpu state */  }; -#define	vcpu_lock_initialized(v) mtx_initialized(&((v)->mtx))  #define	vcpu_lock_init(v)	mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN)  #define	vcpu_lock_destroy(v)	mtx_destroy(&((v)->mtx))  #define	vcpu_lock(v)		mtx_lock_spin(&((v)->mtx)) @@ -126,7 +124,6 @@ struct vm {  	bool		dying;			/* (o) is dying */  	volatile cpuset_t suspended_cpus; 	/* (i) suspended vcpus */  	volatile cpuset_t halted_cpus;		/* (x) cpus in a hard halt */ -	struct vmspace	*vmspace;		/* (o) guest's address space */  	struct vm_mem	mem;			/* (i) guest memory */  	char		name[VM_MAX_NAMELEN];	/* (o) virtual machine name */  	struct vcpu	**vcpu;			/* (i) guest vcpus */ @@ -274,6 +271,7 @@ vcpu_cleanup(struct vcpu *vcpu, bool destroy)  		vmm_stat_free(vcpu->stats);  		fpu_save_area_free(vcpu->guestfpu);  		vcpu_lock_destroy(vcpu); +		free(vcpu, M_VMM);  	}  } @@ -407,7 +405,7 @@ vm_init(struct vm *vm, bool create)  {  	int i; -	vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace)); +	vm->cookie = vmmops_init(vm, vmspace_pmap(vm_vmspace(vm)));  	MPASS(vm->cookie != NULL);  	CPU_ZERO(&vm->active_cpus); @@ -470,9 +468,9 @@ vm_alloc_vcpu(struct vm *vm, int vcpuid)  }  void -vm_slock_vcpus(struct vm *vm) +vm_lock_vcpus(struct vm *vm)  { -	sx_slock(&vm->vcpus_init_lock); +	sx_xlock(&vm->vcpus_init_lock);  }  void @@ -485,7 +483,7 @@ int  vm_create(const char *name, struct vm **retvm)  {  	struct vm *vm; -	struct vmspace *vmspace; +	int error;  	/*  	 * If vmm.ko could not be successfully initialized then don't attempt @@ -497,14 +495,13 @@ vm_create(const char *name, struct vm **retvm)  	if (name == NULL || strlen(name) >= VM_MAX_NAMELEN)  		return (EINVAL); -	vmspace = vmmops_vmspace_alloc(0, 1ul << 39); -	if (vmspace == NULL) -		return (ENOMEM); -  	vm = malloc(sizeof(struct vm), M_VMM, M_WAITOK | M_ZERO); +	error = vm_mem_init(&vm->mem, 0, 1ul << 39); +	if (error != 0) { +		free(vm, M_VMM); +		return (error); +	}  	strcpy(vm->name, name); -	vm->vmspace = vmspace; -	vm_mem_init(&vm->mem);  	sx_init(&vm->vcpus_init_lock, "vm vcpus");  	vm->sockets = 1; @@ -558,7 +555,7 @@ vm_cleanup(struct vm *vm, bool destroy)  	if (destroy) {  		vm_xlock_memsegs(vm); -		pmap = vmspace_pmap(vm->vmspace); +		pmap = vmspace_pmap(vm_vmspace(vm));  		sched_pin();  		PCPU_SET(curvmpmap, NULL);  		sched_unpin(); @@ -582,11 +579,6 @@ vm_cleanup(struct vm *vm, bool destroy)  	if (destroy) {  		vm_mem_destroy(vm); -		vmmops_vmspace_free(vm->vmspace); -		vm->vmspace = NULL; - -		for (i = 0; i < vm->maxcpus; i++) -			free(vm->vcpu[i], M_VMM);  		free(vm->vcpu, M_VMM);  		sx_destroy(&vm->vcpus_init_lock);  	} @@ -1090,12 +1082,6 @@ vcpu_notify_event(struct vcpu *vcpu)  	vcpu_unlock(vcpu);  } -struct vmspace * -vm_vmspace(struct vm *vm) -{ -	return (vm->vmspace); -} -  struct vm_mem *  vm_mem(struct vm *vm)  { @@ -1292,8 +1278,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)); @@ -1304,7 +1289,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_PC) @@ -1416,7 +1401,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)  	vme = &vcpu->exitinfo; -	pmap = vmspace_pmap(vcpu->vm->vmspace); +	pmap = vmspace_pmap(vm_vmspace(vcpu->vm));  	addr = vme->u.paging.gpa;  	esr = vme->u.paging.esr; @@ -1433,7 +1418,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)  		panic("%s: Invalid exception (esr = %lx)", __func__, esr);  	} -	map = &vm->vmspace->vm_map; +	map = &vm_vmspace(vm)->vm_map;  	rv = vm_fault(map, vme->u.paging.gpa, ftype, VM_FAULT_NORMAL, NULL);  	if (rv != KERN_SUCCESS)  		return (EFAULT); @@ -1507,7 +1492,7 @@ vm_run(struct vcpu *vcpu)  	if (CPU_ISSET(vcpuid, &vm->suspended_cpus))  		return (EINVAL); -	pmap = vmspace_pmap(vm->vmspace); +	pmap = vmspace_pmap(vm_vmspace(vm));  	vme = &vcpu->exitinfo;  	evinfo.rptr = NULL;  	evinfo.sptr = &vm->suspend; diff --git a/sys/arm64/vmm/vmm_arm64.c b/sys/arm64/vmm/vmm_arm64.c index 618f4afaf8ee..006239431f29 100644 --- a/sys/arm64/vmm/vmm_arm64.c +++ b/sys/arm64/vmm/vmm_arm64.c @@ -47,7 +47,6 @@  #include <vm/vm_page.h>  #include <vm/vm_param.h> -#include <machine/armreg.h>  #include <machine/vm.h>  #include <machine/cpufunc.h>  #include <machine/cpu.h> diff --git a/sys/arm64/vmm/vmm_dev_machdep.c b/sys/arm64/vmm/vmm_dev_machdep.c index 926a74fa528b..29d14e1ba952 100644 --- a/sys/arm64/vmm/vmm_dev_machdep.c +++ b/sys/arm64/vmm/vmm_dev_machdep.c @@ -68,19 +68,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_vgic_version *vgv; -	struct vm_vgic_descr *vgic; -	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); @@ -94,41 +88,62 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data,  			break;  		break;  	} -	case VM_INJECT_EXCEPTION: +	case VM_INJECT_EXCEPTION: { +		struct vm_exception *vmexc; +  		vmexc = (struct vm_exception *)data;  		error = vm_inject_exception(vcpu, vmexc->esr, vmexc->far);  		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_GET_VGIC_VERSION: +	} +	case VM_GET_VGIC_VERSION: { +		struct vm_vgic_version *vgv; +  		vgv = (struct vm_vgic_version *)data;  		/* TODO: Query the vgic driver for this */  		vgv->version = 3;  		vgv->flags = 0;  		error = 0;  		break; -	case VM_ATTACH_VGIC: +	} +	case VM_ATTACH_VGIC: { +		struct vm_vgic_descr *vgic; +  		vgic = (struct vm_vgic_descr *)data;  		error = vm_attach_vgic(vm, vgic);  		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; diff --git a/sys/arm64/vmm/vmm_hyp.c b/sys/arm64/vmm/vmm_hyp.c index b8c6d2ab7a9a..0ad7930e9a87 100644 --- a/sys/arm64/vmm/vmm_hyp.c +++ b/sys/arm64/vmm/vmm_hyp.c @@ -32,7 +32,6 @@  #include <sys/types.h>  #include <sys/proc.h> -#include <machine/armreg.h>  #include "arm64.h"  #include "hyp.h" diff --git a/sys/arm64/vmm/vmm_reset.c b/sys/arm64/vmm/vmm_reset.c index 1240c3ed16ec..0e4910ea87b4 100644 --- a/sys/arm64/vmm/vmm_reset.c +++ b/sys/arm64/vmm/vmm_reset.c @@ -31,7 +31,6 @@  #include <sys/kernel.h>  #include <sys/lock.h> -#include <machine/armreg.h>  #include <machine/cpu.h>  #include <machine/hypervisor.h> | 
