From: sashiko-bot@kernel.org
To: "Samiullah Khawaja" <skhawaja@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v8 14/18] iommu/vt-d: Handle reattach of the restored domain
Date: Mon, 23 Nov 2026 05:03:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-228696@kernel.org> (raw)
In-Reply-To: <20261123044949.3610702-15-skhawaja@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] iommu/vt-d: guard(mutex) mixed with goto in
domain_attach_restored_iommu()
--
commit 693fa762fb6f04c8a284677c5b4a1aeaceac5c22
Author: Samiullah Khawaja <skhawaja@google.com>
iommu/vt-d: Handle reattach of the restored domain
This commit implements reattachment and detachment of restored domains to
preserved devices across liveupdate using the preserved domain ID, without
modifying preserved context and PASID table entries.
> diff --git a/drivers/iommu/intel/liveupdate.c b/drivers/iommu/intel/liveupdate.c
> index 34651698b8e9a..f907e52576e57 100644
> --- a/drivers/iommu/intel/liveupdate.c
> +++ b/drivers/iommu/intel/liveupdate.c
> @@ -444,6 +444,176 @@ void intel_iommu_handle_drhd_restore_failure(struct intel_iommu *iommu)
[ ... ]
> +static int domain_attach_restored_iommu(struct dmar_domain *domain,
> + struct intel_iommu *iommu,
> + struct iommu_device_ser *device_ser)
> +{
> + struct iommu_domain_info *info, *curr;
> + struct iommu_domain_ser *domain_ser;
> + struct iommu_hw_ser *iommu_hw_ser;
> + int restored_did;
> + int ret;
[ ... ]
> + info = kzalloc_obj(*info);
> + if (!info)
> + return -ENOMEM;
> +
> + guard(mutex)(&iommu->did_lock);
> + curr = xa_load(&domain->iommu_array, iommu->seq_id);
> + if (curr) {
> + kfree(info);
> + if (WARN_ON(curr->did != restored_did))
> + return -EINVAL;
> +
> + curr->refcnt++;
> + return 0;
> + }
> +
> + info->refcnt = 1;
> + info->did = restored_did;
> + info->iommu = iommu;
> + curr = xa_cmpxchg(&domain->iommu_array, iommu->seq_id,
> + NULL, info, GFP_KERNEL);
> + if (curr) {
> + ret = xa_err(curr) ? : -EBUSY;
> + goto err_unlock;
> + }
> +
> + return 0;
> +
> +err_unlock:
> + kfree(info);
> + return ret;
> +}
[Severity: Low]
This isn't a bug, but domain_attach_restored_iommu() mixes
guard(mutex)(&iommu->did_lock) with a single-use goto err_unlock label (where
the lock is still held at the label and released by the guard on return).
Following cleanup.h conventions, info could be freed inline before returning
on the xa_cmpxchg() failure path, or managed with __free(kfree).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123044949.3610702-1-skhawaja@google.com?part=14
next prev parent reply other threads:[~2026-11-23 5:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 4:49 [PATCH v8 00/18] iommu: Add live update state preservation Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 01/18] liveupdate: Export symbols needed by modules Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 02/18] iommu: Implement IOMMU Live update FLB callbacks Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 03/18] iommu/pages: Add APIs to preserve/unpreserve/restore iommu pages Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 04/18] iommupt: Implement preserve/unpreserve/restore callbacks Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 05/18] iommu: Implement IOMMU domain preservation Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 06/18] iommu: Implement device and IOMMU HW preservation Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 07/18] iommu/vt-d: Implement device and iommu preserve/unpreserve ops Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 08/18] iommu/vt-d: Clear unpreserved context entries during shutdown Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 09/18] iommu: Add APIs to get iommu and device restored state Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 10/18] iommu/vt-d: Combine disable_dmar_iommu() and free_dmar_iommu() Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 11/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 12/18] iommu/vt-d: Preserve PASID table of preserved device Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 13/18] iommu: Restore and reattach preserved domains to devices Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 14/18] iommu/vt-d: Handle reattach of the restored domain Samiullah Khawaja
2026-11-23 5:03 ` sashiko-bot [this message]
2026-11-23 4:49 ` [PATCH v8 15/18] iommufd: Implement ioctl to mark HWPT for preservation Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 16/18] iommufd: Persist iommu hardware pagetables for live update Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 17/18] iommufd: Add APIs to preserve/unpreserve a vfio cdev Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 18/18] iommufd/selftest: Add test to verify iommufd preservation Samiullah Khawaja
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=sashiko-outbox-228696@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=skhawaja@google.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