]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
target/hppa: Fix PSW V-bit packaging in cpu_hppa_get for hppa64
authorHelge Deller <deller@gmx.de>
Tue, 3 Sep 2024 15:22:10 +0000 (17:22 +0200)
committerHelge Deller <deller@gmx.de>
Tue, 3 Sep 2024 20:08:22 +0000 (22:08 +0200)
While adding hppa64 support, the psw_v variable got extended from 32 to 64
bits.  So, when packaging the PSW-V bit from the psw_v variable for interrupt
processing, check bit 31 instead the 63th (sign) bit.

This fixes a hard to find Linux kernel boot issue where the loss of the PSW-V
bit due to an ITLB interruption in the middle of a series of ds/addc
instructions (from the divU milicode library) generated the wrong division
result and thus triggered a Linux kernel crash.

Link: https://lore.kernel.org/lkml/718b8afe-222f-4b3a-96d3-93af0e4ceff1@roeck-us.net/
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Fixes: 931adff31478 ("target/hppa: Update cpu_hppa_get/put_psw for hppa64")
Cc: qemu-stable@nongnu.org # v8.2+
target/hppa/cpu.h
target/hppa/helper.c

index 2bcb3b602b871f0a4556cc5b0efee9882543ac26..5478b183dc94d67cb88793aacb32b83fb1fb144a 100644 (file)
@@ -211,7 +211,7 @@ typedef struct CPUArchState {
     uint32_t psw;            /* All psw bits except the following:  */
     uint32_t psw_xb;         /* X and B, in their normal positions */
     target_ulong psw_n;      /* boolean */
-    target_long psw_v;       /* in most significant bit */
+    target_long psw_v;       /* in bit 31 */
 
     /* Splitting the carry-borrow field into the MSB and "the rest", allows
      * for "the rest" to be deleted when it is unused, but the MSB is in use.
index b79ddd8184cc45b412a5efb98f2ab5a87e65ab1a..d4b1a3cd5ad23c64840f0b7e38e70d5c29c3d510 100644 (file)
@@ -53,7 +53,7 @@ target_ulong cpu_hppa_get_psw(CPUHPPAState *env)
     }
 
     psw |= env->psw_n * PSW_N;
-    psw |= (env->psw_v < 0) * PSW_V;
+    psw |= ((env->psw_v >> 31) & 1) * PSW_V;
     psw |= env->psw | env->psw_xb;
 
     return psw;