hppa 64-bit improvements
cover hppa 64-bit improvements
From: Helge Deller <[email protected]>
The 64-bit hppa qemu emulation still fails to boot 64-bit HP-UX. This patch series improves the emulation a lot, since it enables us to boot 64-bit HP-UX installer silently up until an endless loop where the machine reports that it's up an running (it crashed before). This still needs further analysis, but it's a big step forward.
Main changes to archieve this includes:
- Implementing diagnose registers (especially %dr2 for space-register hashing)
- Add Diva GSP card, as the currently used serial port emulation crashes on HP-UX 64-bit
- Fixes and improvements in SeaBIOS-hppa, including:
- parisc: Fix IRT table entries to use slot number
- parisc: Increase PCI alignment for memory bars to 64k
- parisc: Fix PDC_CACHE/PDC_CACHE_RET_SPID return value
- parisc: Allow up to 256 GB RAM on 64-bit machines
The SeaBIOS-hppa binary blob is not sent with this patch series, but will be included in the final pull request. In case you want to test the series, please use devel branch of SeaBIOS-hppa from
https://github.com/hdeller/seabios-hppa/tree/devel
Please review.
Helge Deller (5):
hppa: Sync contents of hppa_hardware.h header file with SeaBIOS-hppa disas/hppa: implement mfdiag/mtdiag disassembly target/hppa: Implement CPU diagnose registers for 64-bit HP-UX hw/char: Add emulation of Diva GSP PCI management boards hw/hppa: Wire up Diva GSP card
MAINTAINERS | 1 + disas/hppa.c | 23 +++- hw/char/Kconfig | 5 + hw/char/diva-gsp.c | 291 +++++++++++++++++++++++++++++++++++++++ hw/char/meson.build | 1 + hw/hppa/Kconfig | 1 + hw/hppa/hppa_hardware.h | 36 ++++- hw/hppa/machine.c | 29 ++-- target/hppa/cpu.c | 3 +- target/hppa/cpu.h | 24 ++-- target/hppa/helper.c | 4 +- target/hppa/insns.decode | 6 +- target/hppa/int_helper.c | 6 +- target/hppa/machine.c | 5 +- target/hppa/sys_helper.c | 2 +- target/hppa/translate.c | 24 +++- 16 files changed, 411 insertions(+), 50 deletions(-) create mode 100644 hw/char/diva-gsp.c
Signature · 1 line
2.47.0
PATCH 2/5 disas/hppa: implement mfdiag/mtdiag disassembly
From: Helge Deller <[email protected]>
The various PA-RISC CPUs implement different CPU-specific diag instructions (mfdiag, mtdiag, mfcpu, mtcpu, ...) to access CPU-internal diagnose/configuration registers, e.g. for cache control, managing space register hashing, control front panel LEDs and read status of the hardware reset button.
Those instructions are mostly undocumented, but are used by ODE, HP-UX and Linux.
This patch adds some neccessary instructions for PCXL and PCXU CPUs.
--- disas/hppa.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
disas/hppa.c +21 -2
@@ -606,7 +606,7 @@ struct pa_opcode In the args field, the following characters are unused: - ' " - / 34 6789:; ' + ' " - / 34 678 :; ' '@ C M [\] ''` e g } '
@@ -650,6 +650,7 @@ Also these: | 6 bit field length at 19,27:31 (fixed extract/deposit) A 13 bit immediate at 18 (to support the BREAK instruction) ^ like b, but describes a control register + 9 like b, but describes a diagnose register ! sar (cr11) register D 26 bit immediate at 31 (to support the DIAG instruction) $ 9 bit immediate at 28 (to support POPBTS)
@@ -1322,13 +1323,19 @@ static const struct pa_opcode pa_opcodes[] = { "fdce", 0x040012c0, 0xfc00ffdf, "cZx(b)", pa10, 0}, { "fdce", 0x040012c0, 0xfc003fdf, "cZx(s,b)", pa10, 0}, { "fice", 0x040002c0, 0xfc001fdf, "cZx(S,b)", pa10, 0}, -{ "diag", 0x14000000, 0xfc000000, "D", pa10, 0}, { "idtlbt", 0x04001800, 0xfc00ffff, "x,b", pa20, FLAG_STRICT}, { "iitlbt", 0x04000800, 0xfc00ffff, "x,b", pa20, FLAG_STRICT}, +/* completely undocumented, but used by ODE, HP-UX and Linux: */ +{ "mfcpu_pcxu", 0x140008a0, 0xfc9fffe0, "9,t", pa20, 0}, /* PCXU: mfdiag */ +{ "mtcpu_pcxu", 0x14001840, 0xfc00ffff, "x,9", pa20, 0}, +/* These may be specific to certain versions of the PA. Joel claimed they were 72000 (7200?) specific. However, I'm almost certain the mtcpu/mfcpu were undocumented, but available in the older 700 machines. */ +{ "mfcpu_c", 0x14000600, 0xfc00ffff, "9,x", pa10, 0}, /* PCXL: for dr0 and dr8 only */ +{ "mfcpu_t", 0x14001400, 0xfc9fffe0, "9,t", pa10, 0}, /* PCXL: all dr except dr0 and dr8 */ +{ "mtcpu_pcxl", 0x14000240, 0xfc00ffff, "x,9", pa11, 0}, /* PCXL: mtcpu for dr0 and dr8 */ { "mtcpu", 0x14001600, 0xfc00ffff, "x,^", pa10, 0}, { "mfcpu", 0x14001A00, 0xfc00ffff, "^,x", pa10, 0}, { "tocen", 0x14403600, 0xffffffff, "", pa10, 0},
@@ -1336,6 +1343,9 @@ static const struct pa_opcode pa_opcodes[] = { "shdwgr", 0x14402600, 0xffffffff, "", pa10, 0}, { "grshdw", 0x14400620, 0xffffffff, "", pa10, 0}, +/* instead of showing D only, show all other registers too */ +{ "diag", 0x14000000, 0xfc000000, "D x,9,t", pa10, 0}, +/* gfw and gfr are not in the HP PA 1.1 manual, but they are in either the Timex FPU or the Mustang ERS (not sure which) manual. */ { "gfw", 0x04001680, 0xfc00ffdf, "cZx(b)", pa11, 0},
@@ -1801,6 +1811,12 @@ fput_creg (unsigned reg, disassemble_info *info) (*info->fprintf_func) (info->stream,"%s" , control_reg[reg]); } +static void +fput_dreg (unsigned reg,disassemble_info *info) +{ + (*info->fprintf_func) (info->stream,"dr%d" , reg); +} +/* Print constants with sign. */ static void
@@ -2007,6 +2023,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)case '^' :fput_creg (GET_FIELD (insn,6 ,10 ), info);break ; +case '9' : +fput_dreg (GET_FIELD (insn,6 ,10 ), info); +break ;case 't' :fput_reg (GET_FIELD (insn,27 ,31 ), info);break ;
Signature · 1 line
2.47.0
PATCH 3/5 target/hppa: Implement CPU diagnose registers for 64-bit HP-UX
In reply to [email protected]From: Helge Deller <[email protected]>
PA-RISC CPUs have diagnose registers (%dr). Those are mostly undocumented and control cache behaviour, memory behaviour, reset button management and many other related internal CPU things.
The Linux kernel turns space-register hashing off unconditionally at bootup. That code was provided by HP at the beginning of the PA-RISC Linux porting effort, and I don't know why it was decided then why Linux should not use space register hashing.
32-bit HP-UX versions seem to not use space register hashing either. But for 64-bit HP-UX versions, Sven Schnelle noticed that space register hashing needs to be enabled and is required, otherwise the HP-UX kernel will crash badly.
On 64-bit CPUs space register hashing is controlled by a bit in diagnose register %dr2. Since we want to support Linux and 32- and 64-bit HP-UX, we need to fully emulate the diagnose registers and handle specifically the content of %dr2.
Furthermore it turned out that commit 3bdf20819e68 seems wrong and conflicts with the general space register diagnose register, so it is partly reverted here.
--- hw/hppa/machine.c | 5 +++++ target/hppa/cpu.c | 3 ++- target/hppa/cpu.h | 24 ++++++++++++++++-------- target/hppa/helper.c | 4 ++-- target/hppa/insns.decode | 6 ++++-- target/hppa/int_helper.c | 6 +++--- target/hppa/machine.c | 5 +++-- target/hppa/sys_helper.c | 2 +- target/hppa/translate.c | 24 +++++++++++++++++------- 9 files changed, 53 insertions(+), 26 deletions(-)
hw/hppa/machine.c +5 -0
@@ -662,6 +662,11 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)cpu_set_pc (cs, firmware_entry); cpu[i]->env.psw =PSW_Q ; cpu[i]->env.gr[5 ] =CPU_HPA + i *0x1000 ; + +/* 64-bit machines start with space-register hashing enabled in %dr2 */ +if (hppa_is_pa20 (&cpu[0 ]->env)) { + cpu[i]->env.dr[2 ] =HPPA64_DIAG_SPHASH_ENABLE ;/* (bit 54) */ + } } cpu[0 ]->env.gr[26 ] = ms->ram_size;
target/hppa/cpu.c +2 -1
@@ -44,7 +44,8 @@ static vaddr hppa_cpu_get_pc(CPUState *cs) {CPUHPPAState *env =cpu_env (cs); -return hppa_form_gva_psw (env->psw, (env->psw &PSW_C ? env->iasq_f :0 ), +return hppa_form_gva_psw (env, env->psw, + (env->psw &PSW_C ? env->iasq_f :0 ), env->iaoq_f &-4 ); }
target/hppa/cpu.h +16 -8
@@ -25,6 +25,7 @@#include "qemu/cpu-float.h" #include "qemu/interval-tree.h" #include "hw/registerfields.h" +#include "hw/hppa/hppa_hardware.h" #define MMU_ABS_W_IDX 6#define MMU_ABS_IDX 7
@@ -232,6 +233,7 @@ typedef struct CPUArchState {target_ulong cr[32 ];/* control registers */ target_ulong cr_back[2 ];/* back of cr17/cr18 */ target_ulong shadow[7 ];/* shadow registers */ +target_ulong dr[32 ];/* diagnose registers */ /* * During unwind of a memory insn, the base register of the address.
@@ -319,27 +321,33 @@ void hppa_translate_code(CPUState *cs, TranslationBlock *tb,#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU -static inline uint64_t gva_offset_mask (target_ulong psw) +static inline uint64_t gva_offset_mask (CPUHPPAState *env,target_ulong psw) { -return (psw &PSW_W - ?MAKE_64BIT_MASK (0 ,62 ) - :MAKE_64BIT_MASK (0 ,32 )); +if (psw &PSW_W ) { +return (env->dr[2 ] &HPPA64_DIAG_SPHASH_ENABLE ) + ?MAKE_64BIT_MASK (0 ,62 ) & + ~((uint64_t )HPPA64_PDC_CACHE_RET_SPID_VAL <<48 ) + :MAKE_64BIT_MASK (0 ,62 ); + }else { +return MAKE_64BIT_MASK (0 ,32 ); + } } -static inline target_ulong hppa_form_gva_psw (target_ulong psw,uint64_t spc, -target_ulong off) +static inline target_ulong hppa_form_gva_psw (CPUHPPAState *env, +target_ulong psw, +uint64_t spc,target_ulong off) {#ifdef CONFIG_USER_ONLY return off &gva_offset_mask (psw);#else -return spc | (off &gva_offset_mask (psw)); +return spc | (off &gva_offset_mask (env, psw));#endif }static inline target_ulong hppa_form_gva (CPUHPPAState *env,uint64_t spc,target_ulong off) { -return hppa_form_gva_psw (env->psw, spc, off); +return hppa_form_gva_psw (env, env->psw, spc, off); }hwaddr hppa_abs_to_phys_pa2_w0 (vaddr addr);
target/hppa/helper.c +2 -2
@@ -133,9 +133,9 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int flags)qemu_fprintf (f,"IA_F %08" PRIx64":%0*" PRIx64" (" TARGET_FMT_lx")\n" "IA_B %08" PRIx64":%0*" PRIx64" (" TARGET_FMT_lx")\n" , env->iasq_f >>32 , w, m & env->iaoq_f, -hppa_form_gva_psw (psw, env->iasq_f, env->iaoq_f), +hppa_form_gva_psw (env, psw, env->iasq_f, env->iaoq_f), env->iasq_b >>32 , w, m & env->iaoq_b, -hppa_form_gva_psw (psw, env->iasq_b, env->iaoq_b)); +hppa_form_gva_psw (env, psw, env->iasq_b, env->iaoq_b)); psw_c[0 ] = (psw &PSW_W ?'W' :'-' ); psw_c[1 ] = (psw &PSW_E ?'E' :'-' );
target/hppa/insns.decode +4 -2
@@ -644,10 +644,12 @@ xmpyu 001110 ..... ..... 010 .0111 .00 t:5 r1=%ra64 r2=%rb64 # For 32-bit PA-7300LC (PCX-L2) diag_getshadowregs_pa1 000101 00 0000 0000 0001 1010 0000 0000 diag_putshadowregs_pa1 000101 00 0000 0000 0001 1010 0100 0000 + diag_mfdiag 000101 dr:5 rt:5 0000 0110 0000 0000 + diag_mtdiag 000101 dr:5 r1:5 0001 0110 0000 0000 # For 64-bit PA8700 (PCX-W2) - diag_getshadowregs_pa2 000101 00 0111 1000 0001 1000 0100 0000 - diag_putshadowregs_pa2 000101 00 0111 0000 0001 1000 0100 0000 + diag_mfdiag 000101 dr:5 0 0000 0000 1000 101 rt:5 + diag_mtdiag 000101 dr:5 r1:5 0001 1000 0100 0000 ] diag_unimp 000101 i:26 }
target/hppa/int_helper.c +3 -3
@@ -112,9 +112,9 @@ void hppa_cpu_do_interrupt(CPUState *cs)*/ if (old_psw &PSW_C ) { env->cr[CR_IIASQ ] = -hppa_form_gva_psw (old_psw, env->iasq_f, env->iaoq_f) >>32 ; +hppa_form_gva_psw (env, old_psw, env->iasq_f, env->iaoq_f) >>32 ; env->cr_back[0 ] = -hppa_form_gva_psw (old_psw, env->iasq_b, env->iaoq_b) >>32 ; +hppa_form_gva_psw (env, old_psw, env->iasq_b, env->iaoq_b) >>32 ; }else { env->cr[CR_IIASQ ] =0 ; env->cr_back[0 ] =0 ;
@@ -165,7 +165,7 @@ void hppa_cpu_do_interrupt(CPUState *cs)if (old_psw &PSW_C ) {int prot, t; - vaddr =hppa_form_gva_psw (old_psw, env->iasq_f, vaddr); + vaddr =hppa_form_gva_psw (env, old_psw, env->iasq_f, vaddr); t =hppa_get_physical_address (env, vaddr,MMU_KERNEL_IDX ,0 ,0 , &paddr, &prot);if (t >=0 ) {
target/hppa/machine.c +3 -2
@@ -198,6 +198,7 @@ static const VMStateField vmstate_env_fields[] = {VMSTATE_UINT64 (iasq_b, CPUHPPAState),VMSTATE_UINT32 (fr0_shadow, CPUHPPAState), +VMSTATE_UINT64_ARRAY (dr, CPUHPPAState,32 ), VMSTATE_END_OF_LIST() };
@@ -208,8 +209,8 @@ static const VMStateDescription * const vmstate_env_subsections[] = {static const VMStateDescription vmstate_env = { .name ="env" , - .version_id =3 , - .minimum_version_id =3 , + .version_id =4 , + .minimum_version_id =4 , .fields = vmstate_env_fields, .subsections = vmstate_env_subsections, };
target/hppa/sys_helper.c +1 -1
@@ -88,7 +88,7 @@ void HELPER(rfi)(CPUHPPAState *env)* To recreate the space identifier, remove the offset bits. * For pa1.x, the mask reduces to no change to space. */ - mask =gva_offset_mask (env->psw); + mask =gva_offset_mask (env, env->psw); env->iaoq_f = env->cr[CR_IIAOQ ]; env->iaoq_b = env->cr_back[1 ];
target/hppa/translate.c +17 -7
@@ -1577,7 +1577,7 @@ static void form_gva(DisasContext *ctx, TCGv_i64 *pgva, TCGv_i64 *pofs, *pofs = ofs; *pgva = addr =tcg_temp_new_i64 ();tcg_gen_andi_i64 (addr, modify <=0 ? ofs : base, -gva_offset_mask (ctx->tb_flags)); +gva_offset_mask (cpu_env (ctx->cs), ctx->tb_flags));#ifndef CONFIG_USER_ONLY if (!is_phys) {tcg_gen_or_i64 (addr, addr,space_select (ctx, sp, base));
@@ -4593,19 +4593,29 @@ static bool trans_diag_getshadowregs_pa1(DisasContext *ctx, arg_empty *a)return !ctx->is_pa20 &&do_getshadowregs (ctx); } -static bool trans_diag_getshadowregs_pa2 (DisasContext *ctx,arg_empty *a) +static bool trans_diag_putshadowregs_pa1 (DisasContext *ctx,arg_empty *a) { -return ctx->is_pa20 &&do_getshadowregs (ctx); +return !ctx->is_pa20 &&do_putshadowregs (ctx); } -static bool trans_diag_putshadowregs_pa1 (DisasContext *ctx,arg_empty *a) +static bool trans_diag_mfdiag (DisasContext *ctx,arg_diag_mfdiag *a) { -return !ctx->is_pa20 &&do_putshadowregs (ctx); +CHECK_MOST_PRIVILEGED (EXCP_PRIV_OPR ); +nullify_over (ctx); +TCGv_i64 dest =dest_gpr (ctx, a->rt); +tcg_gen_ld_i64 (dest, tcg_env, + offsetof(CPUHPPAState, dr[a->dr])); +save_gpr (ctx, a->rt, dest); +return nullify_end (ctx); } -static bool trans_diag_putshadowregs_pa2 (DisasContext *ctx,arg_empty *a) +static bool trans_diag_mtdiag (DisasContext *ctx,arg_diag_mtdiag *a) { -return ctx->is_pa20 &&do_putshadowregs (ctx); +CHECK_MOST_PRIVILEGED (EXCP_PRIV_OPR ); +nullify_over (ctx); +tcg_gen_st_i64 (load_gpr (ctx, a->r1), tcg_env, + offsetof(CPUHPPAState, dr[a->dr])); +return nullify_end (ctx); }static bool trans_diag_unimp (DisasContext *ctx,arg_diag_unimp *a)
Signature · 1 line
2.47.0
PATCH 4/5 hw/char: Add emulation of Diva GSP PCI management boards
In reply to [email protected]From: Helge Deller <[email protected]>
The Diva GSP ("Guardian Service Processor") PCI boards are Remote Management cards for PA-RISC machines. They come with built-in 16550A UARTs for serial consoles and modem functionalities, as well as a mailbox-like memory area for hardware auto-reboot functionality.
Latest generation HP PA-RISC server machines use those Diva cards for console output.
--- MAINTAINERS | 1 + hw/char/Kconfig | 5 + hw/char/diva-gsp.c | 291 ++++++++++++++++++++++++++++++++++++++++++++ hw/char/meson.build | 1 + 4 files changed, 298 insertions(+) create mode 100644 hw/char/diva-gsp.c
MAINTAINERS +1 -0
@@ -1191,6 +1191,7 @@ M: Richard Henderson <[email protected]> R: Helge Deller <[email protected]> S: Odd Fixes F: configs/devices/hppa-softmmu/default.mak +F: hw/char/diva-gsp.c F: hw/display/artist.c F: hw/hppa/ F: hw/input/lasips2.c
hw/char/Kconfig +5 -0
@@ -78,3 +78,8 @@ config GOLDFISH_TTY config SHAKTI_UART bool + +config DIVA_GSP + bool + depends on PCI + select SERIAL
hw/char/diva-gsp.c new file +291 -0
291 lines not on this page · raw message
hw/char/meson.build +1 -0
@@ -20,6 +20,7 @@ system_ss.add(when: 'CONFIG_SHAKTI_UART', if_true: files('shakti_uart.c')) system_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: files('virtio-console.c')) system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen_console.c')) system_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_uartlite.c')) +system_ss.add(when: 'CONFIG_DIVA_GSP', if_true: files('diva-gsp.c')) system_ss.add(when: 'CONFIG_AVR_USART', if_true: files('avr_usart.c')) system_ss.add(when: 'CONFIG_COLDFIRE', if_true: files('mcf_uart.c'))
Signature · 1 line
2.47.0
PATCH 5/5 hw/hppa: Wire up Diva GSP card
In reply to [email protected]From: Helge Deller <[email protected]>
Until now we used a standard serial-pci device to emulate a HP serial console. This worked nicely with 32-bit Linux and 32-bit HP-UX, but 64-bit HP-UX crashes with it and expects either a Diva GSP card, or a real 64-bit capable PCI graphic card (which we don't have yet).
In order to continue with 64-bit HP-UX, switch over to the recently added Diva GSP card emulation.
--- hw/hppa/Kconfig | 1 + hw/hppa/machine.c | 24 ++++++------------------ 2 files changed, 7 insertions(+), 18 deletions(-)
hw/hppa/Kconfig +1 -0
@@ -11,6 +11,7 @@ config HPPA_B160L select LASI select SERIAL_MM select SERIAL_PCI + select DIVA_GSP select ISA_BUS select I8259 select IDE_CMD646
hw/hppa/machine.c +6 -18
@@ -383,28 +383,16 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,pci_init_nic_devices (pci_bus, mc->default_nic); -/* BMC board: HP Powerbar SP2 Diva (with console only) */ - pci_dev =pci_new (-1 ,"pci-serial" ); +/* BMC board: HP Diva GSP */ + pci_dev =pci_new_multifunction (PCI_DEVFN (2 ,0 ),"diva-serial" );if (!lasi_dev) {/* bind default keyboard/serial to Diva card */ -qdev_prop_set_chr (DEVICE (pci_dev),"chardev" ,serial_hd (0 )); +qdev_prop_set_chr (DEVICE (pci_dev),"chardev1" ,serial_hd (0 )); +qdev_prop_set_chr (DEVICE (pci_dev),"chardev2" ,serial_hd (1 )); +qdev_prop_set_chr (DEVICE (pci_dev),"chardev3" ,serial_hd (2 )); +qdev_prop_set_chr (DEVICE (pci_dev),"chardev4" ,serial_hd (3 )); } -qdev_prop_set_uint8 (DEVICE (pci_dev),"prog_if" ,0 );pci_realize_and_unref (pci_dev, pci_bus, &error_fatal); -pci_config_set_vendor_id (pci_dev->config,PCI_VENDOR_ID_HP ); -pci_config_set_device_id (pci_dev->config,0x1048 ); -pci_set_word (&pci_dev->config[PCI_SUBSYSTEM_VENDOR_ID ],PCI_VENDOR_ID_HP ); -pci_set_word (&pci_dev->config[PCI_SUBSYSTEM_ID ],0x1227 );/* Powerbar */ - -/* create a second serial PCI card when running Astro */ -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 )); -qdev_prop_set_chr (DEVICE (pci_dev),"chardev3" ,serial_hd (3 )); -qdev_prop_set_chr (DEVICE (pci_dev),"chardev4" ,serial_hd (4 )); -pci_realize_and_unref (pci_dev, pci_bus, &error_fatal); - }/* create USB OHCI controller for USB keyboard & mouse on Astro machines */ if (!lasi_dev && machine->enable_graphics &&defaults_enabled ()) {
Signature · 1 line
2.47.0
PATCH 1/5 hppa: Sync contents of hppa_hardware.h header file with SeaBIOS-hppa
In reply to [email protected]From: Helge Deller <[email protected]>
The hppa_hardware.h header file holds many constants for addresses and offsets which are needed while building the firmware (SeaBIOS-hppa) and while setting up the virtual machine in QEMU.
This patch brings it in sync between both source code repositories.
--- hw/hppa/hppa_hardware.h | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
hw/hppa/hppa_hardware.h +32 -4
@@ -6,6 +6,11 @@#define FIRMWARE_START 0xf0000000#define FIRMWARE_END 0xf0800000 +#define FIRMWARE_HIGH 0xfffffff0/* upper 32-bits of 64-bit firmware address */ + +#define RAM_MAP_HIGH 0x0100000000/* memory above 3.75 GB is mapped here */ + +#define MEM_PDC_ENTRY 0x4800/* PDC entry address */ #define DEVICE_HPA_LEN 0x00100000
@@ -18,6 +23,7 @@#define LASI_UART_HPA 0xffd05000#define LASI_SCSI_HPA 0xffd06000#define LASI_LAN_HPA 0xffd07000 +#define LASI_RTC_HPA 0xffd09000#define LASI_LPT_HPA 0xffd02000#define LASI_AUDIO_HPA 0xffd04000#define LASI_PS2KBD_HPA 0xffd08000
@@ -27,16 +33,23 @@#define CPU_HPA 0xfffb0000#define MEMORY_HPA 0xfffff000 -#define PCI_HPA DINO_HPA/* PCI bus */ #define IDE_HPA 0xf9000000/* Boot disc controller */ +#define ASTRO_HPA 0xfed00000 +#define ELROY0_HPA 0xfed30000 +#define ELROY2_HPA 0xfed32000 +#define ELROY8_HPA 0xfed38000 +#define ELROYc_HPA 0xfed3c000 +#define ASTRO_MEMORY_HPA 0xfed10200 + +#define SCSI_HPA 0xf1040000/* emulated SCSI, needs to be in f region */ /* offsets to DINO HPA: */ #define DINO_PCI_ADDR 0x064#define DINO_CONFIG_DATA 0x068#define DINO_IO_DATA 0x06c -#define PORT_PCI_CMD (PCI_HPA + DINO_PCI_ADDR) -#define PORT_PCI_DATA (PCI_HPA + DINO_CONFIG_DATA) +#define PORT_PCI_CMD hppa_port_pci_cmd +#define PORT_PCI_DATA hppa_port_pci_data#define FW_CFG_IO_BASE 0xfffa0000
@@ -46,9 +59,24 @@#define HPPA_MAX_CPUS 16/* max. number of SMP CPUs */ #define CPU_CLOCK_MHZ 250/* emulate a 250 MHz CPU */ +#define CR_PSW_DEFAULT 6/* used by SeaBIOS & QEMU for default PSW */ #define CPU_HPA_CR_REG 7/* store CPU HPA in cr7 (SeaBIOS internal) */ #define PIM_STORAGE_SIZE 600/* storage size of pdc_pim_toc_struct (64bit) */ -#define RAM_MAP_HIGH 0x0100000000/* memory above 3.75 GB is mapped here */ +#define ASTRO_BUS_MODULE 0x0a/* C3700: 0x0a, others maybe 0 ? */ + +/* ASTRO Memory and I/O regions */ +#define ASTRO_BASE_HPA 0xfffed00000 +#define ELROY0_BASE_HPA 0xfffed30000/* ELROY0_HPA */ + +#define ROPES_PER_IOC 8/* per Ike half or Pluto/Astro */ + +#define LMMIO_DIRECT0_BASE 0x300 +#define LMMIO_DIRECT0_MASK 0x308 +#define LMMIO_DIRECT0_ROUTE 0x310 + +/* space register hashing */ +#define HPPA64_DIAG_SPHASH_ENABLE 0x200/* DIAG_SPHASH_ENAB (bit 54) */ +#define HPPA64_PDC_CACHE_RET_SPID_VAL 0xfe0/* PDC return value on 64-bit CPU */ #endif
Signature · 1 line
2.47.0
Re: [PATCH 1/5] hppa: Sync contents of hppa_hardware.h header file with SeaBIOS-hppa
Quoted 6 lines · On 1/28/25 08:14, [email protected] wrote:
From: Helge Deller<[email protected]>
The
hppa_hardware.hheader file holds many constants for addresses and offsets which are needed while building the firmware (SeaBIOS-hppa) and while setting up the virtual machine in QEMU.
Quoted 6 lines
This patch brings it in sync between both source code repositories.
Signed-off-by Helge Deller<[email protected]>--- hw/hppa/hppa_hardware.h | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
r~
Re: [PATCH 2/5] disas/hppa: implement mfdiag/mtdiag disassembly
In reply to [email protected]Quoted 11 lines · On 1/28/25 08:14, [email protected] wrote:
From: Helge Deller<[email protected]>
The various PA-RISC CPUs implement different CPU-specific diag instructions (mfdiag, mtdiag, mfcpu, mtcpu, ...) to access CPU-internal diagnose/configuration registers, e.g. for cache control, managing space register hashing, control front panel LEDs and read status of the hardware reset button.
Those instructions are mostly undocumented, but are used by ODE, HP-UX and Linux.
Quoted 6 lines
This patch adds some neccessary instructions for PCXL and PCXU CPUs.
Signed-off-by Helge Deller<[email protected]>--- disas/hppa.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
r~
Re: [PATCH 3/5] target/hppa: Implement CPU diagnose registers for 64-bit HP-UX
In reply to [email protected]Quoted 27 lines · On 1/28/25 08:14, [email protected] wrote:
From: Helge Deller <[email protected]>
PA-RISC CPUs have diagnose registers (%dr). Those are mostly undocumented and control cache behaviour, memory behaviour, reset button management and many other related internal CPU things.
The Linux kernel turns space-register hashing off unconditionally at bootup. That code was provided by HP at the beginning of the PA-RISC Linux porting effort, and I don't know why it was decided then why Linux should not use space register hashing.
32-bit HP-UX versions seem to not use space register hashing either. But for 64-bit HP-UX versions, Sven Schnelle noticed that space register hashing needs to be enabled and is required, otherwise the HP-UX kernel will crash badly.On 64-bit CPUs space register hashing is controlled by a bit in diagnose register %dr2. Since we want to support Linux and 32- and 64-bit HP-UX, we need to fully emulate the diagnose registers and handle specifically the content of %dr2.
Furthermore it turned out that commit
3bdf20819e68seems wrong and conflicts with the general space register diagnose register, so it is partly reverted here.Signed-off-by Helge Deller <[email protected]>Suggested-by Sven Schnelle <[email protected]>Fixes 3bdf20819e68 ("target/hppa: Add diag instructions to set/restore shadow registers")
Quoted 11 lines
--- hw/hppa/machine.c | 5 +++++ target/hppa/cpu.c | 3 ++- target/hppa/cpu.h | 24 ++++++++++++++++-------- target/hppa/helper.c | 4 ++-- target/hppa/insns.decode | 6 ++++-- target/hppa/int_helper.c | 6 +++--- target/hppa/machine.c | 5 +++-- target/hppa/sys_helper.c | 2 +- target/hppa/translate.c | 24 +++++++++++++++++------- 9 files changed, 53 insertions(+), 26 deletions(-)
This does too much at once.
Adding the dr registers should be separate from any of the space hashing. Translator changes can be separate from everything else. Etc.
Quoted 5 lines
hw/hppa/machine.c +0
-0
hw/hppa/machine.c static void hppa_machine_reset(MachineState *ms, ResetType type) · line 670
Quoted 9 lines
hw/hppa/machine.c +5
-0@@ -662,6 +662,11 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)cpu_set_pc (cs, firmware_entry); cpu[i]->env.psw =PSW_Q ; cpu[i]->env.gr[5 ] =CPU_HPA + i *0x1000 ; + +/* 64-bit machines start with space-register hashing enabled in %dr2 */ +if (hppa_is_pa20 (&cpu[0 ]->env)) { + cpu[i]->env.dr[2 ] =HPPA64_DIAG_SPHASH_ENABLE ;/* (bit 54) */ + } }
Why in hw/? I would expect this in hppa_cpu_reset_hold.
target/hppa/cpu.h line 28
Quoted 9 lines
target/hppa/cpu.h +1
-0@@ -25,6 +25,7 @@#include "qemu/cpu-float.h" #include "qemu/interval-tree.h" #include "hw/registerfields.h" +#include "hw/hppa/hppa_hardware.h"
Ideally this would never be in cpu.h.
Quoted 9 lines
target/hppa/cpu.h +1
-3@@ -319,27 +321,33 @@ void hppa_translate_code(CPUState *cs, TranslationBlock *tb,#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU -static inline uint64_t gva_offset_mask (target_ulong psw) +static inline uint64_t gva_offset_mask (CPUHPPAState *env,target_ulong psw) { - return (psw & PSW_W - ? MAKE_64BIT_MASK(0, 62)
target/hppa/cpu.h void hppa_translate_code(CPUState *cs, TranslationBlock *tb, · line 334
Quoted 10 lines
target/hppa/cpu.h +8
-1- : MAKE_64BIT_MASK(0, 32)); +if (psw &PSW_W ) { +return (env->dr[2 ] &HPPA64_DIAG_SPHASH_ENABLE ) + ?MAKE_64BIT_MASK (0 ,62 ) & + ~((uint64_t )HPPA64_PDC_CACHE_RET_SPID_VAL <<48 ) + :MAKE_64BIT_MASK (0 ,62 ); + }else { +return MAKE_64BIT_MASK (0 ,32 ); + } }
This is getting pretty complicated now. I think perhaps we should cache the mask based on current cpu state (updated with writes to psw or dr2).
This would also move the HPPA64_DIAG_SPHASH_ENABLE reference out of cpu.h.
target/hppa/cpu.h void hppa_translate_code(CPUState *cs, TranslationBlock *tb, · line 338
Quoted 6 lines
target/hppa/cpu.h +3
-2-static inline target_ulong hppa_form_gva_psw (target_ulong psw,uint64_t spc, -target_ulong off) +static inline target_ulong hppa_form_gva_psw (CPUHPPAState *env, +target_ulong psw, +uint64_t spc,target_ulong off)
Which means this would take the cached mask as argument, not env + psw. Might rename as hppa_form_gva_mask() at the same time to emphasize the change in arguments.
Quoted 6 lines
target/hppa/insns.decode +0
-0@@ -644,10 +644,12 @@ xmpyu 001110 ..... ..... 010 .0111 .00 t:5 r1=%ra64 r2=%rb64 # For 32-bit PA-7300LC (PCX-L2)
target/hppa/insns.decode xmpyu 001110 ..... ..... 010 .0111 .00 t:5 r1=%ra64 r2=%rb64 · line 652
Quoted 10 lines
target/hppa/insns.decode +4
-2diag_getshadowregs_pa1 000101 00 0000 0000 0001 1010 0000 0000 diag_putshadowregs_pa1 000101 00 0000 0000 0001 1010 0100 0000 + diag_mfdiag 000101 dr:5 rt:5 0000 0110 0000 0000 + diag_mtdiag 000101 dr:5 r1:5 0001 0110 0000 0000 # For 64-bit PA8700 (PCX-W2) - diag_getshadowregs_pa2 000101 00 0111 1000 0001 1000 0100 0000 - diag_putshadowregs_pa2 000101 00 0111 0000 0001 1000 0100 0000 + diag_mfdiag 000101 dr:5 0 0000 0000 1000 101 rt:5 + diag_mtdiag 000101 dr:5 r1:5 0001 1000 0100 0000
Do we not want to distinguish the two different diag instructions? Did you really want to remove get/put_shadowregs_pa2?
Quoted 17 lines
target/hppa/int_helper.c +2
-2@@ -112,9 +112,9 @@ void hppa_cpu_do_interrupt(CPUState *cs)*/ if (old_psw &PSW_C ) { env->cr[CR_IIASQ ] = -hppa_form_gva_psw (old_psw, env->iasq_f, env->iaoq_f) >>32 ; +hppa_form_gva_psw (env, old_psw, env->iasq_f, env->iaoq_f) >>32 ; env->cr_back[0 ] = -hppa_form_gva_psw (old_psw, env->iasq_b, env->iaoq_b) >>32 ; +hppa_form_gva_psw (env, old_psw, env->iasq_b, env->iaoq_b) >>32 ; }else { env->cr[CR_IIASQ ] =0 ; env->cr_back[0 ] =0 ;
target/hppa/int_helper.c void hppa_cpu_do_interrupt(CPUState *cs) · line 171
Quoted 8 lines
target/hppa/int_helper.c +1
-1@@ -165,7 +165,7 @@ void hppa_cpu_do_interrupt(CPUState *cs)if (old_psw &PSW_C ) {int prot, t; - vaddr =hppa_form_gva_psw (old_psw, env->iasq_f, vaddr); + vaddr =hppa_form_gva_psw (env, old_psw, env->iasq_f, vaddr); t =hppa_get_physical_address (env, vaddr,MMU_KERNEL_IDX ,0 ,0 , &paddr, &prot);if (t >=0 ) {
Here we'd need to cache the old mask, since PSW_W is changed in step 2, which would compute a new mask.
r~
Re: [PATCH 3/5] target/hppa: Implement CPU diagnose registers for 64-bit HP-UX
Quoted 40 lines · Richard Henderson
Quoted 31 lines · On 1/28/25 08:14, [email protected] wrote:
From: Helge Deller <[email protected]>
PA-RISC CPUs have diagnose registers (%dr). Those are mostly undocumented and control cache behaviour, memory behaviour, reset button management and many other related internal CPU things.
The Linux kernel turns space-register hashing off unconditionally at bootup. That code was provided by HP at the beginning of the PA-RISC Linux porting effort, and I don't know why it was decided then why Linux should not use space register hashing.
32-bit HP-UX versions seem to not use space register hashing either. But for 64-bit HP-UX versions, Sven Schnelle noticed that space register hashing needs to be enabled and is required, otherwise the HP-UX kernel will crash badly.On 64-bit CPUs space register hashing is controlled by a bit in diagnose register %dr2. Since we want to support Linux and 32- and 64-bit HP-UX, we need to fully emulate the diagnose registers and handle specifically the content of %dr2.
Furthermore it turned out that commit
3bdf20819e68seems wrong and conflicts with the general space register diagnose register, so it is partly reverted here.Signed-off-by Helge Deller <[email protected]>Suggested-by Sven Schnelle <[email protected]>Fixes 3bdf20819e68 ("target/hppa: Add diag instructions to set/restore shadow registers")---
hw/hppa/machine.c | 5 +++++ target/hppa/cpu.c | 3 ++- target/hppa/cpu.h | 24 ++++++++++++++++--------Quoted 7 lines
target/hppa/helper.c | 4 ++-- target/hppa/insns.decode | 6 ++++--
target/hppa/int_helper.c| 6 +++--- target/hppa/machine.c | 5 +++--target/hppa/sys_helper.c| 2 +- target/hppa/translate.c | 24 +++++++++++++++++-------9 files changed, 53 insertions(+), 26 deletions(-)
Quoted 3 lines
This does too much at once.
Adding the dr registers should be separate from any of the space hashing. Translator changes can be separate from everything else. Etc.
Ok.
Quoted 8 lines
Quoted 8 lines
hw/hppa/machine.c +0
-0@@ -662,6 +662,11 @@ static void hppa_machine_reset(MachineState *ms, ResetType type) cpu_set_pc(cs, firmware_entry); cpu[i]->env.psw = PSW_Q; cpu[i]->env.gr[5] = CPU_HPA + i * 0x1000;
Quoted 8 lines
hw/hppa/machine.c static void hppa_machine_reset(MachineState *ms, ResetType type) · line 670
Quoted 6 lines
hw/hppa/machine.c +5
-0+ + /* 64-bit machines start with space-register hashing enabled in %dr2 */ + if (hppa_is_pa20(&cpu[0]->env)) { + cpu[i]->env.dr[2] = HPPA64_DIAG_SPHASH_ENABLE; /* (bit 54) */ + } }Why in hw/? I would expect this in
hppa_cpu_reset_hold.
Ok.
Quoted 23 lines
target/hppa/cpu.h line 28
Quoted 9 lines
target/hppa/cpu.h +1
-0@@ -25,6 +25,7 @@ #include "qemu/cpu-float.h" #include "qemu/interval-tree.h" #include "hw/registerfields.h" +#include "hw/hppa/hppa_hardware.h" Ideally this would never be in
cpu.h.Quoted 11 lines
target/hppa/cpu.h +4
-4@@ -319,27 +321,33 @@ void hppa_translate_code(CPUState *cs, TranslationBlock *tb, #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU -static inline uint64_t gva_offset_mask (target_ulong psw) +static inline uint64_t gva_offset_mask (CPUHPPAState *env,target_ulong psw) { - return (psw & PSW_W - ? MAKE_64BIT_MASK(0, 62) - : MAKE_64BIT_MASK(0, 32)); + if (psw & PSW_W) { + return (env->dr[2] & HPPA64_DIAG_SPHASH_ENABLE) + ? MAKE_64BIT_MASK(0, 62) &
Quoted 8 lines
target/hppa/cpu.h void hppa_translate_code(CPUState *cs, TranslationBlock *tb, · line 334
Quoted 6 lines
target/hppa/cpu.h +5
-0+ ~((uint64_t)HPPA64_PDC_CACHE_RET_SPID_VAL << 48) + : MAKE_64BIT_MASK(0, 62); + } else { + return MAKE_64BIT_MASK(0, 32); + } }This is getting pretty complicated now. I think perhaps we should cache the mask based on current cpu state (updated with writes to psw or dr2).
Good idea. Will try to rewrite.
Quoted 21 lines
This would also move the
HPPA64_DIAG_SPHASH_ENABLEreference out ofcpu.h.target/hppa/cpu.h void hppa_translate_code(CPUState *cs, TranslationBlock *tb, · line 338
Quoted 5 lines
target/hppa/cpu.h +3
-2-static inline target_ulong hppa_form_gva_psw (target_ulong psw,uint64_t spc, - target_ulong off) +static inline target_ulong hppa_form_gva_psw (CPUHPPAState *env, + target_ulong psw, + uint64_t spc, target_ulong off)Which means this would take the cached mask as argument, not env + psw. Might rename as
hppa_form_gva_mask()at the same time to emphasize the change in arguments.Quoted 9 lines
target/hppa/insns.decode +0
-0@@ -644,10 +644,12 @@ xmpyu 001110 ..... ..... 010 .0111 .00 t:5 r1=%ra64 r2=%rb64 # For 32-bit PA-7300LC (PCX-L2)diag_getshadowregs_pa1 000101 00 0000 0000 0001 1010 0000 0000 diag_putshadowregs_pa1 000101 00 0000 0000 0001 1010 0100 0000 + diag_mfdiag 000101 dr:5 rt:5 0000 0110 0000 0000
Quoted 8 lines
Quoted 6 lines
+ diag_mtdiag 000101 dr:5 r1:5 0001 0110 0000 0000 # For 64-bit PA8700 (PCX-W2)
- diag_getshadowregs_pa2 000101 00 0111 1000 0001 1000 0100 0000 - diag_putshadowregs_pa2 000101 00 0111 0000 0001 1000 0100 0000 + diag_mfdiag 000101 dr:5 0 0000 0000 1000 101 rt:5 + diag_mtdiag 000101 dr:5 r1:5 0001 1000 0100 0000Do we not want to distinguish the two different diag instructions?
I did not see a need, as currently they behave the same. Additionally I did not found any other uses in Linux or HP-UX, so I'm not sure if we would benefit about the differentiation in the future. Maybe we will change it when we look at ODE again, but for now I think it's ok.
Quoted 1 line
Did you really want to remove get/put_shadowregs_pa2?
Yes. I think the previous patch is wrong.
Quoted 18 lines
Quoted 18 lines
target/hppa/int_helper.c +0
-0@@ -112,9 +112,9 @@ void hppa_cpu_do_interrupt(CPUState *cs)*/ if (old_psw & PSW_C) {env->cr[CR_IIASQ] =
-hppa_form_gva_psw(old_psw, env->iasq_f, env->iaoq_f)>> 32; +hppa_form_gva_psw(env, old_psw, env->iasq_f, env->iaoq_f)>> 32; env->cr_back[0] =
-hppa_form_gva_psw(old_psw, env->iasq_b, env->iaoq_b)>> 32; +hppa_form_gva_psw(env, old_psw, env->iasq_b, env->iaoq_b)>> 32; } else {
env->cr[CR_IIASQ] = 0;
env->cr_back[0] = 0;target/hppa/int_helper.c +0
-0@@ -165,7 +165,7 @@ void hppa_cpu_do_interrupt(CPUState *cs) if (old_psw & PSW_C) {
Quoted 8 lines
target/hppa/int_helper.c void hppa_cpu_do_interrupt(CPUState *cs) · line 171
Quoted 6 lines
target/hppa/int_helper.c +1
-1int prot, t; - vaddr = hppa_form_gva_psw(old_psw, env->iasq_f, vaddr); + vaddr = hppa_form_gva_psw(env, old_psw, env->iasq_f, vaddr); t = hppa_get_physical_address(env, vaddr, MMU_KERNEL_IDX, 0, 0, &paddr, &prot); if (t >= 0) {Here we'd need to cache the old mask, since
PSW_Wis changed in step 2, which would compute a new mask.
Ok.
Helge