[PATCH V1] libxl/arm: Insert "xen,dev-domid" property to virtio-mmio device node

Oleksandr Tyshchenko posted 1 patch 1 year, 11 months ago
Failed in applying to current master (apply log)
tools/libs/light/libxl_arm.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
[PATCH V1] libxl/arm: Insert "xen,dev-domid" property to virtio-mmio device node
Posted by Oleksandr Tyshchenko 1 year, 11 months ago
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Use specific binding for the virtio devices for which the restricted
memory access using Xen grant mappings need to be enabled.

Based on device-tree binding from Linux:
Documentation/devicetree/bindings/arm/xen,dev-domid.yaml

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
---
!!! This patch is based on non upstreamed yet “Virtio support for toolstack
on Arm” V8 series which is on review now:
https://lore.kernel.org/xen-devel/1651598763-12162-1-git-send-email-olekstysh@gmail.com/

New device-tree binding (commit #5) is a part of solution to restrict memory
access under Xen using xen-grant DMA-mapping layer (which is also on review):
https://lore.kernel.org/xen-devel/1651947548-4055-1-git-send-email-olekstysh@gmail.com/

Changes RFC -> V1:
   - update commit description
   - rebase according to the recent changes to
     "libxl: Introduce basic virtio-mmio support on Arm"
---
 tools/libs/light/libxl_arm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 37403a2..27ff328 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -862,7 +862,8 @@ static int make_vpci_node(libxl__gc *gc, void *fdt,
 
 
 static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
-                                 uint64_t base, uint32_t irq)
+                                 uint64_t base, uint32_t irq,
+                                 uint32_t backend_domid)
 {
     int res;
     gic_interrupt intr;
@@ -887,6 +888,14 @@ static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
     res = fdt_property(fdt, "dma-coherent", NULL, 0);
     if (res) return res;
 
+    if (backend_domid != LIBXL_TOOLSTACK_DOMID) {
+        uint32_t domid[1];
+
+        domid[0] = cpu_to_fdt32(backend_domid);
+        res = fdt_property(fdt, "xen,dev-domid", domid, sizeof(domid));
+        if (res) return res;
+    }
+
     res = fdt_end_node(fdt);
     if (res) return res;
 
@@ -1205,7 +1214,8 @@ next_resize:
             libxl_device_disk *disk = &d_config->disks[i];
 
             if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO)
-                FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq) );
+                FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq,
+                                           disk->backend_domid) );
         }
 
         if (pfdt)
-- 
2.7.4


RE: [PATCH V1] libxl/arm: Insert "xen,dev-domid" property to virtio-mmio device node
Posted by Henry Wang 1 year, 11 months ago
Hi Oleksandr,

> -----Original Message-----
> From: Oleksandr Tyshchenko <olekstysh@gmail.com>
> Subject: [PATCH V1] libxl/arm: Insert "xen,dev-domid" property to virtio-
> mmio device node
> 
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> 
> Use specific binding for the virtio devices for which the restricted
> memory access using Xen grant mappings need to be enabled.
> 
> Based on device-tree binding from Linux:
> Documentation/devicetree/bindings/arm/xen,dev-domid.yaml
> 
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

This patch looks good to me. So
Reviewed-by: Henry Wang <Henry.Wang@arm.com>

Kind regards,
Henry