Skip to contentSkip to conversation

target/hppa qemu v8.2 regression fixes

PATCH In review [email protected] 4 participants 25 messages Jan 12, 2024 – Jan 26, 2024

lore
Share & tools
lore
#7 lore raw

PATCH v3 3/9 hw/pci-host/astro: Add missing astro & elroy registers for NetBSD

In reply to [email protected]

From: Helge Deller <[email protected]>

NetBSD accesses some astro and elroy registers which aren't accessed by Linux yet. Add emulation for those registers to allow NetBSD to boot further.
Please note that this patch is not sufficient to completely boot up NetBSD on the 64-bit C3700 machine yet.

---
 hw/pci-host/astro.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
hw/pci-host/astro.c +23 -3
index 7d68ccee7e..cb2c8a828d 100644
@@ -166,6 +166,8 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
     trace_elroy_write(addr, size, val);
 
     switch ((addr >> 3) << 3) {
+    case 0x000: /* PCI_ID & PCI_COMMAND_STATUS_REG */
+        break;
     case 0x080:
         put_val_in_int64(&s->arb_mask, addr, size, val);
         break;
@@ -175,6 +177,9 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
     case 0x200 ... 0x250 - 1:   /* LMMIO, GMMIO, WLMMIO, WGMMIO, ... */
         put_val_in_arrary(s->mmio_base, 0x200, addr, size, val);
         break;
+    case 0x300: /* ibase */
+    case 0x308: /* imask */
+        break;
     case 0x0680:
         put_val_in_int64(&s->error_config, addr, size, val);
         break;
@@ -538,6 +543,9 @@ static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
     case 0x0030:        /* HP-UX 10.20 and 11.11 reads it. No idea. */
         val = -1;
         break;
+    case 0x0078:        /* NetBSD reads 0x78 ? */
+        val = -1;
+        break;
     case 0x0300 ... 0x03d8:     /* LMMIO_DIRECT0_BASE... */
         index = (addr - 0x300) / 8;
         val = s->ioc_ranges[index];
@@ -624,31 +632,43 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
     case 0x10220:
     case 0x10230:        /* HP-UX 11.11 reads it. No idea. */
         break;
-    case 0x22108:        /* IOC STATUS_CONTROL */
-        put_val_in_int64(&s->ioc_status_ctrl, addr, size, val);
-        break;
     case 0x20200 ... 0x20240 - 1: /* IOC Rope0_Control ... */
         put_val_in_arrary(s->ioc_rope_control, 0x20200, addr, size, val);
         break;
     case 0x20040:        /* IOC Rope config */
+    case 0x22040:
         put_val_in_int64(&s->ioc_rope_config, addr, size, val);
         break;
     case 0x20300:
+    case 0x22300:
         put_val_in_int64(&s->tlb_ibase, addr, size, val);
         break;
     case 0x20308:
+    case 0x22308:
         put_val_in_int64(&s->tlb_imask, addr, size, val);
         break;
     case 0x20310:
+    case 0x22310:
         put_val_in_int64(&s->tlb_pcom, addr, size, val);
         /* TODO: flush iommu */
         break;
     case 0x20318:
+    case 0x22318:
         put_val_in_int64(&s->tlb_tcnfg, addr, size, val);
         break;
     case 0x20320:
+    case 0x22320:
         put_val_in_int64(&s->tlb_pdir_base, addr, size, val);
         break;
+    case 0x22000:       /* func_id */
+        break;
+    case 0x22008:       /* func_class */
+        break;
+    case 0x22050:       /* rope_debug */
+        break;
+    case 0x22108:        /* IOC STATUS_CONTROL */
+        put_val_in_int64(&s->ioc_status_ctrl, addr, size, val);
+        break;
     /*
      * empty placeholders for non-existent elroys, e.g.
      * func_class, pci config & data
Signature · 1 line
2.43.0
#18 lore raw

PATCH v3 6/9 target/hppa: Avoid accessing %gr0 when raising exception

In reply to [email protected]

From: Helge Deller <[email protected]>

The value of unwind_breg may reference register %r0, but we need to avoid accessing gr0 directly and use the value 0 instead.

At runtime I've seen unwind_breg being zero with the Linux kernel when rfi is used to jump to smp_callin().

---
 target/hppa/mem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/mem_helper.c +1 -1
index 011b192406..42bd0063c0 100644
@@ -335,7 +335,7 @@ raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
 
                 cpu_restore_state(cs, retaddr);
 
-                b = env->gr[env->unwind_breg];
+                b = env->unwind_breg ? env->gr[env->unwind_breg] : 0;
                 b >>= (env->psw & PSW_W ? 62 : 30);
                 env->cr[CR_IOR] |= b << 62;
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v3 2/9 hw/hppa/machine: Disable default devices with --nodefaults option

In reply to [email protected]

From: Helge Deller <[email protected]>

Recognize the qemu --nodefaults option, which will disable the following default devices on hppa:
- lsi53c895a SCSI controller,
- artist graphics card,
- LASI 82596 NIC,
- tulip PCI NIC,
- second serial PCI card,
- USB OHCI controller.

Adding this option is very useful to allow manual testing and debugging of the other possible devices on the command line.

---
 hw/hppa/machine.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
hw/hppa/machine.c +6 -4
index b11907617e..54ca2fd91a 100644
@@ -346,8 +346,10 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
     SysBusDevice *s;
 
     /* SCSI disk setup. */
-    dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
-    lsi53c8xx_handle_legacy_cmdline(dev);
+    if (drive_get_max_bus(IF_SCSI) >= 0) {
+        dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
+        lsi53c8xx_handle_legacy_cmdline(dev);
+    }
 
     /* Graphics setup. */
     if (machine->enable_graphics && vga_interface_type != VGA_NONE) {
@@ -360,7 +362,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
     }
 
     /* Network setup. */
-    if (enable_lasi_lan()) {
+    if (nd_table[0].used && enable_lasi_lan()) {
         lasi_82596_init(addr_space, translate(NULL, LASI_LAN_HPA),
                         qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA));
     }
@@ -385,7 +387,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
     pci_set_word(&pci_dev->config[PCI_SUBSYSTEM_ID], 0x1227); /* Powerbar */
 
     /* create a second serial PCI card when running Astro */
-    if (!lasi_dev) {
+    if (serial_hd(1) && !lasi_dev) {
         pci_dev = pci_new(-1, "pci-serial-4x");
         qdev_prop_set_chr(DEVICE(pci_dev), "chardev1", serial_hd(1));
         qdev_prop_set_chr(DEVICE(pci_dev), "chardev2", serial_hd(2));
Signature · 1 line
2.43.0
#19 lore raw

PATCH v3 7/9 target/hppa: Export function hppa_set_ior_and_isr()

In reply to [email protected]

From: Helge Deller <[email protected]>

Move functionality to set IOR and ISR on fault into own function. This will be used by follow-up patches.

---
 target/hppa/cpu.h        |  1 +
 target/hppa/mem_helper.c | 23 ++++++++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)
target/hppa/cpu.h +1 -0
index 8be45c69c9..9556e95fab 100644
@@ -385,6 +385,7 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int);
 #ifndef CONFIG_USER_ONLY
 void hppa_ptlbe(CPUHPPAState *env);
 hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
+void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled);
 bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                        MMUAccessType access_type, int mmu_idx,
                        bool probe, uintptr_t retaddr);
