Skip to contentSkip to conversation

target/hppa: Enhancements and fixes

PATCH Superseded [email protected] 3 participants 25 messages Feb 7, 2024 – Feb 9, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover target/hppa: Enhancements and fixes

From: Helge Deller <[email protected]>

Some enhancements and fixes for the hppa target.

The major change is, that this patchset adds a new SeaBIOS-hppa firmware which is built as 32- and 64-bit firmware.
The new 64-bit firmware is necessary to fully support 64-bit operating systems (HP-UX, Linux, NetBSD,...).

Please review!

Helge

Helge Deller (13):
disas/hppa: Add disassembly for qemu specific instructions target/hppa: Add "diag 0x101" for console output support target/hppa: Fix PSW_W and PSW_E bits in rsm, ssm and mtsm hw/pci-host/astro: Avoid aborting on access failure hw/pci-host/astro: Implement Hard Fail and Soft Fail mode
lasi: allow access to LAN MAC address registers target/hppa: Implement do_transaction_failed handler for I/O errors
lasi: Add reset I/O ports for LASI audio and FDC target/hppa: Allow read-access to PSW with rsm 0,reg instruction target/hppa: Check privilege only when PSW.P is set target/hppa: PDC_BTLB_INFO uses 32-bit ints
target/hppa: Update SeaBIOS-hppa to version 16 hw/hppa/machine: Load 64-bit firmware on 64-bit machines

 disas/hppa.c                |   4 +++
 hw/hppa/machine.c           |  11 ++++++--
 hw/misc/lasi.c              |  13 +++++++++
 hw/pci-host/astro.c         |  41 +++++++++++++++------------
 include/hw/misc/lasi.h      |   2 ++
 include/hw/pci-host/astro.h |   2 ++
 pc-bios/hppa-firmware.img   | Bin 163324 -> 167836 bytes
 pc-bios/hppa-firmware64.img | Bin 0 -> 205944 bytes
 roms/seabios-hppa           |   2 +-
 target/hppa/cpu.c           |   1 +
 target/hppa/cpu.h           |   7 +++++
 target/hppa/helper.h        |   5 +++-
 target/hppa/mem_helper.c    |  21 +++++++++++++-
 target/hppa/op_helper.c     |  32 +++++++++++++++++++++
 target/hppa/sys_helper.c    |  46 ++++++++++++++++++++++++++++--
 target/hppa/translate.c     |  54 ++++++++++++++++++++++++++----------
 16 files changed, 200 insertions(+), 41 deletions(-)
 mode change 100644 => 100755 pc-bios/hppa-firmware.img
 create mode 100755 pc-bios/hppa-firmware64.img
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/13 disas/hppa: Add disassembly for qemu specific instructions

From: Helge Deller <[email protected]>

Add disassembly of opcodes for "HALT QEMU", "RESET QEMU" and "RESTORE SHR" (restore shadow registers).

---
 disas/hppa.c | 4 ++++
 1 file changed, 4 insertions(+)
disas/hppa.c +4 -0
index cce4f4aa37..22dce9b41b 100644
@@ -1609,6 +1609,10 @@ static const struct pa_opcode pa_opcodes[] =
 { "call",	0xe800a000, 0xffe0e000, "nW", pa10, FLAG_STRICT},
 { "ret",	0xe840d000, 0xfffffffd, "n", pa20, FLAG_STRICT},
 
+/* Opcodes assigned to QEMU, used by SeaBIOS firmware and Linux kernel */
+{ "HALT QEMU",	0xfffdead0, 0xfffffffd, "n", pa10, FLAG_STRICT},
+{ "RESET QEMU",	0xfffdead1, 0xfffffffd, "n", pa10, FLAG_STRICT},
+{ "RESTORE SHR",0xfffdead2, 0xfffffffd, "n", pa10, FLAG_STRICT},
 };
 
 #define NUMOPCODES ((sizeof pa_opcodes)/(sizeof pa_opcodes[0]))
Signature · 1 line
2.43.0
Reviewed-by on v1 1/13
#2 lore raw

Re: [PATCH 01/13] disas/hppa: Add disassembly for qemu specific instructions

Quoted 9 lines · On 2/7/24 08:20, [email protected] wrote:

From: Helge Deller <[email protected]>

Add disassembly of opcodes for "HALT QEMU", "RESET QEMU" and "RESTORE SHR" (restore shadow registers).

---
  disas/hppa.c | 4 ++++
  1 file changed, 4 insertions(+)

r~

Quoted 16 lines
disas/hppa.c +4 -0
index cce4f4aa37..22dce9b41b 100644
@@ -1609,6 +1609,10 @@ static const struct pa_opcode pa_opcodes[] =
  { "call",	0xe800a000, 0xffe0e000, "nW", pa10, FLAG_STRICT},
  { "ret",	0xe840d000, 0xfffffffd, "n", pa20, FLAG_STRICT},
 
+/* Opcodes assigned to QEMU, used by SeaBIOS firmware and Linux kernel */
+{ "HALT QEMU",	0xfffdead0, 0xfffffffd, "n", pa10, FLAG_STRICT},
+{ "RESET QEMU",	0xfffdead1, 0xfffffffd, "n", pa10, FLAG_STRICT},
+{ "RESTORE SHR",0xfffdead2, 0xfffffffd, "n", pa10, FLAG_STRICT},
  };
 
  #define NUMOPCODES ((sizeof pa_opcodes)/(sizeof pa_opcodes[0]))
#3 lore raw

PATCH 2/13 target/hppa: Add "diag 0x101" for console output support

In reply to [email protected]

From: Helge Deller <[email protected]>

For debugging purposes at the early stage of the bootup process, the SeaBIOS-hppa firmware sometimes needs to output characters to the serial console. Note that the serial console is the default output method for parisc machines.

At this stage PCI busses and other devices haven't been initialized yet. So, SeaBIOS-hppa will not be able to find the correct I/O ports for the serial ports yet.

Instead, add an emulation for the "diag 0x101" opcode to assist here. Without any other dependencies, SeaBIOS-hppa can then load the character to be printed in register %r26 and issue the diag assembly instruction.

The qemu diag_console_output() helper function will then print that character to the first serial port.

---
 target/hppa/helper.h    |  1 +
 target/hppa/op_helper.c | 32 ++++++++++++++++++++++++++++++++
 target/hppa/translate.c |  6 ++++++
 3 files changed, 39 insertions(+)
