Re: [PATCH 4/4] iommu/vt-d: Remove lazy allocation of domains

From: Lu Baolu
Date: Fri Mar 08 2019 - 20:58:57 EST


Hi James,

On 3/9/19 12:57 AM, James Sewart wrote:
Hey Lu,

On 8 Mar 2019, at 03:09, Lu Baolu<baolu.lu@xxxxxxxxxxxxxxx> wrote:

Do you mind if I work on top of your patches for further cleanups and
sign off a v2 together with you?
Sure, sounds good. Iâll fixup patch 3 and have a go at integrating
iommu_prepare_isa into get_resv_regions. This should make the initial
domain logic here quite concise.
Here attached three extra patches which I think should be added before
PATCH 3/4, and some further cleanup changes which you can merge with
PATCH 4/4.

----------------

0006-iommu-Add-ops-entry-for-vendor-specific-default-doma.patch
0007-iommu-vt-d-Add-is_identity_map-ops-entry.patch

These two patches aim to add a generic method for vendor specific iommu
drivers to specify the type of the default domain for a device. Intel
iommu driver will register an ops for this since it already has its own
identity map adjudicator for a long time.
This seems like a good idea, but as domain alloc is only called for the
default domain on first device attached to a group, we may miss checking
whether a device added later should have an identity domain. Should there
be paths to downgrade a groups domain if one of the devices requires one?


Good catch!

This is supposed to be handled in iommu_no_mapping(). But, obviously
current code sticks to lazy domain allocation. I'm not sure whether
there are any real such cases, but we should handle it in a clean way.
My idea is that we could downgrade to multiple domains per group (just
like what we have now) in this case and print a kernel message for this.

Or any other thoughts?

Best regards,
Lu Baolu