target/hppa/mem_helper.c +12 -11
index 42bd0063c0..7f54160e4c 100644
@@ -299,14 +299,8 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
     return excp == EXCP_DTLB_MISS ? -1 : phys;
 }
 
-G_NORETURN static void
-raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
-                         vaddr addr, bool mmu_disabled)
+void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled)
 {
-    CPUState *cs = env_cpu(env);
-
-    cs->exception_index = excp;
-
     if (env->psw & PSW_Q) {
         /*
          * For pa1.x, the offset and space never overlap, and so we
@@ -333,16 +327,23 @@ raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
                  */
                 uint64_t b;
 
-                cpu_restore_state(cs, retaddr);
-
                 b = env->unwind_breg ? env->gr[env->unwind_breg] : 0;
                 b >>= (env->psw & PSW_W ? 62 : 30);
                 env->cr[CR_IOR] |= b << 62;
-
-                cpu_loop_exit(cs);
             }
         }
     }
+}
+
+G_NORETURN static void
+raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
+                         vaddr addr, bool mmu_disabled)
+{
+    CPUState *cs = env_cpu(env);
+
+    cs->exception_index = excp;
+    hppa_set_ior_and_isr(env, addr, mmu_disabled);
+
     cpu_loop_exit_restore(cs, retaddr);
 }
 
Signature · 1 line
2.43.0
#0 lore raw

v3 cover target/hppa qemu v8.2 regression fixes

From: Helge Deller <[email protected]>

There were some regressions introduced with Qemu v8.2 on the hppa/hppa64 target, e.g.:

- 32-bit HP-UX crashes on B160L (32-bit) machine
- NetBSD boot failure due to power button in page zero
- NetBSD FPU detection failure
- OpenBSD 7.4 boot failure

This patch series fixes those known regressions and additionally:

- allows usage of the max. 3840MB of memory (instead of 3GB),
- adds support for the qemu --nodefaults option (to debug other devices)

This patch set will not fix those known (non-regression) bugs:
- HP-UX and NetBSD still fail to boot on the new 64-bit C3700 machine
- Linux kernel will still fail to boot on C3700 as long as kernel modules are used.

The whole series can be pulled from the "hppa-fixes-8.2" branch from:
https://github.com/hdeller/qemu-hppa.git hppa-fixes-8.2

SeaBIOS v15 has not changed in v3, so it is not included in this patch review series but will be added in final pull request.

Please review.

