From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>, laurent@vivier.eu
Subject: [PATCH v4 10/24] linux-user/i386: Use force_sig, force_sig_fault
Date: Mon, 20 Dec 2021 13:05:14 -0800 [thread overview]
Message-ID: <20211220210529.150423-11-richard.henderson@linaro.org> (raw)
In-Reply-To: <20211220210529.150423-1-richard.henderson@linaro.org>
Replace the local gen_signal with the generic functions that match
how the kernel raises signals. Fill in the missing PC for SIGTRAP.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/i386/cpu_loop.c | 47 +++++++++++++++-----------------------
1 file changed, 18 insertions(+), 29 deletions(-)
diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
index a372cfe1b2..879d44b490 100644
--- a/linux-user/i386/cpu_loop.c
+++ b/linux-user/i386/cpu_loop.c
@@ -84,17 +84,6 @@ static void set_idt(int n, unsigned int dpl)
}
#endif
-static void gen_signal(CPUX86State *env, int sig, int code, abi_ptr addr)
-{
- target_siginfo_t info = {
- .si_signo = sig,
- .si_code = code,
- ._sifields._sigfault._addr = addr
- };
-
- queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-}
-
#ifdef TARGET_X86_64
static bool write_ok_or_segv(CPUX86State *env, abi_ptr addr, size_t len)
{
@@ -107,7 +96,7 @@ static bool write_ok_or_segv(CPUX86State *env, abi_ptr addr, size_t len)
}
env->error_code = PG_ERROR_W_MASK | PG_ERROR_U_MASK;
- gen_signal(env, TARGET_SIGSEGV, TARGET_SEGV_MAPERR, addr);
+ force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, addr);
return false;
}
@@ -193,8 +182,7 @@ static void emulate_vsyscall(CPUX86State *env)
return;
sigsegv:
- /* Like force_sig(SIGSEGV). */
- gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0);
+ force_sig(TARGET_SIGSEGV);
}
#endif
@@ -266,53 +254,54 @@ void cpu_loop(CPUX86State *env)
#endif
case EXCP0B_NOSEG:
case EXCP0C_STACK:
- gen_signal(env, TARGET_SIGBUS, TARGET_SI_KERNEL, 0);
+ force_sig(TARGET_SIGBUS);
break;
case EXCP0D_GPF:
/* XXX: potential problem if ABI32 */
if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
- gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0);
+ force_sig(TARGET_SIGSEGV);
break;
case EXCP0E_PAGE:
- gen_signal(env, TARGET_SIGSEGV,
- (env->error_code & 1 ?
- TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR),
- env->cr[2]);
+ force_sig_fault(TARGET_SIGSEGV,
+ (env->error_code & PG_ERROR_P_MASK ?
+ TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR),
+ env->cr[2]);
break;
case EXCP00_DIVZ:
if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
- gen_signal(env, TARGET_SIGFPE, TARGET_FPE_INTDIV, env->eip);
+ force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->eip);
break;
case EXCP01_DB:
+ if (maybe_handle_vm86_trap(env, trapnr)) {
+ break;
+ }
+ force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip);
+ break;
case EXCP03_INT3:
if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
- if (trapnr == EXCP01_DB) {
- gen_signal(env, TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip);
- } else {
- gen_signal(env, TARGET_SIGTRAP, TARGET_SI_KERNEL, 0);
- }
+ force_sig(TARGET_SIGTRAP);
break;
case EXCP04_INTO:
case EXCP05_BOUND:
if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
- gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0);
+ force_sig(TARGET_SIGSEGV);
break;
case EXCP06_ILLOP:
- gen_signal(env, TARGET_SIGILL, TARGET_ILL_ILLOPN, env->eip);
+ force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->eip);
break;
case EXCP_INTERRUPT:
/* just indicate that signals should be handled asap */
break;
case EXCP_DEBUG:
- gen_signal(env, TARGET_SIGTRAP, TARGET_TRAP_BRKPT, 0);
+ force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip);
break;
case EXCP_ATOMIC:
cpu_exec_step_atomic(cs);
--
2.25.1
next prev parent reply other threads:[~2021-12-20 21:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-20 21:05 [PATCH v4 00/24] linux-user: Clean up siginfo_t handling Richard Henderson
2021-12-20 21:05 ` [PATCH v4 01/24] linux-user/alpha: Set TRAP_UNK for bugchk and unknown gentrap Richard Henderson
2021-12-20 21:05 ` [PATCH v4 02/24] linux-user/alpha: Set FPE_FLTUNK for gentrap ROPRAND Richard Henderson
2021-12-20 21:05 ` [PATCH v4 03/24] linux-user/alpha: Use force_sig_fault Richard Henderson
2021-12-20 21:05 ` [PATCH v4 04/24] linux-user/cris: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 05/24] linux-user/hppa: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 06/24] linux-user/hppa: Use the proper si_code for PRIV_OPR, PRIV_REG, OVERFLOW Richard Henderson
2021-12-20 21:05 ` [PATCH v4 07/24] linux-user: Remove TARGET_NSIGFPE Richard Henderson
2021-12-20 22:42 ` Philippe Mathieu-Daudé
2021-12-20 21:05 ` [PATCH v4 08/24] linux-user/hppa: Set FPE_CONDTRAP for COND Richard Henderson
2021-12-20 22:44 ` Philippe Mathieu-Daudé
2021-12-20 21:05 ` [PATCH v4 09/24] linux-user/i386: Split out maybe_handle_vm86_trap Richard Henderson
2021-12-20 21:05 ` Richard Henderson [this message]
2021-12-20 21:05 ` [PATCH v4 11/24] linux-user/m68k: Use force_sig_fault Richard Henderson
2021-12-20 21:05 ` [PATCH v4 12/24] linux-user/microblaze: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 13/24] linux-user/microblaze: Fix SIGFPE si_codes Richard Henderson
2021-12-20 21:05 ` [PATCH v4 14/24] linux-user/mips: Improve do_break Richard Henderson
2021-12-20 21:05 ` [PATCH v4 15/24] linux-user/mips: Use force_sig_fault Richard Henderson
2021-12-20 21:05 ` [PATCH v4 16/24] target/mips: Extract break code into env->error_code Richard Henderson
2021-12-20 21:05 ` [PATCH v4 17/24] target/mips: Extract trap " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 18/24] linux-user/openrisc: Use force_sig_fault Richard Henderson
2021-12-20 21:05 ` [PATCH v4 19/24] linux-user/ppc: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 20/24] linux-user/riscv: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 21/24] linux-user/s390x: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 22/24] linux-user/sh4: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 23/24] linux-user/sparc: " Richard Henderson
2021-12-20 21:05 ` [PATCH v4 24/24] linux-user/xtensa: " Richard Henderson
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=20211220210529.150423-11-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=laurent@vivier.eu \
--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).