Alpha system emulation, v6
cover Alpha system emulation, v6
Changes v5->v6
* Rebase against master, which now includes most of the target-alpha/ changes from v5.
* VGA now works, with the PALcode initializing text mode.
There are still problems with interrupts getting lost, somehow. It doesn't seem to happen with the ISA or clock devices, but only with the virtio pci devices.
The lossage is of course not repeatable, making it difficult to see what's wrong. Often no problem is seen for 20-30 minutes. Ideas for tracking this down are welcome...
r~
Richard Henderson (8):
Export the unassigned_mem read/write functions.
pci: Export pci_to_cpu_addr.
target-alpha: Add custom PALcode image for CLIPPER emulation.
target-alpha: Add CLIPPER emulation.
target-alpha: Implement WAIT IPR.
target-alpha: Implement HALT IPR.
target-alpha: Add high-resolution access to wall clock and an alarm.
vga: Fix type of lfb/map_addr/end.
.gitmodules | 3 + Makefile | 3 +- Makefile.target | 1 + configure | 8 +- cpu-common.h | 7 + default-configs/alpha-softmmu.mak | 2 + exec.c | 12 +- hw/alpha_dp264.c | 189 +++++++++ hw/alpha_pci.c | 358 +++++++++++++++++ hw/alpha_sys.h | 44 ++ hw/alpha_typhoon.c | 799 +++++++++++++++++++++++++++++++++++++ hw/pci.c | 3 +- hw/pci.h | 1 + hw/vga_int.h | 10 +- pc-bios/README | 3 + pc-bios/palcode-clipper | Bin 0 -> 185703 bytes roms/qemu-palcode | 1 + target-alpha/cpu.h | 4 + target-alpha/helper.h | 5 + target-alpha/op_helper.c | 25 ++ target-alpha/translate.c | 50 ++- 21 files changed, 1503 insertions(+), 25 deletions(-) create mode 100644 hw/alpha_dp264.c create mode 100644 hw/alpha_pci.c create mode 100644 hw/alpha_sys.h create mode 100644 hw/alpha_typhoon.c create mode 100755 pc-bios/palcode-clipper create mode 160000 roms/qemu-palcode
Signature · 1 line
1.7.4.4
PATCH 1/8 Export the unassigned_mem read/write functions.
--- cpu-common.h | 7 +++++++ exec.c | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)
cpu-common.h +7 -0
@@ -56,6 +56,13 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,cpu_register_physical_memory_offset (start_addr, size, phys_offset,0 ); } +extern CPUReadMemoryFunc unassigned_mem_readb; +extern CPUReadMemoryFunc unassigned_mem_readw; +extern CPUReadMemoryFunc unassigned_mem_readl; +extern CPUWriteMemoryFunc unassigned_mem_writeb; +extern CPUWriteMemoryFunc unassigned_mem_writew; +extern CPUWriteMemoryFunc unassigned_mem_writel; +ram_addr_t cpu_get_physical_page_desc (target_phys_addr_t addr);ram_addr_t qemu_ram_alloc_from_ptr (DeviceState *dev,const char *name,ram_addr_t size,void *host);
exec.c +6 -6
@@ -3227,7 +3227,7 @@ ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)return ram_addr; } -static uint32_t unassigned_mem_readb (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readb (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);
@@ -3238,7 +3238,7 @@ static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)return 0 ; } -static uint32_t unassigned_mem_readw (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readw (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);
@@ -3249,7 +3249,7 @@ static uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)return 0 ; } -static uint32_t unassigned_mem_readl (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readl (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);
@@ -3260,7 +3260,7 @@ static uint32_t unassigned_mem_readl(void *opaque, target_phys_addr_t addr)return 0 ; } -static void unassigned_mem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);
@@ -3270,7 +3270,7 @@ static void unassigned_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_#endif } -static void unassigned_mem_writew (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writew (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);
@@ -3280,7 +3280,7 @@ static void unassigned_mem_writew(void *opaque, target_phys_addr_t addr, uint32_#endif } -static void unassigned_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);
Signature · 1 line
1.7.4.4
PATCH 2/8 pci: Export pci_to_cpu_addr.
In reply to Richard HendersonThis is, more or less, the read accessor to pci_bus_set_mem_base as a write accessor. It will be needed for implementing sparse memory spaces for Alpha.
--- hw/pci.c | 3 +-- hw/pci.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)
hw/pci.c +1 -2
@@ -820,8 +820,7 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,return pci_dev; } -static target_phys_addr_t pci_to_cpu_addr (PCIBus *bus, -target_phys_addr_t addr) +target_phys_addr_t pci_to_cpu_addr (PCIBus *bus,target_phys_addr_t addr) {return addr + bus->mem_base; }
hw/pci.h +1 -0
@@ -246,6 +246,7 @@ void pci_device_reset(PCIDevice *dev);void pci_bus_reset (PCIBus *bus);void pci_bus_set_mem_base (PCIBus *bus,target_phys_addr_t base); +target_phys_addr_t pci_to_cpu_addr (PCIBus *bus,target_phys_addr_t addr);PCIDevice *pci_nic_init (NICInfo *nd,const char *default_model,const char *default_devaddr);
Signature · 1 line
1.7.4.4
PATCH 5/8 target-alpha: Implement WAIT IPR.
In reply to Richard Henderson--- target-alpha/translate.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-)
target-alpha/translate.c +21 -10
@@ -1618,9 +1618,10 @@ static void gen_mfpr(int ra, int regno) } } -static void gen_mtpr (int rb,int regno) +static ExitStatus gen_mtpr (DisasContext *ctx,int rb,int regno) {TCGv tmp; +int data;if (rb ==31 ) { tmp =tcg_const_i64 (0 );
@@ -1628,19 +1629,27 @@ static void gen_mtpr(int rb, int regno) tmp = cpu_ir[rb]; } -/* These two register numbers perform a TLB cache flush. Thankfully we -can only do this inside PALmode, which means that the current basic -block cannot be affected by the change in mappings. */ -if (regno ==255 ) { +switch (regno) { +case 255 :/* TBIA */ gen_helper_tbia (); - }else if (regno ==254 ) { +break ; + +case 254 :/* TBIS */ gen_helper_tbis (tmp); - }else { +break ; + +case 253 : +/* WAIT */ + tmp =tcg_const_i64 (1 ); +tcg_gen_st32_i64 (tmp, cpu_env, offsetof(CPUState , halted)); +return gen_excp (ctx,EXCP_HLT ,0 ); + +default :/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */ -int data =cpu_pr_data (regno); + data =cpu_pr_data (regno);if (data !=0 ) {if (data &PR_BYTE ) {tcg_gen_st8_i64 (tmp, cpu_env, data & ~PR_BYTE );
@@ -1650,11 +1659,14 @@ static void gen_mtpr(int rb, int regno) tcg_gen_st_i64(tmp, cpu_env, data); } } +break ; }if (rb ==31 ) {tcg_temp_free (tmp); } + +return NO_EXIT ; }#endif /* !USER_ONLY*/
@@ -3054,8 +3066,7 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)/* HW_MTPR (PALcode) */ #ifndef CONFIG_USER_ONLY if (ctx->tb->flags &TB_FLAGS_PAL_MODE ) { -gen_mtpr (rb, insn &0xffff ); -break ; +return gen_mtpr (ctx, rb, insn &0xffff ); }#endif goto invalid_opc;
Signature · 1 line
1.7.4.4
PATCH 4/8 target-alpha: Add CLIPPER emulation.
In reply to Richard HendersonThis is a DP264 variant, SMP capable, no unusual hardware present.
The emulation does not currently include any PCI IOMMU code. Hopefully the generic support for that can be merged to HEAD soon.
--- Makefile.target | 1 + default-configs/alpha-softmmu.mak | 2 + hw/alpha_dp264.c | 189 +++++++++ hw/alpha_pci.c | 358 +++++++++++++++++ hw/alpha_sys.h | 44 ++ hw/alpha_typhoon.c | 781 +++++++++++++++++++++++++++++++++++++ 6 files changed, 1375 insertions(+), 0 deletions(-) create mode 100644 hw/alpha_dp264.c create mode 100644 hw/alpha_pci.c create mode 100644 hw/alpha_sys.h create mode 100644 hw/alpha_typhoon.c
Makefile.target +1 -0
@@ -376,6 +376,7 @@ obj-s390x-y = s390-virtio-bus.o s390-virtio.o obj-alpha-y = i8259.o mc146818rtc.o obj-alpha-y += vga.o cirrus_vga.o +obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
default-configs/alpha-softmmu.mak +2 -0
@@ -3,7 +3,9 @@ include pci.mak CONFIG_SERIAL=y CONFIG_I8254=y +CONFIG_PCKBD=y CONFIG_VGA_PCI=y CONFIG_IDE_CORE=y CONFIG_IDE_QDEV=y CONFIG_VMWARE_VGA=y +CONFIG_IDE_CMD646=y
hw/alpha_dp264.c new file +189 -0
189 lines not on this page · raw message
hw/alpha_pci.c new file +335 -0
335 lines not on this page · raw message
+void alpha_pci_vga_setup(PCIBus *pci_bus)
+{
+ switch (vga_interface_type) {
+#ifdef CONFIG_SPICE
+ case VGA_QXL:
+ pci_create_simple(pci_bus, -1, "qxl-vga");
+ return;
+#endif
+ case VGA_CIRRUS:
+ pci_cirrus_vga_init(pci_bus);
+ return;
+ case VGA_VMWARE:
+ if (pci_vmsvga_init(pci_bus)) {
+ return;
+ }
+ break;
+ }
+ /* If VGA is enabled at all, and one of the above didn't work, then
+ fallback to Standard VGA. */
+ if (vga_interface_type != VGA_NONE) {
+ pci_vga_init(pci_bus);
+ }
+}
hw/alpha_sys.h new file +44 -0
44 lines not on this page · raw message
hw/alpha_typhoon.c new file +781 -0
781 lines not on this page · raw message
Signature · 1 line
1.7.4.4
PATCH 6/8 target-alpha: Implement HALT IPR.
In reply to Richard Henderson--- target-alpha/helper.h | 1 + target-alpha/op_helper.c | 10 ++++++++++ target-alpha/translate.c | 5 +++++ 3 files changed, 16 insertions(+), 0 deletions(-)
target-alpha/helper.h +1 -0
@@ -113,6 +113,7 @@ DEF_HELPER_2(stq_c_phys, i64, i64, i64) DEF_HELPER_FLAGS_0(tbia, TCG_CALL_CONST, void) DEF_HELPER_FLAGS_1(tbis, TCG_CALL_CONST, void, i64) +DEF_HELPER_1 (halt, void, i64);#endif #include "def-helper.h"
target-alpha/op_helper.c +10 -0
@@ -21,6 +21,7 @@#include "host-utils.h" #include "softfloat.h" #include "helper.h" +#include "sysemu.h" #include "qemu-timer.h" /*****************************************************************************/
@@ -1215,6 +1216,15 @@ void helper_tbis(uint64_t p) {tlb_flush_page (env, p); } + +void helper_halt (uint64_t restart) +{ +if (restart) { +qemu_system_reset_request (); + }else { +qemu_system_shutdown_request (); + } +}#endif /*****************************************************************************/
target-alpha/translate.c +5 -0
@@ -1646,6 +1646,11 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno)tcg_gen_st32_i64 (tmp, cpu_env, offsetof(CPUState , halted));return gen_excp (ctx,EXCP_HLT ,0 ); +case 252 : +/* HALT */ +gen_helper_halt (tmp); +return EXIT_PC_STALE ; +default :/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */
Signature · 1 line
1.7.4.4
PATCH 3/8 target-alpha: Add custom PALcode image for CLIPPER emulation.
In reply to Richard Henderson--- .gitmodules | 3 +++ Makefile | 3 ++- configure | 8 +++++++- pc-bios/README | 3 +++ pc-bios/palcode-clipper | Bin 0 -> 185703 bytes roms/qemu-palcode | 1 + 6 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 pc-bios/palcode-clipper create mode 160000 roms/qemu-palcode
.gitmodules +3 -0
@@ -10,3 +10,6 @@ [submodule "roms/ipxe"] path = roms/ipxe url = git://git.qemu.org/ipxe.git +[submodule "roms/qemu-palcode"] + path = roms/qemu-palcode + url = git://repo.or.cz/qemu-palcode.git
Makefile +2 -1
@@ -206,7 +206,8 @@ bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \ mpc8544ds.dtb \ multiboot.bin linuxboot.bin \ s390-zipl.rom \ -spapr-rtas.bin slof.bin +spapr-rtas.bin slof.bin \ +palcode-sx164 else BLOBS= endif
configure +7 -1
@@ -3474,7 +3474,13 @@ FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES="$FILES pc-bios/spapr-rtas/Makefile" FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" -for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.rom $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do +for bios_file in \ + $source_path/pc-bios/*.bin \ + $source_path/pc-bios/*.rom \ + $source_path/pc-bios/*.dtb \ + $source_path/pc-bios/openbios-* \ + $source_path/pc-bios/palcode-* +do FILES="$FILES pc-bios/`basename $bios_file`" done mkdir -p $DIRS
pc-bios/README +3 -0
@@ -31,3 +31,6 @@ - The S390 zipl loader is an addition to the official IBM s390-tools package. That fork is maintained in its own git repository at: git://repo.or.cz/s390-tools.git + +- The Alpha palcode image is available from: + git://repo.or.cz/qemu-palcode.git
pc-bios/palcode-clipper new file binary +0 -0
roms/qemu-palcode new file +1 -0
@@ -0,0 +1 @@ +Subproject commit 7abb12f60eb3069019e9497e193733d77d8f0722
Signature · 1 line
1.7.4.4
PATCH 7/8 target-alpha: Add high-resolution access to wall clock and an alarm.
In reply to Richard HendersonThe alarm is a fully general one-shot time comparator, which will be usable under Linux as a hrtimer source. It's much more flexible than the RTC source available on real hardware.
The wall clock allows the guest access to the host timekeeping. Much like the KVM wall clock source for other guests.
Both are accessed via the PALcode Cserve entry point.
--- hw/alpha_typhoon.c | 22 ++++++++++++++++++++-- target-alpha/cpu.h | 4 ++++ target-alpha/helper.h | 4 ++++ target-alpha/op_helper.c | 15 +++++++++++++++ target-alpha/translate.c | 14 ++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-)
hw/alpha_typhoon.c +20 -2
@@ -681,6 +681,16 @@ static void typhoon_set_timer_irq(void *opaque, int irq, int level) } } +static void typhoon_alarm_timer (void *opaque) +{ +TyphoonState *s = (TyphoonState *)((uintptr_t )opaque & ~3 ); +int cpu = (uintptr_t )opaque &3 ; + +/* Set the ITI bit for this cpu. */ + s->cchip.misc |=1 << (cpu +4 ); +cpu_interrupt (s->cchip.cpu[cpu],CPU_INTERRUPT_TIMER ); +} +PCIBus *typhoon_init (qemu_irq *p_isa_irq,qemu_irq *p_rtc_irq,CPUState *cpus[3 ],pci_map_irq_fn sys_map_irq) {
@@ -689,14 +699,22 @@ PCIBus *typhoon_init(qemu_irq *p_isa_irq, qemu_irq *p_rtc_irq,PCIHostState *p;TyphoonState *s;PCIBus *b; -int region; +int i, region; dev =qdev_create (NULL ,"typhoon-pcihost" ); p =FROM_SYSBUS (PCIHostState,sysbus_from_qdev (dev)); s =container_of (p, TyphoonState, host);/* Remember the CPUs so that we can deliver interrupts to them. */ -memcpy (s->cchip.cpu, cpus,4 *sizeof (CPUState *)); +for (i =0 ; i <4 ; i++) { +CPUState *env = cpus[i]; + s->cchip.cpu[i] = env; +if (env) { + env->alarm_timer =qemu_new_timer_ns (rtc_clock, + typhoon_alarm_timer, + (void *)((uintptr_t )s + i)); + } + } *p_isa_irq = *qemu_allocate_irqs (typhoon_set_isa_irq, s,1 ); *p_rtc_irq = *qemu_allocate_irqs (typhoon_set_timer_irq, s,1 );
target-alpha/cpu.h +4 -0
@@ -267,6 +267,10 @@ struct CPUAlphaState {uint64_t scratch[24 ];#endif +/* This alarm doesn't exist in real hardware; we wish it did. */ +struct QEMUTimer *alarm_timer; +uint64_t alarm_expire; +#if TARGET_LONG_BITS >HOST_LONG_BITS /* temporary fixed-point registers * used to emulate 64 bits target on 32 bits hosts
target-alpha/helper.h +4 -0
@@ -113,7 +113,11 @@ DEF_HELPER_2(stq_c_phys, i64, i64, i64) DEF_HELPER_FLAGS_0(tbia, TCG_CALL_CONST, void) DEF_HELPER_FLAGS_1(tbis, TCG_CALL_CONST, void, i64) +DEF_HELPER_1 (halt, void, i64); + +DEF_HELPER_FLAGS_0(get_time, TCG_CALL_CONST, i64) +DEF_HELPER_FLAGS_1(set_alarm, TCG_CALL_CONST, void, i64)#endif #include "def-helper.h"
target-alpha/op_helper.c +15 -0
@@ -1225,6 +1225,21 @@ void helper_halt(uint64_t restart) qemu_system_shutdown_request(); } } + +uint64_t helper_get_time (void ) +{ +return qemu_get_clock_ns (rtc_clock); +} + +void helper_set_alarm (uint64_t expire) +{ +if (expire) { + env->alarm_expire = expire; +qemu_mod_timer (env->alarm_timer, expire); + }else { +qemu_del_timer (env->alarm_timer); + } +}#endif /*****************************************************************************/
target-alpha/translate.c +14 -0
@@ -1591,6 +1591,9 @@ static int cpu_pr_data(int pr) return offsetof(CPUAlphaState, shadow[pr - 32]); case 40 ... 63: return offsetof(CPUAlphaState, scratch[pr - 40]); + +case 251 : +return offsetof(CPUAlphaState , alarm_expire); }return 0 ; }
@@ -1605,6 +1608,12 @@ static void gen_mfpr(int ra, int regno)return ; } +if (regno ==250 ) { +/* WALL_TIME */ +gen_helper_get_time (cpu_ir[ra]); +return ; + } +/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */ if (data ==0 ) {
@@ -1651,6 +1660,11 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno)gen_helper_halt (tmp);return EXIT_PC_STALE ; +case 251 : +/* ALARM */ +gen_helper_set_alarm (tmp); +break ; +default :/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */
Signature · 1 line
1.7.4.4
PATCH 8/8 vga: Fix type of lfb/map_addr/end.
In reply to Richard HendersonThese addresses have been passed through pci_to_cpu_addr, and thus need to be full target_phys_addr_t.
--- hw/vga_int.h | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
hw/vga_int.h +5 -5
@@ -106,13 +106,13 @@ typedef void (* vga_update_retrace_info_fn)(struct VGACommonState *s); typedef struct VGACommonState { uint8_t *vram_ptr; ram_addr_t vram_offset; + target_phys_addr_t lfb_addr; + target_phys_addr_t lfb_end; + target_phys_addr_t map_addr; + target_phys_addr_t map_end; uint32_t vram_size; - uint32_t lfb_addr; - uint32_t lfb_end; - uint32_t map_addr; - uint32_t map_end; - uint32_t lfb_vram_mapped; /* whether 0xa0000 is mapped as ram */ uint32_t latch; + uint32_t lfb_vram_mapped; /* whether 0xa0000 is mapped as ram */ uint8_t sr_index; uint8_t sr[256]; uint8_t gr_index;
Signature · 1 line
1.7.4.4