On 26 September 2018 at 08:38, Thomas Huth <th...@redhat.com> wrote: > The IplParameterBlock and QemuIplParameters structures are declared > with QEMU_PACKED, so the compiler assumes that the structures do not > need to be aligned in memory. Since the are listed after a "bool" > within the S390IPLState, the IplParameterBlock and QemuIplParameters > are also indeed mis-aligned in memory. This causes problems on Sparc > during migration, since we use VMSTATE_UINT16 in vmstate_iplb to access > the devno member for example, and the corresponding migration functions > (like qemu_get_be16s) then try to access a 16-bit value from a mis- > aligned memory address. > The easiest solution to fix this problem is to move the packed structures > to the beginning of the S390IPLState. Also add some additional comments > here to prevent that this problem will be introduced again in the future.
> +QEMU_BUILD_BUG_MSG(offsetof(S390IPLState, iplb) & 3, "alignment of iplb > wrong"); Incidentally, new gcc has an attribute "warn_if_not_aligned" so you can say struct S390IPLState { ... IplParameterBlock iplb __attribute__((warn_if_not_aligned(4))); ... }; and then the compiler will warn if the alignment isn't as specified. But that needs such a new version of gcc we're better off with our QEMU_BUILD_BUG_MSG. thanks -- PMM