All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes
@ 2024-01-12 10:29 deller
  2024-01-12 10:29 ` [PATCH v3 1/9] hw/hppa/machine: Allow up to 3840 MB total memory deller
                   ` (8 more replies)
  0 siblings, 9 replies; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller

From: Helge Deller <deller@gmx.de>

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(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v3 1/9] hw/hppa/machine: Allow up to 3840 MB total memory
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 10:29 ` [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option deller
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Helge Deller, Nelson H . F . Beebe, Bruno Haible

From: Helge Deller <deller@gmx.de>

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.

Signed-off-by: Helge Deller <deller@gmx.de>
Noticed-by: Nelson H. F. Beebe <beebe@math.utah.edu>
Fixes: b7746b1194c8 ("hw/hppa/machine: Restrict the total memory size to 3GB")
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Bruno Haible <bruno@clisp.org>
---
 hw/hppa/machine.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c8da7c18d5..b11907617e 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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);
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
  2024-01-12 10:29 ` [PATCH v3 1/9] hw/hppa/machine: Allow up to 3840 MB total memory deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 20:39   ` Richard Henderson
  2024-01-26 12:02   ` David Woodhouse
  2024-01-12 10:29 ` [PATCH v3 3/9] hw/pci-host/astro: Add missing astro & elroy registers for NetBSD deller
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller

From: Helge Deller <deller@gmx.de>

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.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 hw/hppa/machine.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index b11907617e..54ca2fd91a 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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));
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 3/9] hw/pci-host/astro: Add missing astro & elroy registers for NetBSD
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
  2024-01-12 10:29 ` [PATCH v3 1/9] hw/hppa/machine: Allow up to 3840 MB total memory deller
  2024-01-12 10:29 ` [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 10:29 ` [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0 deller
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller, Bruno Haible

From: Helge Deller <deller@gmx.de>

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.

Signed-off-by: Helge Deller <deller@gmx.de>
Tested-by: Bruno Haible <bruno@clisp.org>
---
 hw/pci-host/astro.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/hw/pci-host/astro.c b/hw/pci-host/astro.c
index 7d68ccee7e..cb2c8a828d 100644
--- a/hw/pci-host/astro.c
+++ b/hw/pci-host/astro.c
@@ -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
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
                   ` (2 preceding siblings ...)
  2024-01-12 10:29 ` [PATCH v3 3/9] hw/pci-host/astro: Add missing astro & elroy registers for NetBSD deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 21:54   ` Richard Henderson
  2024-01-12 10:29 ` [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC deller
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller, Bruno Haible

From: Helge Deller <deller@gmx.de>

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

Signed-off-by: Helge Deller <deller@gmx.de>
Tested-by: Bruno Haible <bruno@clisp.org>
---
 target/hppa/mem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
index 08abd1a9f9..011b192406 100644
--- a/target/hppa/mem_helper.c
+++ b/target/hppa/mem_helper.c
@@ -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;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
                   ` (3 preceding siblings ...)
  2024-01-12 10:29 ` [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0 deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 22:07   ` Richard Henderson
  2024-01-12 10:29 ` [PATCH v3 6/9] target/hppa: Avoid accessing %gr0 when raising exception deller
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller, Bruno Haible

From: Helge Deller <deller@gmx.de>

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.

Signed-off-by: Helge Deller <deller@gmx.de>
Tested-by: Bruno Haible <bruno@clisp.org>
---
 hw/hppa/machine.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 54ca2fd91a..9e611620cc 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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);
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 6/9] target/hppa: Avoid accessing %gr0 when raising exception
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
                   ` (4 preceding siblings ...)
  2024-01-12 10:29 ` [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 10:29 ` [PATCH v3 7/9] target/hppa: Export function hppa_set_ior_and_isr() deller
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller, Bruno Haible

From: Helge Deller <deller@gmx.de>

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().

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Bruno Haible <bruno@clisp.org>
---
 target/hppa/mem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
index 011b192406..42bd0063c0 100644
--- a/target/hppa/mem_helper.c
+++ b/target/hppa/mem_helper.c
@@ -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;
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 7/9] target/hppa: Export function hppa_set_ior_and_isr()
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
                   ` (5 preceding siblings ...)
  2024-01-12 10:29 ` [PATCH v3 6/9] target/hppa: Avoid accessing %gr0 when raising exception deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 22:08   ` Richard Henderson
  2024-01-12 10:29 ` [PATCH v3 8/9] target/hppa: Fix IOR and ISR on unaligned access trap deller
  2024-01-12 10:29 ` [PATCH v3 9/9] target/hppa: Fix IOR and ISR on error in probe deller
  8 siblings, 1 reply; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller

From: Helge Deller <deller@gmx.de>

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

Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/cpu.h        |  1 +
 target/hppa/mem_helper.c | 23 ++++++++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 8be45c69c9..9556e95fab 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -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);
diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
index 42bd0063c0..7f54160e4c 100644
--- a/target/hppa/mem_helper.c
+++ b/target/hppa/mem_helper.c
@@ -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);
 }
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 8/9] target/hppa: Fix IOR and ISR on unaligned access trap
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
                   ` (6 preceding siblings ...)
  2024-01-12 10:29 ` [PATCH v3 7/9] target/hppa: Export function hppa_set_ior_and_isr() deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 22:08   ` Richard Henderson
  2024-01-12 10:29 ` [PATCH v3 9/9] target/hppa: Fix IOR and ISR on error in probe deller
  8 siblings, 1 reply; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller

