[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PULL 01/15] hw/s390x/ipl: Fix alignment problems of S390IP
From: |
Cornelia Huck |
Subject: |
[qemu-s390x] [PULL 01/15] hw/s390x/ipl: Fix alignment problems of S390IPLState members |
Date: |
Thu, 4 Oct 2018 17:28:43 +0200 |
From: Thomas Huth <address@hidden>
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 misaligned memory address.
The easiest solution to fix this problem is to move the packed structures
to the beginning of the S390IPLState, right after the DeviceState of course
which has to stay first for QOM reasons. But since DeviceState is a non-packed
struct, we can be sure that it will be padded to the correct alignment at the
end. If not, the QEMU_BUILD_BUG_MSG in this patch will tell us.
Signed-off-by: Thomas Huth <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: David Hildenbrand <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
hw/s390x/ipl.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index 4e87b89418..b3a07a12d8 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -132,15 +132,15 @@ typedef struct QemuIplParameters QemuIplParameters;
struct S390IPLState {
/*< private >*/
DeviceState parent_obj;
+ IplParameterBlock iplb;
+ QemuIplParameters qipl;
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;
@@ -157,6 +157,7 @@ struct S390IPLState {
bool iplbext_migration;
};
typedef struct S390IPLState S390IPLState;
+QEMU_BUILD_BUG_MSG(offsetof(S390IPLState, iplb) & 3, "alignment of iplb
wrong");
#define S390_IPL_TYPE_FCP 0x00
#define S390_IPL_TYPE_CCW 0x02
--
2.14.4
- [qemu-s390x] [PULL 00/15] s390x updates, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 01/15] hw/s390x/ipl: Fix alignment problems of S390IPLState members,
Cornelia Huck <=
- [qemu-s390x] [PULL 04/15] s390x: Fence huge pages prior to 3.1, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 05/15] target/s390x: exception on non-aligned LPSW(E), Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 02/15] hw/s390x/css: Remove QEMU_PACKED from struct SenseId, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 06/15] s390x: move tcg_s390_program_interrupt() into TCG code and mark it noreturn, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 07/15] s390x/tcg: factor out and fix DATA exception injection, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 08/15] s390x/tcg: store in the TB flags if AFP is enabled, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 09/15] s390x/tcg: support flags for instructions, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 10/15] s390x/tcg: add instruction flags for floating point instructions, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 11/15] s390x/tcg: check for AFP-register, BFP and DFP data exceptions, Cornelia Huck, 2018/10/04
- [qemu-s390x] [PULL 14/15] s390x/tcg: refactor specification checking, Cornelia Huck, 2018/10/04