[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 20/20] xen/arm: vIOMMU: Modify the partial device tree for dom0less
From: Rahul Singh <rahul.singh@xxxxxxx> 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 confiure 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> Signed-off-by: Milan Djokic <milan_djokic@xxxxxxxx> --- xen/common/device-tree/dom0less-build.c | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tree/dom0less-build.c index 6bb038111d..3cfffa6581 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -314,7 +314,35 @@ static int __init handle_prop_pfdt(struct kernel_info *kinfo, return ( propoff != -FDT_ERR_NOTFOUND ) ? propoff : 0; } -static int __init scan_pfdt_node(struct kernel_info *kinfo, const void *pfdt, +static void modify_pfdt_node(void *pfdt, int nodeoff) +{ + int proplen, i, rc; + const fdt32_t *prop; + fdt32_t *prop_c; + + prop = fdt_getprop(pfdt, nodeoff, "iommus", &proplen); + if ( !prop ) + return; + + prop_c = xzalloc_bytes(proplen); + + for ( i = 0; i < proplen / 8; ++i ) + { + prop_c[i * 2] = cpu_to_fdt32(GUEST_PHANDLE_VSMMUV3); + prop_c[i * 2 + 1] = prop[i * 2 + 1]; + } + + rc = fdt_setprop(pfdt, nodeoff, "iommus", prop_c, proplen); + if ( rc ) + { + dprintk(XENLOG_ERR, "Can't set the iommus property in partial FDT"); + return; + } + + return; +} + +static int __init scan_pfdt_node(struct kernel_info *kinfo, void *pfdt, int nodeoff, uint32_t address_cells, uint32_t size_cells, bool scan_passthrough_prop) @@ -340,6 +368,7 @@ static int __init scan_pfdt_node(struct kernel_info *kinfo, const void *pfdt, node_next = fdt_first_subnode(pfdt, nodeoff); while ( node_next > 0 ) { + modify_pfdt_node(pfdt, node_next); rc = scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells, scan_passthrough_prop); if ( rc ) -- 2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |