diff mbox

[02/10] s390/ioinst: fix endianness in ioinst_schib_valid

Message ID 1434383829-26451-3-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno June 15, 2015, 3:57 p.m. UTC
From: Alexander Graf <agraf@suse.de>

The ioinst_schib_valid gets a SCHIB in guest endianness, we should
byteswap the fields we access.

Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target-s390x/ioinst.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Note that it creates some asymmetry with the ioinst_orb_valid function.
We might want to move the copy_schib_from_guest from hw/s390x/css.c to
target-s390x/ioinst.c and do the byteswapping only once.
diff mbox

Patch

diff --git a/target-s390x/ioinst.c b/target-s390x/ioinst.c
index e220cea..77f2a1f 100644
--- a/target-s390x/ioinst.c
+++ b/target-s390x/ioinst.c
@@ -129,12 +129,12 @@  void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1)
 
 static int ioinst_schib_valid(SCHIB *schib)
 {
-    if ((schib->pmcw.flags & PMCW_FLAGS_MASK_INVALID) ||
-        (schib->pmcw.chars & PMCW_CHARS_MASK_INVALID)) {
+    if ((be16_to_cpu(schib->pmcw.flags) & PMCW_FLAGS_MASK_INVALID) ||
+        (be32_to_cpu(schib->pmcw.chars) & PMCW_CHARS_MASK_INVALID)) {
         return 0;
     }
     /* Disallow extended measurements for now. */
-    if (schib->pmcw.chars & PMCW_CHARS_MASK_XMWME) {
+    if (be32_to_cpu(schib->pmcw.chars) & PMCW_CHARS_MASK_XMWME) {
         return 0;
     }
     return 1;