target/hppa/helper.h +1 -0
index 20698f68ed..1bdbcd8f98 100644
@@ -103,4 +103,5 @@ DEF_HELPER_FLAGS_1(ptlbe, TCG_CALL_NO_RWG, void, env)
 DEF_HELPER_FLAGS_2(lpa, TCG_CALL_NO_WG, tl, env, tl)
 DEF_HELPER_FLAGS_1(change_prot_id, TCG_CALL_NO_RWG, void, env)
 DEF_HELPER_1(diag_btlb, void, env)
+DEF_HELPER_1(diag_console_output, void, env)
 #endif
target/hppa/op_helper.c +32 -0
index b1f24a5aad..2c2c4aa183 100644
@@ -24,6 +24,8 @@
 #include "exec/helper-proto.h"
 #include "exec/cpu_ldst.h"
 #include "qemu/timer.h"
+#include "sysemu/sysemu.h"
+#include "chardev/char-fe.h"
 #include "trace.h"
 
 G_NORETURN void HELPER(excp)(CPUHPPAState *env, int excp)
@@ -484,3 +486,33 @@ uint64_t HELPER(hshradd)(uint64_t r1, uint64_t r2, uint32_t sh)
     }
     return ret;
 }
+
+/*
+ * diag_console_output() is a helper function used during the initial bootup
+ * process of the SeaBIOS-hppa firmware.  During the bootup phase, addresses of
+ * serial ports on e.g. PCI busses are unknown and most other devices haven't
+ * been initialized and configured yet.  With help of a simple "diag" assembler
+ * instruction and an ASCII character code in register %r26 firmware can easily
+ * print debug output without any dependencies to the first serial port and use
+ * that as serial console.
+ */
+void HELPER(diag_console_output)(CPUHPPAState *env)
+{
+    CharBackend *serial_backend;
+    Chardev *serial_port;
+    unsigned char c;
+
+    /* find first serial port */
+    serial_port = serial_hd(0);
+    if (!serial_port)
+        return;
+
+    /* get serial_backend for the serial port */
+    serial_backend = serial_port->be;
+    if (!serial_backend ||
+        !qemu_chr_fe_backend_connected(serial_backend))
+        return;
+
+    c = (unsigned char)env->gr[26];
+    qemu_chr_fe_write(serial_backend, &c, sizeof(c));
+}
target/hppa/translate.c +6 -0
index 08d09d50d7..53ec57ee86 100644
@@ -4411,6 +4411,12 @@ static bool trans_diag(DisasContext *ctx, arg_diag *a)
         gen_helper_diag_btlb(tcg_env);
         return nullify_end(ctx);
     }
+    if (a->i == 0x101) {
+        /* print char in %r26 to first serial console, used by SeaBIOS-hppa */
+        nullify_over(ctx);
+        gen_helper_diag_console_output(tcg_env);
+        return nullify_end(ctx);
+    }
 #endif
     qemu_log_mask(LOG_UNIMP, "DIAG opcode 0x%04x ignored\n", a->i);
     return true;
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH 02/13] target/hppa: Add "diag 0x101" for console output support

Quoted 24 lines · On 2/7/24 08:20, [email protected] wrote:
target/hppa/op_helper.c +20 -0
@@ -484,3 +486,33 @@ uint64_t HELPER(hshradd)(uint64_t r1, uint64_t r2, uint32_t sh)
      }
      return ret;
  }
+
+/*
+ * diag_console_output() is a helper function used during the initial bootup
+ * process of the SeaBIOS-hppa firmware.  During the bootup phase, addresses of
+ * serial ports on e.g. PCI busses are unknown and most other devices haven't
+ * been initialized and configured yet.  With help of a simple "diag" assembler
+ * instruction and an ASCII character code in register %r26 firmware can easily
+ * print debug output without any dependencies to the first serial port and use
+ * that as serial console.
+ */
+void HELPER(diag_console_output)(CPUHPPAState *env)
+{
+    CharBackend *serial_backend;
+    Chardev *serial_port;
+    unsigned char c;
+
+    /* find first serial port */
+    serial_port = serial_hd(0);
+    if (!serial_port)
+        return;

target/hppa/op_helper.c uint64_t HELPER(hshradd)(uint64_t r1, uint64_t r2, uint32_t sh) · line 518

Quoted 10 lines
target/hppa/op_helper.c +10 -0
+
+    /* get serial_backend for the serial port */
+    serial_backend = serial_port->be;
+    if (!serial_backend ||
+        !qemu_chr_fe_backend_connected(serial_backend))
+        return;
+
+    c = (unsigned char)env->gr[26];
+    qemu_chr_fe_write(serial_backend, &c, sizeof(c));
+}

Looks like this should go in sys_helper.c instead. Missing ifdefs break hppa-linux-user?

Also, missing braces.

r~

#5 lore raw

PATCH 3/13 target/hppa: Fix PSW_W and PSW_E bits in rsm, ssm and mtsm

In reply to [email protected]

From: Helge Deller <[email protected]>

The ssm and rsm instructions number the PSW_W and PSW_E bits differently than how they are actually in the PSW. Both bits are relevant on 64-bit CPUs only.

Fix the existing ssm and rsm instructions to handle the bits correctly. For that drop the swap_system_mask() helper function in favour of new helper functions get_system_mask, set_system_mask and mtsm_system_mask.

get_system_mask() returns the PSW bits how they should be returned in the target register of the ssm and rsm instructions. set_system_mask() sets the PSW bits without any further modification.

Note that the a->i constant value of ssm and rsm have already been converted to match the physical PSW bits by expand_sm_imm() in the instruction decoder.

The mtsm instruction is different, as it takes the new PSW from a register at runtime, and as such the PSW.E and PSW.W bits are moved at runtime to the right bit positions before setting the PSW.

---
 target/hppa/cpu.h        |  2 ++
 target/hppa/helper.h     |  4 +++-
 target/hppa/sys_helper.c | 46 +++++++++++++++++++++++++++++++++++++---
 target/hppa/translate.c  | 38 +++++++++++++++++++++------------
 4 files changed, 73 insertions(+), 17 deletions(-)
target/hppa/cpu.h +2 -0
index 7a181e8f33..06b65f2258 100644
@@ -122,7 +122,9 @@
 #define PSW_T            0x01000000
 #define PSW_S            0x02000000
 #define PSW_E            0x04000000
+#define PSW_E_BIT                37 /* PA2.0 only */
 #define PSW_W            0x08000000 /* PA2.0 only */
