Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/vmm.c
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | |||||
SYSCTL_INT(_hw_vmm, OID_AUTO, ipinum, CTLFLAG_RD, &vmm_ipinum, 0, | SYSCTL_INT(_hw_vmm, OID_AUTO, ipinum, CTLFLAG_RD, &vmm_ipinum, 0, | ||||
"IPI vector used for vcpu notifications"); | "IPI vector used for vcpu notifications"); | ||||
static int trace_guest_exceptions; | static int trace_guest_exceptions; | ||||
SYSCTL_INT(_hw_vmm, OID_AUTO, trace_guest_exceptions, CTLFLAG_RDTUN, | SYSCTL_INT(_hw_vmm, OID_AUTO, trace_guest_exceptions, CTLFLAG_RDTUN, | ||||
&trace_guest_exceptions, 0, | &trace_guest_exceptions, 0, | ||||
"Trap into hypervisor on all guest exceptions and reflect them back"); | "Trap into hypervisor on all guest exceptions and reflect them back"); | ||||
static int vmm_force_iommu = 0; | |||||
TUNABLE_INT("hw.vmm.force_iommu", &vmm_force_iommu); | |||||
SYSCTL_INT(_hw_vmm, OID_AUTO, force_iommu, CTLFLAG_RDTUN, &vmm_force_iommu, 0, | |||||
"Force use of I/O MMU even if no passthrough devices were found."); | |||||
static void vm_free_memmap(struct vm *vm, int ident); | static void vm_free_memmap(struct vm *vm, int ident); | ||||
static bool sysmem_mapping(struct vm *vm, struct mem_map *mm); | static bool sysmem_mapping(struct vm *vm, struct mem_map *mm); | ||||
static void vcpu_notify_event_locked(struct vcpu *vcpu, bool lapic_intr); | static void vcpu_notify_event_locked(struct vcpu *vcpu, bool lapic_intr); | ||||
#ifdef KTR | #ifdef KTR | ||||
static const char * | static const char * | ||||
vcpu_state2str(enum vcpu_state state) | vcpu_state2str(enum vcpu_state state) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
vmm_handler(module_t mod, int what, void *arg) | vmm_handler(module_t mod, int what, void *arg) | ||||
{ | { | ||||
int error; | int error; | ||||
switch (what) { | switch (what) { | ||||
case MOD_LOAD: | case MOD_LOAD: | ||||
vmmdev_init(); | vmmdev_init(); | ||||
if (vmm_force_iommu || ppt_avail_devices() > 0) | |||||
iommu_init(); | |||||
error = vmm_init(); | error = vmm_init(); | ||||
if (error == 0) | if (error == 0) | ||||
vmm_initialized = 1; | vmm_initialized = 1; | ||||
break; | break; | ||||
case MOD_UNLOAD: | case MOD_UNLOAD: | ||||
error = vmmdev_cleanup(); | error = vmmdev_cleanup(); | ||||
if (error == 0) { | if (error == 0) { | ||||
vmm_resume_p = NULL; | vmm_resume_p = NULL; | ||||
Show All 20 Lines | static moduledata_t vmm_kmod = { | ||||
"vmm", | "vmm", | ||||
vmm_handler, | vmm_handler, | ||||
NULL | NULL | ||||
}; | }; | ||||
/* | /* | ||||
* vmm initialization has the following dependencies: | * vmm initialization has the following dependencies: | ||||
* | * | ||||
* - iommu initialization must happen after the pci passthru driver has had | |||||
* a chance to attach to any passthru devices (after SI_SUB_CONFIGURE). | |||||
* | |||||
* - VT-x initialization requires smp_rendezvous() and therefore must happen | * - VT-x initialization requires smp_rendezvous() and therefore must happen | ||||
* after SMP is fully functional (after SI_SUB_SMP). | * after SMP is fully functional (after SI_SUB_SMP). | ||||
*/ | */ | ||||
DECLARE_MODULE(vmm, vmm_kmod, SI_SUB_SMP + 1, SI_ORDER_ANY); | DECLARE_MODULE(vmm, vmm_kmod, SI_SUB_SMP + 1, SI_ORDER_ANY); | ||||
MODULE_VERSION(vmm, 1); | MODULE_VERSION(vmm, 1); | ||||
static void | static void | ||||
vm_init(struct vm *vm, bool create) | vm_init(struct vm *vm, bool create) | ||||
▲ Show 20 Lines • Show All 478 Lines • ▼ Show 20 Lines | vm_assign_pptdev(struct vm *vm, int bus, int slot, int func) | ||||
vm_paddr_t maxaddr; | vm_paddr_t maxaddr; | ||||
/* Set up the IOMMU to do the 'gpa' to 'hpa' translation */ | /* Set up the IOMMU to do the 'gpa' to 'hpa' translation */ | ||||
if (ppt_assigned_devices(vm) == 0) { | if (ppt_assigned_devices(vm) == 0) { | ||||
KASSERT(vm->iommu == NULL, | KASSERT(vm->iommu == NULL, | ||||
("vm_assign_pptdev: iommu must be NULL")); | ("vm_assign_pptdev: iommu must be NULL")); | ||||
maxaddr = sysmem_maxaddr(vm); | maxaddr = sysmem_maxaddr(vm); | ||||
vm->iommu = iommu_create_domain(maxaddr); | vm->iommu = iommu_create_domain(maxaddr); | ||||
if (vm->iommu == NULL) | |||||
return (ENXIO); | |||||
vm_iommu_map(vm); | vm_iommu_map(vm); | ||||
} | } | ||||
error = ppt_assign_device(vm, bus, slot, func); | error = ppt_assign_device(vm, bus, slot, func); | ||||
return (error); | return (error); | ||||
} | } | ||||
void * | void * | ||||
▲ Show 20 Lines • Show All 1,695 Lines • Show Last 20 Lines |