Changes v2->v3:
- Added comment about Figures H-10 and H-11 in the parisc2.0 spec in patch which calculate PDC address translation if PSW.W=0
- Introduce and use hppa_set_ior_and_isr()
- Use drive_get_max_bus(IF_SCSI), nd_table[] and serial_hd() to check if default devices should be created
- Added Tested-by and Reviewed-by tags

Changes v1->v2:
- fix OpenBSD boot with SeaBIOS v15 instead of v14
- commit message enhancements suggested by BALATON Zoltan
- use uint64_t for ram_max in patch #1

Helge Deller (9):
hw/hppa/machine: Allow up to 3840 MB total memory hw/hppa/machine: Disable default devices with --nodefaults option hw/pci-host/astro: Add missing astro & elroy registers for NetBSD target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0 hw/hppa: Move software power button address back into PDC target/hppa: Avoid accessing %gr0 when raising exception target/hppa: Export function hppa_set_ior_and_isr() target/hppa: Fix IOR and ISR on unaligned access trap target/hppa: Fix IOR and ISR on error in probe

 hw/hppa/machine.c        | 28 +++++++++++++++++-----------
 hw/pci-host/astro.c      | 26 +++++++++++++++++++++++---
 target/hppa/cpu.c        |  6 +-----
 target/hppa/cpu.h        |  1 +
 target/hppa/mem_helper.c | 27 ++++++++++++++-------------
 target/hppa/op_helper.c  |  6 +-----
 6 files changed, 57 insertions(+), 37 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/9 hw/hppa/machine: Allow up to 3840 MB total memory

From: Helge Deller <[email protected]>

The physical hardware allows DIMMs of 4 MB size and above, allowing up to 3840 MB of memory, but is restricted by setup code to 3 GB. Increase the limit to allow up to the maximum amount of memory.

Btw. the memory area from 0xf000.0000 to 0xffff.ffff is reserved by the architecture for firmware and I/O memory and can not be used for standard memory.

An upcoming 64-bit SeaBIOS-hppa firmware will allow more than 3.75GB on 64-bit HPPA64. In this case the ram_max for the pa20 case will change.

Fixes b7746b1194c8 ("hw/hppa/machine: Restrict the total memory size to 3GB")
---
 hw/hppa/machine.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
hw/hppa/machine.c +6 -3
index c8da7c18d5..b11907617e 100644
@@ -276,6 +276,7 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
     unsigned int smp_cpus = machine->smp.cpus;
     TranslateFn *translate;
     MemoryRegion *cpu_region;
+    uint64_t ram_max;
 
     /* Create CPUs.  */
     for (unsigned int i = 0; i < smp_cpus; i++) {
@@ -288,8 +289,10 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
      */
     if (hppa_is_pa20(&cpu[0]->env)) {
         translate = translate_pa20;
+        ram_max = 0xf0000000;      /* 3.75 GB (limited by 32-bit firmware) */
     } else {
         translate = translate_pa10;
+        ram_max = 0xf0000000;      /* 3.75 GB (32-bit CPU) */
     }
 
     for (unsigned int i = 0; i < smp_cpus; i++) {
@@ -311,9 +314,9 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
                                 cpu_region);
 
     /* Main memory region. */
-    if (machine->ram_size > 3 * GiB) {
-        error_report("RAM size is currently restricted to 3GB");
-        exit(EXIT_FAILURE);
+    if (machine->ram_size > ram_max) {
+        info_report("Max RAM size limited to %" PRIu64 " MB", ram_max / MiB);
+        machine->ram_size = ram_max;
     }
     memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1);
 
Signature · 1 line
2.43.0
#21 lore raw

PATCH v3 8/9 target/hppa: Fix IOR and ISR on unaligned access trap

In reply to [email protected]

From: Helge Deller <[email protected]>

Put correct values (depending on CPU arch) into IOR and ISR on fault.

---
 target/hppa/cpu.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
target/hppa/cpu.c +1 -5
index 04de1689d7..fda32d7f59 100644
@@ -110,11 +110,7 @@ void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
     CPUHPPAState *env = &cpu->env;
 
     cs->exception_index = EXCP_UNALIGN;
-    if (env->psw & PSW_Q) {
-        /* ??? Needs tweaking for hppa64.  */
-        env->cr[CR_IOR] = addr;
-        env->cr[CR_ISR] = addr >> 32;
-    }
+    hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx));
 
     cpu_loop_exit_restore(cs, retaddr);
 }
Signature · 1 line
2.43.0
#8 lore raw

PATCH v3 4/9 target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0

In reply to [email protected]

From: Helge Deller <[email protected]>

Fix the address translation for PDC space on PA2.0 if PSW.W=0. Basically, for any address in the 32-bit PDC range from 0xf0000000 to 0xf1000000 keep the lower 32-bits and just set the upper 32-bits to 0xfffffff0.

This mapping fixes the emulated power button in PDC space for 32- and 64-bit machines and is how the physical C3700 machine seems to map PDC.

