On 25/09/2018 17:20, Thomas Huth 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. > > Signed-off-by: Thomas Huth <th...@redhat.com> > --- > hw/s390x/ipl.h | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h > index 4e87b89..f72a82f 100644 > --- a/hw/s390x/ipl.h > +++ b/hw/s390x/ipl.h > @@ -132,15 +132,17 @@ typedef struct QemuIplParameters QemuIplParameters; > struct S390IPLState { > /*< private >*/ > DeviceState parent_obj; > + /* Packed structs first (to make sure we've got a proper alignment): */
Is that a sad smiley at the end? ;) > + IplParameterBlock iplb; > + QemuIplParameters qipl; > + /* Other private members without packed attribute: */ > uint64_t start_addr; > uint64_t compat_start_addr; > uint64_t bios_start_addr; > uint64_t compat_bios_start_addr; > bool enforce_bios; > - IplParameterBlock iplb; > bool iplb_valid; > bool netboot; > - QemuIplParameters qipl; > /* reset related properties don't have to be migrated or reset */ > enum s390_reset reset_type; > int reset_cpu_index; > Instead of the comment, compile time asserts using offsetof? Anyhow Reviewed-by: David Hildenbrand <da...@redhat.com> -- Thanks, David / dhildenb