+#define PSW_W_BIT                36 /* PA2.0 only */
 #define PSW_Z            0x40000000 /* PA1.x only */
 #define PSW_Y            0x80000000 /* PA1.x only */
 
target/hppa/helper.h +3 -1
index 1bdbcd8f98..abffd3f531 100644
@@ -92,7 +92,9 @@ DEF_HELPER_1(rfi_r, void, env)
 DEF_HELPER_FLAGS_2(write_interval_timer, TCG_CALL_NO_RWG, void, env, tl)
 DEF_HELPER_FLAGS_2(write_eirr, TCG_CALL_NO_RWG, void, env, tl)
 DEF_HELPER_FLAGS_2(write_eiem, TCG_CALL_NO_RWG, void, env, tl)
-DEF_HELPER_FLAGS_2(swap_system_mask, TCG_CALL_NO_RWG, tl, env, tl)
+DEF_HELPER_FLAGS_1(get_system_mask, TCG_CALL_NO_RWG, tl, env)
+DEF_HELPER_FLAGS_2(set_system_mask, TCG_CALL_NO_RWG, void, env, tl)
+DEF_HELPER_FLAGS_2(mtsm_system_mask, TCG_CALL_NO_RWG, void, env, tl)
 DEF_HELPER_FLAGS_3(itlba_pa11, TCG_CALL_NO_RWG, void, env, tl, tl)
 DEF_HELPER_FLAGS_3(itlbp_pa11, TCG_CALL_NO_RWG, void, env, tl, tl)
 DEF_HELPER_FLAGS_3(idtlbt_pa20, TCG_CALL_NO_RWG, void, env, tl, tl)
target/hppa/sys_helper.c +43 -3

58 lines not on this page · raw message

target/hppa/translate.c +25 -13
index 53ec57ee86..10fdc0813d 100644
@@ -2163,13 +2163,20 @@ static bool trans_rsm(DisasContext *ctx, arg_rsm *a)
     nullify_over(ctx);
 
     tmp = tcg_temp_new_i64();
-    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
-    tcg_gen_andi_i64(tmp, tmp, ~a->i);
-    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
-    save_gpr(ctx, a->t, tmp);
+    if (a->t != 0) {
+        gen_helper_get_system_mask(tmp, tcg_env);
+        save_gpr(ctx, a->t, tmp);
+    }
+
+    if (a->i) {
+        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
+        tcg_gen_andi_i64(tmp, tmp, ~a->i);
+        gen_helper_set_system_mask(tcg_env, tmp);
+
+        /* Exit, check e.g. for new interrupts */
+        ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
+    }
 
-    /* Exit the TB to recognize new interrupts, e.g. PSW_M.  */
-    ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
     return nullify_end(ctx);
 #endif
 }
@@ -2183,11 +2190,17 @@ static bool trans_ssm(DisasContext *ctx, arg_ssm *a)
     nullify_over(ctx);
 
     tmp = tcg_temp_new_i64();
-    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
-    tcg_gen_ori_i64(tmp, tmp, a->i);
-    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
-    save_gpr(ctx, a->t, tmp);
+    if (a->t != 0) {
+        gen_helper_get_system_mask(tmp, tcg_env);
+        save_gpr(ctx, a->t, tmp);
+    }
+
+    if (a->i) {
+        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
+        tcg_gen_ori_i64(tmp, tmp, a->i);
+        gen_helper_set_system_mask(tcg_env, tmp);
 
+    }
     /* Exit the TB to recognize new interrupts, e.g. PSW_I.  */
     ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
     return nullify_end(ctx);
@@ -2198,12 +2211,11 @@ static bool trans_mtsm(DisasContext *ctx, arg_mtsm *a)
 {
     CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
 #ifndef CONFIG_USER_ONLY
-    TCGv_i64 tmp, reg;
+    TCGv_i64 reg;
     nullify_over(ctx);
 
     reg = load_gpr(ctx, a->r);
-    tmp = tcg_temp_new_i64();
-    gen_helper_swap_system_mask(tmp, tcg_env, reg);
+    gen_helper_mtsm_system_mask(tcg_env, reg);
 
     /* Exit the TB to recognize new interrupts.  */
     ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH 03/13] target/hppa: Fix PSW_W and PSW_E bits in rsm, ssm and mtsm

Quoted 4 lines · On 2/7/24 08:20, [email protected] wrote:
  #define PSW_E            0x04000000
target/hppa/cpu.h +2 -0
+#define PSW_E_BIT                37 /* PA2.0 only */
  #define PSW_W            0x08000000 /* PA2.0 only */
+#define PSW_W_BIT                36 /* PA2.0 only */

...

target/hppa/sys_helper.c void HELPER(reset)(CPUHPPAState *env) · line 72

Quoted 12 lines
target/hppa/sys_helper.c +12 -0
+target_ulong HELPER(get_system_mask)(CPUHPPAState *env)
+{
+    target_ulong psw = env->psw;
+
+    /* mask out invalid bits */
+    target_ulong psw_new = psw & PSW_SM;
+
+    /* ssm/rsm instructions number PSW_W and PSW_E differently */
+    psw_new &= ~PSW_W;
+    if (psw & PSW_W) {
+        psw_new |= 1ull << (63 - PSW_W_BIT);
+    }

Um, this has changed nothing, since 1 << (63 - 36) == 0x8000000 == PSW_W.

The conversion of PSW_SM_W to PSW_W happens in expand_sm_imm().
There's a comment there about keeping unimplemented bits disabled, including PSW_E. Perhaps this is the wrong layer in which to do this?

In any case, what is the actual problem that you're seeing? Because it *isn't* that we were not considering the different placement of the bits, as your commit message suggests.

Quoted 6 lines
target/hppa/translate.c +0 -0
index 53ec57ee86..10fdc0813d 100644
@@ -2163,13 +2163,20 @@ static bool trans_rsm(DisasContext *ctx, arg_rsm *a)
      nullify_over(ctx);

target/hppa/translate.c static bool trans_rsm(DisasContext *ctx, arg_rsm *a) · line 2169

Quoted 10 lines
target/hppa/translate.c +4 -4
 
      tmp = tcg_temp_new_i64();
-    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
-    tcg_gen_andi_i64(tmp, tmp, ~a->i);
-    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
-    save_gpr(ctx, a->t, tmp);
+    if (a->t != 0) {
+        gen_helper_get_system_mask(tmp, tcg_env);
+        save_gpr(ctx, a->t, tmp);
+    }

If a->t == 0, tmp is uninitialized...

target/hppa/translate.c static bool trans_rsm(DisasContext *ctx, arg_rsm *a) · line 2172

Quoted 3 lines
target/hppa/translate.c +3 -0
+
+    if (a->i) {
+        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));