Figures H-10 and H-11 in the parisc2.0 spec [1] show that the 32-bit region will be mapped somewhere into a higher and bigger 64-bit PDC space. The start and end of this 64-bit space is defined by the physical address bits. But the figures don't specifiy where exactly the mapping will start inside that region. Tests on a real HP C3700 regarding the address of the power button indicate, that the lower 32-bits will stay the same though.
[1] https://parisc.wiki.kernel.org/images-parisc/7/73/Parisc2.0.pdf

---
 target/hppa/mem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/mem_helper.c +1 -1
index 08abd1a9f9..011b192406 100644
@@ -56,7 +56,7 @@ hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr)
         addr = (int32_t)addr;
     } else {
         /* PDC address space */
-        addr &= MAKE_64BIT_MASK(0, 24);
+        addr = (uint32_t)addr;
         addr |= -1ull << (TARGET_PHYS_ADDR_SPACE_BITS - 4);
     }
     return addr;
Signature · 1 line
2.43.0
#12 lore raw

PATCH v3 5/9 hw/hppa: Move software power button address back into PDC

In reply to [email protected]

From: Helge Deller <[email protected]>

The various operating systems (e.g. Linux, NetBSD) have issues mapping the power button when it's stored in page zero. NetBSD even crashes, because it fails to map that page and then accesses unmapped memory.

Since we now have a consistent memory mapping of PDC in 32-bit and 64-bit address space (the lower 32-bits of the address are in sync) the power button can be moved back to PDC space.

This patch fixes the power button on Linux, NetBSD and HP-UX.

---
 hw/hppa/machine.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/hppa/machine.c +5 -4
index 54ca2fd91a..9e611620cc 100644
@@ -36,8 +36,8 @@
 
 #define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
 
-/* Power button address at &PAGE0->pad[4] */
-#define HPA_POWER_BUTTON (0x40 + 4 * sizeof(uint32_t))
+#define HPA_POWER_BUTTON        (FIRMWARE_END - 0x10)
+static hwaddr soft_power_reg;
 
 #define enable_lasi_lan()       0
 
@@ -45,7 +45,6 @@ static DeviceState *lasi_dev;
 
 static void hppa_powerdown_req(Notifier *n, void *opaque)
 {
-    hwaddr soft_power_reg = HPA_POWER_BUTTON;
     uint32_t val;
 
     val = ldl_be_phys(&address_space_memory, soft_power_reg);
@@ -221,7 +220,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
     fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
                     g_memdup(mc->name, len), len);
 
-    val = cpu_to_le64(HPA_POWER_BUTTON);
+    val = cpu_to_le64(soft_power_reg);
     fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
@@ -295,6 +294,8 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
         ram_max = 0xf0000000;      /* 3.75 GB (32-bit CPU) */
     }
 
+    soft_power_reg = translate(NULL, HPA_POWER_BUTTON);
+
     for (unsigned int i = 0; i < smp_cpus; i++) {
         g_autofree char *name = g_strdup_printf("cpu%u-io-eir", i);
 
Signature · 1 line
2.43.0
#23 lore raw

PATCH v3 9/9 target/hppa: Fix IOR and ISR on error in probe

In reply to [email protected]

From: Helge Deller <[email protected]>

Put correct values (depending on CPU arch) into IOR and ISR on fault.

---
 target/hppa/op_helper.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
target/hppa/op_helper.c +1 -5
index 7f607c3afd..ce15469465 100644
@@ -351,11 +351,7 @@ 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) {
-        if (env->psw & PSW_Q) {
-            /* ??? Needs tweaking for hppa64.  */
-            env->cr[CR_IOR] = addr;
-            env->cr[CR_ISR] = addr >> 32;
-        }
+        hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx));
         if (excp == EXCP_DTLB_MISS) {
             excp = EXCP_NA_DTLB_MISS;
         }
Signature · 1 line
2.43.0
Reviewed-by on v3 2/9
#3 lore raw

Re: [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option

In reply to [email protected]
Quoted 11 lines · On 1/12/24 21:29, [email protected] wrote:

From: Helge Deller<[email protected]>

Recognize the qemu --nodefaults option, which will disable the following default devices on hppa:
- lsi53c895a SCSI controller,
- artist graphics card,
- LASI 82596 NIC,
- tulip PCI NIC,
- second serial PCI card,
- USB OHCI controller.

Quoted 7 lines

Adding this option is very useful to allow manual testing and debugging of the other possible devices on the command line.

---
  hw/hppa/machine.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)

r~

#9 lore raw

Re: [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0

In reply to [email protected]
Quoted 31 lines · On 1/12/24 21:29, [email protected] wrote:

From: Helge Deller <[email protected]>

Fix the address translation for PDC space on PA2.0 if PSW.W=0. Basically, for any address in the 32-bit PDC range from 0xf0000000 to 0xf1000000 keep the lower 32-bits and just set the upper 32-bits to 0xfffffff0.

This mapping fixes the emulated power button in PDC space for 32- and 64-bit machines and is how the physical C3700 machine seems to map PDC.

Figures H-10 and H-11 in the parisc2.0 spec [1] show that the 32-bit region will be mapped somewhere into a higher and bigger 64-bit PDC space. The start and end of this 64-bit space is defined by the physical address bits. But the figures don't specifiy where exactly the mapping will start inside that region. Tests on a real HP C3700 regarding the address of the power button indicate, that the lower 32-bits will stay the same though.
[1] https://parisc.wiki.kernel.org/images-parisc/7/73/Parisc2.0.pdf

---
  target/hppa/mem_helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/mem_helper.c +0 -0
index 08abd1a9f9..011b192406 100644

target/hppa/mem_helper.c hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr) · line 62

