Skip to content

Commit

Permalink
arm/xen: Assign xen-grant DMA ops for xen-grant DMA devices
Browse files Browse the repository at this point in the history
By assigning xen-grant DMA ops we will restrict memory access for
passed device using Xen grant mappings. This is needed for using any
virtualized device (e.g. virtio) in Xen guests in a safe manner.

Please note, for the virtio devices the XEN_VIRTIO config should
be enabled (it forces ARCH_HAS_RESTRICTED_VIRTIO_MEMORY_ACCESS).

Signed-off-by: Oleksandr Tyshchenko <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Juergen Gross <[email protected]>
  • Loading branch information
Oleksandr Tyshchenko authored and jgross1 committed Jun 6, 2022
1 parent 625ab90 commit fea9816
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/xen/arm/xen-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
#define _ASM_ARM_XEN_OPS_H

#include <xen/swiotlb-xen.h>
#include <xen/xen-ops.h>

static inline void xen_setup_dma_ops(struct device *dev)
{
#ifdef CONFIG_XEN
if (xen_swiotlb_detect())
if (xen_is_grant_dma_device(dev))
xen_grant_setup_dma_ops(dev);
else if (xen_swiotlb_detect())
dev->dma_ops = &xen_swiotlb_dma_ops;
#endif
}
Expand Down

0 comments on commit fea9816

Please sign in to comment.