From: Joao Martins <joao.m.martins@oracle.com>
To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>,
"Tian, Kevin" <kevin.tian@intel.com>
Cc: "robin.murphy@arm.com" <robin.murphy@arm.com>,
"will@kernel.org" <will@kernel.org>,
"joro@8bytes.org" <joro@8bytes.org>,
"jgg@nvidia.com" <jgg@nvidia.com>,
"ryan.roberts@arm.com" <ryan.roberts@arm.com>,
"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
"mshavit@google.com" <mshavit@google.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
jiangkunkun <jiangkunkun@huawei.com>,
zhukeqian <zhukeqian1@huawei.com>, Linuxarm <linuxarm@huawei.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [PATCH v3 2/4] iommu/io-pgtable-arm: Add read_and_clear_dirty() support
Date: Wed, 22 May 2024 15:37:57 +0100 [thread overview]
Message-ID: <4618c24f-aaa8-453f-aa9d-67a864e1c93b@oracle.com> (raw)
In-Reply-To: <13e93238f21b42539097d7e347be684e@huawei.com>
On 22/05/2024 15:03, Shameerali Kolothum Thodi wrote:
>
>
>> -----Original Message-----
>> From: Tian, Kevin <kevin.tian@intel.com>
>> Sent: Wednesday, May 22, 2024 8:12 AM
>> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>;
>> iommu@lists.linux.dev; linux-arm-kernel@lists.infradead.org
>> Cc: robin.murphy@arm.com; will@kernel.org; joro@8bytes.org;
>> jgg@nvidia.com; ryan.roberts@arm.com; nicolinc@nvidia.com;
>> mshavit@google.com; eric.auger@redhat.com; joao.m.martins@oracle.com;
>> jiangkunkun <jiangkunkun@huawei.com>; zhukeqian
>> <zhukeqian1@huawei.com>; Linuxarm <linuxarm@huawei.com>
>> Subject: RE: [PATCH v3 2/4] iommu/io-pgtable-arm: Add read_and_clear_dirty()
>> support
>>
>>> From: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
>>> Sent: Tuesday, April 30, 2024 9:43 PM
>>> +
>>> +static int arm_lpae_read_and_clear_dirty(struct io_pgtable_ops *ops,
>>> + unsigned long iova, size_t size,
>>> + unsigned long flags,
>>> + struct iommu_dirty_bitmap *dirty)
>>> +{
>>> + struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
>>> + struct io_pgtable_cfg *cfg = &data->iop.cfg;
>>> + struct io_pgtable_walk_data walk_data = {
>>> + .dirty = dirty,
>>> + .flags = flags,
>>> + .addr = iova,
>>> + .end = iova + size,
>>> + };
>>> + arm_lpae_iopte *ptep = data->pgd;
>>> + int lvl = data->start_level;
>>> +
>>> + if (WARN_ON(!size))
>>> + return -EINVAL;
>>> + if (WARN_ON((iova + size - 1) & ~(BIT(cfg->ias) - 1)))
>>> + return -EINVAL;
>>> + if (data->iop.fmt != ARM_64_LPAE_S1)
>>> + return -EINVAL;
>>> +
>>> + return __arm_lpae_iopte_walk_dirty(data, &walk_data, ptep, lvl);
>>
>> Intel/AMD drivers also checks:
>>
>> if (!dmar_domain->dirty_tracking && dirty->bitmap)
>> return -EINVAL;
>
> Is that really required? Is the concern here is user may issue
> GET_DIRTY_BITMAP IOCTL without any validation and that may
> result in unnecessary scanning of page tables? May be we should
> handle it in core code then I think.
This is just to catch the case where IOMMUFD can call into read_and_clear()
without dirty tracking enabled and without a bitmap structure to clear dirty
bits -- in order to ensure a clean PTE data snapshot after start(). And thus it
errors out on others.
Right now we don't track in iommufd that dirty tracking is active in the domain,
vendor does so in its own way. I mean we could move that to core, but we end up
duplicating what the iommu driver is already doing.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-05-22 14:39 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 13:43 [PATCH v3 0/4] iommu/smmuv3: Add IOMMUFD dirty tracking support for SMMUv3 Shameer Kolothum
2024-04-30 13:43 ` [PATCH v3 1/4] iommu/arm-smmu-v3: Add feature detection for HTTU Shameer Kolothum
2024-05-22 7:02 ` Tian, Kevin
2024-04-30 13:43 ` [PATCH v3 2/4] iommu/io-pgtable-arm: Add read_and_clear_dirty() support Shameer Kolothum
2024-04-30 14:51 ` Ryan Roberts
2024-05-12 12:51 ` Jason Gunthorpe
2024-05-22 7:12 ` Tian, Kevin
2024-05-22 12:37 ` Jason Gunthorpe
2024-05-22 14:03 ` Shameerali Kolothum Thodi
2024-05-22 14:37 ` Joao Martins [this message]
2024-05-22 16:56 ` Jason Gunthorpe
2024-05-22 17:10 ` Joao Martins
2024-05-22 17:50 ` Jason Gunthorpe
2024-05-22 18:15 ` Joao Martins
2024-05-22 18:39 ` Joao Martins
2024-05-23 3:30 ` Tian, Kevin
2024-05-24 11:30 ` Joao Martins
2024-05-24 14:07 ` Jason Gunthorpe
2024-05-27 1:21 ` Tian, Kevin
2024-05-27 9:50 ` Joao Martins
2024-06-01 18:55 ` Jason Gunthorpe
2024-06-03 18:50 ` Joao Martins
2024-04-30 13:43 ` [PATCH v3 3/4] iommu/arm-smmu-v3: Add support for dirty tracking in domain alloc Shameer Kolothum
2024-04-30 15:05 ` Ryan Roberts
2024-05-12 12:57 ` Jason Gunthorpe
2024-05-22 7:16 ` Tian, Kevin
2024-05-22 12:38 ` Jason Gunthorpe
2024-05-22 14:30 ` Shameerali Kolothum Thodi
2024-05-22 23:49 ` Tian, Kevin
2024-04-30 13:43 ` [PATCH v3 4/4] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping Shameer Kolothum
2024-05-12 12:08 ` Jason Gunthorpe
2024-05-22 7:19 ` Tian, Kevin
2024-05-22 12:39 ` Jason Gunthorpe
2024-05-22 23:52 ` Tian, Kevin
2024-05-22 13:26 ` Shameerali Kolothum Thodi
2024-05-22 13:41 ` Jason Gunthorpe
2024-05-12 12:58 ` [PATCH v3 0/4] iommu/smmuv3: Add IOMMUFD dirty tracking support for SMMUv3 Jason Gunthorpe
2024-05-22 13:28 ` Shameerali Kolothum Thodi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4618c24f-aaa8-453f-aa9d-67a864e1c93b@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=jiangkunkun@huawei.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=mshavit@google.com \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=ryan.roberts@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=will@kernel.org \
--cc=zhukeqian1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).