Re: [PATCH v3 1/1] iommu/sva: Invalidate KVA range on kernel TLB flush

From: Baolu Lu
Date: Wed Aug 27 2025 - 02:37:38 EST


On 8/27/25 00:21, Dave Hansen wrote:
On 8/25/25 19:49, Baolu Lu wrote:
What's strange is that order is almost always 0, except in the path of
remove_pmd_table() -> free_hugepage_table(), where order can be greater
than 0. However, in this context path, free_hugepage_table() isn't used
to free a page table page itself. Instead, it's used to free the actual
pages that a leaf PMD is pointing to.
When I first read this, I thought you meant that remove_pmd_table() was
trying to free a high-order page composed of multiple pte pages. I don't
think it is doing that.

Just to be clear: remove_pmd_table() has two modes:

1. The pmd_leaf() code that calls free_hugepage_table(). It is
removing the memory pointed to by a PMD*entry*. It is*NOT*
removing page tables themselves.
2. The !pmd_leaf() code that does remove the pointers to
individual pte pages and frees them via free_pte_table().

*Neither* of these is freeing high-order page tables pages. It either
frees plain old kernel data pages or it frees an order-0 page table page.

In other words, the pmd_leaf() (mode #1) code is irrelevant to us. Those
entries are all _PAGE_KERNEL so IOMMU accesses with user privilege can't
do anything with them.

I have the same understanding, so case #3 (higher-order non-compound
page table pages) doesn't exist. Page table pages always have an order
equal to 0.

I will head in the direction you pointed out in your previous reply and
post the change later for further review. Thank you for the insights.


Or have I just horribly confused myself?

Thanks,
baolu