From 0aa2c237d52da7243d9c7158a8c5600b9b98bec7 Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Thu, 19 Mar 2020 14:56:45 +0800 Subject: [PATCH] hv: change GPU passthru translation mode to TT_PASSTHROUGH This is a WA to fix the invisible cursor issue. The TT_PASSTHROUGH mode will not use iommu to do the address translation. Tracked-On: #4509 Signed-off-by: Xiaoguang Wu Reviewed-by: Zhao Yakui --- hypervisor/arch/x86/vtd.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index 4c1a9c907..fb7d384f4 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -22,6 +22,7 @@ #include #include #include +#include #define DBG_IOMMU 0 @@ -1136,6 +1137,21 @@ static int32_t iommu_attach_device(struct iommu_domain *domain, uint8_t bus, uin pr_err("dmaru[%d] doesn't support trans passthrough", dmar_unit->index); ret = -ENODEV; } + } else if ((bus == ((CONFIG_GPU_SBDF >> 8) & 0xFFU)) && (devfun == (CONFIG_GPU_SBDF & 0xFFU))) { + hi_64 = dmar_set_bitslice(hi_64, + CTX_ENTRY_UPPER_AW_MASK, CTX_ENTRY_UPPER_AW_POS, (uint64_t)width_to_agaw(domain->addr_width)); + + /* TODO: This is a GVT-G WA to resolve invisible cursor issue in Guest. But this change is harmlessly + * due to benefits for SOS graphic performance. Will revisit how much benefits after root cause the + * cursor issue, then determine if it needs to revert or not. + */ + if (is_sos_vm(get_vm_from_vmid(domain->vm_id))) { + lo_64 = dmar_set_bitslice(lo_64, + CTX_ENTRY_LOWER_TT_MASK, CTX_ENTRY_LOWER_TT_POS, DMAR_CTX_TT_PASSTHROUGH); + } else { + lo_64 = dmar_set_bitslice(lo_64, + CTX_ENTRY_LOWER_TT_MASK, CTX_ENTRY_LOWER_TT_POS, DMAR_CTX_TT_UNTRANSLATED); + } } else { /* TODO: add Device TLB support */ hi_64 = dmar_set_bitslice(hi_64,