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

From: Pratyush Yadav

Date: Mon May 18 2026 - 10:15:48 EST


On Mon, May 18 2026, Pranjal Shrivastava wrote:

> 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 had the same question and Jason told me otherwise:
https://lore.kernel.org/linux-mm/20250909155044.GN789684@xxxxxxxxxx/

I took him at his word and didn't really look much deeper. I use them
for memfd preservation as well. See struct memfd_luo_folio_ser in
include/linux/kho/abi/memfd.h.

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

--
Regards,
Pratyush Yadav