diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index afa4c4650e5e..0400b2208b95 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -102,6 +102,7 @@ options WITNESS # Enable checks to detect deadlocks and cycles options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones options VERBOSE_SYSINIT=0 # Support debug.verbose_sysinit, off by default +options IOMMU # Kernel Sanitizers #options COVERAGE # Generic kernel coverage. Used by KCOV @@ -127,7 +128,6 @@ device cpufreq # Bus support. device acpi -options ACPI_DMAR device pci options PCI_HP # PCI-Express native HotPlug options PCI_IOV # PCI SR-IOV support diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL index 0c5f43b20d54..35c19346f08b 100644 --- a/sys/amd64/conf/MINIMAL +++ b/sys/amd64/conf/MINIMAL @@ -93,6 +93,7 @@ options WITNESS # Enable checks to detect deadlocks and cycles options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones options VERBOSE_SYSINIT=0 # Support debug.verbose_sysinit, off by default +options IOMMU # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel @@ -103,7 +104,6 @@ device cpufreq # Bus support. device acpi -options ACPI_DMAR device pci # atkbdc0 controls both the keyboard and the PS/2 mouse diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 index 348ef57f8750..df9fa9285303 100644 --- a/sys/conf/files.x86 +++ b/sys/conf/files.x86 @@ -165,8 +165,8 @@ dev/imcsmb/imcsmb.c optional imcsmb dev/imcsmb/imcsmb_pci.c optional imcsmb pci dev/intel/spi.c optional intelspi dev/io/iodev.c optional io -dev/iommu/busdma_iommu.c optional acpi acpi_dmar pci -dev/iommu/iommu_gas.c optional acpi acpi_dmar pci +dev/iommu/busdma_iommu.c optional acpi iommu pci +dev/iommu/iommu_gas.c optional acpi iommu pci dev/ipmi/ipmi.c optional ipmi dev/ipmi/ipmi_acpi.c optional ipmi acpi dev/ipmi/ipmi_isa.c optional ipmi isa @@ -302,14 +302,14 @@ x86/cpufreq/hwpstate_amd.c optional cpufreq x86/cpufreq/hwpstate_intel.c optional cpufreq x86/cpufreq/p4tcc.c optional cpufreq x86/cpufreq/powernow.c optional cpufreq -x86/iommu/intel_ctx.c optional acpi acpi_dmar pci -x86/iommu/intel_drv.c optional acpi acpi_dmar pci -x86/iommu/intel_fault.c optional acpi acpi_dmar pci -x86/iommu/intel_idpgtbl.c optional acpi acpi_dmar pci -x86/iommu/intel_intrmap.c optional acpi acpi_dmar pci -x86/iommu/intel_qi.c optional acpi acpi_dmar pci -x86/iommu/intel_quirks.c optional acpi acpi_dmar pci -x86/iommu/intel_utils.c optional acpi acpi_dmar pci +x86/iommu/intel_ctx.c optional acpi iommu pci +x86/iommu/intel_drv.c optional acpi iommu pci +x86/iommu/intel_fault.c optional acpi iommu pci +x86/iommu/intel_idpgtbl.c optional acpi iommu pci +x86/iommu/intel_intrmap.c optional acpi iommu pci +x86/iommu/intel_qi.c optional acpi iommu pci +x86/iommu/intel_quirks.c optional acpi iommu pci +x86/iommu/intel_utils.c optional acpi iommu pci x86/isa/atrtc.c standard x86/isa/clock.c standard x86/isa/isa.c optional isa diff --git a/sys/conf/options b/sys/conf/options index 25a5dfbaf588..e22197093f58 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -704,9 +704,11 @@ EPOCH_TRACE opt_global.h ACPI_DEBUG opt_acpi.h ACPI_MAX_TASKS opt_acpi.h ACPI_MAX_THREADS opt_acpi.h -ACPI_DMAR opt_acpi.h DEV_ACPI opt_acpi.h +# options for IOMMU support +IOMMU opt_iommu.h + # ISA support DEV_ISA opt_isa.h ISAPNP opt_isa.h diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c index 24edc9738942..c8d37268f466 100644 --- a/sys/dev/acpica/acpi_pci.c +++ b/sys/dev/acpica/acpi_pci.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" +#include "opt_iommu.h" #include #include @@ -459,7 +460,7 @@ acpi_pci_detach(device_t dev) return (pci_detach(dev)); } -#ifdef ACPI_DMAR +#ifdef IOMMU static bus_dma_tag_t acpi_pci_get_dma_tag(device_t bus, device_t child) { diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 49a45c1598d3..342e55681fb3 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" +#include "opt_iommu.h" #include "opt_bus.h" #include @@ -5683,7 +5684,7 @@ pci_get_resource_list (device_t dev, device_t child) return (&dinfo->resources); } -#ifdef ACPI_DMAR +#ifdef IOMMU bus_dma_tag_t pci_get_dma_tag(device_t bus, device_t dev) { diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL index 1c5a21878684..1948c9649e70 100644 --- a/sys/i386/conf/MINIMAL +++ b/sys/i386/conf/MINIMAL @@ -93,6 +93,7 @@ options WITNESS # Enable checks to detect deadlocks and cycles options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones options VERBOSE_SYSINIT=0 # Support debug.verbose_sysinit, off by default +options IOMMU # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel @@ -104,7 +105,6 @@ device cpufreq # Bus support. device acpi -options ACPI_DMAR device pci # atkbdc0 controls both the keyboard and the PS/2 mouse diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 9e8e4f23b2f9..70cd3416487d 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -439,6 +439,8 @@ device s3pci device tdfx # Enable 3Dfx Voodoo support device tdfx_linux # Enable Linuxulator support +options IOMMU # Enable IOMMU support + # # ACPI support using the Intel ACPI Component Architecture reference # implementation. @@ -450,7 +452,6 @@ device tdfx_linux # Enable Linuxulator support device acpi options ACPI_DEBUG -options ACPI_DMAR # ACPI WMI Mapping driver device acpi_wmi diff --git a/sys/x86/x86/busdma_machdep.c b/sys/x86/x86/busdma_machdep.c index c2c74721d8de..92eab0cae842 100644 --- a/sys/x86/x86/busdma_machdep.c +++ b/sys/x86/x86/busdma_machdep.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" +#include "opt_iommu.h" #include #include @@ -268,7 +269,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat) return (tc->impl->tag_destroy(dmat)); } -#ifndef ACPI_DMAR +#ifndef IOMMU bool bus_dma_iommu_set_buswide(device_t dev); int bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t start, vm_size_t length, int flags); diff --git a/sys/x86/x86/io_apic.c b/sys/x86/x86/io_apic.c index da5b5c36cb99..444bcb87064e 100644 --- a/sys/x86/x86/io_apic.c +++ b/sys/x86/x86/io_apic.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" +#include "opt_iommu.h" #include "opt_isa.h" #include @@ -314,7 +315,7 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin) { struct ioapic *io = (struct ioapic *)intpin->io_intsrc.is_pic; uint32_t low, high; -#ifdef ACPI_DMAR +#ifdef IOMMU int error; #endif @@ -331,7 +332,7 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin) ioapic_write(io->io_addr, IOAPIC_REDTBL_LO(intpin->io_intpin), low | IOART_INTMSET); -#ifdef ACPI_DMAR +#ifdef IOMMU mtx_unlock_spin(&icu_lock); iommu_unmap_ioapic_intr(io->io_apic_id, &intpin->io_remap_cookie); @@ -340,7 +341,7 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin) return; } -#ifdef ACPI_DMAR +#ifdef IOMMU mtx_unlock_spin(&icu_lock); error = iommu_map_ioapic_intr(io->io_apic_id, intpin->io_cpu, intpin->io_vector, intpin->io_edgetrigger, @@ -712,7 +713,7 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase) intpin->io_cpu = PCPU_GET(apic_id); value = ioapic_read(apic, IOAPIC_REDTBL_LO(i)); ioapic_write(apic, IOAPIC_REDTBL_LO(i), value | IOART_INTMSET); -#ifdef ACPI_DMAR +#ifdef IOMMU /* dummy, but sets cookie */ mtx_unlock_spin(&icu_lock); iommu_map_ioapic_intr(io->io_apic_id, diff --git a/sys/x86/x86/msi.c b/sys/x86/x86/msi.c index 12fc85eb21c9..f85d4a5161e5 100644 --- a/sys/x86/x86/msi.c +++ b/sys/x86/x86/msi.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" +#include "opt_iommu.h" #include #include @@ -383,7 +384,7 @@ msi_alloc(device_t dev, int count, int maxcount, int *irqs) struct msi_intsrc *msi, *fsrc; u_int cpu, domain, *mirqs; int cnt, i, vector; -#ifdef ACPI_DMAR +#ifdef IOMMU u_int cookies[count]; int error; #endif @@ -449,7 +450,7 @@ msi_alloc(device_t dev, int count, int maxcount, int *irqs) return (ENOSPC); } -#ifdef ACPI_DMAR +#ifdef IOMMU mtx_unlock(&msi_lock); error = iommu_alloc_msi_intr(dev, cookies, count); mtx_lock(&msi_lock); @@ -531,7 +532,7 @@ msi_release(int *irqs, int count) msi = (struct msi_intsrc *)intr_lookup_source(irqs[i]); KASSERT(msi->msi_first == first, ("message not in group")); KASSERT(msi->msi_dev == first->msi_dev, ("owner mismatch")); -#ifdef ACPI_DMAR +#ifdef IOMMU iommu_unmap_msi_intr(first->msi_dev, msi->msi_remap_cookie); #endif msi->msi_first = NULL; @@ -541,7 +542,7 @@ msi_release(int *irqs, int count) } /* Clear out the first message. */ -#ifdef ACPI_DMAR +#ifdef IOMMU mtx_unlock(&msi_lock); iommu_unmap_msi_intr(first->msi_dev, first->msi_remap_cookie); mtx_lock(&msi_lock); @@ -564,7 +565,7 @@ msi_map(int irq, uint64_t *addr, uint32_t *data) { struct msi_intsrc *msi; int error; -#ifdef ACPI_DMAR +#ifdef IOMMU struct msi_intsrc *msi1; int i, k; #endif @@ -595,7 +596,7 @@ msi_map(int irq, uint64_t *addr, uint32_t *data) msi = msi->msi_first; } -#ifdef ACPI_DMAR +#ifdef IOMMU if (!msi->msi_msix) { for (k = msi->msi_count - 1, i = first_msi_irq; k > 0 && i < first_msi_irq + num_msi_irqs; i++) { @@ -633,7 +634,7 @@ msix_alloc(device_t dev, int *irq) struct msi_intsrc *msi; u_int cpu, domain; int i, vector; -#ifdef ACPI_DMAR +#ifdef IOMMU u_int cookie; int error; #endif @@ -684,7 +685,7 @@ msix_alloc(device_t dev, int *irq) } msi->msi_dev = dev; -#ifdef ACPI_DMAR +#ifdef IOMMU mtx_unlock(&msi_lock); error = iommu_alloc_msi_intr(dev, &cookie, 1); mtx_lock(&msi_lock); @@ -739,7 +740,7 @@ msix_release(int irq) KASSERT(msi->msi_dev != NULL, ("unowned message")); /* Clear out the message. */ -#ifdef ACPI_DMAR +#ifdef IOMMU mtx_unlock(&msi_lock); iommu_unmap_msi_intr(msi->msi_dev, msi->msi_remap_cookie); mtx_lock(&msi_lock);