vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 2b906e6f109d26364a2a7309c428ee5cbf0648bc
parent c14f1cf9af928d769bb73c5aaac69e7ba15bdb71
Author: Russ Cox <rsc@swtch.com>
Date:   Sun, 29 Jun 2008 15:14:59 -0400

libvx32/Linux: segmentation faults do not update cr2!

Diffstat:
Msrc/libvx32/linux.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/libvx32/linux.c b/src/libvx32/linux.c @@ -320,7 +320,11 @@ int vx32_sighandler(int signo, siginfo_t *si, void *v) if (emu->trapenv == NULL) return 0; emu->cpu.traperr = ctx->err; - emu->cpu.trapva = ctx->cr2; + // Usually, ctx->cr2 == si->si_addr. + // But on a segmentation fault (as opposed to a paging fault), + // cr2 is not updated and the kernel sends an si_addr == 0. + // Be sure to use si_addr, not cr2. + emu->cpu.trapva = (uint32_t)si->si_addr; memmove(mc->gregs, emu->trapenv->gregs, 19*4); return 1; }