From: Pranjal Shrivastava <praan@google.com>
To: Samiullah Khawaja <skhawaja@google.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Lu Baolu <baolu.lu@linux.intel.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
David Woodhouse <dwmw2@infradead.org>,
Robin Murphy <robin.murphy@arm.com>,
Kevin Tian <kevin.tian@intel.com>,
Alex Williamson <alex@shazbot.org>, Shuah Khan <shuah@kernel.org>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, Pratyush Yadav <pratyush@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
David Matlack <dmatlack@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vipin Sharma <vipinsh@google.com>,
Ankit Soni <Ankit.Soni@amd.com>,
Nicolin Chen <nicolinc@nvidia.com>, John Starks <dev@jstarks.net>
Subject: Re: [PATCH v8 02/18] iommu: Implement IOMMU Live update FLB callbacks
Date: Mon, 30 Nov 2026 18:47:43 +0000 [thread overview]
Message-ID: <aw3Ezx2TwsQO-Ges@google.com> (raw)
In-Reply-To: <aw3DAewDOvnhTHmB@google.com>
On Mon, Nov 30, 2026 at 06:40:01PM +0000, Pranjal Shrivastava wrote:
> On Mon, Nov 23, 2026 at 04:49:33AM +0000, Samiullah Khawaja wrote:
> > Add liveupdate FLB for IOMMU state preservation. Use KHO preserve memory
> > alloc/free helper functions to allocate memory for the IOMMU Live update
> > FLB object and the serialization structs for device, domain and iommu.
> >
> > During retrieve, walk through the preserved obj array headers and
> > restore each folio. Also recreate the FLB obj.
> >
> > +/*
> > + * Restore a set of serialized objects from the previous kernel. The objects
> > + * are read using the size recorded by the previous kernel in their header.
> > + *
> > + * Failure to restore preserved IOMMU state is considered fatal. This is
> > + * because the IOMMU translations for preserved IOMMUs were kept enabled in the
> > + * previous kernel and the preserved devices have their IOMMU domains still
> > + * present. Not being able to restore means that the memory mapped into
> > + * preserved domains might be already corrupted by the preserved devices.
> > + */
> > +static void iommu_ser_set_restore(struct iommu_ser_set *set, u64 head_pa)
> > +{
> > + size_t entry_size = sizeof(struct iommu_hdr_ser);
> > +
> > + if (head_pa) {
> > + struct kho_block_header_ser *block = phys_to_virt(head_pa);
> > + struct iommu_hdr_ser *hdr = (void *)(block + 1);
> > +
> > + entry_size = hdr->size;
> > + }
> > +
> > + if (entry_size < sizeof(struct iommu_hdr_ser) ||
> > + entry_size > KHO_BLOCK_SIZE - sizeof(struct kho_block_header_ser))
> > + goto err_fatal;
> > +
>
> With the callers passing sizeof(struct iommu_domain_ser) etc. Or, if
> every layout change is supposed to bump IOMMU_LUO_FLB_VERSION (see the
> comment on the ABI doc below), simply require that entry_size matches
> sizeof() of the struct.
>
Oops, I lost a part of the comment while trimming, what I meant was:
The lower bound here only guarantees that the common header is
readable, but the users of these sets dereference each entry as the
full iommu_{domain,device,hw}_ser. If the previous kernel recorded a
smaller size, we'd read past the end of each object into the next
entry. Should the lower bound be the size of the struct the set holds,
e.g.:
static void iommu_ser_set_restore(struct iommu_ser_set *set, u64 head_pa,
size_t min_size)
[...]
if (entry_size < min_size ||
entry_size > KHO_BLOCK_SIZE - sizeof(struct kho_block_header_ser))
goto err_fatal;
With the callers passing sizeof(struct iommu_domain_ser) etc.? Or, if
every layout change is supposed to bump IOMMU_LUO_FLB_VERSION, simply
require that entry_size matches sizeof() of the struct.
Thanks,
Praan
next prev parent reply other threads:[~2026-11-30 18:47 UTC|newest]
Thread overview: 27+ 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-30 10:28 ` Ankit Soni
2026-11-30 18:40 ` Pranjal Shrivastava
2026-11-30 18:47 ` Pranjal Shrivastava [this message]
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-30 17:06 ` Dongli Zhang
2026-11-23 4:49 ` [PATCH v8 05/18] iommu: Implement IOMMU domain preservation Samiullah Khawaja
2026-11-24 5:23 ` Ankit Soni
2026-11-24 17:40 ` Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 06/18] iommu: Implement device and IOMMU HW preservation Samiullah Khawaja
2026-11-24 4:29 ` Ankit Soni
2026-11-24 17:40 ` 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 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=aw3Ezx2TwsQO-Ges@google.com \
--to=praan@google.com \
--cc=Ankit.Soni@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=baolu.lu@linux.intel.com \
--cc=dev@jstarks.net \
--cc=dmatlack@google.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=robin.murphy@arm.com \
--cc=shuah@kernel.org \
--cc=skhawaja@google.com \
--cc=vipinsh@google.com \
--cc=will@kernel.org \
/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