From 214bdf8e7199a34fe6f46ac7a83b61d8cc3f8ad0 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Sat, 18 Dec 2021 12:43:40 +0100 Subject: [PATCH 1/4] hw: m68k: Add virt compat machine type for 7.0 Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Message-Id: <20211218114340.1856757-1-laurent@vivier.eu> --- hw/m68k/virt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c index 0efa4a45c7..78e926a554 100644 --- a/hw/m68k/virt.c +++ b/hw/m68k/virt.c @@ -304,10 +304,17 @@ type_init(virt_machine_register_types) } \ type_init(machvirt_machine_##major##_##minor##_init); -static void virt_machine_6_2_options(MachineClass *mc) +static void virt_machine_7_0_options(MachineClass *mc) { } -DEFINE_VIRT_MACHINE(6, 2, true) +DEFINE_VIRT_MACHINE(7, 0, true) + +static void virt_machine_6_2_options(MachineClass *mc) +{ + virt_machine_7_0_options(mc); + compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len); +} +DEFINE_VIRT_MACHINE(6, 2, false) static void virt_machine_6_1_options(MachineClass *mc) { From 0969e00b3933a10a481f5bc13c834bf1abbc438d Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Fri, 7 Jan 2022 11:50:49 +0100 Subject: [PATCH 2/4] q800: fix segfault with invalid MacROM "qemu-system-m68k -M q800 -bios /dev/null" crashes with a segfault in q800_init(). This happens because the code doesn't check that rom_ptr() returned a non-NULL pointer . To avoid NULL pointer, don't allow 0 sized file and use bios_size with rom_ptr(). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/756 Reported-by: Peter Maydell Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth Reviewed-by: Mark Cave-Ayland Message-Id: <20220107105049.961489-1-laurent@vivier.eu> Signed-off-by: Laurent Vivier --- hw/m68k/q800.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index e4c7c9b88a..55dfe5036f 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -672,12 +672,13 @@ static void q800_init(MachineState *machine) /* Remove qtest_enabled() check once firmware files are in the tree */ if (!qtest_enabled()) { - if (bios_size < 0 || bios_size > MACROM_SIZE) { + if (bios_size <= 0 || bios_size > MACROM_SIZE) { error_report("could not load MacROM '%s'", bios_name); exit(1); } - ptr = rom_ptr(MACROM_ADDR, MACROM_SIZE); + ptr = rom_ptr(MACROM_ADDR, bios_size); + assert(ptr != NULL); stl_phys(cs->as, 0, ldl_p(ptr)); /* reset initial SP */ stl_phys(cs->as, 4, MACROM_ADDR + ldl_p(ptr + 4)); /* reset initial PC */ From 4e136629f003d0f5be2985b15176acbec2c5a344 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sat, 8 Jan 2022 16:41:47 +0000 Subject: [PATCH 3/4] macfb: fix VRAM dirty memory region logging The macfb VRAM memory region was configured with coalescing rather than dirty memory logging enabled, causing some areas of the screen not to redraw after a full screen update. Signed-off-by: Mark Cave-Ayland Fixes: 8ac919a065 ("hw/m68k: add Nubus macfb video card") Reviewed-by: Laurent Vivier Message-Id: <20220108164147.30813-1-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 277d3e6633..4bd7c3ad6a 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -661,9 +661,9 @@ static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) memory_region_init_ram(&s->mem_vram, OBJECT(dev), "macfb-vram", MACFB_VRAM_SIZE, &error_abort); + memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA); s->vram = memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask = MACFB_VRAM_SIZE - 1; - memory_region_set_coalescing(&s->mem_vram); s->vbl_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, macfb_vbl_timer, s); macfb_update_mode(s); From 31144eb6393b66b06a13e8a6ad0e730f9e82d4c6 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sat, 8 Jan 2022 18:04:53 +0000 Subject: [PATCH 4/4] target/m68k: don't word align SP in stack frame if M68K_FEATURE_UNALIGNED_DATA feature enabled Commit a9431a03f7 ("target/m68k: add M68K_FEATURE_UNALIGNED_DATA feature") added a new feature for processors from the 68020 onwards which do not require data accesses to be word aligned. Unfortunately the original commit missed an additional case whereby the SP is still word aligned when setting up an additional format 1 stack frame so add the necessary M68K_FEATURE_UNALIGNED_DATA feature guard. Signed-off-by: Mark Cave-Ayland Fixes: a9431a03f7 ("target/m68k: add M68K_FEATURE_UNALIGNED_DATA feature") Reviewed-by: Laurent Vivier Message-Id: <20220108180453.18680-1-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/op_helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index c0f4825034..acbd473515 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -415,7 +415,10 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw) oldsr = sr; env->aregs[7] = sp; cpu_m68k_set_sr(env, sr &= ~SR_M); - sp = env->aregs[7] & ~1; + sp = env->aregs[7]; + if (!m68k_feature(env, M68K_FEATURE_UNALIGNED_DATA)) { + sp &= ~1; + } do_stack_frame(env, &sp, 1, oldsr, 0, retaddr); } else { do_stack_frame(env, &sp, 0, oldsr, 0, retaddr);