Quoted 8 lines
target/hppa/mem_helper.c +1 -1
@@ -56,7 +56,7 @@ hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr)
          addr = (int32_t)addr;
      } else {
          /* PDC address space */
-        addr &= MAKE_64BIT_MASK(0, 24);
+        addr = (uint32_t)addr;
          addr |= -1ull << (TARGET_PHYS_ADDR_SPACE_BITS - 4);
      }
      return addr;

Please adjust the code comment that immediately precedes this, not just within the commit message.

r~

#13 lore raw

Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC

In reply to [email protected]
Quoted 13 lines · On 1/12/24 21:29, [email protected] wrote:
hw/hppa/machine.c +1 -1
+static hwaddr soft_power_reg;
 
  #define enable_lasi_lan()       0
@@ -45,7 +45,6 @@ static DeviceState *lasi_dev;
 
  static void hppa_powerdown_req(Notifier *n, void *opaque)
  {
-    hwaddr soft_power_reg = HPA_POWER_BUTTON;
      uint32_t val;
 
      val = ldl_be_phys(&address_space_memory, soft_power_reg);

hw/hppa/machine.c static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus, · line 223

Quoted 5 lines
hw/hppa/machine.c +1 -1
@@ -221,7 +220,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
      fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
                      g_memdup(mc->name, len), len);
 
-    val = cpu_to_le64(HPA_POWER_BUTTON);
+    val = cpu_to_le64(soft_power_reg);

I think it would be better to pass this as a parameter to create_fw_cfg, or to drop the translated FW_CFG_IO_BASE parameter and merely pass in translate itself.

r~

Reviewed-by on v3 9/9
#24 lore raw

Re: [PATCH v3 9/9] target/hppa: Fix IOR and ISR on error in probe

In reply to [email protected]
Quoted 8 lines · On 1/12/24 21:29, [email protected] wrote:

From: Helge Deller<[email protected]>

Put correct values (depending on CPU arch) into IOR and ISR on fault.

---
  target/hppa/op_helper.c | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)

r~

Reviewed-by on v3 8/9
#22 lore raw

Re: [PATCH v3 8/9] target/hppa: Fix IOR and ISR on unaligned access trap

In reply to [email protected]
Quoted 8 lines · On 1/12/24 21:29, [email protected] wrote:

From: Helge Deller<[email protected]>

Put correct values (depending on CPU arch) into IOR and ISR on fault.

---
  target/hppa/cpu.c | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)

r~

Reviewed-by on v3 7/9
#20 lore raw

Re: [PATCH v3 7/9] target/hppa: Export function hppa_set_ior_and_isr()

In reply to [email protected]
Quoted 10 lines · On 1/12/24 21:29, [email protected] wrote:

From: Helge Deller<[email protected]>

Move functionality to set IOR and ISR on fault into own function. This will be used by follow-up patches.

---
  target/hppa/cpu.h        |  1 +
  target/hppa/mem_helper.c | 23 ++++++++++++-----------
  2 files changed, 13 insertions(+), 11 deletions(-)

r~

author Tested-by Bruno Haible
#10 lore raw

Re: [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0

In reply to Richard Henderson
Quoted 2 lines

Please adjust the code comment that immediately precedes this, not just within the commit message.

Like this: ?

Fix the address translation for PDC space on PA2.0 if PSW.W=0. Basically, for any address in the 32-bit PDC range from 0xf0000000 to 0xf1000000 keep the lower 32-bits and just set the upper 32-bits to 0xfffffff0.

This mapping fixes the emulated power button in PDC space for 32- and 64-bit machines and is how the physical C3700 machine seems to map PDC.

Figures H-10 and H-11 in the parisc2.0 spec [1] show that the 32-bit region will be mapped somewhere into a higher and bigger 64-bit PDC space. The start and end of this 64-bit space is defined by the physical address bits. But the figures don't specifiy where exactly the mapping will start inside that region. Tests on a real HP C3700 regarding the address of the power button indicate, that the lower 32-bits will stay the same though.
[1] https://parisc.wiki.kernel.org/images-parisc/7/73/Parisc2.0.pdf

roms/seabios-hppa +1 -1
index 4c6ecda618..e4eac85880 160000
@@ -1 +1 @@
-Subproject commit 4c6ecda618f2066707f50c53f31419244fd7f77a
+Subproject commit e4eac85880e8677f96d8b9e94de9f2eec9c0751f
target/hppa/mem_helper.c +8 -2
index 08abd1a9f9..4c28c58ee9 100644
@@ -55,8 +55,14 @@ hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr)
         /* I/O address space */
         addr = (int32_t)addr;
     } else {
-        /* PDC address space */
-        addr &= MAKE_64BIT_MASK(0, 24);
+        /*
+         * PDC address space:
+         * Figures H-10 and H-11 of the parisc2.0 spec do not specify
+         * where to map into the 64-bit PDC address space.
+         * We map with an offset which equals the 32-bit address, which
+         * is what can be seen on physical machines too.
+         */
+        addr = (uint32_t)addr;
         addr |= -1ull << (TARGET_PHYS_ADDR_SPACE_BITS - 4);
     }
     return addr;
