Skip to content

Commit

Permalink
Add more missing memory checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Jan 14, 2024
1 parent 911deea commit 2eb39a8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/mem/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ readmembl_no_mmut(uint32_t addr, uint32_t a64)
mem_mapping_t *map;

GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_READ, 1);
mem_debug_check_addr(addr, 0);

mem_logical_addr = addr;

Expand Down Expand Up @@ -928,6 +929,7 @@ writemembl_no_mmut(uint32_t addr, uint32_t a64, uint8_t val)
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_WRITE, 1);

mem_logical_addr = addr;
mem_debug_check_addr(addr, 1);

if (page_lookup[addr >> 12] && page_lookup[addr >> 12]->write_b) {
page_lookup[addr >> 12]->write_b(addr, val, page_lookup[addr >> 12]);
Expand Down Expand Up @@ -1092,6 +1094,8 @@ readmemwl_no_mmut(uint32_t addr, uint32_t *a64)
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_READ, 2);

mem_logical_addr = addr;
mem_debug_check_addr(addr, 0);
mem_debug_check_addr(addr + 1, 0);

if (addr & 1) {
if (!cpu_cyrix_alignment || (addr & 7) == 7)
Expand Down Expand Up @@ -1138,6 +1142,8 @@ writememwl_no_mmut(uint32_t addr, uint32_t *a64, uint16_t val)
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_WRITE, 2);

mem_logical_addr = addr;
mem_debug_check_addr(addr, 1);
mem_debug_check_addr(addr + 1, 1);

if (addr & 1) {
if (!cpu_cyrix_alignment || (addr & 7) == 7)
Expand Down Expand Up @@ -1366,6 +1372,10 @@ readmemll_no_mmut(uint32_t addr, uint32_t *a64)
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_READ, 4);

mem_logical_addr = addr;
mem_debug_check_addr(addr, 0);
mem_debug_check_addr(addr + 1, 0);
mem_debug_check_addr(addr + 2, 0);
mem_debug_check_addr(addr + 3, 0);

if (addr & 3) {
if (!cpu_cyrix_alignment || (addr & 7) > 4)
Expand Down Expand Up @@ -1414,6 +1424,10 @@ writememll_no_mmut(uint32_t addr, uint32_t *a64, uint32_t val)
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_WRITE, 4);

mem_logical_addr = addr;
mem_debug_check_addr(addr, 1);
mem_debug_check_addr(addr + 1, 1);
mem_debug_check_addr(addr + 2, 1);
mem_debug_check_addr(addr + 3, 1);

if (addr & 3) {
if (!cpu_cyrix_alignment || (addr & 7) > 4)
Expand Down
15 changes: 15 additions & 0 deletions src/mem/mmu_2386.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ readmembl_no_mmut_2386(uint32_t addr, uint32_t a64)
mem_mapping_t *map;

GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_READ, 1);
mem_debug_check_addr(addr, 0);

mem_logical_addr = addr;

Expand All @@ -325,6 +326,7 @@ writemembl_no_mmut_2386(uint32_t addr, uint32_t a64, uint8_t val)
mem_mapping_t *map;

GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_WRITE, 1);
mem_debug_check_addr(addr, 1);

mem_logical_addr = addr;

Expand Down Expand Up @@ -473,6 +475,8 @@ readmemwl_no_mmut_2386(uint32_t addr, uint32_t *a64)
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_READ, 2);

mem_logical_addr = addr;
mem_debug_check_addr(addr, 0);
mem_debug_check_addr(addr + 1, 0);

if (addr & 1) {
if (!cpu_cyrix_alignment || (addr & 7) == 7)
Expand Down Expand Up @@ -514,6 +518,8 @@ writememwl_no_mmut_2386(uint32_t addr, uint32_t *a64, uint16_t val)
mem_mapping_t *map;

GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_WRITE, 2);
mem_debug_check_addr(addr, 1);
mem_debug_check_addr(addr + 1, 1);

mem_logical_addr = addr;

Expand Down Expand Up @@ -719,6 +725,11 @@ readmemll_no_mmut_2386(uint32_t addr, uint32_t *a64)
mem_mapping_t *map;

GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_READ, 4);

mem_debug_check_addr(addr, 0);
mem_debug_check_addr(addr + 1, 0);
mem_debug_check_addr(addr + 2, 0);
mem_debug_check_addr(addr + 3, 0);

mem_logical_addr = addr;

Expand Down Expand Up @@ -766,6 +777,10 @@ writememll_no_mmut_2386(uint32_t addr, uint32_t *a64, uint32_t val)
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_WRITE, 4);

mem_logical_addr = addr;
mem_debug_check_addr(addr, 1);
mem_debug_check_addr(addr + 1, 1);
mem_debug_check_addr(addr + 2, 2);
mem_debug_check_addr(addr + 3, 3);

if (addr & 3) {
if (!cpu_cyrix_alignment || (addr & 7) > 4)
Expand Down

0 comments on commit 2eb39a8

Please sign in to comment.