On Thu, 31 Aug 2023, Vikram Garhwal wrote:
> Update sysctl XEN_SYSCTL_dt_overlay to enable support for dtbo nodes addition
> using device tree overlay.
> 
> xl dt-overlay add file.dtbo:
>     Each time overlay nodes are added using .dtbo, a new fdt(memcpy of
>     device_tree_flattened) is created and updated with overlay nodes. This
>     updated fdt is further unflattened to a dt_host_new. Next, it checks if 
> any
>     of the overlay nodes already exists in the dt_host. If overlay nodes 
> doesn't
>     exist then find the overlay nodes in dt_host_new, find the overlay node's
>     parent in dt_host and add the nodes as child under their parent in the
>     dt_host. The node is attached as the last node under target parent.
> 
>     Finally, add IRQs, add device to IOMMUs, set permissions and map MMIO for 
> the
>     overlay node.
> 
> When a node is added using overlay, a new entry is allocated in the
> overlay_track to keep the track of memory allocation due to addition of 
> overlay
> node. This is helpful for freeing the memory allocated when a device tree node
> is removed.
> 
> The main purpose of this to address first part of dynamic programming i.e.
> making xen aware of new device tree node which means updating the dt_host with
> overlay node information. Here we are adding/removing node from dt_host, and
> checking/setting IOMMU and IRQ permission but never mapping them to any 
> domain.
> Right now, mapping/Un-mapping will happen only when a new domU is
> created/destroyed using "xl create".
> 
> Signed-off-by: Vikram Garhwal <vikram.garh...@amd.com>
> @@ -359,6 +546,312 @@ static long handle_remove_overlay_nodes(const void 
> *overlay_fdt,
>      return rc;
>  }
>  
> +static void free_nodes_full_path(unsigned int num_nodes, char 
> **nodes_full_path)
> +{
> +    unsigned int i;
> +
> +    if ( nodes_full_path != NULL )
> +        return;

Shouldn't this be:

    if ( nodes_full_path == NULL )
        return;


> +    for ( i = 0; i < num_nodes && nodes_full_path[i] != NULL; i++ )
> +    {
> +        xfree(nodes_full_path[i]);
> +    }
> +
> +    xfree(nodes_full_path);
> +}

Reply via email to