aboutsummaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2015-09-27 14:26:04 -0700
committerRichard Henderson <rth@twiddle.net>2015-10-07 20:03:15 +1100
commita0577d2aa9bd42d5d584fa03649a166ba45c2f3d (patch)
tree3aefc90eb42de4c32213479c96d94bdfc2115dd1 /linux-user/main.c
parentdd8070d865ad1b32876931f812a80645f97112ff (diff)
downloadqemu-a0577d2aa9bd42d5d584fa03649a166ba45c2f3d.zip
qemu-a0577d2aa9bd42d5d584fa03649a166ba45c2f3d.tar.gz
qemu-a0577d2aa9bd42d5d584fa03649a166ba45c2f3d.tar.bz2
target-tilegx: Use TILEGX_EXCP_SIGNAL instead of TILEGX_EXCP_SEGV
Consolidate signal handling under a single exception. Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 9e8b92b..1f60ff2 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3414,17 +3414,6 @@ void cpu_loop(CPUS390XState *env)
#ifdef TARGET_TILEGX
-static void gen_sigsegv_maperr(CPUTLGState *env, target_ulong addr)
-{
- target_siginfo_t info;
-
- info.si_signo = TARGET_SIGSEGV;
- info.si_errno = 0;
- info.si_code = TARGET_SEGV_MAPERR;
- info._sifields._sigfault._addr = addr;
- queue_signal(env, info.si_signo, &info);
-}
-
static void gen_sigill_reg(CPUTLGState *env)
{
target_siginfo_t info;
@@ -3436,17 +3425,36 @@ static void gen_sigill_reg(CPUTLGState *env)
queue_signal(env, info.si_signo, &info);
}
-static void do_signal(CPUTLGState *env)
+static void do_signal(CPUTLGState *env, int signo, int sigcode)
{
target_siginfo_t info;
- info.si_signo = env->signo;
+ info.si_signo = signo;
info.si_errno = 0;
- info.si_code = env->sigcode;
info._sifields._sigfault._addr = env->pc;
+
+ if (signo == TARGET_SIGSEGV) {
+ /* The passed in sigcode is a dummy; check for a page mapping
+ and pass either MAPERR or ACCERR. */
+ target_ulong addr = env->excaddr;
+ info._sifields._sigfault._addr = addr;
+ if (page_check_range(addr, 1, PAGE_VALID) < 0) {
+ sigcode = TARGET_SEGV_MAPERR;
+ } else {
+ sigcode = TARGET_SEGV_ACCERR;
+ }
+ }
+ info.si_code = sigcode;
+
queue_signal(env, info.si_signo, &info);
}
+static void gen_sigsegv_maperr(CPUTLGState *env, target_ulong addr)
+{
+ env->excaddr = addr;
+ do_signal(env, TARGET_SIGSEGV, 0);
+}
+
static void set_regval(CPUTLGState *env, uint8_t reg, uint64_t val)
{
if (unlikely(reg >= TILEGX_R_COUNT)) {
@@ -3634,15 +3642,12 @@ void cpu_loop(CPUTLGState *env)
do_fetch(env, trapnr, false);
break;
case TILEGX_EXCP_SIGNAL:
- do_signal(env);
+ do_signal(env, env->signo, env->sigcode);
break;
case TILEGX_EXCP_REG_IDN_ACCESS:
case TILEGX_EXCP_REG_UDN_ACCESS:
gen_sigill_reg(env);
break;
- case TILEGX_EXCP_SEGV:
- gen_sigsegv_maperr(env, env->excaddr);
- break;
default:
fprintf(stderr, "trapnr is %d[0x%x].\n", trapnr, trapnr);
g_assert_not_reached();