aboutsummaryrefslogtreecommitdiff
path: root/sys/modules
diff options
context:
space:
mode:
authorKa Ho Ng <khng@FreeBSD.org>2021-03-22 09:33:43 +0000
committerKa Ho Ng <khng@FreeBSD.org>2021-03-22 09:33:43 +0000
commit74ada297e8978b8efda3dffdd1bb24aee7c5faa4 (patch)
tree8d882d9629766188c1b138d5d72a88cb2e07ce97 /sys/modules
parentede14736fd6d74db0374f4a233491ad5dc0e9b1d (diff)
downloadsrc-74ada297e8978b8efda3dffdd1bb24aee7c5faa4.tar.gz
src-74ada297e8978b8efda3dffdd1bb24aee7c5faa4.zip
AMD-vi: Fix IOMMU device interrupts being overridden
Currently, AMD-vi PCI-e passthrough will lead to the following lines in dmesg: "kernel: CPU0: local APIC error 0x40 ivhd0: Error: completion failed tail:0x720, head:0x0." After some tracing, the problem is due to the interaction with amdvi_alloc_intr_resources() and pci_driver_added(). In ivrs_drv, the identification of AMD-vi IVHD is done by walking over the ACPI IVRS table and ivhdX device_ts are added under the acpi bus, while there are no driver handling the corresponding IOMMU PCI function. In amdvi_alloc_intr_resources(), the MSI intr are allocated with the ivhdX device_t instead of the IOMMU PCI function device_t. bus_setup_intr() is called on ivhdX. the IOMMU pci function device_t is only used for pci_enable_msi(). Since bus_setup_intr() is not called on IOMMU pci function, the IOMMU PCI function device_t's dinfo->cfg.msi is never updated to reflect the supposed msi_data and msi_addr. So the msi_data and msi_addr stay in the value 0. When pci_driver_added() tried to loop over the children of a pci bus, and do pci_cfg_restore() on each of them, msi_addr and msi_data with value 0 will be written to the MSI capability of the IOMMU pci function, thus explaining the errors in dmesg. This change includes an amdiommu driver which currently does attaching, detaching and providing DEVMETHODs for setting up and tearing down interrupt. The purpose of the driver is to prevent pci_driver_added() from calling pci_cfg_restore() on the IOMMU PCI function device_t. The introduction of the amdiommu driver handles allocation of an IRQ resource within the IOMMU PCI function, so that the dinfo->cfg.msi is populated. This has been tested on EPYC Rome 7282 with Radeon 5700XT GPU. Sponsored by: The FreeBSD Foundation Reviewed by: jhb Approved by: philip (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28984
Diffstat (limited to 'sys/modules')
-rw-r--r--sys/modules/vmm/Makefile3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile
index b5d62c358272..ef0d9dcb6786 100644
--- a/sys/modules/vmm/Makefile
+++ b/sys/modules/vmm/Makefile
@@ -51,6 +51,9 @@ SRCS+= ept.c \
# amd-specific files
.PATH: ${SRCTOP}/sys/amd64/vmm/amd
SRCS+= vmcb.c \
+ amdiommu.c \
+ ivhd_if.c \
+ ivhd_if.h \
svm.c \
svm_support.S \
npt.c \