[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN][PATCH v10 10/20] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Mon, 28 Aug 2023 09:29:09 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sH8fOpIa/VdTb5+hMeaiMFFThm9UBQvalLHuR+YsZSM=; b=SiN+npcCIywwOc4wOBeQQdsPKdaSG9XwMTcAnLyQ9d/RkwhsDG9G0ling1gytCYiDHqCscOtMh4tBkWqH/xEQacC9IQtFXWk1j6NAMdLANaOB1SNCUSbYxcs1FTEMqHkIBAL0clY5QWDlK0HC+FVKXyArTWdt+H75G6jm8V0DoKk+jgn354m2uVDkN0Ol9NkkzB97SF6SYQhEqqqxPfRB1HhImf4w1DrgJCutcHTo0EEMXPLoUgkgh7JfOEGmyt5c9yjUXrWP1RUnGBA8sWzcHNkYu2WBcdMZntVF7PEWRmnxaRi/8T4Hf5loBagB2HPXe+ZY0mvK4Btpmst+ZoSMw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YxvBQprhS/i+qtzcLjG+9kazbxSNxMD4Ohi+PoJUHiN2mkem1kXvKvxQ/Qh6OxpwPOa51kbP6HR9v0y5oxs7PStGplK+JwB8EbUEoRXYNn8ACoxnrWv+axqklGKMiFbIgzUM7hoICnb1eYpsOTzH70GLebr+jcRHIYrwiYOXDWLUkcRqQ6DUQEA1Sv7GBDb43iHOYcnZl/JXLEhvG4EXDp9tCvzWKZiLx95jsptWQ8q4qQC2H1CKCwvUetlarc6DruzOrtt3oFwemUvfZ6AP3NTo1LsOAD7LDMOgu0N5oYTh0T7AiDYuWCDy8LzgVA8bOb9VfUEIdJhqtoHDD9XitA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: michal.orzel@xxxxxxx, sstabellini@xxxxxxxxxx, julien@xxxxxxx
  • Delivery-date: Mon, 28 Aug 2023 16:29:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Aug 25, 2023 at 01:02:12AM -0700, Vikram Garhwal wrote:
> Protect iommu_add_dt_device() with dtdevs_lock to prevent concurrent access
> to add/remove/assign/deassign.
> With addition of dynamic programming feature(follow-up patches in this 
> series),
> this function can be concurrently accessed by while making a device
> assign/deassign for passthrough and by dynamic node add/remove using device 
> tree
> overlays.
There was a comment from Julien on v9 on commit message. In v11, I Will remove
references to PCI because this is misleading.
> 
> Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
> Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
> 
> ---
>     Changes from v7:
>         Update commit message and fix indent.
> ---
> ---
>  xen/drivers/passthrough/device_tree.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/passthrough/device_tree.c 
> b/xen/drivers/passthrough/device_tree.c
> index 5d84c07b50..1202eac625 100644
> --- a/xen/drivers/passthrough/device_tree.c
> +++ b/xen/drivers/passthrough/device_tree.c
> @@ -148,6 +148,8 @@ int iommu_add_dt_device(struct dt_device_node *np)
>      if ( dev_iommu_fwspec_get(dev) )
>          return 0;
>  
> +    spin_lock(&dtdevs_lock);
> +
>      /*
>       * According to the Documentation/devicetree/bindings/iommu/iommu.txt
>       * from Linux.
> @@ -160,7 +162,10 @@ int iommu_add_dt_device(struct dt_device_node *np)
>           * these callback implemented.
>           */
>          if ( !ops->add_device || !ops->dt_xlate )
> -            return -EINVAL;
> +        {
> +            rc = -EINVAL;
> +            goto fail;
> +        }
>  
>          if ( !dt_device_is_available(iommu_spec.np) )
>              break;
> @@ -191,6 +196,8 @@ int iommu_add_dt_device(struct dt_device_node *np)
>      if ( rc < 0 )
>          iommu_fwspec_free(dev);
>  
> + fail:
> +    spin_unlock(&dtdevs_lock);
>      return rc;
>  }
>  
> -- 
> 2.17.1
> 
> 



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.