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: <0e3c15ab-f38f-43e3-9de0-78e8ce486aca@linux.intel.com>
Date: Mon, 16 Jun 2025 15:09:02 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: jgg@...dia.com, kevin.tian@...el.com, corbet@....net, will@...nel.org,
 bagasdotme@...il.com, robin.murphy@....com, joro@...tes.org,
 thierry.reding@...il.com, vdumpa@...dia.com, jonathanh@...dia.com,
 shuah@...nel.org, jsnitsel@...hat.com, nathan@...nel.org,
 peterz@...radead.org, yi.l.liu@...el.com, mshavit@...gle.com,
 praan@...gle.com, zhangzekun11@...wei.com, iommu@...ts.linux.dev,
 linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org, linux-tegra@...r.kernel.org,
 linux-kselftest@...r.kernel.org, patches@...ts.linux.dev, mochs@...dia.com,
 alok.a.tiwari@...cle.com, vasant.hegde@....com, dwmw2@...radead.org
Subject: Re: [PATCH v6 10/25] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC
 ioctl

On 6/16/25 15:04, Nicolin Chen wrote:
> On Mon, Jun 16, 2025 at 02:54:10PM +0800, Baolu Lu wrote:
>> On 6/16/25 14:47, Nicolin Chen wrote:
>>> On Mon, Jun 16, 2025 at 02:12:04PM +0800, Baolu Lu wrote:
>>>> On 6/14/25 15:14, Nicolin Chen wrote:
>>>>> +	if (!viommu->ops || !viommu->ops->get_hw_queue_size ||
>>>>> +	    !viommu->ops->hw_queue_init_phys) {
>>>>> +		rc = -EOPNOTSUPP;
>>>>> +		goto out_put_viommu;
>>>>> +	}
>>> Hmm, here it does abort when !viommu->ops->hw_queue_init_phys ..
>>>
>>>>> +	/*
>>>>> +	 * FIXME once ops->hw_queue_init is introduced, this should check "if
>>>>> +	 * ops->hw_queue_init_phys". And "access" should be initialized to NULL.
>>>>> +	 */
>>>> I just don't follow here. Up until now, only viommu->ops->
>>>> hw_queue_init_phys has been added, which means the current code only
>>>> supports hardware queues that access guest memory using physical
>>>> addresses. The access object is not needed for the other type of
>>>> hardware queue that uses guest IOVA.
>>>>
>>>> So, why not just abort here if ops->hw_queue_init_phys is not supported
>>>> by the IOMMU driver?
>>> .. so, it already does.
>>>
>>>> Leave other logics to the patches that introduce
>>>> ops->hw_queue_init? I guess that would make this patch more readible.
>>> The patch is doing in the way to support the hw_queue_init_phys
>>> case only. It is just adding some extra FIXMEs as the guideline
>>> for the future patch adding hw_queue_init op.
>>>
>>> I personally don't feel these are confusing. Maybe you can help
>>> point out what specific wording feels odd here? Maybe "FIXME"s
>>> should be "TODO"s?
>> Oh, I probably misunderstood the logic here. For both hw_queue_init and
>> hw_queue_init_phys, using an access object to pin the pages for hardware
>> access is necessary, right? My understanding was that pinning pages is
>> only required for hw_queue_init_phys.
> No. The access is only used by the ops->hw_queue_init_phys case.
> 
> The ops->hw_queue_init case will use the cmd->nesting_parent_iova
> directly without calling iommufd_hw_queue_alloc_phys().
> 
> This FIXME means that, when adding ops->hw_queue_init, add this:
> 
> -	struct iommufd_access *access;
> +	struct iommufd_access *access = NULL;
> ...
> -	access = iommufd_hw_queue_alloc_phys(cmd, viommu, &base_pa);
> +	if (ops->hw_queue_init_phys) {
> +		access = iommufd_hw_queue_alloc_phys(cmd, viommu, &base_pa);
> 
> Also, the other FIXME guideline states that these two ops should be
> mutually exclusive. So, add this too:
> +	if (WARN_ON_ONCE(ops->hw_queue_init &&
> +			 ops->hw_queue_init_phys)) {
> +		rc = -EOPNOTSUPP;

Okay, above matches my understanding. Thanks for the explanation.

Thanks,
baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