Skip to contentSkip to conversation

HPPA64 updates

PATCH In review [email protected] 3 participants 12 messages Mar 2, 2024 – Mar 3, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover HPPA64 updates

From: Helge Deller <[email protected]>

Some fixes for the hppa64 target.
Add references to SeaBIOS-hppa and hppa-firmware into pc-bios/README file and add rom make targets. Patches 2-5 need review.

Guenter Roeck (1):
target/hppa: Fix unaligned double word accesses for hppa64

Helge Deller (4):
target/hppa: Restore unwind_breg before calculating ior pc-bios/meson: Add hppa-firmware64.img blob pc-bios/README: Add information about hppa-firmware roms/hppa: Add build rules for hppa-firmware

 pc-bios/README           | 6 ++++++
 pc-bios/meson.build      | 1 +
 roms/Makefile            | 7 +++++++
 target/hppa/cpu.c        | 3 ++-
 target/hppa/helper.c     | 7 ++++++-
 target/hppa/mem_helper.c | 3 ++-
 target/hppa/op_helper.c  | 3 ++-
 7 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.44.0
#1 lore raw

PATCH 1/5 target/hppa: Fix unaligned double word accesses for hppa64

From: Guenter Roeck <[email protected]>

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. Clearing bit 32..39 in psw prior to restoring it solves the problem.

Fixes 931adff31478 ("target/hppa: Update cpu_hppa_get/put_psw for hppa64")
Cc Richard Henderson <[email protected]>
Cc Charlie Jenkins <[email protected]>
Cc Helge Deller <[email protected]>
---
 target/hppa/helper.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
target/hppa/helper.c +6 -1
index 859644c47a..7b798d1227 100644
@@ -76,7 +76,12 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ulong psw)
     }
     psw &= ~reserved;
 
-    env->psw = psw & ~(PSW_N | PSW_V | PSW_CB);
+    if (hppa_is_pa20(env)) {
+        env->psw = psw & ~(PSW_N | PSW_V | PSW_CB | 0xff00000000ull);
+    } else {
+        env->psw = psw & ~(PSW_N | PSW_V | PSW_CB);
+    }
+
     env->psw_n = (psw / PSW_N) & 1;
     env->psw_v = -((psw / PSW_V) & 1);
 
Signature · 1 line
2.44.0
#2 lore raw

Re: [PATCH 1/5] target/hppa: Fix unaligned double word accesses for hppa64

Quoted 26 lines · On 3/2/24 12:35, [email protected] wrote:

From: Guenter Roeck <[email protected]>

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. Clearing bit 32..39 in psw prior to restoring it solves the problem.

Fixes 931adff31478 ("target/hppa: Update cpu_hppa_get/put_psw for hppa64")
Cc Richard Henderson <[email protected]>
Cc Charlie Jenkins <[email protected]>
Cc Helge Deller <[email protected]>
---
  target/hppa/helper.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
target/hppa/helper.c +0 -0
index 859644c47a..7b798d1227 100644

target/hppa/helper.c void cpu_hppa_put_psw(CPUHPPAState *env, target_ulong psw) · line 83

Quoted 9 lines
target/hppa/helper.c +5 -1
@@ -76,7 +76,12 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ulong psw)
      }
      psw &= ~reserved;
 
-    env->psw = psw & ~(PSW_N | PSW_V | PSW_CB);
+    if (hppa_is_pa20(env)) {
+        env->psw = psw & ~(PSW_N | PSW_V | PSW_CB | 0xff00000000ull);
+    } else {
+        env->psw = psw & ~(PSW_N | PSW_V | PSW_CB);
+    }

https://patchew.org/QEMU/[email protected]/

was the better version.

r~

#3 lore raw

Re: [PATCH 1/5] target/hppa: Fix unaligned double word accesses for hppa64

Quoted 22 lines · Richard Henderson
Quoted 21 lines · On 3/2/24 12:35, [email protected] wrote:

From: Guenter Roeck <[email protected]>

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. Clearing bit 32..39 in psw prior to restoring it solves the problem.

Fixes 931adff31478 ("target/hppa: Update cpu_hppa_get/put_psw for hppa64")
Cc Richard Henderson <[email protected]>
Cc Charlie Jenkins <[email protected]>
Cc Helge Deller <[email protected]>