... but read here.

Quoted 6 lines
target/hppa/translate.c +0 -2
@@ -2183,11 +2190,17 @@ static bool trans_ssm(DisasContext *ctx, arg_ssm *a)
      nullify_over(ctx);
 
      tmp = tcg_temp_new_i64();
-    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
-    tcg_gen_ori_i64(tmp, tmp, a->i);

target/hppa/translate.c static bool trans_ssm(DisasContext *ctx, arg_ssm *a) · line 2200

Quoted 10 lines
target/hppa/translate.c +8 -2
-    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
-    save_gpr(ctx, a->t, tmp);
+    if (a->t != 0) {
+        gen_helper_get_system_mask(tmp, tcg_env);
+        save_gpr(ctx, a->t, tmp);
+    }
+
+    if (a->i) {
+        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
+        tcg_gen_ori_i64(tmp, tmp, a->i);

Likewise.

r~

#7 lore raw

Re: [PATCH 03/13] target/hppa: Fix PSW_W and PSW_E bits in rsm, ssm and mtsm

Quoted 6 lines · Richard Henderson
Quoted 4 lines · On 2/7/24 08:20, [email protected] wrote:

  #define PSW_E            0x04000000 +#define PSW_E_BIT                37 /* PA2.0 only */ #define PSW_W            0x08000000 /* PA2.0 only */ +#define PSW_W_BIT                36 /* PA2.0 only */

...

Quoted 14 lines

target/hppa/sys_helper.c void HELPER(reset)(CPUHPPAState *env) · line 72

Quoted 12 lines
target/hppa/sys_helper.c +12 -0
+target_ulong HELPER(get_system_mask)(CPUHPPAState *env)
+{
+    target_ulong psw = env->psw;
+
+    /* mask out invalid bits */
+    target_ulong psw_new = psw & PSW_SM;
+
+    /* ssm/rsm instructions number PSW_W and PSW_E differently */
+    psw_new &= ~PSW_W;
+    if (psw & PSW_W) {
+        psw_new |= 1ull << (63 - PSW_W_BIT);
+    }

Um, this has changed nothing, since 1 << (63 - 36) == 0x8000000 == PSW_W.

Yep.
I seem to have mixed strange things when writing that. I've dropped the patch for now.

Thanks!
Helge

Quoted 49 lines

The conversion of PSW_SM_W to PSW_W happens in expand_sm_imm().
There's a comment there about keeping unimplemented bits disabled, including PSW_E. Perhaps this is the wrong layer in which to do this?

In any case, what is the actual problem that you're seeing?  Because it *isn't* that we were not considering the different placement of the bits, as your commit message suggests.

Quoted 5 lines
target/hppa/translate.c +0 -0
index 53ec57ee86..10fdc0813d 100644

target/hppa/translate.c static bool trans_rsm(DisasContext *ctx, arg_rsm *a) · line 2168

Quoted 10 lines
target/hppa/translate.c +4 -4
@@ -2163,13 +2163,20 @@ static bool trans_rsm(DisasContext *ctx, arg_rsm *a)
       nullify_over(ctx);
       tmp = tcg_temp_new_i64();
-    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
-    tcg_gen_andi_i64(tmp, tmp, ~a->i);
-    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
-    save_gpr(ctx, a->t, tmp);
+    if (a->t != 0) {
+        gen_helper_get_system_mask(tmp, tcg_env);
+        save_gpr(ctx, a->t, tmp);
+    }

If a->t == 0, tmp is uninitialized...

target/hppa/translate.c static bool trans_rsm(DisasContext *ctx, arg_rsm *a) · line 2172

Quoted 3 lines
target/hppa/translate.c +3 -0
+
+    if (a->i) {
+        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));

... but read here.

Quoted 5 lines
target/hppa/translate.c +0 -2
@@ -2183,11 +2190,17 @@ static bool trans_ssm(DisasContext *ctx, arg_ssm *a)
       nullify_over(ctx);
       tmp = tcg_temp_new_i64();
-    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
-    tcg_gen_ori_i64(tmp, tmp, a->i);

target/hppa/translate.c static bool trans_ssm(DisasContext *ctx, arg_ssm *a) · line 2199

Quoted 10 lines
target/hppa/translate.c +8 -2
-    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
-    save_gpr(ctx, a->t, tmp);
+    if (a->t != 0) {
+        gen_helper_get_system_mask(tmp, tcg_env);
+        save_gpr(ctx, a->t, tmp);
+    }
+
+    if (a->i) {
+        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
+        tcg_gen_ori_i64(tmp, tmp, a->i);

Likewise.

r~

#8 lore raw

PATCH 4/13 hw/pci-host/astro: Avoid aborting on access failure

In reply to [email protected]

From: Helge Deller <[email protected]>

Instead of stopping the emulation, report a MEMTX_DECODE_ERROR if the OS tries to access non-existent registers.

---
 hw/pci-host/astro.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
hw/pci-host/astro.c +13 -17
index 37d271118c..42bd65de53 100644
@@ -122,10 +122,6 @@ static MemTxResult elroy_chip_read_with_attrs(void *opaque, hwaddr addr,
     case 0x0800:                /* IOSAPIC_REG_SELECT */
         val = s->iosapic_reg_select;
         break;
-    case 0x0808:
-        val = UINT64_MAX;            /* XXX: tbc. */
-        g_assert_not_reached();
-        break;
     case 0x0810:                /* IOSAPIC_REG_WINDOW */
         switch (s->iosapic_reg_select) {
         case 0x01:              /* IOSAPIC_REG_VERSION */
@@ -135,15 +131,15 @@ static MemTxResult elroy_chip_read_with_attrs(void *opaque, hwaddr addr,
             if (s->iosapic_reg_select < ARRAY_SIZE(s->iosapic_reg)) {
                 val = s->iosapic_reg[s->iosapic_reg_select];
             } else {
-                trace_iosapic_reg_read(s->iosapic_reg_select, size, val);
-                g_assert_not_reached();
+                val = 0;
+                ret = MEMTX_DECODE_ERROR;
             }
         }
         trace_iosapic_reg_read(s->iosapic_reg_select, size, val);
         break;
     default:
-        trace_elroy_read(addr, size, val);
-        g_assert_not_reached();
+        val = 0;
+        ret = MEMTX_DECODE_ERROR;
     }
     trace_elroy_read(addr, size, val);
 
@@ -160,6 +156,7 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
                                               uint64_t val, unsigned size,
                                               MemTxAttrs attrs)
 {
+    MemTxResult ret = MEMTX_OK;
     ElroyState *s = opaque;
     int i;
 
@@ -191,7 +188,7 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
         if (s->iosapic_reg_select < ARRAY_SIZE(s->iosapic_reg)) {
             s->iosapic_reg[s->iosapic_reg_select] = val;
         } else {
-            g_assert_not_reached();
+            ret = MEMTX_DECODE_ERROR;
         }
         break;
     case 0x0840:                /* IOSAPIC_REG_EOI */
@@ -204,9 +201,9 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
         }
         break;
     default:
-        g_assert_not_reached();
+        ret = MEMTX_DECODE_ERROR;
     }
-    return MEMTX_OK;
+    return ret;
 }
 
 static const MemoryRegionOps elroy_chip_ops = {
@@ -594,8 +591,8 @@ static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
 #undef EMPTY_PORT
 
     default:
-        trace_astro_chip_read(addr, size, val);
-        g_assert_not_reached();
+        val = 0;
+        ret = MEMTX_DECODE_ERROR;
     }
 
     /* for 32-bit accesses mask return value */
