vx32

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

commit d2d43ccb6890cbd0afaaa45a24db7b8d6b05129c
parent e353c388b738920a4b17c7630c3ddc597e2c09d5
Author: Russ Cox <rsc@swtch.com>
Date:   Sun, 29 Jun 2008 21:33:11 -0400

[merge]

Diffstat:
src/9vx/vx32.c | 5+----
src/libvx32/linux.c | 6+++++-
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/9vx/vx32.c b/src/9vx/vx32.c @@ -260,10 +260,7 @@ touser(void *initsp) if(rc == VXTRAP_PAGEFAULT){ int read; nfaults++; - if(vp->cpu->traperr == 0xffffffff) - read = -1; - else - read = !(vp->cpu->traperr & 2); + read = !(vp->cpu->traperr & 2); addr = (uchar*)vp->cpu->trapva; if(traceprocs) print("fault %p read=%d\n", addr, read); 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; }