]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
target/s390x/tcg/mem_helper: Test the right bits in psw_key_valid()
authorThomas Huth <thuth@redhat.com>
Mon, 5 Dec 2022 14:20:43 +0000 (15:20 +0100)
committerThomas Huth <thuth@redhat.com>
Thu, 15 Dec 2022 14:02:34 +0000 (15:02 +0100)
The PSW key mask is a 16 bit field, and the psw_key variable is
in the range from 0 to 15, so it does not make sense to use
"0x80 >> psw_key" for testing the bits here. We should use 0x8000
instead.

Message-Id: <20221205142043.95185-1-thuth@redhat.com>
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
target/s390x/tcg/mem_helper.c

index 3758b9e688cf641177f5b982daa1f50af6fea17e..006b6798a78656cd2692acc49de90c1b61c9a805 100644 (file)
@@ -51,7 +51,7 @@ static inline bool psw_key_valid(CPUS390XState *env, uint8_t psw_key)
 
     if (env->psw.mask & PSW_MASK_PSTATE) {
         /* PSW key has range 0..15, it is valid if the bit is 1 in the PKM */
-        return pkm & (0x80 >> psw_key);
+        return pkm & (0x8000 >> psw_key);
     }
     return true;
 }