---
  target/hppa/helper.c | 7 ++++++-

  1 file changed, 6 insertions(+), 1 deletion(-)
Quoted 16 lines

target/hppa/helper.c void cpu_hppa_put_psw(CPUHPPAState *env, target_ulong psw) · line 82

Quoted 13 lines
target/hppa/helper.c +5 -1
index 859644c47a..7b798d1227 100644
@@ -76,7 +76,12 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ulong psw)
       }
       psw &= ~reserved;
-    env->psw = psw & ~(PSW_N | PSW_V | PSW_CB);
+    if (hppa_is_pa20(env)) {
+        env->psw = psw & ~(PSW_N | PSW_V | PSW_CB | 0xff00000000ull);
+    } else {
+        env->psw = psw & ~(PSW_N | PSW_V | PSW_CB);
+    }

https://patchew.org/QEMU/[email protected]/
was the better version.

Oh, yes. Will use that one in the pull request.
Thanks!
Helge

#4 lore raw

PATCH 2/5 target/hppa: Restore unwind_breg before calculating ior

In reply to [email protected]

From: Helge Deller <[email protected]>

When calculating the IOR for the exception handlers, the current unwind_breg value is needed on 64-bit hppa machines.
Restore that value by calling cpu_restore_state() earlier, which in turn calls hppa_restore_state_to_opc() which restores the unwind_breg for the current instruction.

Fixes 3824e0d643f3 ("target/hppa: Export function hppa_set_ior_and_isr()")
---
 target/hppa/cpu.c        | 3 ++-
 target/hppa/mem_helper.c | 3 ++-
 target/hppa/op_helper.c  | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
target/hppa/cpu.c +2 -1
index afe73d4474..3831cb6db2 100644
@@ -121,9 +121,10 @@ void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
     CPUHPPAState *env = &cpu->env;
 
     cs->exception_index = EXCP_UNALIGN;
+    cpu_restore_state(cs, retaddr);
     hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx));
 
-    cpu_loop_exit_restore(cs, retaddr);
+    cpu_loop_exit(cs);
 }
 #endif /* CONFIG_USER_ONLY */
 
target/hppa/mem_helper.c +2 -1
index 66b8fa7d72..3fc895c1c2 100644
@@ -348,9 +348,10 @@ raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
     CPUState *cs = env_cpu(env);
 
     cs->exception_index = excp;
+    cpu_restore_state(cs, retaddr);
     hppa_set_ior_and_isr(env, addr, mmu_disabled);
 
-    cpu_loop_exit_restore(cs, retaddr);
+    cpu_loop_exit(cs);
 }
 
 void hppa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
target/hppa/op_helper.c +2 -1
index b1f24a5aad..480fe80844 100644
@@ -351,11 +351,12 @@ target_ulong HELPER(probe)(CPUHPPAState *env, target_ulong addr,
     excp = hppa_get_physical_address(env, addr, mmu_idx, 0, &phys,
                                      &prot, NULL);
     if (excp >= 0) {
+        cpu_restore_state(env_cpu(env), GETPC());
         hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx));
         if (excp == EXCP_DTLB_MISS) {
             excp = EXCP_NA_DTLB_MISS;
         }
-        hppa_dynamic_excp(env, excp, GETPC());
+        helper_excp(env, excp);
     }
     return (want & prot) != 0;
 #endif
Signature · 1 line
2.44.0
Reviewed-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] target/hppa: Restore unwind_breg before calculating ior

Quoted 8 lines · On 3/2/24 12:35, [email protected] wrote:

From: Helge Deller<[email protected]>

When calculating the IOR for the exception handlers, the current unwind_breg value is needed on 64-bit hppa machines.
Restore that value by calling cpu_restore_state() earlier, which in turn calls hppa_restore_state_to_opc() which restores the unwind_breg for the current instruction.

Quoted 7 lines
Fixes 3824e0d643f3 ("target/hppa: Export function hppa_set_ior_and_isr()")
---
  target/hppa/cpu.c        | 3 ++-
  target/hppa/mem_helper.c | 3 ++-
  target/hppa/op_helper.c  | 3 ++-
  3 files changed, 6 insertions(+), 3 deletions(-)

