Skip to content

Commit d0f4aa7

Browse files
committed
Merge tag 'hppa-fixes-8.2-pull-request' of https://github.com/hdeller/qemu-hppa into staging
target/hppa qemu v8.2 regression fixes 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. 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 # -----BEGIN PGP SIGNATURE----- # # iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCZaImPQAKCRD3ErUQojoP # X2C5AP9fbIkCni45JU6KC6OmFsCbAReRQCPwLO+MzR8/us2ywgD+PsGxSBk8ASxM # nqtv3J9JC3i+XSnbtwLV+qChnO+IXwc= # =FAMY # -----END PGP SIGNATURE----- # gpg: Signature made Sat 13 Jan 2024 05:57:17 GMT # gpg: using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F # gpg: Good signature from "Helge Deller <[email protected]>" [unknown] # gpg: aka "Helge Deller <[email protected]>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 4544 8228 2CD9 10DB EF3D 25F8 3E5F 3D04 A7A2 4603 # Subkey fingerprint: BCE9 123E 1AD2 9F07 C049 BBDE F712 B510 A23A 0F5F * tag 'hppa-fixes-8.2-pull-request' of https://github.com/hdeller/qemu-hppa: target/hppa: Update SeaBIOS-hppa to version 15 target/hppa: Fix IOR and ISR on error in probe target/hppa: Fix IOR and ISR on unaligned access trap target/hppa: Export function hppa_set_ior_and_isr() target/hppa: Avoid accessing %gr0 when raising exception hw/hppa: Move software power button address back into PDC target/hppa: Fix PDC address translation on PA2.0 with PSW.W=0 hw/pci-host/astro: Add missing astro & elroy registers for NetBSD hw/hppa/machine: Disable default devices with --nodefaults option hw/hppa/machine: Allow up to 3840 MB total memory Signed-off-by: Peter Maydell <[email protected]>
2 parents 9da8dfe + 4bda822 commit d0f4aa7

File tree

8 files changed

+65
-39
lines changed

8 files changed

+65
-39
lines changed

hw/hppa/machine.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@
3636

3737
#define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
3838

39-
/* Power button address at &PAGE0->pad[4] */
40-
#define HPA_POWER_BUTTON (0x40 + 4 * sizeof(uint32_t))
39+
#define HPA_POWER_BUTTON (FIRMWARE_END - 0x10)
40+
static hwaddr soft_power_reg;
4141

4242
#define enable_lasi_lan() 0
4343

4444
static DeviceState *lasi_dev;
4545

4646
static void hppa_powerdown_req(Notifier *n, void *opaque)
4747
{
48-
hwaddr soft_power_reg = HPA_POWER_BUTTON;
4948
uint32_t val;
5049

5150
val = ldl_be_phys(&address_space_memory, soft_power_reg);
@@ -221,7 +220,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
221220
fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
222221
g_memdup(mc->name, len), len);
223222

224-
val = cpu_to_le64(HPA_POWER_BUTTON);
223+
val = cpu_to_le64(soft_power_reg);
225224
fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
226225
g_memdup(&val, sizeof(val)), sizeof(val));
227226

@@ -276,6 +275,7 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
276275
unsigned int smp_cpus = machine->smp.cpus;
277276
TranslateFn *translate;
278277
MemoryRegion *cpu_region;
278+
uint64_t ram_max;
279279

