diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 5b905ba6fe6e3e66aa5ee177e64fd12299297d51..a0a61f90cfbf9d7b72de7cf53107e4bfe15249cb 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef DEBUG /* For development, we want to crash whenever the ring is screwed. */ @@ -214,6 +215,13 @@ static inline bool virtqueue_use_indirect(struct virtqueue *_vq, return (vq->indirect && total_sg > 1 && vq->vq.num_free); } +static inline bool should_force_dma(struct virtio_device *dev) +{ + return (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT) && + (!virtio_has_feature(dev, VIRTIO_F_VERSION_1) || + !virtio_has_feature(dev, VIRTIO_F_ACCESS_PLATFORM))); +} + /* * Modern virtio devices have feature bits to specify whether they need a * quirk and bypass the IOMMU. If not there, just use the DMA API. @@ -257,6 +265,9 @@ static bool vring_use_dma_api(struct virtio_device *vdev) if (xen_domain()) return true; + if (should_force_dma(vdev)) + return true; + return false; }