Commit 1bc99f56 authored by Xu Yiwei's avatar Xu Yiwei Committed by guzitao
Browse files

sw64: iommu: adjust iova map space

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IBDJNZ



--------------------------------

Device Passthrough on QEMU is causing iova overlaps on an unexpected
address, which happens to be the lower boundary of our BAR address.
This is caused by QEMU visiting that address intentionally during its
hot-plug initalization.

The quickest way to fix this is by including that address in our current
IOVA check boundary, so applications will stop mapping IOVA on that address.

Signed-off-by: default avatarXu Yiwei <xuyiwei@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent f0f2811d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1464,7 +1464,7 @@ sunway_iommu_iova_to_phys(struct iommu_domain *dom, dma_addr_t iova)
	struct sunway_iommu_domain *sdomain = to_sunway_domain(dom);
	unsigned long paddr, grn;

	if (iova > SW64_BAR_ADDRESS)
	if (iova >= SW64_BAR_ADDRESS)
		return iova;

	paddr = fetch_pte(sdomain, iova, PTE_LEVEL2_VAL);
@@ -1501,7 +1501,7 @@ sunway_iommu_map(struct iommu_domain *dom, unsigned long iova,
	 * and pci device BAR, check should be introduced manually
	 * to avoid VFIO trying to map pci config space.
	 */
	if (iova > SW64_BAR_ADDRESS)
	if (iova >= SW64_BAR_ADDRESS)
		return 0;

	mutex_lock(&sdomain->api_lock);
@@ -1519,7 +1519,7 @@ sunway_iommu_unmap(struct iommu_domain *dom, unsigned long iova,
	struct sunway_iommu_domain *sdomain = to_sunway_domain(dom);
	size_t unmap_size;

	if (iova > SW64_BAR_ADDRESS)
	if (iova >= SW64_BAR_ADDRESS)
		return page_size;

	mutex_lock(&sdomain->api_lock);