|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v5 18/22] libxl/arm: vIOMMU: Modify the partial device tree for iommus
Hi Milan,
> To configure IOMMU in guest for passthrough devices, user will need to
> copy the unmodified "iommus" property from host device tree to partial
> device tree. To enable the dom0 linux kernel to configure the IOMMU
> correctly replace the phandle in partial device tree with virtual
> IOMMU phandle when "iommus" property is set.
>
> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
> Singed-off-by: Milan Djokic <milan_djokic@xxxxxxxx>
A misspelled tag ;-)
> Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
>
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 72b19d68af10..0dc3789d08ea 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -1342,6 +1342,41 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt,
> void *pfdt)
> return 0;
> }
>
> +static int modify_partial_fdt(libxl__gc *gc, void *pfdt)
> +{
> + int nodeoff, proplen, i, r;
> + const fdt32_t *prop;
> + fdt32_t *prop_c;
> +
> + nodeoff = fdt_path_offset(pfdt, "/passthrough");
> + if (nodeoff < 0)
> + return nodeoff;
> +
> + for (nodeoff = fdt_first_subnode(pfdt, nodeoff);
> + nodeoff >= 0;
> + nodeoff = fdt_next_subnode(pfdt, nodeoff)) {
> +
> + prop = fdt_getprop(pfdt, nodeoff, "iommus", &proplen);
> + if (!prop)
> + continue;
> +
> + prop_c = libxl__zalloc(gc, proplen);
> +
> + for (i = 0; i < proplen / 8; ++i) {
What happen if `proplen` isn't divisible by 8? Especially as `proplen`
is used as is in the `fdt_setprop` call below.
> + prop_c[i * 2] = cpu_to_fdt32(GUEST_PHANDLE_VSMMUV3);
> + prop_c[i * 2 + 1] = prop[i * 2 + 1];
> + }
> +
> + r = fdt_setprop(pfdt, nodeoff, "iommus", prop_c, proplen);
> + if (r) {
> + LOG(ERROR, "Can't set the iommus property in partial FDT");
> + return r;
> + }
> + }
> +
> + return 0;
> +}
> +
> #else
>
> static int check_partial_fdt(libxl__gc *gc, void *fdt, size_t size)
> @@ -1360,6 +1395,13 @@ static int copy_partial_fdt(libxl__gc *gc, void *fdt,
> void *pfdt)
> return -FDT_ERR_INTERNAL;
> }
>
> +static int modify_partial_fdt(libxl__gc *gc, void *pfdt)
> +{
> + LOG(ERROR, "partial device tree not supported");
> +
> + return ERROR_FAIL;
That's a libxl error code, not an FDT_* one. You could return
-FDT_ERR_INTERNAL like copy_partial_fdt() instead.
> +}
> +
> #endif /* ENABLE_PARTIAL_DEVICE_TREE */
>
> #define FDT_MAX_SIZE (1<<20)
> @@ -1482,8 +1524,11 @@ static int libxl__prepare_dtb(libxl__gc *gc,
> libxl_domain_config *d_config,
> if (d_config->num_pcidevs)
> FDT( make_vpci_node(gc, fdt, ainfo, dom) );
>
> - if (info->arch_arm.viommu_type == LIBXL_VIOMMU_TYPE_SMMUV3)
> + if (info->arch_arm.viommu_type == LIBXL_VIOMMU_TYPE_SMMUV3) {
> FDT( make_vsmmuv3_node(gc, fdt, ainfo, dom) );
> + if (pfdt)
> + FDT( modify_partial_fdt(gc, pfdt) );
What happens if you call this function repeatedly? Wouldn't it be better
to call it once before the "next_resize" loop?
Thanks,
--
Anthony Perard | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |