Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Qinxin Xia <xiaqinxin@huawei.com>
Cc: robin.murphy@arm.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
	yangyicong@huawei.com, wangzhou1@hisilicon.com,
	prime.zeng@hisilicon.com, xuwei5@huawei.com,
	fanghao11@huawei.com, jonathan.cameron@huawei.com,
	linuxarm@huawei.com
Subject: Re: [PATCH 1/2] iommu/debug: Add IOMMU page table dump debug facility
Date: Tue, 9 Sep 2025 14:06:33 +0100	[thread overview]
Message-ID: <aMAmWQJy_G50xoBf@willie-the-truck> (raw)
In-Reply-To: <20250814093005.2040511-2-xiaqinxin@huawei.com>

On Thu, Aug 14, 2025 at 05:30:04PM +0800, Qinxin Xia wrote:
> +/**
> + * iova_info_dump - dump iova alloced
> + * @s - file structure used to generate serialized output
> + * @iovad: - iova domain in question.
> + */
> +static int iommu_iova_info_dump(struct seq_file *s, struct iommu_domain *domain)
> +{
> +	struct iova_domain *iovad;
> +	unsigned long long pfn;
> +	unsigned long i_shift;
> +	struct rb_node *node;
> +	unsigned long flags;
> +	size_t prot_size;
> +
> +	iovad = iommu_domain_to_iovad(domain);
> +	if (!iovad)
> +		return -ENOMEM;
> +
> +	i_shift = iova_shift(iovad);
> +
> +	/* Take the lock so that no other thread is manipulating the rbtree */
> +	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
> +	assert_spin_locked(&iovad->iova_rbtree_lock);
> +
> +	for (node = rb_first(&iovad->rbroot); node; node = rb_next(node)) {
> +		struct iova *iova = rb_entry(node, struct iova, node);
> +
> +		if (iova->pfn_hi <= iova->pfn_lo)
> +			continue;
> +
> +		for (pfn = iova->pfn_lo; pfn <= iova->pfn_hi; ) {
> +			prot_size = domain->ops->dump_iova_prot(s, domain, pfn << i_shift);
> +			pfn = ((pfn << i_shift) + prot_size) >> i_shift;
> +		}
> +	}
> +
> +	spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);

Why is the IOVA rbtree lock sufficient for serialising the page-table
accesses made by ->dump_iova_prot()? I don't see anything here that
prevents the walker walking into page-table pages that are e.g. being
freed or manipulated concurrently.

Will


  parent reply	other threads:[~2025-09-09 17:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14  9:30 [PATCH 0/2] iommu: Add io_ptdump debug interface for iommu Qinxin Xia
2025-08-14  9:30 ` [PATCH 1/2] iommu/debug: Add IOMMU page table dump debug facility Qinxin Xia
2025-08-15  6:47   ` kernel test robot
2025-08-15  9:57   ` kernel test robot
2025-09-09 13:06   ` Will Deacon [this message]
2025-09-10  2:58     ` Qinxin Xia
2025-09-11 14:58       ` Will Deacon
2025-08-14  9:30 ` [PATCH 2/2] iommu/io-pgtable: Add ARM SMMUv3 page table dump support Qinxin Xia
2025-08-15  9:14   ` kernel test robot
2025-09-02 16:10 ` [PATCH 0/2] iommu: Add io_ptdump debug interface for iommu Jason Gunthorpe
2025-09-10  3:20   ` Qinxin Xia
2025-09-10 14:15     ` Jason Gunthorpe
2025-09-11 14:08       ` Qinxin Xia
2025-09-15 16:28         ` Jason Gunthorpe
2025-10-18 10:39           ` Qinxin Xia

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=aMAmWQJy_G50xoBf@willie-the-truck \
    --to=will@kernel.org \
    --cc=fanghao11@huawei.com \
    --cc=iommu@lists.linux.dev \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=robin.murphy@arm.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=xiaqinxin@huawei.com \
    --cc=xuwei5@huawei.com \
    --cc=yangyicong@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