diff --git a/hypervisor/arch/x86/Kconfig b/hypervisor/arch/x86/Kconfig index 081c729e2..2696ff718 100644 --- a/hypervisor/arch/x86/Kconfig +++ b/hypervisor/arch/x86/Kconfig @@ -340,3 +340,10 @@ config MCE_ON_PSC_WORKAROUND_DISABLED conditionally applied to the models that may be affected by the issue. However, the software workaround has negative impact on performance. If all the guest OS kernels are trusted, this option may be set for performance. + +config IOMMU_ENFORCE_SNP + bool "IOMMU enforce snoop behavior of DMA operation" + default n + help + GPU IOMMU doesn't support snoop control capability, + To enable gvt-d,disable IOMMU snoop control by default. diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index dfb05eba3..5a7a2113c 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -1263,7 +1263,17 @@ struct iommu_domain *create_iommu_domain(uint16_t vm_id, uint64_t translation_ta domain->trans_table_ptr = translation_table; domain->addr_width = addr_width; domain->is_tt_ept = true; + +#ifdef CONFIG_IOMMU_ENFORCE_SNP domain->iommu_snoop = true; +#else + /* TODO: GPU IOMMU doesn't have snoop control capbility, + * so set domain->iommu_snoop false to enable gvt-d by default. + * If want to refine iommu snoop control policy, + * need to change domain->iommu_snoop dynamically. + */ + domain->iommu_snoop = false; +#endif dev_dbg(DBG_LEVEL_IOMMU, "create domain [%d]: vm_id = %hu, ept@0x%x", vmid_to_domainid(domain->vm_id), domain->vm_id, domain->trans_table_ptr);