Reviewed-by
#11 lore raw

Re: [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0

Quoted 4 lines · Helge Deller
Quoted 2 lines

Please adjust the code comment that immediately precedes this, not just within the commit message.

Like this: ?

Yes, thanks.

target/hppa/mem_helper.c hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr) · line 65

Quoted 8 lines
target/hppa/mem_helper.c +8 -0
+        /*
+         * PDC address space:
+         * Figures H-10 and H-11 of the parisc2.0 spec do not specify
+         * where to map into the 64-bit PDC address space.
+         * We map with an offset which equals the 32-bit address, which
+         * is what can be seen on physical machines too.
+         */
+        addr = (uint32_t)addr;

r~

author Tested-by Bruno Haible
#14 lore raw

Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC

In reply to Richard Henderson
Quoted 3 lines

I think it would be better to pass this as a parameter to create_fw_cfg, or to drop the translated FW_CFG_IO_BASE parameter and merely pass in translate itself.

Like this?

The various operating systems (e.g. Linux, NetBSD) have issues mapping the power button when it's stored in page zero. NetBSD even crashes, because it fails to map that page and then accesses unmapped memory.

Since we now have a consistent memory mapping of PDC in 32-bit and 64-bit address space (the lower 32-bits of the address are in sync) the power button can be moved back to PDC space.

This patch fixes the power button on Linux, NetBSD and HP-UX.

hw/hppa/machine.c +8 -6
index 54ca2fd91a..da85050f60 100644
@@ -36,8 +36,8 @@
 
 #define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
 
-/* Power button address at &PAGE0->pad[4] */
-#define HPA_POWER_BUTTON (0x40 + 4 * sizeof(uint32_t))
+#define HPA_POWER_BUTTON        (FIRMWARE_END - 0x10)
+static hwaddr soft_power_reg;
 
 #define enable_lasi_lan()       0
 
@@ -45,7 +45,6 @@ static DeviceState *lasi_dev;
 
 static void hppa_powerdown_req(Notifier *n, void *opaque)
 {
-    hwaddr soft_power_reg = HPA_POWER_BUTTON;
     uint32_t val;
 
     val = ldl_be_phys(&address_space_memory, soft_power_reg);
@@ -191,7 +190,7 @@ static void fw_cfg_boot_set(void *opaque, const char *boot_device,
 }
 
 static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
-                                 hwaddr addr)
+                                 hwaddr addr, hwaddr pwr_button_addr)
 {
     FWCfgState *fw_cfg;
     uint64_t val;
@@ -221,7 +220,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
     fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
                     g_memdup(mc->name, len), len);
 
-    val = cpu_to_le64(HPA_POWER_BUTTON);
+    val = cpu_to_le64(pwr_button_addr);
     fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
@@ -295,6 +294,8 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
         ram_max = 0xf0000000;      /* 3.75 GB (32-bit CPU) */
     }
 
+    soft_power_reg = translate(NULL, HPA_POWER_BUTTON);
+
     for (unsigned int i = 0; i < smp_cpus; i++) {
         g_autofree char *name = g_strdup_printf("cpu%u-io-eir", i);
 
@@ -407,7 +408,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
     qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier);
 
     /* fw_cfg configuration interface */
-    create_fw_cfg(machine, pci_bus, translate(NULL, FW_CFG_IO_BASE));
+    create_fw_cfg(machine, pci_bus, translate(NULL, FW_CFG_IO_BASE),
+        translate(NULL, HPA_POWER_BUTTON));
 
     /* Load firmware.  Given that this is not "real" firmware,
        but one explicitly written for the emulation, we might as
#15 lore raw

Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC

Quoted 26 lines · Helge Deller
Quoted 3 lines

I think it would be better to pass this as a parameter to create_fw_cfg, or to drop the translated FW_CFG_IO_BASE parameter and merely pass in translate itself.

Like this?

The various operating systems (e.g. Linux, NetBSD) have issues mapping the power button when it's stored in page zero. NetBSD even crashes, because it fails to map that page and then accesses unmapped memory.

Since we now have a consistent memory mapping of PDC in 32-bit and 64-bit address space (the lower 32-bits of the address are in sync) the power button can be moved back to PDC space.

This patch fixes the power button on Linux, NetBSD and HP-UX.

hw/hppa/machine.c +0 -0
index 54ca2fd91a..da85050f60 100644

hw/hppa/machine.c line 40

Quoted 7 lines
hw/hppa/machine.c +2 -2
@@ -36,8 +36,8 @@
 
  #define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
 
-/* Power button address at &PAGE0->pad[4] */
-#define HPA_POWER_BUTTON (0x40 + 4 * sizeof(uint32_t))
+#define HPA_POWER_BUTTON        (FIRMWARE_END - 0x10)
+static hwaddr soft_power_reg;

