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

Re: [XEN][RFC PATCH v3 08/14] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock


  • To: Vikram Garhwal <fnu.vikram@xxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Mon, 14 Mar 2022 17:34:55 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=iJDL7ccx5slMFHnI8wW4Mi3rtx40GYNDx/jcbdVxNkU=; b=PZtgxOtFGEuvrK/cNiHDsI0EveGoeVHX3epP+TlnvLhTqEl0RO/aPdnZkdmLadtcrkcp+HD7FNBU4mH5RoIZcnD7ho/GrwtTIgcRUaMChHUJcuju9Wg0JVvuGuTGiRcwxGTz6laiGTvDkTU/e0QQKV5wt0duzJoCdtgQof4mILKwLFz2AI3v6ukfdFVsSQoRTxpXVV+PC6Xmb14z9P+4AyA/O9Cq8xqtRTofKnfTAltsPacTbtNgRUSyjuvoxMOR2RMCuP6d77tTAQW4rwAJta3AN2feecF2u6C5hv+2zg9etvbNsBsdDCqATL5h5TzB8+j8hVFDwHHF2x6DE3ST3A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EwRAHQqE0iFWHwInheFEVWatqea7JEt4njNEktvZ1uMYjyIc3Vka5i4uTRKLSmaeCAtD98+HWr6WIrfTKOZJE6cn0/P4/KcIiyxoLu45bygC+R2vlCvy2yjHcpFqR4iidADVsRXAyLGNTajO747C6CfTB4tMLwffLmZfNrzKU28dP2HbYdDo0vtn810SZIoOWuMIKJhNMTHCmqhMvAsYy+2pO4v1AtD03GZC7RQ1SAgCL+07Odqw7wl3LZtQx+Ut8zldwzaIdvXi1ohH+Vq/76cBY4CsJgHA3YGjSDabfbLMwkNLL/W8lggZhs+ETUCS+xzWIMOx/M7NCHj7pvnDsw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, "volodymyr_babchuk@xxxxxxxx" <volodymyr_babchuk@xxxxxxxx>
  • Delivery-date: Mon, 14 Mar 2022 17:35:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYMyVll+vC1BXMkUCqASVymvvkmKy/LVYA
  • Thread-topic: [XEN][RFC PATCH v3 08/14] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock


> On 8 Mar 2022, at 19:46, Vikram Garhwal <fnu.vikram@xxxxxxxxxx> wrote:
> 
> Protect iommu_add_dt_device() with dtdevs_lock to prevent concurrent access 
> add.
> 
> Signed-off-by: Vikram Garhwal <fnu.vikram@xxxxxxxxxx>

Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>

> ---
> 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 b3b04f8e03..776809a8f2 100644
> --- a/xen/drivers/passthrough/device_tree.c
> +++ b/xen/drivers/passthrough/device_tree.c
> @@ -145,6 +145,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.
> @@ -157,7 +159,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;
> @@ -188,6 +193,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;
> }
> 
> 




 


Rackspace

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