@@ -610,6 +607,7 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
                                               uint64_t val, unsigned size,
                                               MemTxAttrs attrs)
 {
+    MemTxResult ret = MEMTX_OK;
     AstroState *s = opaque;
 
     trace_astro_chip_write(addr, size, val);
@@ -686,11 +684,9 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
 #undef EMPTY_PORT
 
     default:
-        /* Controlled by astro_chip_mem_valid above.  */
-        trace_astro_chip_write(addr, size, val);
-        g_assert_not_reached();
+        ret = MEMTX_DECODE_ERROR;
     }
-    return MEMTX_OK;
+    return ret;
 }
 
 static const MemoryRegionOps astro_chip_ops = {
Signature · 1 line
2.43.0
Reviewed-by on v1 4/13
#9 lore raw

Re: [PATCH 04/13] hw/pci-host/astro: Avoid aborting on access failure

Quoted 10 lines · On 2/7/24 08:20, [email protected] wrote:
hw/pci-host/astro.c +1 -0
@@ -610,6 +607,7 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
                                                uint64_t val, unsigned size,
                                                MemTxAttrs attrs)
  {
+    MemTxResult ret = MEMTX_OK;
      AstroState *s = opaque;
 
      trace_astro_chip_write(addr, size, val);
@@ -686,11 +684,9 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
  #undef EMPTY_PORT

hw/pci-host/astro.c static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr, · line 690

Quoted 10 lines
hw/pci-host/astro.c +2 -4
 
      default:
-        /* Controlled by astro_chip_mem_valid above.  */
-        trace_astro_chip_write(addr, size, val);
-        g_assert_not_reached();
+        ret = MEMTX_DECODE_ERROR;
      }
-    return MEMTX_OK;
+    return ret;
  }

For writes it's cleaner to just return these values directly than introduce a local. Unlike reads, were you still want to go through the tracepoint on the way out.

Otherwise,

r~

#10 lore raw

PATCH 5/13 hw/pci-host/astro: Implement Hard Fail and Soft Fail mode

In reply to [email protected]

From: Helge Deller <[email protected]>

The Astro/Elroy chip can work in either Hard-Fail or Soft-Fail mode.

Hard fail means the system bus will send an HPMC (=crash) to the processor, soft fail means the system bus will ignore timeouts of MMIO-reads or MMIO-writes and return -1ULL.

The HF mode is controlled by a bit in the status register and is usually programmed by the OS. Return the corresponing values based on the current value of that bit.

---
 hw/pci-host/astro.c         | 23 +++++++++++++++++------
 include/hw/pci-host/astro.h |  2 ++
 2 files changed, 19 insertions(+), 6 deletions(-)
hw/pci-host/astro.c +17 -6
index 42bd65de53..39549df3f5 100644
@@ -131,15 +131,21 @@ static MemTxResult elroy_chip_read_with_attrs(void *opaque, hwaddr addr,
             if (s->iosapic_reg_select < ARRAY_SIZE(s->iosapic_reg)) {
                 val = s->iosapic_reg[s->iosapic_reg_select];
             } else {
-                val = 0;
-                ret = MEMTX_DECODE_ERROR;
+                goto check_hf;
             }
         }
         trace_iosapic_reg_read(s->iosapic_reg_select, size, val);
         break;
     default:
-        val = 0;
-        ret = MEMTX_DECODE_ERROR;
+    check_hf:
+        if (s->status_control & HF_ENABLE) {
+            val = 0;
+            ret = MEMTX_DECODE_ERROR;
+        } else {
+            /* return -1ULL if HardFail is disabled */
+            val = ~0;
+            ret = MEMTX_OK;
+        }
     }
     trace_elroy_read(addr, size, val);
 
@@ -188,7 +194,7 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
         if (s->iosapic_reg_select < ARRAY_SIZE(s->iosapic_reg)) {
             s->iosapic_reg[s->iosapic_reg_select] = val;
         } else {
-            ret = MEMTX_DECODE_ERROR;
+            goto check_hf;
         }
         break;
     case 0x0840:                /* IOSAPIC_REG_EOI */
@@ -201,7 +207,12 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
         }
         break;
     default:
-        ret = MEMTX_DECODE_ERROR;
+    check_hf:
+        if (s->status_control & HF_ENABLE) {
+            ret = MEMTX_DECODE_ERROR;
+        } else {
+            ret = MEMTX_OK;
+        }
     }
     return ret;
 }
include/hw/pci-host/astro.h +2 -0
index f63fd220f3..e2966917cd 100644
@@ -27,6 +27,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(ElroyState, ELROY_PCI_HOST_BRIDGE)
 #define IOS_DIST_BASE_ADDR      0xfffee00000ULL
 #define IOS_DIST_BASE_SIZE           0x10000ULL
 
