#include <linux/scatterlist.h>
 #include <linux/kmemcheck.h>
 #include <linux/bug.h>
+#include <linux/mem_encrypt.h>
 
 /**
  * List of possible attributes associated with a DMA mapping. The semantics
        return 0;
 }
 
+static inline void dma_check_mask(struct device *dev, u64 mask)
+{
+       if (sme_active() && (mask < (((u64)sme_get_me_mask() << 1) - 1)))
+               dev_warn(dev, "SME is active, device will require DMA bounce buffers\n");
+}
+
 static inline int dma_supported(struct device *dev, u64 mask)
 {
        const struct dma_map_ops *ops = get_dma_ops(dev);
 {
        if (!dev->dma_mask || !dma_supported(dev, mask))
                return -EIO;
+
+       dma_check_mask(dev, mask);
+
        *dev->dma_mask = mask;
        return 0;
 }
 {
        if (!dma_supported(dev, mask))
                return -EIO;
+
+       dma_check_mask(dev, mask);
+
        dev->coherent_dma_mask = mask;
        return 0;
 }
 
        if (no_iotlb_memory)
                panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer");
 
+       if (sme_active())
+               pr_warn_once("SME is active and system is using DMA bounce buffers\n");
+
        mask = dma_get_seg_boundary(hwdev);
 
        tbl_dma_addr &= mask;