r~

#6 lore raw

PATCH 3/5 pc-bios/meson: Add hppa-firmware64.img blob

In reply to [email protected]

From: Helge Deller <[email protected]>

Add the missing 64-bit hppa firmware blob so that it gets installed.

Fixes 7c0dfcf9395e ("target/hppa: Update SeaBIOS-hppa to version 16")
---
 pc-bios/meson.build | 1 +
 1 file changed, 1 insertion(+)
pc-bios/meson.build +1 -0
index e67fa433a1..0760612bea 100644
@@ -73,6 +73,7 @@ blobs = [
   'qemu_vga.ndrv',
   'edk2-licenses.txt',
   'hppa-firmware.img',
+  'hppa-firmware64.img',
   'opensbi-riscv32-generic-fw_dynamic.bin',
   'opensbi-riscv64-generic-fw_dynamic.bin',
   'npcm7xx_bootrom.bin',
Signature · 1 line
2.44.0
Reviewed-by on v1 3/5
#7 lore raw

Re: [PATCH 3/5] pc-bios/meson: Add hppa-firmware64.img blob

Quoted 9 lines · On 3/2/24 12:35, [email protected] wrote:

From: Helge Deller<[email protected]>

Add the missing 64-bit hppa firmware blob so that it gets installed.

Fixes 7c0dfcf9395e ("target/hppa: Update SeaBIOS-hppa to version 16")
---
  pc-bios/meson.build | 1 +
  1 file changed, 1 insertion(+)

r~

#8 lore raw

PATCH 4/5 pc-bios/README: Add information about hppa-firmware

In reply to [email protected]

From: Helge Deller <[email protected]>

---
 pc-bios/README | 6 ++++++
 1 file changed, 6 insertions(+)
pc-bios/README +6 -0
index b8a0210d24..6ffc46006e 100644
@@ -75,3 +75,9 @@
   initialize and run boot images stored in SPI flash, but may grow more
   features over time as needed. The source code is available at:
   https://github.com/google/vbootrom
+
+- hppa-firmware.img (32-bit) and hppa-firmware64.img (64-bit) are firmware
+  files for the HP-PARISC (hppa) architecture.
+  The are built form the SeaBIOS-hppa sources, which is a fork of SeaBIOS
+  adapted for hppa.
+  SeaBIOS-hppa is available at https://github.com/hdeller/seabios-hppa
Signature · 1 line
2.44.0
#10 lore raw

PATCH 5/5 roms/hppa: Add build rules for hppa-firmware

In reply to [email protected]

From: Helge Deller <[email protected]>

---
 roms/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)
roms/Makefile +7 -0
index 67f709ba2d..8e5d8d26a9 100644
@@ -68,6 +68,7 @@ default help:
 	@echo "  opensbi32-generic  -- update OpenSBI for 32-bit generic machine"
 	@echo "  opensbi64-generic  -- update OpenSBI for 64-bit generic machine"
 	@echo "  qboot              -- update qboot"
+	@echo "  hppa-firmware      -- update 32- and 64-bit hppa firmware"
 	@echo "  clean              -- delete the files generated by the previous" \
 	                              "build targets"
 
@@ -177,6 +178,11 @@ npcm7xx_bootrom:
 	$(MAKE) -C vbootrom CROSS_COMPILE=$(arm_cross_prefix)
 	cp vbootrom/npcm7xx_bootrom.bin ../pc-bios/npcm7xx_bootrom.bin
 
+hppa-firmware:
+	$(MAKE) -C seabios-hppa parisc
+	cp seabios-hppa/out/hppa-firmware.img      ../pc-bios/
+	cp seabios-hppa/out-64/hppa-firmware64.img ../pc-bios/
+
 clean:
 	rm -rf seabios/.config seabios/out seabios/builds
 	$(MAKE) -C ipxe/src veryclean
@@ -189,3 +195,4 @@ clean:
 	$(MAKE) -C opensbi clean
 	$(MAKE) -C qboot clean
 	$(MAKE) -C vbootrom clean
+	$(MAKE) -C seabios-hppa clean
Signature · 1 line
2.44.0