Re: [PATCH v2 02/16] iommu: Implement IOMMU Live update FLB callbacks

From: Pranjal Shrivastava

Date: Mon May 18 2026 - 07:57:22 EST


On Fri, May 01, 2026 at 09:45:19PM +0000, David Matlack wrote:

[...]

> > +
> > +/**
> > + * struct iommu_hdr_ser - Common header for all serialized IOMMU objects
> > + * @ref_count: Reference count for the object
> > + * @deleted: Flag indicating if the object is deleted
> > + * @incoming: Flag indicating if the object was preserved in previous kernel
> > + */
> > +struct iommu_hdr_ser {
> > + u32 ref_count;
> > + u32 deleted:1;
> > + u32 incoming:1;
>
> Are C bitfields safe to use in Live Update ABI?
>

AFAIU, they aren't. The C standard does not dictate how bitfields are
packed into their underlying types (e.g., whether they are packed MSB to
LSB or vice-versa), making them highly dependent on the compiler and arch
endianness.

I agree that we cannot rely on bitfields. Let's convert this to something
like u32 flags; field and define explicit bitmasks.

> > +} __packed;
>
> > +/**
> > + * struct iommu_flb_obj - FLB object allocated in current kernel pointing to
> > + * preserved state in FLB
> > + * @lock: Mutex protecting the object
> > + * @ser: Pointer to the serialized state in FLB
> > + * @curr_iommu_array: Pointer to the current array of IOMMU instances
> > + * @curr_domain_array: Pointer to the current array of domains
> > + * @curr_device_array: Pointer to the current array of devices
> > + */
> > +struct iommu_flb_obj {
> > + /* @lock: Protects the serialized objects during concurrent preservation */
> > + struct mutex lock;
> > + struct iommu_flb_ser *ser;
> > +
> > + struct iommu_hw_array_ser *curr_iommu_array;
> > + struct iommu_domain_array_ser *curr_domain_array;
> > + struct iommu_device_array_ser *curr_device_array;
> > +} __packed;
>
> This struct is not ABI so it should not be __packed nor defined in this
> file. I haven't read the whole series yet but this definition can
> probably go in drivers/iommu/liveupdate.c.

+1.

Thanks,
Praan