From 729315ebca0811c11e937d00231f8e05de5b446d Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 27 Sep 2018 10:23:34 +0200 Subject: hw/s390x/css: Remove QEMU_PACKED from struct SenseId The uint16_t member cu_type of struct SenseId is not naturally aligned, and since the struct is marked with QEMU_PACKED, this can lead to unaligned memory accesses - which does not work on architectures like Sparc. Thus remove the QEMU_PACKED here and rather copy the struct byte by byte when we do copy_sense_id_to_guest(). Signed-off-by: Thomas Huth Message-Id: <1538036615-32542-3-git-send-email-thuth@redhat.com> Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- include/hw/s390x/css.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 9da5912921..bec82d0e5b 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -48,7 +48,7 @@ typedef struct SenseId { uint8_t unused; /* padding byte */ /* extended part */ CIW ciw[MAX_CIWS]; /* variable # of CIWs */ -} QEMU_PACKED SenseId; +} SenseId; /* Note: No QEMU_PACKED due to unaligned members */ /* Channel measurements, from linux/drivers/s390/cio/cmf.c. */ typedef struct CMB { -- cgit v1.2.3 From cb89b349074310ff9eb7ebe18a8ae24d7d9ea3fb Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 27 Sep 2018 10:23:35 +0200 Subject: hw/s390x/ioinst: Fix alignment problem in struct SubchDev struct SubchDev embeds several other structures which are marked with QEMU_PACKED. This causes the compiler to not care for proper alignment of these structures. When we later pass around pointers to the unaligned struct members during migration, this causes problems on host architectures like Sparc that can not do unaligned memory access. Most of the structs in ioinst.h are naturally aligned, so we can fix most of the problem by removing the QEMU_PACKED statements (and use QEMU_BUILD_BUG_MSG() statements instead to make sure that there is no padding). However, for the struct SCHIB, we have to keep the QEMU_PACKED since the compiler adds some padding here otherwise. Move this struct to the beginning of struct SubchDev instead to fix the alignment problem here, too. Signed-off-by: Thomas Huth Message-Id: <1538036615-32542-4-git-send-email-thuth@redhat.com> Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- include/hw/s390x/css.h | 4 ++-- include/hw/s390x/ioinst.h | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index bec82d0e5b..aae19c4272 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -118,11 +118,12 @@ typedef enum IOInstEnding { typedef struct SubchDev SubchDev; struct SubchDev { /* channel-subsystem related things: */ + SCHIB curr_status; /* Needs alignment and thus must come first */ + ORB orb; uint8_t cssid; uint8_t ssid; uint16_t schid; uint16_t devno; - SCHIB curr_status; uint8_t sense_data[32]; hwaddr channel_prog; CCW1 last_cmd; @@ -131,7 +132,6 @@ struct SubchDev { bool thinint_active; uint8_t ccw_no_data_cnt; uint16_t migrated_schid; /* used for missmatch detection */ - ORB orb; CcwDataStream cds; /* transport-provided data: */ int (*ccw_cb) (SubchDev *, CCW1); diff --git a/include/hw/s390x/ioinst.h b/include/hw/s390x/ioinst.h index 5f2db6949d..c6737a30d4 100644 --- a/include/hw/s390x/ioinst.h +++ b/include/hw/s390x/ioinst.h @@ -25,7 +25,8 @@ typedef struct SCSW { uint8_t dstat; uint8_t cstat; uint16_t count; -} QEMU_PACKED SCSW; +} SCSW; +QEMU_BUILD_BUG_MSG(sizeof(SCSW) != 12, "size of SCSW is wrong"); #define SCSW_FLAGS_MASK_KEY 0xf000 #define SCSW_FLAGS_MASK_SCTL 0x0800 @@ -94,7 +95,8 @@ typedef struct PMCW { uint8_t pam; uint8_t chpid[8]; uint32_t chars; -} QEMU_PACKED PMCW; +} PMCW; +QEMU_BUILD_BUG_MSG(sizeof(PMCW) != 28, "size of PMCW is wrong"); #define PMCW_FLAGS_MASK_QF 0x8000 #define PMCW_FLAGS_MASK_W 0x4000 @@ -127,7 +129,8 @@ typedef struct IRB { uint32_t esw[5]; uint32_t ecw[8]; uint32_t emw[8]; -} QEMU_PACKED IRB; +} IRB; +QEMU_BUILD_BUG_MSG(sizeof(IRB) != 96, "size of IRB is wrong"); /* operation request block */ typedef struct ORB { @@ -136,7 +139,8 @@ typedef struct ORB { uint8_t lpm; uint8_t ctrl1; uint32_t cpa; -} QEMU_PACKED ORB; +} ORB; +QEMU_BUILD_BUG_MSG(sizeof(ORB) != 12, "size of ORB is wrong"); #define ORB_CTRL0_MASK_KEY 0xf000 #define ORB_CTRL0_MASK_SPND 0x0800 @@ -165,7 +169,8 @@ typedef struct CCW0 { uint8_t flags; uint8_t reserved; uint16_t count; -} QEMU_PACKED CCW0; +} CCW0; +QEMU_BUILD_BUG_MSG(sizeof(CCW0) != 8, "size of CCW0 is wrong"); /* channel command word (type 1) */ typedef struct CCW1 { @@ -173,7 +178,8 @@ typedef struct CCW1 { uint8_t flags; uint16_t count; uint32_t cda; -} QEMU_PACKED CCW1; +} CCW1; +QEMU_BUILD_BUG_MSG(sizeof(CCW1) != 8, "size of CCW1 is wrong"); #define CCW_FLAG_DC 0x80 #define CCW_FLAG_CC 0x40 @@ -192,7 +198,8 @@ typedef struct CCW1 { typedef struct CRW { uint16_t flags; uint16_t rsid; -} QEMU_PACKED CRW; +} CRW; +QEMU_BUILD_BUG_MSG(sizeof(CRW) != 4, "size of CRW is wrong"); #define CRW_FLAGS_MASK_S 0x4000 #define CRW_FLAGS_MASK_R 0x2000 -- cgit v1.2.3 From 28221f9c999a9b34f58d94599da9c229df9a4fed Mon Sep 17 00:00:00 2001 From: Janosch Frank Date: Fri, 28 Sep 2018 11:34:35 +0200 Subject: s390x: Fence huge pages prior to 3.1 As the kernel has no way of disallowing the start of a huge page backed VM, we can migrate a running huge backed VM to a host that has no huge page KVM support. Let's glue huge page support support to the 3.1 machine, so we do not migrate to a destination host that doesn't have QEMU huge page support and can stop migration if KVM doesn't indicate support. Signed-off-by: Janosch Frank Message-Id: <20180928093435.198573-1-frankja@linux.ibm.com> Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- include/hw/s390x/s390-virtio-ccw.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-virtio-ccw.h index e9c4f4182b..8aa27199c9 100644 --- a/include/hw/s390x/s390-virtio-ccw.h +++ b/include/hw/s390x/s390-virtio-ccw.h @@ -39,12 +39,15 @@ typedef struct S390CcwMachineClass { bool ri_allowed; bool cpu_model_allowed; bool css_migration_enabled; + bool hpage_1m_allowed; } S390CcwMachineClass; /* runtime-instrumentation allowed by the machine */ bool ri_allowed(void); /* cpu model allowed by the machine */ bool cpu_model_allowed(void); +/* 1M huge page mappings allowed by the machine */ +bool hpage_1m_allowed(void); /** * Returns true if (vmstate based) migration of the channel subsystem -- cgit v1.2.3