lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZOSuz+16JD5E0k3z@nvidia.com>
Date:   Tue, 22 Aug 2023 09:49:19 -0300
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Michael Shavit <mshavit@...gle.com>
Cc:     iommu@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org, nicolinc@...dia.com,
        tina.zhang@...el.com, jean-philippe@...aro.org, will@...nel.org,
        robin.murphy@....com, Dawei Li <set_pte_at@...look.com>,
        Joerg Roedel <joro@...tes.org>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Lu Baolu <baolu.lu@...ux.intel.com>,
        Mark Brown <broonie@...nel.org>
Subject: Re: [RFC PATCH v2 1/9] iommu/arm-smmu-v3: group attached devices by
 smmu

On Tue, Aug 22, 2023 at 06:56:57PM +0800, Michael Shavit wrote:
> Always insert a new master in the devices_list besides other masters
> that belong to the same smmu.
> This allows code to batch commands by SMMU when iterating over masters
> that a domain is attached to.
> 
> Signed-off-by: Michael Shavit <mshavit@...gle.com>
> ---
> 
> Changes in v2:
> - New commit
> 
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 22 ++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index f17704c35858d..37b9223c145ba 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2382,6 +2382,24 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master)
>  		arm_smmu_write_ctx_desc(master, 0, NULL);
>  }
>  
> +static void arm_smmu_domain_device_list_add(struct arm_smmu_domain *smmu_domain,
> +					   struct arm_smmu_master *master)
> +{
> +	struct arm_smmu_master *iter;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&smmu_domain->devices_lock, flags);
> +	if (list_empty(&smmu_domain->devices))
> +		list_add(&master->domain_head, &smmu_domain->devices);
> +	else {
> +		list_for_each_entry(iter, &smmu_domain->devices, domain_head)
> +			if (iter->smmu == master->smmu)
> +				break;
> +		list_add(&master->domain_head, &iter->domain_head);
> +	}

IIRC you are not supposed to touch iter after the list_for_each. Like this:

 list_for_each_entry(iter, &smmu_domain->devices, domain_head) {
      if (iter->smmu == master->smmu) {
          list_add(&master->domain_head, iter->domain_head);
 	  goto out;
      }
 }
 list_add(&master->domain_head, &smmu_domain->devices);
out:
 spin_unlock_irqrestore(&smmu_domain->devices_lock, flags);

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