aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-12-20 20:39:04 +0000
committerPeter Maydell <peter.maydell@linaro.org>2018-12-20 20:39:04 +0000
commit41e2c56ed95db328a4e24c5756312c0158de71ce (patch)
tree18c78c0c5dc66dd3f89a6bbb1c5c6569e8f475ec
parent95de6f4b92efea391a3cbb8651d774a4d3529861 (diff)
parentaba7a5a2de3dba5917024df25441f715b9249e31 (diff)
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20181220' into staging
Two s390x bugfixes. # gpg: Signature made Thu 20 Dec 2018 16:36:42 GMT # gpg: using RSA key DECF6B93C6F02FAF # gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" # gpg: aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" # gpg: aka "Cornelia Huck <cohuck@kernel.org>" # gpg: aka "Cornelia Huck <cohuck@redhat.com>" # Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0 18CE DECF 6B93 C6F0 2FAF * remotes/cohuck/tags/s390x-20181220: hw/s390x: Fix bad mask in time2tod() hw/s390/ccw.c: Don't take address of packed members Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/s390x/css.c32
-rw-r--r--include/hw/s390x/tod.h2
2 files changed, 27 insertions, 7 deletions
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 04ec5cc970..f92b046cd3 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -1290,9 +1290,19 @@ void copy_scsw_to_guest(SCSW *dest, const SCSW *src)
static void copy_schib_to_guest(SCHIB *dest, const SCHIB *src)
{
int i;
-
- copy_pmcw_to_guest(&dest->pmcw, &src->pmcw);
- copy_scsw_to_guest(&dest->scsw, &src->scsw);
+ /*
+ * We copy the PMCW and SCSW in and out of local variables to
+ * avoid taking the address of members of a packed struct.
+ */
+ PMCW src_pmcw, dest_pmcw;
+ SCSW src_scsw, dest_scsw;
+
+ src_pmcw = src->pmcw;
+ copy_pmcw_to_guest(&dest_pmcw, &src_pmcw);
+ dest->pmcw = dest_pmcw;
+ src_scsw = src->scsw;
+ copy_scsw_to_guest(&dest_scsw, &src_scsw);
+ dest->scsw = dest_scsw;
dest->mba = cpu_to_be64(src->mba);
for (i = 0; i < ARRAY_SIZE(dest->mda); i++) {
dest->mda[i] = src->mda[i];
@@ -1339,9 +1349,19 @@ static void copy_scsw_from_guest(SCSW *dest, const SCSW *src)
static void copy_schib_from_guest(SCHIB *dest, const SCHIB *src)
{
int i;
-
- copy_pmcw_from_guest(&dest->pmcw, &src->pmcw);
- copy_scsw_from_guest(&dest->scsw, &src->scsw);
+ /*
+ * We copy the PMCW and SCSW in and out of local variables to
+ * avoid taking the address of members of a packed struct.
+ */
+ PMCW src_pmcw, dest_pmcw;
+ SCSW src_scsw, dest_scsw;
+
+ src_pmcw = src->pmcw;
+ copy_pmcw_from_guest(&dest_pmcw, &src_pmcw);
+ dest->pmcw = dest_pmcw;
+ src_scsw = src->scsw;
+ copy_scsw_from_guest(&dest_scsw, &src_scsw);
+ dest->scsw = dest_scsw;
dest->mba = be64_to_cpu(src->mba);
for (i = 0; i < ARRAY_SIZE(dest->mda); i++) {
dest->mda[i] = src->mda[i];
diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h
index cbd7552e7a..47ef9de869 100644
--- a/include/hw/s390x/tod.h
+++ b/include/hw/s390x/tod.h
@@ -56,7 +56,7 @@ typedef struct S390TODClass {
/* Converts ns to s390's clock format */
static inline uint64_t time2tod(uint64_t ns)
{
- return (ns << 9) / 125 + (((ns & 0xff10000000000000ull) / 125) << 9);
+ return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9);
}
/* Converts s390's clock format to ns */