280280
/* Create CPUs. */
281281
for (unsigned int i = 0; i < smp_cpus; i++) {
@@ -288,10 +288,14 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
288288
*/
289289
if (hppa_is_pa20(&cpu[0]->env)) {
290290
translate = translate_pa20;
291+
ram_max = 0xf0000000; /* 3.75 GB (limited by 32-bit firmware) */
291292
} else {
292293
translate = translate_pa10;
294+
ram_max = 0xf0000000; /* 3.75 GB (32-bit CPU) */
293295
}
294296

297+
soft_power_reg = translate(NULL, HPA_POWER_BUTTON);
298+
295299
for (unsigned int i = 0; i < smp_cpus; i++) {
296300
g_autofree char *name = g_strdup_printf("cpu%u-io-eir", i);
297301

@@ -311,9 +315,9 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
311315
cpu_region);
312316

313317
/* Main memory region. */
314-
if (machine->ram_size > 3 * GiB) {
315-
error_report("RAM size is currently restricted to 3GB");
316-
exit(EXIT_FAILURE);
318+
if (machine->ram_size > ram_max) {
319+
info_report("Max RAM size limited to %" PRIu64 " MB", ram_max / MiB);
320+
machine->ram_size = ram_max;
317321
}
318322
memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1);
319323

@@ -343,8 +347,10 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
343347
SysBusDevice *s;
344348

345349
/* SCSI disk setup. */
346-
dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
347-
lsi53c8xx_handle_legacy_cmdline(dev);
350+
if (drive_get_max_bus(IF_SCSI) >= 0) {
351+
dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
352+
lsi53c8xx_handle_legacy_cmdline(dev);
353+
}
348354

349355
/* Graphics setup. */
350356
if (machine->enable_graphics && vga_interface_type != VGA_NONE) {
@@ -357,7 +363,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
357363
}
358364

359365
/* Network setup. */
360-
if (enable_lasi_lan()) {
366+
if (nd_table[0].used && enable_lasi_lan()) {
361367
lasi_82596_init(addr_space, translate(NULL, LASI_LAN_HPA),
362368
qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA));
363369
}
@@ -382,7 +388,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
382388
pci_set_word(&pci_dev->config[PCI_SUBSYSTEM_ID], 0x1227); /* Powerbar */
383389

384390
/* create a second serial PCI card when running Astro */
385-
if (!lasi_dev) {
391+
if (serial_hd(1) && !lasi_dev) {
386392
pci_dev = pci_new(-1, "pci-serial-4x");
387393
qdev_prop_set_chr(DEVICE(pci_dev), "chardev1", serial_hd(1));
388394
qdev_prop_set_chr(DEVICE(pci_dev), "chardev2", serial_hd(2));

hw/pci-host/astro.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
166166
trace_elroy_write(addr, size, val);
167167

168168
switch ((addr >> 3) << 3) {
169+
case 0x000: /* PCI_ID & PCI_COMMAND_STATUS_REG */
170+
break;
169171
case 0x080:
170172
put_val_in_int64(&s->arb_mask, addr, size, val);
171173
break;
@@ -175,6 +177,9 @@ static MemTxResult elroy_chip_write_with_attrs(void *opaque, hwaddr addr,
175177
case 0x200 ... 0x250 - 1: /* LMMIO, GMMIO, WLMMIO, WGMMIO, ... */
176178
put_val_in_arrary(s->mmio_base, 0x200, addr, size, val);
177179
break;
180+
case 0x300: /* ibase */
181+
case 0x308: /* imask */
182+
break;
178183
case 0x0680:
179184
put_val_in_int64(&s->error_config, addr, size, val);
180185
break;
@@ -538,6 +543,9 @@ static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
538543
case 0x0030: /* HP-UX 10.20 and 11.11 reads it. No idea. */
539544
val = -1;
540545
break;
546+
case 0x0078: /* NetBSD reads 0x78 ? */
547+
val = -1;
548+
break;
541549
case 0x0300 ... 0x03d8: /* LMMIO_DIRECT0_BASE... */
542550
index = (addr - 0x300) / 8;
543551
val = s->ioc_ranges[index];
@@ -624,31 +632,43 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
624632
case 0x10220:
625633
case 0x10230: /* HP-UX 11.11 reads it. No idea. */
626634
break;
627-
case 0x22108: /* IOC STATUS_CONTROL */
628-
put_val_in_int64(&s->ioc_status_ctrl, addr, size, val);
629-
break;
630635
case 0x20200 ... 0x20240 - 1: /* IOC Rope0_Control ... */
631636
put_val_in_arrary(s->ioc_rope_control, 0x20200, addr, size, val);
632637
break;
633638
case 0x20040: /* IOC Rope config */
639+
case 0x22040:
634640
put_val_in_int64(&s->ioc_rope_config, addr, size, val);
635641
break;
636642
case 0x20300:
643+
case 0x22300:
637644
put_val_in_int64(&s->tlb_ibase, addr, size, val);
638645
break;
639646
case 0x20308:
647+
case 0x22308:
640648
put_val_in_int64(&s->tlb_imask, addr, size, val);
641649
break;
642650
case 0x20310:
651+
case 0x22310:
643652
put_val_in_int64(&s->tlb_pcom, addr, size, val);
644653
/* TODO: flush iommu */
645654
break;
646655
case 0x20318:
656+
case 0x22318:
647657
put_val_in_int64(&s->tlb_tcnfg, addr, size, val);
648658
break;
649659
case 0x20320:
660+
case 0x22320:
650661
put_val_in_int64(&s->tlb_pdir_base, addr, size, val);
651662
break;
663+
case 0x22000: /* func_id */
664+
break;
665+
case 0x22008: /* func_class */
666+
break;
667+
case 0x22050: /* rope_debug */
668+
break;
669+
case 0x22108: /* IOC STATUS_CONTROL */
670+
put_val_in_int64(&s->ioc_status_ctrl, addr, size, val);
671+
break;
652672
/*
653673
* empty placeholders for non-existent elroys, e.g.
654674
* func_class, pci config & data

pc-bios/hppa-firmware.img

-506 KB
Binary file not shown.

roms/seabios-hppa

Submodule seabios-hppa updated from 4c6ecda to e4eac85

target/hppa/cpu.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
110110
CPUHPPAState *env = &cpu->env;
111111

112112
cs->exception_index = EXCP_UNALIGN;
113-
if (env->psw & PSW_Q) {
114-
/* ??? Needs tweaking for hppa64. */
115-
env->cr[CR_IOR] = addr;
116-
env->cr[CR_ISR] = addr >> 32;
117-
}
113+
hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx));
118114

119115
cpu_loop_exit_restore(cs, retaddr);
120116
}

target/hppa/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int);
385385
#ifndef CONFIG_USER_ONLY
386386
void hppa_ptlbe(CPUHPPAState *env);
387387
hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr);
388+
void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled);
388389
bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
389390
MMUAccessType access_type, int mmu_idx,
390391
bool probe, uintptr_t retaddr);

