From 1f1eb7fdba15fe5bf3656934ece96d25dcacccfb Mon Sep 17 00:00:00 2001 From: Junming Liu Date: Thu, 20 Feb 2020 10:03:40 +0000 Subject: [PATCH] hv:disable iommu snoop control to enable gvt-d by an option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If one of the enabled VT-d DMAR units doesn’t support snoop control, then bit 11 of leaf PET of EPT is not set, since the field is treated as reserved(0) by VT-d hardware implementations not supporting snoop control. GUP IOMMU doesn’t support snoop control, this patch add an option to disable iommu snoop control for gvt-d. v2 -> v3: * refine the MICRO name and description. Tracked-On: #4405 Signed-off-by: Junming Liu Reviewed-by: Wu Binbin Acked-by: Eddie Dong --- hypervisor/arch/x86/Kconfig | 7 +++++++ hypervisor/arch/x86/vtd.c | 10 ++++++++++ 2 files changed, 17 insertions(+) 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);