You've forgotten to remove the global.

r~

Quoted 48 lines
hw/hppa/machine.c +6 -4
  #define enable_lasi_lan()       0
 
@@ -45,7 +45,6 @@ static DeviceState *lasi_dev;
 
  static void hppa_powerdown_req(Notifier *n, void *opaque)
  {
-    hwaddr soft_power_reg = HPA_POWER_BUTTON;
      uint32_t val;
 
      val = ldl_be_phys(&address_space_memory, soft_power_reg);
@@ -191,7 +190,7 @@ static void fw_cfg_boot_set(void *opaque, const char *boot_device,
  }
 
  static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
-                                 hwaddr addr)
+                                 hwaddr addr, hwaddr pwr_button_addr)
  {
      FWCfgState *fw_cfg;
      uint64_t val;
@@ -221,7 +220,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
      fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
                      g_memdup(mc->name, len), len);
 
-    val = cpu_to_le64(HPA_POWER_BUTTON);
+    val = cpu_to_le64(pwr_button_addr);
      fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
                      g_memdup(&val, sizeof(val)), sizeof(val));
 
@@ -295,6 +294,8 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
          ram_max = 0xf0000000;      /* 3.75 GB (32-bit CPU) */
      }
 
+    soft_power_reg = translate(NULL, HPA_POWER_BUTTON);
+
      for (unsigned int i = 0; i < smp_cpus; i++) {
          g_autofree char *name = g_strdup_printf("cpu%u-io-eir", i);
 
@@ -407,7 +408,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
      qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier);
 
      /* fw_cfg configuration interface */
-    create_fw_cfg(machine, pci_bus, translate(NULL, FW_CFG_IO_BASE));
+    create_fw_cfg(machine, pci_bus, translate(NULL, FW_CFG_IO_BASE),
+        translate(NULL, HPA_POWER_BUTTON));
 
      /* Load firmware.  Given that this is not "real" firmware,
         but one explicitly written for the emulation, we might as
#16 lore raw

Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC

Quoted 22 lines · Richard Henderson
Quoted 21 lines · Helge Deller
Quoted 3 lines

I think it would be better to pass this as a parameter to create_fw_cfg, or to drop the translated FW_CFG_IO_BASE parameter and merely pass in translate itself.

Like this?

The various operating systems (e.g. Linux, NetBSD) have issues mapping the power button when it's stored in page zero. NetBSD even crashes, because it fails to map that page and then accesses unmapped memory.

Since we now have a consistent memory mapping of PDC in 32-bit and 64-bit address space (the lower 32-bits of the address are in sync) the power button can be moved back to PDC space.

This patch fixes the power button on Linux, NetBSD and HP-UX.

Quoted 12 lines

hw/hppa/machine.c line 38

Quoted 10 lines
hw/hppa/machine.c +2 -2
index 54ca2fd91a..da85050f60 100644
@@ -36,8 +36,8 @@
   #define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
-/* Power button address at &PAGE0->pad[4] */
-#define HPA_POWER_BUTTON (0x40 + 4 * sizeof(uint32_t))
+#define HPA_POWER_BUTTON        (FIRMWARE_END - 0x10)
+static hwaddr soft_power_reg;

You've forgotten to remove the global.

No... I did not forgot it.
This is still needed by other functions (e.g. hppa_powerdown_req()) in the same file.

If we want to remove it, it will become a much bigger and intrusive patch (if there is even a nice clean way to do it).

Helge

Quoted 40 lines

r~

Quoted 37 lines
hw/hppa/machine.c +2 -3
   #define enable_lasi_lan()       0
@@ -45,7 +45,6 @@ static DeviceState *lasi_dev;
   static void hppa_powerdown_req(Notifier *n, void *opaque)
   {
-    hwaddr soft_power_reg = HPA_POWER_BUTTON;
       uint32_t val;
       val = ldl_be_phys(&address_space_memory, soft_power_reg);
@@ -191,7 +190,7 @@ static void fw_cfg_boot_set(void *opaque, const char *boot_device,
   }
   static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
-                                 hwaddr addr)
+                                 hwaddr addr, hwaddr pwr_button_addr)
   {
       FWCfgState *fw_cfg;
       uint64_t val;
@@ -221,7 +220,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
       fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
                       g_memdup(mc->name, len), len);
-    val = cpu_to_le64(HPA_POWER_BUTTON);
+    val = cpu_to_le64(pwr_button_addr);
       fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
                       g_memdup(&val, sizeof(val)), sizeof(val));
@@ -295,6 +294,8 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)

          ram_max = 0xf0000000;      /* 3.75 GB (32-bit CPU) */ }
