From: Toni Wilen Date: Sun, 16 Apr 2017 19:11:45 +0000 (+0300) Subject: Halt if initial PC is corrupt or odd. X-Git-Tag: 3500~58 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=2207757596d795b04822e4b47b4c7a83d5c58842;p=francis%2Fwinuae.git Halt if initial PC is corrupt or odd. --- diff --git a/include/newcpu.h b/include/newcpu.h index 0c3ac3a9..ebee8729 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -693,6 +693,7 @@ extern bool can_cpu_tracer (void); #define CPU_HALT_PCI_CONFLICT 8 #define CPU_HALT_CPU_STUCK 9 #define CPU_HALT_SSP_IN_NON_EXISTING_ADDRESS 10 +#define CPU_HALT_INVALID_START_ADDRESS 11 void cpu_semaphore_get(void); void cpu_semaphore_release(void); diff --git a/newcpu.cpp b/newcpu.cpp index b5e26d37..7a99c546 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -5571,6 +5571,14 @@ void m68k_go (int may_quit) event_wait = true; unset_special(SPCFLAG_MODE_CHANGE); + if (!regs.halted) { + // check that PC points to something that looks like memory. + uaecptr pc = m68k_getpc(); + addrbank *ab = get_mem_bank_real(pc); + if (ab == NULL || ab == &dummy_bank || (!currprefs.cpu_compatible && !valid_address(pc, 2)) || (pc & 1)) { + cpu_halt(CPU_HALT_INVALID_START_ADDRESS); + } + } if (regs.halted) { cpu_halt (regs.halted); if (regs.halted < 0) {