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: <d8f2646d-be6a-9636-3e9d-8e1d65ecb0c4@linux.intel.com>
Date:   Tue, 26 Jul 2022 16:47:00 +0800
From:   Baolu Lu <baolu.lu@...ux.intel.com>
To:     Jason Gunthorpe <jgg@...dia.com>
Cc:     baolu.lu@...ux.intel.com, "Tian, Kevin" <kevin.tian@...el.com>,
        Joerg Roedel <joro@...tes.org>,
        Christoph Hellwig <hch@...radead.org>,
        "Raj, Ashok" <ashok.raj@...el.com>, Will Deacon <will@...nel.org>,
        Robin Murphy <robin.murphy@....com>,
        Jean-Philippe Brucker <jean-philippe@...aro.com>,
        "Jiang, Dave" <dave.jiang@...el.com>,
        Vinod Koul <vkoul@...nel.org>,
        Eric Auger <eric.auger@...hat.com>,
        "Liu, Yi L" <yi.l.liu@...el.com>,
        "Pan, Jacob jun" <jacob.jun.pan@...el.com>,
        Zhangfei Gao <zhangfei.gao@...aro.org>,
        "Zhu, Tony" <tony.zhu@...el.com>,
        "iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v10 08/12] iommu/sva: Refactoring
 iommu_sva_bind/unbind_device()

On 2022/7/25 22:47, Jason Gunthorpe wrote:
> On Mon, Jul 25, 2022 at 06:22:06PM +0800, Baolu Lu wrote:
>> On 2022/7/25 15:50, Tian, Kevin wrote:
>>>> From: Baolu Lu <baolu.lu@...ux.intel.com>
>>>> Sent: Sunday, July 24, 2022 9:48 PM
>>>>>
>>>>> The API is really refcounting the PASID:
>>>>>
>>>>>> +struct iommu_sva *iommu_sva_bind_device(struct device *dev,
>>>>>> +					struct mm_struct *mm);
>>>>>> +void iommu_sva_unbind_device(struct iommu_sva *handle);
>>>>>
>>>>> So what you need to do is store that 'iommu_sva' in the group's PASID
>>>>> xarray.
>>>>>
>>>>> The bind logic would be
>>>>>
>>>>>      sva = xa_load(group->pasid, mm->pasid)
>>>>>      if (sva)
>>>>>         refcount_inc(sva->users)
>>>>>         return sva
>>>>>      sva = kalloc
>>>>>      sva->domain = domain
>>>>>      xa_store(group->pasid, sva);
>>>>
>>>> Thanks for the suggestion. It makes a lot of sense to me.
>>>>
>>>> Furthermore, I'd like to separate the generic data from the caller-
>>>> specific things because the group->pasid_array should also be able to
>>>> serve other usages. Hence, the attach/detach_device_pasid interfaces
>>>> might be changed like below:
>>>>
>>>> /* Collection of per-pasid IOMMU data */
>>>> struct group_pasid {
>>>> 	struct iommu_domain *domain;
>>>> 	void *priv;
>>>> };
>>>>
>>>
>>> Is there any reason why pasid refcnt is sva specific and needs to be
>>> in a priv field?
>>
>> I am going to store the iommu_sva data which represents the bind
>> relationship between device and domain.
> 
> Why do you need that?
> 
> If you are starting at the pasid xarray then you already know the
> group/device, so we don't need to store it again.
> 
> The only thing needed is the refcount so just store a refcount in this
> structure and be done with it. If someone needs to add something later
> then we can use a union or something, but right now adding an untagged
> void * is bad.

Fair enough. I will update it accordingly.

Best regards,
baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