target/hppa/mem_helper.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr)
5555
/* I/O address space */
5656
addr = (int32_t)addr;
5757
} else {
58-
/* PDC address space */
59-
addr &= MAKE_64BIT_MASK(0, 24);
58+
/*
59+
* PDC address space:
60+
* Figures H-10 and H-11 of the parisc2.0 spec do not specify
61+
* where to map into the 64-bit PDC address space.
62+
* We map with an offset which equals the 32-bit address, which
63+
* is what can be seen on physical machines too.
64+
*/
65+
addr = (uint32_t)addr;
6066
addr |= -1ull << (TARGET_PHYS_ADDR_SPACE_BITS - 4);
6167
}
6268
return addr;
@@ -299,14 +305,8 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
299305
return excp == EXCP_DTLB_MISS ? -1 : phys;
300306
}
301307

302-
G_NORETURN static void
303-
raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
304-
vaddr addr, bool mmu_disabled)
308+
void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled)
305309
{
306-
CPUState *cs = env_cpu(env);
307-
308-
cs->exception_index = excp;
309-
310310
if (env->psw & PSW_Q) {
311311
/*
312312
* For pa1.x, the offset and space never overlap, and so we
@@ -333,16 +333,23 @@ raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
333333
*/
334334
uint64_t b;
335335

336-
cpu_restore_state(cs, retaddr);
337-
338-
b = env->gr[env->unwind_breg];
336+
b = env->unwind_breg ? env->gr[env->unwind_breg] : 0;
339337
b >>= (env->psw & PSW_W ? 62 : 30);
340338
env->cr[CR_IOR] |= b << 62;
341-
342-
cpu_loop_exit(cs);
343339
}
344340
}
345341
}
342+
}
343+
344+
G_NORETURN static void
345+
raise_exception_with_ior(CPUHPPAState *env, int excp, uintptr_t retaddr,
346+
vaddr addr, bool mmu_disabled)
347+
{
348+
CPUState *cs = env_cpu(env);
349+
350+
cs->exception_index = excp;
351+
hppa_set_ior_and_isr(env, addr, mmu_disabled);
352+
346353
cpu_loop_exit_restore(cs, retaddr);
347354
}
348355

target/hppa/op_helper.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,7 @@ target_ulong HELPER(probe)(CPUHPPAState *env, target_ulong addr,
351351
excp = hppa_get_physical_address(env, addr, mmu_idx, 0, &phys,
352352
&prot, NULL);
353353
if (excp >= 0) {
354-
if (env->psw & PSW_Q) {
355-
/* ??? Needs tweaking for hppa64. */
356-
env->cr[CR_IOR] = addr;
357-
env->cr[CR_ISR] = addr >> 32;
358-
}
354+
hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx));
359355
if (excp == EXCP_DTLB_MISS) {
360356
excp = EXCP_NA_DTLB_MISS;
361357
}

0 commit comments

Comments
 (0)