[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250929155723.GE2695987@ziepe.ca>
Date: Mon, 29 Sep 2025 12:57:23 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: Samiullah Khawaja <skhawaja@...gle.com>
Cc: David Woodhouse <dwmw2@...radead.org>,
Lu Baolu <baolu.lu@...ux.intel.com>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>,
Pasha Tatashin <pasha.tatashin@...een.com>, iommu@...ts.linux.dev,
Robin Murphy <robin.murphy@....com>,
Pratyush Yadav <pratyush@...nel.org>,
Kevin Tian <kevin.tian@...el.com>, linux-kernel@...r.kernel.org,
Saeed Mahameed <saeedm@...dia.com>,
Adithya Jayachandran <ajayachandra@...dia.com>,
Parav Pandit <parav@...dia.com>,
Leon Romanovsky <leonro@...dia.com>, William Tu <witu@...dia.com>,
Vipin Sharma <vipinsh@...gle.com>, dmatlack@...gle.com,
zhuyifei@...gle.com, Chris Li <chrisl@...nel.org>, praan@...gle.com
Subject: Re: [RFC PATCH 08/15] iommu/vt-d: Implement live update
preserve_iommu_context
On Sun, Sep 28, 2025 at 07:06:16PM +0000, Samiullah Khawaja wrote:
> +static int unpreserve_iommu_context(struct intel_iommu *iommu, int end)
> +{
> + struct context_entry *context;
> + int i;
> +
> + if (end < 0)
> + end = ROOT_ENTRY_NR;
> +
> + for (i = 0; i < end; i++) {
> + context = iommu_context_addr(iommu, i, 0, 0);
> + if (context)
> + WARN_ON_ONCE(kho_unpreserve_folio(virt_to_folio(context)));
Wrong function. IIRC all of these allocations came from iommu-pages.c
and have struct page metadata.
iommu-pages needs to participate in restoring them and put back it's
struct page information.
> static int preserve_iommu_state(struct intel_iommu *iommu,
> struct iommu_unit_ser *ser)
> {
> - pr_warn("Not implemented\n");
> - return 0;
> + int ret;
> +
> + spin_lock(&iommu->lock);
> + ret = preserve_iommu_context(iommu);
> + if (ret)
> + goto error;
> +
> + ret = kho_preserve_folio(virt_to_folio(iommu->root_entry));
> + if (ret) {
> + unpreserve_iommu_context(iommu, -1);
> + goto error;
> + }
> +
> + ser->phys_addr = iommu->reg_phys;
> + ser->root_table = __pa(iommu->root_entry);
> + atomic_set(&iommu->preserved, 1);
Why all these atomics??
Also most probably this should all be flowing through the core code as
I think the core code has to genericall prevent attach/detach/probe
from happing once serialization has started.
Jason
Powered by blists - more mailing lists