+    soft_power_reg = translate(NULL, HPA_POWER_BUTTON);
+
      for (unsigned int i = 0; i < smp_cpus; i++) { g_autofree char *name = g_strdup_printf("cpu%u-io-eir", i);

hw/hppa/machine.c +2 -1
@@ -407,7 +408,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
       qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier);
       /* fw_cfg configuration interface */
-    create_fw_cfg(machine, pci_bus, translate(NULL, FW_CFG_IO_BASE));
+    create_fw_cfg(machine, pci_bus, translate(NULL, FW_CFG_IO_BASE),
+        translate(NULL, HPA_POWER_BUTTON));
       /* Load firmware.  Given that this is not "real" firmware,

         but one explicitly written for the emulation, we might as

Reviewed-by
#17 lore raw

Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC

Quoted 36 lines · Helge Deller
Quoted 22 lines · Richard Henderson
Quoted 21 lines · Helge Deller
Quoted 3 lines

I think it would be better to pass this as a parameter to create_fw_cfg, or to drop the translated FW_CFG_IO_BASE parameter and merely pass in translate itself.

Like this?

The various operating systems (e.g. Linux, NetBSD) have issues mapping the power button when it's stored in page zero. NetBSD even crashes, because it fails to map that page and then accesses unmapped memory.

Since we now have a consistent memory mapping of PDC in 32-bit and 64-bit address space (the lower 32-bits of the address are in sync) the power button can be moved back to PDC space.

This patch fixes the power button on Linux, NetBSD and HP-UX.

Quoted 12 lines

hw/hppa/machine.c line 38

Quoted 10 lines
hw/hppa/machine.c +2 -2
index 54ca2fd91a..da85050f60 100644
@@ -36,8 +36,8 @@
   #define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
-/* Power button address at &PAGE0->pad[4] */
-#define HPA_POWER_BUTTON (0x40 + 4 * sizeof(uint32_t))
+#define HPA_POWER_BUTTON        (FIRMWARE_END - 0x10)
+static hwaddr soft_power_reg;

You've forgotten to remove the global.

Quoted 3 lines

No... I did not forgot it.
This is still needed by other functions (e.g. hppa_powerdown_req()) in the same file.

Ah, I missed that. In which case,

to the original.

r~

#4 lore raw

Re: [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option

In reply to [email protected]
Quoted 11 lines · On Fri, 2024-01-12 at 11:29 +0100, [email protected] wrote:

From: Helge Deller <[email protected]>

Recognize the qemu --nodefaults option, which will disable the following default devices on hppa:
- lsi53c895a SCSI controller,
- artist graphics card,
- LASI 82596 NIC,
- tulip PCI NIC,
- second serial PCI card,
- USB OHCI controller.

Quoted 4 lines

Adding this option is very useful to allow manual testing and debugging of the other possible devices on the command line.

Well, the LASI 82596 hasn't actually been built since 2019, when there was a typo in the meson conversion and it started to depend on the non- existent CONFIG_LASI_I82596 option instead of CONFIG_LASI_82596.

But that doesn't really matter because enable_lasi_lan() has been #defined to zero for hw/hppa/machine.c ever since the LASI support was first introduced, so nothing ever tries to instantiate one anyway.

As part of the -nic rework¹ I plan to allow the user to explicitly specify "lasi_82596" as the model if they want one, or else the default -nic will be a PCI one as it is at the moment. OK?

¹ https://lore.kernel.org/qemu-devel/[email protected]/T/

#5 lore raw

Re: [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option

Quoted 17 lines · David Woodhouse
Quoted 11 lines · On Fri, 2024-01-12 at 11:29 +0100, [email protected] wrote:

From: Helge Deller <[email protected]>

Recognize the qemu --nodefaults option, which will disable the following default devices on hppa:
- lsi53c895a SCSI controller,
- artist graphics card,
- LASI 82596 NIC,
- tulip PCI NIC,
- second serial PCI card,
- USB OHCI controller.

Quoted 4 lines

Adding this option is very useful to allow manual testing and debugging of the other possible devices on the command line.

Quoted 7 lines

Well, the LASI 82596 hasn't actually been built since 2019, when there was a typo in the meson conversion and it started to depend on the non- existent CONFIG_LASI_I82596 option instead of CONFIG_LASI_82596.

But that doesn't really matter because enable_lasi_lan() has been #defined to zero for hw/hppa/machine.c ever since the LASI support was first introduced, so nothing ever tries to instantiate one anyway.

True.
I do have code for LASI_82596 in my github repo, but since it's not working correctly yet, I haven't pushed it yet upstream. I do plan to work at it when time permits though..

Quoted 3 lines

As part of the -nic rework¹ I plan to allow the user to explicitly specify "lasi_82596" as the model if they want one, or else the default -nic will be a PCI one as it is at the moment. OK?

Yes, that would be great.
Thanks!
Helge

Quoted 1 line

¹ https://lore.kernel.org/qemu-devel/[email protected]/T/