From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PULL 12/19] target-tilegx: Use TILEGX_EXCP_SIGNAL instead of TILEGX_EXCP_SEGV
Date: Wed, 7 Oct 2015 20:33:10 +1100 [thread overview]
Message-ID: <1444210397-20679-13-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1444210397-20679-1-git-send-email-rth@twiddle.net>
Consolidate signal handling under a single exception.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
linux-user/main.c | 41 +++++++++++++++++++++++------------------
target-tilegx/cpu.c | 7 ++++++-
target-tilegx/cpu.h | 3 +--
3 files changed, 30 insertions(+), 21 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();
diff --git a/target-tilegx/cpu.c b/target-tilegx/cpu.c
index 78b73e4..3c5481d 100644
--- a/target-tilegx/cpu.c
+++ b/target-tilegx/cpu.c
@@ -22,6 +22,7 @@
#include "qemu-common.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
+#include "linux-user/syscall_defs.h"
static void tilegx_cpu_dump_state(CPUState *cs, FILE *f,
fprintf_function cpu_fprintf, int flags)
@@ -121,8 +122,12 @@ static int tilegx_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,
{
TileGXCPU *cpu = TILEGX_CPU(cs);
- cs->exception_index = TILEGX_EXCP_SEGV;
+ /* The sigcode field will be filled in by do_signal in main.c. */
+ cs->exception_index = TILEGX_EXCP_SIGNAL;
cpu->env.excaddr = address;
+ cpu->env.signo = TARGET_SIGSEGV;
+ cpu->env.sigcode = 0;
+
return 1;
}
diff --git a/target-tilegx/cpu.h b/target-tilegx/cpu.h
index 023ccd4..6f04fe7 100644
--- a/target-tilegx/cpu.h
+++ b/target-tilegx/cpu.h
@@ -60,8 +60,7 @@ enum {
typedef enum {
TILEGX_EXCP_NONE = 0,
TILEGX_EXCP_SYSCALL = 1,
- TILEGX_EXCP_SEGV = 2,
- TILEGX_EXCP_SIGNAL = 3,
+ TILEGX_EXCP_SIGNAL = 2,
TILEGX_EXCP_OPCODE_UNKNOWN = 0x101,
TILEGX_EXCP_OPCODE_UNIMPLEMENTED = 0x102,
TILEGX_EXCP_OPCODE_CMPEXCH = 0x103,
--
2.4.3
next prev parent reply other threads:[~2015-10-07 9:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-07 9:32 [Qemu-devel] [PULL 00/19] Collected tilegx patches Richard Henderson
2015-10-07 9:32 ` [Qemu-devel] [PULL 01/19] target-tilegx: Tidy simd_helper.c Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 02/19] target-tilegx: Implement v*shl, v*shru, and v*shrs instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 03/19] target-tilegx: Implement v*add and v*sub instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 04/19] target-tilegx: Implement v1multu instruction Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 05/19] target-tilegx: Implement crc instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 06/19] target-tilegx: Implement table index instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 07/19] target-tilegx: Implement complex multiply instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 08/19] target-tilegx: Let x1 pipe process bpt instruction only Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 09/19] linux-user/syscall_defs.h: Sync the latest si_code from Linux kernel Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 11/19] target-tilegx: Decode ill pseudo-instructions Richard Henderson
2015-10-07 9:33 ` Richard Henderson [this message]
2015-10-07 9:33 ` [Qemu-devel] [PULL 13/19] target-tilegx: Fix a typo for mnemonic about "ld_add" Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 14/19] target-tilegx: Handle nofault prefetch instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 15/19] target-tilegx: Implement v2sh* instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 16/19] target-tilegx: Implement v?int_* instructions Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 17/19] target-tilegx: Implement v2mults instruction Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 18/19] target-tilegx: Use TILEGX_EXCP_OPCODE_UNKNOWN and TILEGX_EXCP_OPCODE_UNIMPLEMENTED correctly Richard Henderson
2015-10-07 9:33 ` [Qemu-devel] [PULL 19/19] target-tilegx: Support iret instruction and related special registers Richard Henderson
2015-10-08 13:18 ` [Qemu-devel] [PULL 00/19] Collected tilegx patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444210397-20679-13-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).