[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disable swiotlb for Dom0

On 10/08/2021 16:38, Roman Skakun wrote:
Hi, Stefano!


I have observed your patch here:

And I collided with the same issue, when Dom0 device trying to use
swiotlb fops for devices which are controlled by IOMMU.

The issue Stefano reported was when the dom0 is not direct mapped. However...


... if you are really using 4.15, then the domain will always be direct mapped. So I think this is a different one.


Any reason to not use the stable branch for 5.10? I don't know whether your issue will be fixed there, but the stable branch usually contains a lot of bug fixes (including security one). So it is a good idea to use it over the first release of a kernel version.

Issue caused in xen_swiotlb_map_page():
  dev: rcar-fcp, cap: 0, dma_mask: ffffffff, page: fffffe00180c7400, 
page_to_phys: 64b1d0000,
xen_phys_to_dma(phys): 64b1d0000

I can't seem to find this printk in Linux 5.10. Did you add it yourself?

There is retrieved MFN(0x64b1d0000), which belongs to DomU. Dom0
swiotlb couldn't proceed to this address and throws the log:

[   99.504990] rcar-fcp fea2f000.fcp: swiotlb buffer is full (sz: 3686400 
bytes), total 32768 (slots), used 64 (slots)

This line suggests that the SWIOTLB tried to bounce the DMA buffer. In general, the use of the bounce buffer should be rare. So I would suggest to find out why this is used.

Looking at the code, this suggests that one of the following check is false:

         * If the address happens to be in the device's DMA window,
         * we can safely return the device addr and not worry about bounce
         * buffering it.
        if (dma_capable(dev, dev_addr, size, true) &&
            !range_straddles_page_boundary(phys, size) &&
                !xen_arch_need_swiotlb(dev, phys, dev_addr) &&
                swiotlb_force != SWIOTLB_FORCE)
                goto done;

Temporary, I resolved this issue by disabling swiotlb for dom0 at all
because sure that all devices goes through IOMMU, but this mention can
be true only for me.

But, I think of a more reliable way is to declare a special IOMMU
property in xen dts for each device. If the device controlled by IOMMU
not need to set swiotlb fops in arch_setup_dma_ops.
What do you think about it?

Let me start with that I agree we should disable swiotlb when we know the device is protected. However, from what you describe, it sounds like the same issue would appear if the IOMMU was disabled.

Therefore, I think we should first find out why Linux wants to bounce the DMA buffer. Does your device have any DMA restriction?


Julien Grall



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.