From owner-svn-src-all@FreeBSD.ORG Wed Jun 4 17:57:49 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4B60DBA; Wed, 4 Jun 2014 17:57:49 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 38A9C2E16; Wed, 4 Jun 2014 17:57:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s54HvnJD028935; Wed, 4 Jun 2014 17:57:49 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s54Hvm4L028931; Wed, 4 Jun 2014 17:57:48 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201406041757.s54Hvm4L028931@svn.freebsd.org> From: John Baldwin Date: Wed, 4 Jun 2014 17:57:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r267070 - in stable/10/sys/amd64/vmm: . io X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2014 17:57:49 -0000 Author: jhb Date: Wed Jun 4 17:57:48 2014 New Revision: 267070 URL: http://svnweb.freebsd.org/changeset/base/267070 Log: MFC 260972: There is no need to initialize the IOMMU if no passthru devices have been configured for bhyve to use. Modified: stable/10/sys/amd64/vmm/io/iommu.c stable/10/sys/amd64/vmm/io/ppt.c stable/10/sys/amd64/vmm/io/ppt.h stable/10/sys/amd64/vmm/vmm.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/vmm/io/iommu.c ============================================================================== --- stable/10/sys/amd64/vmm/io/iommu.c Wed Jun 4 17:56:57 2014 (r267069) +++ stable/10/sys/amd64/vmm/io/iommu.c Wed Jun 4 17:57:48 2014 (r267070) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -43,7 +44,13 @@ __FBSDID("$FreeBSD$"); #include "vmm_mem.h" #include "iommu.h" -static boolean_t iommu_avail; +SYSCTL_DECL(_hw_vmm); +SYSCTL_NODE(_hw_vmm, OID_AUTO, iommu, CTLFLAG_RW, 0, "bhyve iommu parameters"); + +static int iommu_avail; +SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, initialized, CTLFLAG_RD, &iommu_avail, + 0, "bhyve iommu initialized?"); + static struct iommu_ops *ops; static void *host_domain; @@ -160,7 +167,7 @@ iommu_init(void) if (error) return; - iommu_avail = TRUE; + iommu_avail = 1; /* * Create a domain for the devices owned by the host Modified: stable/10/sys/amd64/vmm/io/ppt.c ============================================================================== --- stable/10/sys/amd64/vmm/io/ppt.c Wed Jun 4 17:56:57 2014 (r267069) +++ stable/10/sys/amd64/vmm/io/ppt.c Wed Jun 4 17:57:48 2014 (r267070) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -100,7 +101,12 @@ static struct pptdev { } msix; } pptdevs[64]; +SYSCTL_DECL(_hw_vmm); +SYSCTL_NODE(_hw_vmm, OID_AUTO, ppt, CTLFLAG_RW, 0, "bhyve passthru devices"); + static int num_pptdevs; +SYSCTL_INT(_hw_vmm_ppt, OID_AUTO, devices, CTLFLAG_RD, &num_pptdevs, 0, + "number of pci passthru devices"); static int ppt_probe(device_t dev) @@ -282,7 +288,14 @@ ppt_teardown_msix(struct pptdev *ppt) } int -ppt_num_devices(struct vm *vm) +ppt_avail_devices(void) +{ + + return (num_pptdevs); +} + +int +ppt_assigned_devices(struct vm *vm) { int i, num; Modified: stable/10/sys/amd64/vmm/io/ppt.h ============================================================================== --- stable/10/sys/amd64/vmm/io/ppt.h Wed Jun 4 17:56:57 2014 (r267069) +++ stable/10/sys/amd64/vmm/io/ppt.h Wed Jun 4 17:57:48 2014 (r267070) @@ -36,10 +36,16 @@ int ppt_setup_msi(struct vm *vm, int vcp uint64_t addr, uint64_t msg, int numvec); int ppt_setup_msix(struct vm *vm, int vcpu, int bus, int slot, int func, int idx, uint64_t addr, uint64_t msg, uint32_t vector_control); -int ppt_num_devices(struct vm *vm); +int ppt_assigned_devices(struct vm *vm); boolean_t ppt_is_mmio(struct vm *vm, vm_paddr_t gpa); /* + * Returns the number of devices sequestered by the ppt driver for assignment + * to virtual machines. + */ +int ppt_avail_devices(void); + +/* * The following functions should never be called directly. * Use 'vm_assign_pptdev()' and 'vm_unassign_pptdev()' instead. */ Modified: stable/10/sys/amd64/vmm/vmm.c ============================================================================== --- stable/10/sys/amd64/vmm/vmm.c Wed Jun 4 17:56:57 2014 (r267069) +++ stable/10/sys/amd64/vmm/vmm.c Wed Jun 4 17:57:48 2014 (r267070) @@ -266,7 +266,8 @@ vmm_handler(module_t mod, int what, void switch (what) { case MOD_LOAD: vmmdev_init(); - iommu_init(); + if (ppt_avail_devices() > 0) + iommu_init(); error = vmm_init(); if (error == 0) vmm_initialized = 1; @@ -604,7 +605,7 @@ vm_unassign_pptdev(struct vm *vm, int bu if (error) return (error); - if (ppt_num_devices(vm) == 0) { + if (ppt_assigned_devices(vm) == 0) { vm_iommu_unmap(vm); vm_gpa_unwire(vm); } @@ -624,7 +625,7 @@ vm_assign_pptdev(struct vm *vm, int bus, * * We need to do this before the first pci passthru device is attached. */ - if (ppt_num_devices(vm) == 0) { + if (ppt_assigned_devices(vm) == 0) { KASSERT(vm->iommu == NULL, ("vm_assign_pptdev: iommu must be NULL")); maxaddr = vmm_mem_maxaddr();