aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2024-02-16 17:58:11 -0800
committerHelge Deller <deller@gmx.de>2024-03-03 06:38:34 +0100
commita9bdc4c95e402599e4184d4814800668479adb2b (patch)
treed4e320af461ee82abfbadc6336c28bf77e389d73
parente1007b6bab5cf97705bf4f2aaec1f607787355b8 (diff)
downloadqemu-a9bdc4c95e402599e4184d4814800668479adb2b.zip
qemu-a9bdc4c95e402599e4184d4814800668479adb2b.tar.gz
qemu-a9bdc4c95e402599e4184d4814800668479adb2b.tar.bz2
target: hppa: Fix unaligned double word accesses for hppa64
Unaligned 64-bit accesses were found in Linux to clobber carry bits, resulting in bad results if an arithmetic operation involving a carry bit was executed after an unaligned 64-bit operation. hppa 2.0 defines additional carry bits in PSW register bits 32..39. When restoring PSW after executing an unaligned instruction trap, those bits were not cleared and ended up to be active all the time. Since there are no bits other than the upper carry bits needed in the upper 32 bit of env->psw and since those are stored in env->psw_cb, just clear the entire upper 32 bit when storing psw to solve the problem unconditionally. Fixes: 931adff31478 ("target/hppa: Update cpu_hppa_get/put_psw for hppa64") Cc: Richard Henderson <richard.henderson@linaro.org> Cc: Charlie Jenkins <charlie@rivosinc.com> Cc: Helge Deller <deller@gmx.de> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r--target/hppa/helper.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/target/hppa/helper.c b/target/hppa/helper.c
index 859644c..9d217d0 100644
--- a/target/hppa/helper.c
+++ b/target/hppa/helper.c
@@ -76,7 +76,8 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ulong psw)
}
psw &= ~reserved;
- env->psw = psw & ~(PSW_N | PSW_V | PSW_CB);
+ env->psw = psw & (uint32_t)~(PSW_N | PSW_V | PSW_CB);
+
env->psw_n = (psw / PSW_N) & 1;
env->psw_v = -((psw / PSW_V) & 1);