+#define HF_ENABLE       0x40    /* enable HF mode (default is -1 mode) */
+
 struct AstroState;
 
 struct ElroyState {
Signature · 1 line
2.43.0
Reviewed-by on v1 5/13
#11 lore raw

Re: [PATCH 05/13] hw/pci-host/astro: Implement Hard Fail and Soft Fail mode

Quoted 12 lines · On 2/7/24 08:20, [email protected] wrote:

From: Helge Deller<[email protected]>

The Astro/Elroy chip can work in either Hard-Fail or Soft-Fail mode.

Hard fail means the system bus will send an HPMC (=crash) to the processor, soft fail means the system bus will ignore timeouts of MMIO-reads or MMIO-writes and return -1ULL.

The HF mode is controlled by a bit in the status register and is usually programmed by the OS. Return the corresponing values based on the current value of that bit.

Quoted 5 lines
---
  hw/pci-host/astro.c         | 23 +++++++++++++++++------
  include/hw/pci-host/astro.h |  2 ++
  2 files changed, 19 insertions(+), 6 deletions(-)

r~

#12 lore raw

PATCH 6/13 lasi: allow access to LAN MAC address registers

In reply to [email protected]

From: Helge Deller <[email protected]>

Firmware and qemu reads and writes the MAC address for the LASI LAN via registers in LASI. Allow those accesses and return zero even if LASI LAN isn't enabled to avoid HPMCs (=crashes).

---
 hw/misc/lasi.c | 2 ++
 1 file changed, 2 insertions(+)
hw/misc/lasi.c +2 -0
index 003f5b5ed8..9cfa5bb316 100644
@@ -38,6 +38,7 @@ static bool lasi_chip_mem_valid(void *opaque, hwaddr addr,
     case LASI_LPT:
     case LASI_UART:
     case LASI_LAN:
+    case LASI_LAN + 12: /* LASI LAN MAC */
     case LASI_RTC:
 
     case LASI_PCR ... LASI_AMR:
@@ -78,6 +79,7 @@ static MemTxResult lasi_chip_read_with_attrs(void *opaque, hwaddr addr,
     case LASI_LPT:
     case LASI_UART:
     case LASI_LAN:
+    case LASI_LAN + 12:
         val = 0;
         break;
     case LASI_RTC:
Signature · 1 line
2.43.0
#13 lore raw

PATCH 7/13 target/hppa: Implement do_transaction_failed handler for I/O errors

In reply to [email protected]

From: Helge Deller <[email protected]>

Add the do_transaction_failed() handler to tigger a HPMC to the CPU in case of I/O transaction errors.

This is a preparation commit.
We still lack implementation for some registers, so do not yet enable sending HPMCs. Having this hunk here now nevertheless helps for the further development, so that it can easily be enabled later on.

---
 target/hppa/cpu.c        |  1 +
 target/hppa/cpu.h        |  5 +++++
 target/hppa/mem_helper.c | 19 +++++++++++++++++++
 3 files changed, 25 insertions(+)
target/hppa/cpu.c +1 -0
index 5f87c1b12a..afe73d4474 100644
@@ -191,6 +191,7 @@ static const TCGCPUOps hppa_tcg_ops = {
     .cpu_exec_interrupt = hppa_cpu_exec_interrupt,
     .do_interrupt = hppa_cpu_do_interrupt,
     .do_unaligned_access = hppa_cpu_do_unaligned_access,
+    .do_transaction_failed = hppa_cpu_do_transaction_failed,
 #endif /* !CONFIG_USER_ONLY */
 };
 
target/hppa/cpu.h +5 -0
index 06b65f2258..5a4b56c975 100644
@@ -383,6 +383,11 @@ bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req);
 int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
                               int type, hwaddr *pphys, int *pprot,
                               HPPATLBEntry **tlb_entry);
+void hppa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
+                                     vaddr addr, unsigned size,
+                                     MMUAccessType access_type,
+                                     int mmu_idx, MemTxAttrs attrs,
+                                     MemTxResult response, uintptr_t retaddr);
 extern const MemoryRegionOps hppa_io_eir_ops;
 extern const VMStateDescription vmstate_hppa_cpu;
 void hppa_cpu_alarm_timer(void *);
target/hppa/mem_helper.c +19 -0
index 629a9d90ef..676c0b3003 100644
@@ -353,6 +353,25 @@ raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
     cpu_loop_exit_restore(cs, retaddr);
 }
 
+void hppa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
+                                     vaddr addr, unsigned size,
+                                     MMUAccessType access_type,
+                                     int mmu_idx, MemTxAttrs attrs,
+                                     MemTxResult response, uintptr_t retaddr)
+{
+    CPUHPPAState *env = cpu_env(cs);
+
+    qemu_log_mask(LOG_GUEST_ERROR, "HPMC at " TARGET_FMT_lx ":" TARGET_FMT_lx
+                " while accessing I/O at %#08" HWADDR_PRIx "\n",
+                env->iasq_f, env->iaoq_f, physaddr);
+
+    /* FIXME: Enable HPMC exceptions when firmware has clean device probing */
+    if (0) {
+        raise_exception_with_ior(env, EXCP_HPMC, retaddr, addr,
+                                 MMU_IDX_MMU_DISABLED(mmu_idx));
+    }
+}
+
 bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
                        MMUAccessType type, int mmu_idx,
                        bool probe, uintptr_t retaddr)
Signature · 1 line
2.43.0
#14 lore raw

PATCH 8/13 lasi: Add reset I/O ports for LASI audio and FDC

In reply to [email protected]

From: Helge Deller <[email protected]>

Linux writes zeroes at bootup into the default ports for LASI audio and LASI floppy controller to reset those devices. Allow writing to those registers to avoid HPMCs.

---
 hw/misc/lasi.c         | 11 +++++++++++
 include/hw/misc/lasi.h |  2 ++
 2 files changed, 13 insertions(+)
