From 0f1ef0ec808ab037d1e7be6d8f3dbab8f1131f2f Mon Sep 17 00:00:00 2001 From: Neel Natu Date: Wed, 11 Sep 2013 07:11:14 +0000 Subject: [PATCH] Fix a limitation in bhyve that would limit the number of virtual machines to the maximum number of VT-d domains (256 on a Sandybridge). We now allocate a VT-d domain for a guest only if the administrator has explicitly configured one or more PCI passthru device(s). If there are no PCI passthru devices configured (the common case) then the number of virtual machines is no longer limited by the maximum number of VT-d domains. Reviewed by: grehan@ Approved by: re@ --- sys/amd64/vmm/io/ppt.c | 6 ++++++ sys/amd64/vmm/io/ppt.h | 1 + sys/amd64/vmm/vmm.c | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/amd64/vmm/io/ppt.c b/sys/amd64/vmm/io/ppt.c index 878bf8a03f93..64d9ff551509 100644 --- a/sys/amd64/vmm/io/ppt.c +++ b/sys/amd64/vmm/io/ppt.c @@ -592,3 +592,9 @@ ppt_setup_msix(struct vm *vm, int vcpu, int bus, int slot, int func, return (0); } +int +ppt_num_devices(void) +{ + + return (num_pptdevs); +} diff --git a/sys/amd64/vmm/io/ppt.h b/sys/amd64/vmm/io/ppt.h index 63c8228d5f97..931893c92662 100644 --- a/sys/amd64/vmm/io/ppt.h +++ b/sys/amd64/vmm/io/ppt.h @@ -38,4 +38,5 @@ int ppt_setup_msi(struct vm *vm, int vcpu, int bus, int slot, int func, int destcpu, int vector, int numvec); int ppt_setup_msix(struct vm *vm, int vcpu, int bus, int slot, int func, int idx, uint32_t msg, uint32_t vector_control, uint64_t addr); +int ppt_num_devices(void); #endif diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index b4f3c33367af..5fc6b94e1478 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -213,7 +213,8 @@ vmm_handler(module_t mod, int what, void *arg) switch (what) { case MOD_LOAD: vmmdev_init(); - iommu_init(); + if (ppt_num_devices() > 0) + iommu_init(); error = vmm_init(); if (error == 0) vmm_initialized = 1;