From: Helge Deller <deller@gmx.de>

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

Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/cpu.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 04de1689d7..fda32d7f59 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -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);
 }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 9/9] target/hppa: Fix IOR and ISR on error in probe
  2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
                   ` (7 preceding siblings ...)
  2024-01-12 10:29 ` [PATCH v3 8/9] target/hppa: Fix IOR and ISR on unaligned access trap deller
@ 2024-01-12 10:29 ` deller
  2024-01-12 22:08   ` Richard Henderson
  8 siblings, 1 reply; 25+ messages in thread
From: deller @ 2024-01-12 10:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Helge Deller

From: Helge Deller <deller@gmx.de>

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

Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/op_helper.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c
index 7f607c3afd..ce15469465 100644
--- a/target/hppa/op_helper.c
+++ b/target/hppa/op_helper.c
@@ -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;
         }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option
  2024-01-12 10:29 ` [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option deller
@ 2024-01-12 20:39   ` Richard Henderson
  2024-01-26 12:02   ` David Woodhouse
  1 sibling, 0 replies; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 20:39 UTC (permalink / raw)
  To: deller, qemu-devel; +Cc: Helge Deller

On 1/12/24 21:29, deller@kernel.org wrote:
> From: Helge Deller<deller@gmx.de>
> 
> 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.
> 
> Signed-off-by: Helge Deller<deller@gmx.de>
> ---
>   hw/hppa/machine.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0
  2024-01-12 10:29 ` [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0 deller
@ 2024-01-12 21:54   ` Richard Henderson
  2024-01-12 22:23     ` Helge Deller
  0 siblings, 1 reply; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 21:54 UTC (permalink / raw)
  To: deller, qemu-devel; +Cc: Helge Deller, Bruno Haible

On 1/12/24 21:29, deller@kernel.org wrote:
> From: Helge Deller <deller@gmx.de>
> 
> 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
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> Tested-by: Bruno Haible <bruno@clisp.org>
> ---
>   target/hppa/mem_helper.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
> index 08abd1a9f9..011b192406 100644
> --- a/target/hppa/mem_helper.c
> +++ b/target/hppa/mem_helper.c
> @@ -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~


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC
  2024-01-12 10:29 ` [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC deller
@ 2024-01-12 22:07   ` Richard Henderson
  2024-01-12 22:44     ` Helge Deller
  0 siblings, 1 reply; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 22:07 UTC (permalink / raw)
  To: deller, qemu-devel; +Cc: Helge Deller, Bruno Haible

On 1/12/24 21:29, deller@kernel.org wrote:
> +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);

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~


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 7/9] target/hppa: Export function hppa_set_ior_and_isr()
  2024-01-12 10:29 ` [PATCH v3 7/9] target/hppa: Export function hppa_set_ior_and_isr() deller
@ 2024-01-12 22:08   ` Richard Henderson
  0 siblings, 0 replies; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 22:08 UTC (permalink / raw)
  To: deller, qemu-devel; +Cc: Helge Deller

On 1/12/24 21:29, deller@kernel.org wrote:
> From: Helge Deller<deller@gmx.de>
> 
> Move functionality to set IOR and ISR on fault into own
> function. This will be used by follow-up patches.
> 
> Signed-off-by: Helge Deller<deller@gmx.de>
> ---
>   target/hppa/cpu.h        |  1 +
>   target/hppa/mem_helper.c | 23 ++++++++++++-----------
>   2 files changed, 13 insertions(+), 11 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 8/9] target/hppa: Fix IOR and ISR on unaligned access trap
  2024-01-12 10:29 ` [PATCH v3 8/9] target/hppa: Fix IOR and ISR on unaligned access trap deller
@ 2024-01-12 22:08   ` Richard Henderson
  0 siblings, 0 replies; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 22:08 UTC (permalink / raw)
  To: deller, qemu-devel; +Cc: Helge Deller

On 1/12/24 21:29, deller@kernel.org wrote:
> From: Helge Deller<deller@gmx.de>
> 
> Put correct values (depending on CPU arch) into IOR and ISR on fault.
> 
> Signed-off-by: Helge Deller<deller@gmx.de>
> ---
>   target/hppa/cpu.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 9/9] target/hppa: Fix IOR and ISR on error in probe
  2024-01-12 10:29 ` [PATCH v3 9/9] target/hppa: Fix IOR and ISR on error in probe deller
@ 2024-01-12 22:08   ` Richard Henderson
  0 siblings, 0 replies; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 22:08 UTC (permalink / raw)
  To: deller, qemu-devel; +Cc: Helge Deller

On 1/12/24 21:29, deller@kernel.org wrote:
> From: Helge Deller<deller@gmx.de>
> 
> Put correct values (depending on CPU arch) into IOR and ISR on fault.
> 
> Signed-off-by: Helge Deller<deller@gmx.de>
> ---
>   target/hppa/op_helper.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0
  2024-01-12 21:54   ` Richard Henderson
@ 2024-01-12 22:23     ` Helge Deller
  2024-01-12 22:24       ` Richard Henderson
  0 siblings, 1 reply; 25+ messages in thread
From: Helge Deller @ 2024-01-12 22:23 UTC (permalink / raw)
  To: Richard Henderson, Laurent Vivier, qemu-devel

> 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

Signed-off-by: Helge Deller <deller@gmx.de>
Tested-by: Bruno Haible <bruno@clisp.org>

diff --git a/roms/seabios-hppa b/roms/seabios-hppa
index 4c6ecda618..e4eac85880 160000
--- a/roms/seabios-hppa
+++ b/roms/seabios-hppa
@@ -1 +1 @@
-Subproject commit 4c6ecda618f2066707f50c53f31419244fd7f77a
+Subproject commit e4eac85880e8677f96d8b9e94de9f2eec9c0751f
diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
index 08abd1a9f9..4c28c58ee9 100644
--- a/target/hppa/mem_helper.c
+++ b/target/hppa/mem_helper.c
@@ -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;


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0
  2024-01-12 22:23     ` Helge Deller
@ 2024-01-12 22:24       ` Richard Henderson
  0 siblings, 0 replies; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 22:24 UTC (permalink / raw)
  To: Helge Deller, Laurent Vivier, qemu-devel

On 1/13/24 09:23, Helge Deller wrote:
>> Please adjust the code comment that immediately precedes this, not just
>> within the commit message.
> 
> Like this: ?

Yes, thanks.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

> +        /*
> +         * 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~



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC
  2024-01-12 22:07   ` Richard Henderson
@ 2024-01-12 22:44     ` Helge Deller
  2024-01-12 23:11       ` Richard Henderson
  0 siblings, 1 reply; 25+ messages in thread
From: Helge Deller @ 2024-01-12 22:44 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, Helge Deller

> 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.

Signed-off-by: Helge Deller <deller@gmx.de>
Tested-by: Bruno Haible <bruno@clisp.org>

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 54ca2fd91a..da85050f60 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC
  2024-01-12 22:44     ` Helge Deller
@ 2024-01-12 23:11       ` Richard Henderson
  2024-01-12 23:15         ` Helge Deller
  0 siblings, 1 reply; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 23:11 UTC (permalink / raw)
  To: Helge Deller; +Cc: qemu-devel, Helge Deller

On 1/13/24 09:44, Helge Deller wrote:
>> 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.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> Tested-by: Bruno Haible <bruno@clisp.org>
> 
> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
> index 54ca2fd91a..da85050f60 100644
> --- a/hw/hppa/machine.c
> +++ b/hw/hppa/machine.c
> @@ -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~

>   
>   #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



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC
  2024-01-12 23:11       ` Richard Henderson
@ 2024-01-12 23:15         ` Helge Deller
  2024-01-12 23:27           ` Richard Henderson
  0 siblings, 1 reply; 25+ messages in thread
From: Helge Deller @ 2024-01-12 23:15 UTC (permalink / raw)
  To: Richard Henderson, Helge Deller; +Cc: qemu-devel

On 1/13/24 00:11, Richard Henderson wrote:
> On 1/13/24 09:44, Helge Deller wrote:
>>> 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.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>> Tested-by: Bruno Haible <bruno@clisp.org>
>>
>> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
>> index 54ca2fd91a..da85050f60 100644
>> --- a/hw/hppa/machine.c
>> +++ b/hw/hppa/machine.c
>> @@ -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
> r~
>
>>   #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
>



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC
  2024-01-12 23:15         ` Helge Deller
@ 2024-01-12 23:27           ` Richard Henderson
  0 siblings, 0 replies; 25+ messages in thread
From: Richard Henderson @ 2024-01-12 23:27 UTC (permalink / raw)
  To: Helge Deller, Helge Deller; +Cc: qemu-devel

On 1/13/24 10:15, Helge Deller wrote:
> On 1/13/24 00:11, Richard Henderson wrote:
>> On 1/13/24 09:44, Helge Deller wrote:
>>>> 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.
>>>
>>> Signed-off-by: Helge Deller <deller@gmx.de>
>>> Tested-by: Bruno Haible <bruno@clisp.org>
>>>
>>> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
>>> index 54ca2fd91a..da85050f60 100644
>>> --- a/hw/hppa/machine.c
>>> +++ b/hw/hppa/machine.c
>>> @@ -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.

Ah, I missed that.  In which case,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

to the original.


r~


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option
  2024-01-12 10:29 ` [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option deller
  2024-01-12 20:39   ` Richard Henderson
@ 2024-01-26 12:02   ` David Woodhouse
  2024-01-26 14:49     ` Helge Deller
  1 sibling, 1 reply; 25+ messages in thread
From: David Woodhouse @ 2024-01-26 12:02 UTC (permalink / raw)
  To: deller, qemu-devel; +Cc: Richard Henderson, Helge Deller

[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]

On Fri, 2024-01-12 at 11:29 +0100, deller@kernel.org wrote:
> From: Helge Deller <deller@gmx.de>
> 
> 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.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>

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/20240108204909.564514-1-dwmw2@infradead.org/T/

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option
  2024-01-26 12:02   ` David Woodhouse
@ 2024-01-26 14:49     ` Helge Deller
  2024-01-26 14:51       ` David Woodhouse
  0 siblings, 1 reply; 25+ messages in thread
From: Helge Deller @ 2024-01-26 14:49 UTC (permalink / raw)
  To: David Woodhouse, deller, qemu-devel; +Cc: Richard Henderson

On 1/26/24 13:02, David Woodhouse wrote:
> On Fri, 2024-01-12 at 11:29 +0100, deller@kernel.org wrote:
>> From: Helge Deller <deller@gmx.de>
>>
>> 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.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>
> 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..

> 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

> ¹ https://lore.kernel.org/qemu-devel/20240108204909.564514-1-dwmw2@infradead.org/T/



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option
  2024-01-26 14:49     ` Helge Deller
@ 2024-01-26 14:51       ` David Woodhouse
  0 siblings, 0 replies; 25+ messages in thread
From: David Woodhouse @ 2024-01-26 14:51 UTC (permalink / raw)
  To: Helge Deller, deller, qemu-devel; +Cc: Richard Henderson

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

On Fri, 2024-01-26 at 15:49 +0100, Helge Deller wrote:
> 
> > 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.

Looks like this:

https://git.infradead.org/?p=users/dwmw2/qemu.git;a=commitdiff;h=b954e8004e89b

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2024-01-26 14:52 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12 10:29 [PATCH v3 0/9] target/hppa qemu v8.2 regression fixes deller
2024-01-12 10:29 ` [PATCH v3 1/9] hw/hppa/machine: Allow up to 3840 MB total memory deller
2024-01-12 10:29 ` [PATCH v3 2/9] hw/hppa/machine: Disable default devices with --nodefaults option deller
2024-01-12 20:39   ` Richard Henderson
2024-01-26 12:02   ` David Woodhouse
2024-01-26 14:49     ` Helge Deller
2024-01-26 14:51       ` David Woodhouse
2024-01-12 10:29 ` [PATCH v3 3/9] hw/pci-host/astro: Add missing astro & elroy registers for NetBSD deller
2024-01-12 10:29 ` [PATCH v3 4/9] target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0 deller
2024-01-12 21:54   ` Richard Henderson
2024-01-12 22:23     ` Helge Deller
2024-01-12 22:24       ` Richard Henderson
2024-01-12 10:29 ` [PATCH v3 5/9] hw/hppa: Move software power button address back into PDC deller
2024-01-12 22:07   ` Richard Henderson
2024-01-12 22:44     ` Helge Deller
2024-01-12 23:11       ` Richard Henderson
2024-01-12 23:15         ` Helge Deller
2024-01-12 23:27           ` Richard Henderson
2024-01-12 10:29 ` [PATCH v3 6/9] target/hppa: Avoid accessing %gr0 when raising exception deller
2024-01-12 10:29 ` [PATCH v3 7/9] target/hppa: Export function hppa_set_ior_and_isr() deller
2024-01-12 22:08   ` Richard Henderson
2024-01-12 10:29 ` [PATCH v3 8/9] target/hppa: Fix IOR and ISR on unaligned access trap deller
2024-01-12 22:08   ` Richard Henderson
2024-01-12 10:29 ` [PATCH v3 9/9] target/hppa: Fix IOR and ISR on error in probe deller
2024-01-12 22:08   ` Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.