Re: [PATCH 6/7] iommu/vt-d: Refactor first_level_by_default()
From: Jason Gunthorpe
Date: Fri Oct 11 2024 - 12:31:39 EST
On Fri, Oct 11, 2024 at 12:27:21PM +0800, Lu Baolu wrote:
> The first stage page table is compatible across host and guest kernels.
> Therefore, this driver uses the first stage page table as the default for
> paging domains.
>
> The helper first_level_by_default() determines the feasibility of using
> the first stage page table based on a global policy. This policy requires
> consistency in scalable mode and first stage translation capability among
> all iommu units. However, this is unnecessary as domain allocation,
> attachment, and removal operations are performed on a per-device basis.
>
> The domain type (IOMMU_DOMAIN_DMA vs. IOMMU_DOMAIN_UNMANAGED) should not
> be a factor in determining the first stage page table usage. Both types
> are for paging domains, and there's no fundamental difference between them.
> The driver should not be aware of this distinction unless the core
> specifies allocation flags that require special handling.
>
> Convert first_level_by_default() from global to per-iommu and remove the
> 'type' input.
>
> Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> ---
> drivers/iommu/intel/iommu.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Jason