Skip to content

Commit

Permalink
Eliminate the exec range check problem
Browse files Browse the repository at this point in the history
  • Loading branch information
lgblgblgb committed Dec 9, 2021
1 parent f91422d commit fe6354b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion targets/mega65/hypervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static int debug_on = 0;
static int hypervisor_serial_out_asciizer;

static int first_hypervisor_leave;
static int execution_range_check_gate;

static int hypervisor_queued_trap = -1;

Expand Down Expand Up @@ -238,6 +239,7 @@ void hypervisor_start_machine ( void )
in_hypervisor = 0;
hypervisor_queued_trap = -1;
first_hypervisor_leave = 1;
execution_range_check_gate = 0;
hypervisor_enter(TRAP_RESET);
}

Expand Down Expand Up @@ -282,6 +284,7 @@ void hypervisor_leave ( void )
if (XEMU_UNLIKELY(first_hypervisor_leave)) {
DEBUGPRINT("HYPERVISOR: first return after RESET, start of processing workarounds." NL);
first_hypervisor_leave = 0;
execution_range_check_gate = 1;
if (hypervisor_request_stub_rom) {
DEBUGPRINT("MEM: using stub-ROM was forced" NL);
hypervisor_request_stub_rom = 0;
Expand Down Expand Up @@ -368,7 +371,7 @@ void hypervisor_debug ( void )
DEBUG("HYPERVISOR-DEBUG: allowed to run outside of hypervisor memory, no debug info, PC = $%04X" NL, cpu65.pc);
return;
}
if (XEMU_UNLIKELY((cpu65.pc & 0xC000) != 0x8000 && do_execution_range_check)) {
if (XEMU_UNLIKELY((cpu65.pc & 0xC000) != 0x8000 && do_execution_range_check && execution_range_check_gate)) {
DEBUG("HYPERVISOR-DEBUG: execution outside of the hypervisor memory, PC = $%04X" NL, cpu65.pc);
char msg[128];
sprintf(msg, "Hypervisor fatal error: execution outside of the hypervisor memory, PC=$%04X SP=$%04X", cpu65.pc, cpu65.sphi | cpu65.s);
Expand Down

1 comment on commit fe6354b

@lgblgblgb
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For #140

Please sign in to comment.