hw/misc/lasi.c +11 -0
index 9cfa5bb316..970fc98b5c 100644
@@ -36,10 +36,13 @@ static bool lasi_chip_mem_valid(void *opaque, hwaddr addr,
     case LASI_IAR:
 
     case LASI_LPT:
+    case LASI_AUDIO:
+    case LASI_AUDIO + 4:
     case LASI_UART:
     case LASI_LAN:
     case LASI_LAN + 12: /* LASI LAN MAC */
     case LASI_RTC:
+    case LASI_FDC:
 
     case LASI_PCR ... LASI_AMR:
         ret = true;
@@ -80,6 +83,7 @@ static MemTxResult lasi_chip_read_with_attrs(void *opaque, hwaddr addr,
     case LASI_UART:
     case LASI_LAN:
     case LASI_LAN + 12:
+    case LASI_FDC:
         val = 0;
         break;
     case LASI_RTC:
@@ -145,12 +149,19 @@ static MemTxResult lasi_chip_write_with_attrs(void *opaque, hwaddr addr,
     case LASI_LPT:
         /* XXX: reset parallel port */
         break;
+    case LASI_AUDIO:
+    case LASI_AUDIO + 4:
+        /* XXX: reset audio port */
+        break;
     case LASI_UART:
         /* XXX: reset serial port */
         break;
     case LASI_LAN:
         /* XXX: reset LAN card */
         break;
+    case LASI_FDC:
+        /* XXX: reset Floppy controller */
+        break;
     case LASI_RTC:
         s->rtc_ref = val - time(NULL);
         break;
include/hw/misc/lasi.h +2 -0
index 0a8c7352be..f01c0f680a 100644
@@ -26,9 +26,11 @@ OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP)
 #define LASI_IAR        0x10
 
 #define LASI_LPT        0x02000
+#define LASI_AUDIO      0x04000
 #define LASI_UART       0x05000
 #define LASI_LAN        0x07000
 #define LASI_RTC        0x09000
+#define LASI_FDC        0x0A000
 
 #define LASI_PCR        0x0C000 /* LASI Power Control register */
 #define LASI_ERRLOG     0x0C004 /* LASI Error Logging register */
Signature · 1 line
2.43.0
#15 lore raw

PATCH 9/13 target/hppa: Allow read-access to PSW with rsm 0, reg instruction

In reply to [email protected]

From: Helge Deller <[email protected]>

HP-UX 11 and HP ODE tools use the "rsm 0,%reg" instruction in not priviledged code paths to get the current PSW flags. The constant 0 means that no bits of the PSW shall be reset, so this is effectively a read-only access to the PSW. Allow this read-only access even for not privileged code.

---
 target/hppa/translate.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
target/hppa/translate.c +7 -1
index 10fdc0813d..7e58775bbf 100644
@@ -2156,10 +2156,16 @@ static bool trans_ldsid(DisasContext *ctx, arg_ldsid *a)
 
 static bool trans_rsm(DisasContext *ctx, arg_rsm *a)
 {
+#ifdef CONFIG_USER_ONLY
     CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
-#ifndef CONFIG_USER_ONLY
+#else
     TCGv_i64 tmp;
 
+    /* HP-UX 11i and HP ODE use rsm for read-access to PSW */
+    if (a->i) {
+        CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
+    }
+
     nullify_over(ctx);
 
     tmp = tcg_temp_new_i64();
Signature · 1 line
2.43.0
Acked-by on v1 9/13
#16 lore raw

Re: [PATCH 09/13] target/hppa: Allow read-access to PSW with rsm 0,reg instruction

Quoted 22 lines · On 2/7/24 08:20, [email protected] wrote:

From: Helge Deller <[email protected]>

HP-UX 11 and HP ODE tools use the "rsm 0,%reg" instruction in not priviledged code paths to get the current PSW flags. The constant 0 means that no bits of the PSW shall be reset, so this is effectively a read-only access to the PSW. Allow this read-only access even for not privileged code.

---
  target/hppa/translate.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
target/hppa/translate.c +1 -0
index 10fdc0813d..7e58775bbf 100644
@@ -2156,10 +2156,16 @@ static bool trans_ldsid(DisasContext *ctx, arg_ldsid *a)
 
  static bool trans_rsm(DisasContext *ctx, arg_rsm *a)
  {
+#ifdef CONFIG_USER_ONLY
      CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);

target/hppa/translate.c static bool trans_ldsid(DisasContext *ctx, arg_ldsid *a) · line 2169

Quoted 10 lines
target/hppa/translate.c +6 -1
-#ifndef CONFIG_USER_ONLY
+#else
      TCGv_i64 tmp;
 
+    /* HP-UX 11i and HP ODE use rsm for read-access to PSW */
+    if (a->i) {
+        CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
+    }
+
      nullify_over(ctx);

Wow, that is not documented in the manual. I wonder what this user-land software uses this for? There aren't many bits in there that are relevant to user-land.

I suppose PSW_W is readable from there, but that can be inferred from SAR...

r~

#17 lore raw

PATCH 10/13 target/hppa: Check privilege only when PSW.P is set

In reply to [email protected]

From: Helge Deller <[email protected]>

CHECK_MOST_PRIVILEGED() should check the privilege level only when the PSW.P bit is set.

---
 target/hppa/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/translate.c +1 -1
index 7e58775bbf..21c2734a1f 100644
@@ -604,7 +604,7 @@ static bool gen_illegal(DisasContext *ctx)
 #else
 #define CHECK_MOST_PRIVILEGED(EXCP) \
     do {                                     \
-        if (ctx->privilege != 0) {           \
+        if (ctx->privilege != 0 && (ctx->tb_flags & PSW_P)) { \
             return gen_excp_iir(ctx, EXCP);  \
         }                                    \
     } while (0)
Signature · 1 line
2.43.0
#18 lore raw

Re: [PATCH 10/13] target/hppa: Check privilege only when PSW.P is set

Quoted 15 lines · On 2/7/24 08:20, [email protected] wrote:

From: Helge Deller <[email protected]>

CHECK_MOST_PRIVILEGED() should check the privilege level only when the PSW.P bit is set.

---
  target/hppa/translate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/translate.c +0 -0
index 7e58775bbf..21c2734a1f 100644

target/hppa/translate.c static bool gen_illegal(DisasContext *ctx) · line 610

Quoted 8 lines
target/hppa/translate.c +1 -1
@@ -604,7 +604,7 @@ static bool gen_illegal(DisasContext *ctx)
  #else
  #define CHECK_MOST_PRIVILEGED(EXCP) \
      do {                                     \
-        if (ctx->privilege != 0) {           \
+        if (ctx->privilege != 0 && (ctx->tb_flags & PSW_P)) { \
              return gen_excp_iir(ctx, EXCP);  \
          }                                    \
      } while (0)

PSW_P is documented as applying only to protection identifiers. I do not believe this to be correct at all.

r~

#19 lore raw

PATCH 11/13 target/hppa: PDC_BTLB_INFO uses 32-bit ints

In reply to [email protected]

From: Helge Deller <[email protected]>

The BTLB helper function stores the BTLB info (four 32-bit ints) into the memory of the guest. They are only available when emulating a 32-bit CPU in the guest, so use "uint32_t" instead of "target_ulong" here.

---
 target/hppa/mem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/mem_helper.c +1 -1
index 676c0b3003..66b8fa7d72 100644
@@ -684,7 +684,7 @@ void HELPER(diag_btlb)(CPUHPPAState *env)
     case 0:
         /* return BTLB parameters */
         qemu_log_mask(CPU_LOG_MMU, "PDC_BLOCK_TLB: PDC_BTLB_INFO\n");
-        vaddr = probe_access(env, env->gr[24], 4 * sizeof(target_ulong),
+        vaddr = probe_access(env, env->gr[24], 4 * sizeof(uint32_t),
                              MMU_DATA_STORE, mmu_idx, ra);
         if (vaddr == NULL) {
             env->gr[28] = -10; /* invalid argument */
Signature · 1 line
2.43.0
Reviewed-by on v1 11/13
#20 lore raw

Re: [PATCH 11/13] target/hppa: PDC_BTLB_INFO uses 32-bit ints

Quoted 7 lines · On 2/7/24 08:20, [email protected] wrote:

From: Helge Deller <[email protected]>

The BTLB helper function stores the BTLB info (four 32-bit ints) into the memory of the guest. They are only available when emulating a 32-bit CPU in the guest, so use "uint32_t" instead of "target_ulong" here.

r~

#21 lore raw

PATCH 12/13 target/hppa: Update SeaBIOS-hppa to version 16

In reply to [email protected]

From: Helge Deller <[email protected]>

SeaBIOS-hppa version 16 news & enhancements:

- Initial 64-bit firmware release
- Added fault handler to catch and report firmware bugs
- Use Qemu's builtin_console_out() via diag 0x101
- parisc-qemu-install Makefile target to install firmware in qemu
- Added -fw_cfg opt/OS64,string=3 option

Fixes:

- Avoid crash when booting without SCSI controller
- Avoid possible crashes while detecting LASI LAN & graphics
- Don't check layers in PDC_MEM_MAP_HPA, fixes NetBSD
- Ensure cache definition does not trigger endless loops
- Mark B160L as 32-bit machine in inventory

---
 pc-bios/hppa-firmware.img   | Bin 163324 -> 167836 bytes
 pc-bios/hppa-firmware64.img | Bin 0 -> 205944 bytes
 roms/seabios-hppa           |   2 +-
 3 files changed, 1 insertion(+), 1 deletion(-)
 mode change 100644 => 100755 pc-bios/hppa-firmware.img
 create mode 100755 pc-bios/hppa-firmware64.img
pc-bios/hppa-firmware.img binary +0 -0
old mode 100644
new mode 100755
index 1b3a8418250db977e0c0c4ae7194ba7e0199c30d..3cd2e2e68e06823a9a57ac582c19b025f4cd32de
GIT binary patch
pc-bios/hppa-firmware64.img new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..17fb91dc7303d34aaa61ea713d81f7ed5ae6223b
GIT binary patch
roms/seabios-hppa +1 -1
index e4eac85880..d7078ed49b 160000
@@ -1 +1 @@
-Subproject commit e4eac85880e8677f96d8b9e94de9f2eec9c0751f
+Subproject commit d7078ed49b4f896dd2c8694129667a9662155d2f
Signature · 1 line
2.43.0
Acked-by on v1 12/13
#22 lore raw

Re: [PATCH 12/13] target/hppa: Update SeaBIOS-hppa to version 16

Quoted 12 lines · On 2/7/24 08:20, [email protected] wrote:

From: Helge Deller<[email protected]>

SeaBIOS-hppa version 16 news & enhancements:

- Initial 64-bit firmware release
- Added fault handler to catch and report firmware bugs
- Use Qemu's builtin_console_out() via diag 0x101
- parisc-qemu-install Makefile target to install firmware in qemu
- Added -fw_cfg opt/OS64,string=3 option

Fixes:

Quoted 8 lines

- Avoid crash when booting without SCSI controller
- Avoid possible crashes while detecting LASI LAN & graphics
- Don't check layers in PDC_MEM_MAP_HPA, fixes NetBSD
- Ensure cache definition does not trigger endless loops
- Mark B160L as 32-bit machine in inventory

---

r~

#23 lore raw

PATCH 13/13 hw/hppa/machine: Load 64-bit firmware on 64-bit machines

In reply to [email protected]

From: Helge Deller <[email protected]>

Load the 64-bit SeaBIOS-hppa firmware by default when running on a 64-bit machine. This will enable us to later support more than 4GB of RAM and is required that the OS (or PALO bootloader) will start or install a 64-bit kernel instead of a 32-bit kernel.

Note that SeaBIOS-hppa v16 provides the "-fw_cfg opt/OS64,string=3" option with which the user can control what the firmware shall report back to the OS:
Support of 32-bit OS, support of a 64-bit OS, or support for both (default).

---
 hw/hppa/machine.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/hppa/machine.c +8 -3
index eb78c46ff1..a47baa572d 100644
@@ -333,6 +333,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
+    const char *firmware = machine->firmware;
     MachineClass *mc = MACHINE_GET_CLASS(machine);
     DeviceState *dev;
     PCIDevice *pci_dev;
@@ -408,9 +409,13 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
 
     /* Load firmware.  Given that this is not "real" firmware,
        but one explicitly written for the emulation, we might as
-       well load it directly from an ELF image.  */
-    firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
-                                       machine->firmware ?: "hppa-firmware.img");
+       well load it directly from an ELF image. Load the 64-bit
+       firmware on 64-bit machines by default if not specified
+       on command line. */
+    if (!firmware) {
+        firmware = lasi_dev ? "hppa-firmware.img" : "hppa-firmware64.img";
+    }
+    firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware);
     if (firmware_filename == NULL) {
         error_report("no firmware provided");
         exit(1);
Signature · 1 line
2.43.0
Acked-by on v1 13/13
#24 lore raw

Re: [PATCH 13/13] hw/hppa/machine: Load 64-bit firmware on 64-bit machines

Quoted 7 lines · On 2/7/24 08:20, [email protected] wrote:

From: Helge Deller<[email protected]>

Load the 64-bit SeaBIOS-hppa firmware by default when running on a 64-bit machine. This will enable us to later support more than 4GB of RAM and is required that the OS (or PALO bootloader) will start or install a 64-bit kernel instead of a 32-bit kernel.

Quoted 8 lines

Note that SeaBIOS-hppa v16 provides the "-fw_cfg opt/OS64,string=3" option with which the user can control what the firmware shall report back to the OS:
Support of 32-bit OS, support of a 64-bit OS, or support for both (default).

---
  hw/hppa/machine.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)

r~