Skip to contentSkip to conversation

target/hppa: Fix random 32-bit linux-user crashes

PATCH In review Helge Deller 2 participants 2 messages Sep 3, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/hppa: Fix random 32-bit linux-user crashes

The linux-user hppa target crashes randomly for me since commit 081a0ed188d8 ("target/hppa: Do not mask in copy_iaoq_entry").

That commit dropped the masking of the IAOQ addresses while copying them from other registers and instead keeps them with all 64 bits up until the full gva is formed with the help of hppa_form_gva_psw().

So, when running in linux-user mode on an emulated 64-bit CPU, we need to mask to a 32-bit address space at the very end in hppa_form_gva_psw() if the PSW-W flag isn't set (which is the case for linux-user on hppa).

Fixes 081a0ed188d8 ("target/hppa: Do not mask in copy_iaoq_entry")
target/hppa/cpu.h +1 -1
index 2bcb3b602b..56d9568d6c 100644
@@ -319,7 +319,7 @@ static inline target_ulong hppa_form_gva_psw(target_ulong psw, uint64_t spc,
                                              target_ulong off)
 {
 #ifdef CONFIG_USER_ONLY
-    return off;
+    return off & gva_offset_mask(psw);
 #else
     return spc | (off & gva_offset_mask(psw));
 #endif
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Helge Deller

The linux-user hppa target crashes randomly for me since commit 081a0ed188d8 ("target/hppa: Do not mask in copy_iaoq_entry").

That commit dropped the masking of the IAOQ addresses while copying them from other registers and instead keeps them with all 64 bits up until the full gva is formed with the help of hppa_form_gva_psw().

So, when running in linux-user mode on an emulated 64-bit CPU, we need to mask to a 32-bit address space at the very end in hppa_form_gva_psw() if the PSW-W flag isn't set (which is the case for linux-user on hppa).

Fixes 081a0ed188d8 ("target/hppa: Do not mask in copy_iaoq_entry")
target/hppa/cpu.h +0 -0
index 2bcb3b602b..56d9568d6c 100644

target/hppa/cpu.h static inline target_ulong hppa_form_gva_psw(target_ulong psw, uint64_t spc, · line 325

Quoted 8 lines
target/hppa/cpu.h +1 -1
@@ -319,7 +319,7 @@ static inline target_ulong hppa_form_gva_psw(target_ulong psw, uint64_t spc,
                                               target_ulong off)
  {
  #ifdef CONFIG_USER_ONLY
-    return off;
+    return off & gva_offset_mask(psw);
  #else
      return spc | (off & gva_offset_mask(psw));
  #endif

r~