All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Consolidate the error handling around device attachment
@ 2023-03-21 19:53 Jason Gunthorpe
  2023-03-21 19:53 ` [PATCH 1/9] iommu: Make __iommu_group_set_domain() handle error unwind Jason Gunthorpe
                   ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: Jason Gunthorpe @ 2023-03-21 19:53 UTC (permalink / raw)
  To: iommu, Joerg Roedel, Robin Murphy, Will Deacon
  Cc: Lu Baolu, Kevin Tian, Nicolin Chen

Device attachment has a bunch of different flows open coded in different
ways throughout the code.

One of the things that became apparently recently is that error handling
is important and we do need to consistently treat errors during attach and
have some strategy to unwind back to a safe state.

Implement a single algorithm for this in one function. It will call each
device's attach, if it fails it will try to go back to the prior domain or
as a contingency against a UAF crash try to go to a blocking domain.

As part of this we consolidate how the default domain is created and
attached as well into one place with a consistent flow.

The new worker functions are called __iommu_device_set_domain() and
__iommu_group_set_domain_internal(), each has sensible error handling
internally. At the end __iommu_group_set_domain_internal() is the only
function that stores to group->domain, and must be called to change this
value.

Some flags tell the intent of the caller, if the caller cannot accept a
failure, or if the caller is a first attach and wants to do the deferred
logic.

Several of the confusing workflows where we store things in group->domain
or group->default_domain before they are fully setup are removed.

Cc: Nicolin Chen <nicolinc@nvidia.com>
Cc: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Jason Gunthorpe (9):
  iommu: Make __iommu_group_set_domain() handle error unwind
  iommu: Use __iommu_group_set_domain() for __iommu_attach_group()
  iommu: Use __iommu_group_set_domain() in iommu_change_dev_def_domain()
  iommu: Replace __iommu_group_dma_first_attach() with set_domain
  iommu: Make iommu_group_do_dma_first_attach() simpler
  iommu: Fix iommu_probe_device() to attach the right domain
  iommu: Remove the assignment of group->domain during default domain
    alloc
  iommu: Consolidate the default_domain setup to one function
  iommu: Remove __iommu_group_for_each_dev()

 drivers/iommu/iommu.c | 444 +++++++++++++++++++++---------------------
 1 file changed, 222 insertions(+), 222 deletions(-)


base-commit: 771ad306397838108f264e180e31188136907616
-- 
2.40.0


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-03-24 19:36 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 19:53 [PATCH 0/9] Consolidate the error handling around device attachment Jason Gunthorpe
2023-03-21 19:53 ` [PATCH 1/9] iommu: Make __iommu_group_set_domain() handle error unwind Jason Gunthorpe
2023-03-24  7:17   ` Tian, Kevin
2023-03-24 15:17     ` Jason Gunthorpe
2023-03-21 19:53 ` [PATCH 2/9] iommu: Use __iommu_group_set_domain() for __iommu_attach_group() Jason Gunthorpe
2023-03-24  7:18   ` Tian, Kevin
2023-03-21 19:53 ` [PATCH 3/9] iommu: Use __iommu_group_set_domain() in iommu_change_dev_def_domain() Jason Gunthorpe
2023-03-24  7:19   ` Tian, Kevin
2023-03-24 13:17     ` Jason Gunthorpe
2023-03-21 19:53 ` [PATCH 4/9] iommu: Replace __iommu_group_dma_first_attach() with set_domain Jason Gunthorpe
2023-03-24  7:20   ` Tian, Kevin
2023-03-21 19:53 ` [PATCH 5/9] iommu: Make iommu_group_do_dma_first_attach() simpler Jason Gunthorpe
2023-03-24  7:23   ` Tian, Kevin
2023-03-24 15:23     ` Jason Gunthorpe
2023-03-21 19:53 ` [PATCH 6/9] iommu: Fix iommu_probe_device() to attach the right domain Jason Gunthorpe
2023-03-24  7:29   ` Tian, Kevin
2023-03-24 15:42     ` Jason Gunthorpe
2023-03-24 19:36     ` Jason Gunthorpe
2023-03-21 19:53 ` [PATCH 7/9] iommu: Remove the assignment of group->domain during default domain alloc Jason Gunthorpe
2023-03-24  7:30   ` Tian, Kevin
2023-03-21 19:53 ` [PATCH 8/9] iommu: Consolidate the default_domain setup to one function Jason Gunthorpe
2023-03-21 19:53 ` [PATCH 9/9] iommu: Remove __iommu_group_for_each_dev() Jason Gunthorpe
2023-03-22 13:08   ` Joerg Roedel
2023-03-22 13:41     ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.