From 56eb21e15827fd0326c57dcab59771cb03ad9df6 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Sun, 6 May 2012 01:44:31 +0400 Subject: [PATCH 1/6] cputlb: fix watchpoints handling Cleanup commit e554861766d9ae84dd5720baa4869f4ed711506f have changed code_address calculation in the tlb_set_page function in case of access to a page with a watchpoint. This caused QEMU segfault in the xtensa test_break unit test. Fix it by moving code_address assignment above memory_region_section_get_iotlb call. Signed-off-by: Max Filippov Signed-off-by: Blue Swirl --- cputlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cputlb.c b/cputlb.c index 7f40a6222..0d1e2527f 100644 --- a/cputlb.c +++ b/cputlb.c @@ -272,10 +272,10 @@ void tlb_set_page(CPUArchState *env, target_ulong vaddr, } else { addend = 0; } - iotlb = memory_region_section_get_iotlb(env, section, vaddr, paddr, prot, - &address); code_address = address; + iotlb = memory_region_section_get_iotlb(env, section, vaddr, paddr, prot, + &address); index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); env->iotlb[mmu_idx][index] = iotlb - vaddr; From 7f1b17f2974ba0981e12615129e56b92ce31afa4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 10 May 2012 09:39:17 +0200 Subject: [PATCH 2/6] vga: disable default VGA if appropriate -device is used This is a partial revert of commits a369da5 (vga: improve VGA logic, committed 2012-01-22) and c5bd4f3 (vga: fix -nodefaults -device VGA, 2012-01-24) which broke command-line option parsing in different ways. Since commit a369da5 it has become impossible to specify a VGA device entirely with QemuOpts-enabled options, i.e. without needing an explicit "-vga none". In addition, until commit c5bd4f3 -nodefaults would not disable the device you specified with the legacy "-vga" option, independent of the order. Since commit c5bd4f3 QEMU -nodefaults will override a previous -vga option. I did not reintroduce machine->no_vga. Boards can simply ignore the vga_interface_type variable, and most will indeed do so. Signed-off-by: Paolo Bonzini Signed-off-by: Blue Swirl --- vl.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/vl.c b/vl.c index 5e0080b98..c4f87e868 100644 --- a/vl.c +++ b/vl.c @@ -273,6 +273,7 @@ static int default_monitor = 1; static int default_floppy = 1; static int default_cdrom = 1; static int default_sdcard = 1; +static int default_vga = 1; static struct { const char *driver; @@ -288,6 +289,12 @@ static struct { { .driver = "virtio-serial-pci", .flag = &default_virtcon }, { .driver = "virtio-serial-s390", .flag = &default_virtcon }, { .driver = "virtio-serial", .flag = &default_virtcon }, + { .driver = "VGA", .flag = &default_vga }, + { .driver = "isa-vga", .flag = &default_vga }, + { .driver = "cirrus-vga", .flag = &default_vga }, + { .driver = "isa-cirrus-vga", .flag = &default_vga }, + { .driver = "vmware-svga", .flag = &default_vga }, + { .driver = "qxl-vga", .flag = &default_vga }, }; static void res_free(void) @@ -2277,7 +2284,7 @@ int main(int argc, char **argv, char **envp) const char *loadvm = NULL; QEMUMachine *machine; const char *cpu_model; - const char *vga_model = NULL; + const char *vga_model = "none"; const char *pid_file = NULL; const char *incoming = NULL; #ifdef CONFIG_VNC @@ -2709,6 +2716,7 @@ int main(int argc, char **argv, char **envp) break; case QEMU_OPTION_vga: vga_model = optarg; + default_vga = 0; break; case QEMU_OPTION_g: { @@ -3118,7 +3126,7 @@ int main(int argc, char **argv, char **envp) default_floppy = 0; default_cdrom = 0; default_sdcard = 0; - vga_model = "none"; + default_vga = 0; break; case QEMU_OPTION_xen_domid: if (!(xen_available())) { @@ -3488,14 +3496,11 @@ int main(int argc, char **argv, char **envp) if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) exit(1); - /* must be after qdev registration but before machine init */ - if (vga_model) { - select_vgahw(vga_model); - } else if (cirrus_vga_available()) { - select_vgahw("cirrus"); - } else { - select_vgahw("none"); + /* If no default VGA is requested, the default is "none". */ + if (default_vga && cirrus_vga_available()) { + vga_model = "cirrus"; } + select_vgahw(vga_model); if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0) exit(0); From 22036a49dd618051d932177b5d93daee746e5609 Mon Sep 17 00:00:00 2001 From: Artyom Tarasenko Date: Sat, 12 May 2012 11:15:20 +0200 Subject: [PATCH 3/6] Implement address masking for SPARC v9 CPUs According to UltraSPARC - IIi User's manual: 14.1.11 Address Masking (Impdep #125) When PSTATE.AM=1, the CALL, JMPL, and RDPC instructions and all traps transmit zero in the high-order 32-bits of the PC to their specified destination registers. Signed-off-by: Artyom Tarasenko Signed-off-by: Blue Swirl --- target-sparc/translate.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 4967152e8..b95f91cd3 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -1343,6 +1343,11 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29)); target_ulong target = dc->pc + offset; +#ifdef TARGET_SPARC64 + if (unlikely(AM_CHECK(dc))) { + target &= 0xffffffffULL; + } +#endif if (cond == 0x0) { /* unconditional not taken */ if (a) { @@ -1388,6 +1393,11 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29)); target_ulong target = dc->pc + offset; +#ifdef TARGET_SPARC64 + if (unlikely(AM_CHECK(dc))) { + target &= 0xffffffffULL; + } +#endif if (cond == 0x0) { /* unconditional not taken */ if (a) { @@ -1434,6 +1444,9 @@ static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29)); target_ulong target = dc->pc + offset; + if (unlikely(AM_CHECK(dc))) { + target &= 0xffffffffULL; + } flush_cond(dc, r_cond); gen_cond_reg(r_cond, cond, r_reg); if (a) { @@ -2486,6 +2499,11 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) tcg_temp_free(r_const); target += dc->pc; gen_mov_pc_npc(dc, cpu_cond); +#ifdef TARGET_SPARC64 + if (unlikely(AM_CHECK(dc))) { + target &= 0xffffffffULL; + } +#endif dc->npc = target; } goto jmp_insn; @@ -2610,7 +2628,11 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) { TCGv r_const; - r_const = tcg_const_tl(dc->pc); + if (unlikely(AM_CHECK(dc))) { + r_const = tcg_const_tl(dc->pc & 0xffffffffULL); + } else { + r_const = tcg_const_tl(dc->pc); + } gen_movl_TN_reg(rd, r_const); tcg_temp_free(r_const); } @@ -4579,6 +4601,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) r_const = tcg_const_i32(3); gen_helper_check_align(cpu_env, cpu_dst, r_const); tcg_temp_free_i32(r_const); + gen_address_mask(dc, cpu_dst); tcg_gen_mov_tl(cpu_npc, cpu_dst); dc->npc = DYNAMIC_PC; } From 00b2ace50904068256239b0e2e5b680381aea262 Mon Sep 17 00:00:00 2001 From: Artyom Tarasenko Date: Sat, 12 May 2012 11:15:21 +0200 Subject: [PATCH 4/6] fix block loads broken in commit 30038fd818 Fix UltraSPARC/JPS1/UA2007 VIS block load instructions broken in 30038fd81808f7c3bca92be2369e74c8ca7b3d69. Signed-off-by: Artyom Tarasenko [blauwirbel@gmail.com: trimmed unwanted part of patch] Signed-off-by: Blue Swirl --- target-sparc/ldst_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index 04ffddf3c..efe5e704b 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -2098,7 +2098,7 @@ void helper_ldf_asi(CPUSPARCState *env, target_ulong addr, int asi, int size, return; } helper_check_align(env, addr, 0x3f); - for (i = 0; i < 8; i++, rd += 2, addr += 4) { + for (i = 0; i < 8; i++, rd += 2, addr += 8) { env->fpr[rd / 2].ll = helper_ld_asi(env, addr, asi & 0x19, 8, 0); } return; From d1d80055baddf2c107d9da893f79c9199362e2e9 Mon Sep 17 00:00:00 2001 From: Artyom Tarasenko Date: Sat, 12 May 2012 11:15:22 +0200 Subject: [PATCH 5/6] sun4u: initialize OBIO interrupt mappings Similarly to PCI interrupt mappings, the OBIO ones have to be initialized. Signed-off-by: Artyom Tarasenko Signed-off-by: Blue Swirl --- hw/apb_pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/apb_pci.c b/hw/apb_pci.c index 7e28808ec..d4e11bc1b 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -404,6 +404,9 @@ static void pci_pbm_reset(DeviceState *d) for (i = 0; i < 8; i++) { s->pci_irq_map[i] &= PBM_PCI_IMR_MASK; } + for (i = 0; i < 32; i++) { + s->obio_irq_map[i] &= PBM_PCI_IMR_MASK; + } if (s->nr_resets++ == 0) { /* Power on reset */ @@ -426,6 +429,9 @@ static int pci_pbm_init_device(SysBusDevice *dev) for (i = 0; i < 8; i++) { s->pci_irq_map[i] = (0x1f << 6) | (i << 2); } + for (i = 0; i < 32; i++) { + s->obio_irq_map[i] = ((0x1f << 6) | 0x20) + i; + } s->pbm_irqs = qemu_allocate_irqs(pci_apb_set_irq, s, MAX_IVEC); /* apb_config */ From 94d1991445fa3582c042ee4e5b72606e2fc39cc2 Mon Sep 17 00:00:00 2001 From: Artyom Tarasenko Date: Sat, 12 May 2012 11:15:23 +0200 Subject: [PATCH 6/6] sun4u: implement interrupt clearing registers Implement registers for clearing OBIO and PCI interrupts Signed-off-by: Artyom Tarasenko Signed-off-by: Blue Swirl --- hw/apb_pci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/apb_pci.c b/hw/apb_pci.c index d4e11bc1b..c28411a46 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -85,6 +85,8 @@ typedef struct APBState { unsigned int nr_resets; } APBState; +static void pci_apb_set_irq(void *opaque, int irq_num, int level); + static void apb_config_writel (void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { @@ -113,6 +115,16 @@ static void apb_config_writel (void *opaque, target_phys_addr_t addr, s->obio_irq_map[(addr & 0xff) >> 3] |= val & ~PBM_PCI_IMR_MASK; } break; + case 0x1400 ... 0x143f: /* PCI interrupt clear */ + if (addr & 4) { + pci_apb_set_irq(s, (addr & 0x3f) >> 3, 0); + } + break; + case 0x1800 ... 0x1860: /* OBIO interrupt clear */ + if (addr & 4) { + pci_apb_set_irq(s, 0x20 | ((addr & 0xff) >> 3), 0); + } + break; case 0x2000 ... 0x202f: /* PCI control */ s->pci_control[(addr & 0x3f) >> 2] = val; break;