[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 09/24] linux-user/i386: Split out maybe_handle_vm86_trap
From: |
Richard Henderson |
Subject: |
[PATCH v4 09/24] linux-user/i386: Split out maybe_handle_vm86_trap |
Date: |
Mon, 20 Dec 2021 13:05:13 -0800 |
Reduce the number of ifdefs within cpu_loop().
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/i386/cpu_loop.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
index f6a1cc632b..a372cfe1b2 100644
--- a/linux-user/i386/cpu_loop.c
+++ b/linux-user/i386/cpu_loop.c
@@ -198,6 +198,17 @@ static void emulate_vsyscall(CPUX86State *env)
}
#endif
+static bool maybe_handle_vm86_trap(CPUX86State *env, int trapnr)
+{
+#ifndef TARGET_X86_64
+ if (env->eflags & VM_MASK) {
+ handle_vm86_trap(env, trapnr);
+ return true;
+ }
+#endif
+ return false;
+}
+
void cpu_loop(CPUX86State *env)
{
CPUState *cs = env_cpu(env);
@@ -259,12 +270,9 @@ void cpu_loop(CPUX86State *env)
break;
case EXCP0D_GPF:
/* XXX: potential problem if ABI32 */
-#ifndef TARGET_X86_64
- if (env->eflags & VM_MASK) {
- handle_vm86_fault(env);
+ if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
-#endif
gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0);
break;
case EXCP0E_PAGE:
@@ -274,22 +282,16 @@ void cpu_loop(CPUX86State *env)
env->cr[2]);
break;
case EXCP00_DIVZ:
-#ifndef TARGET_X86_64
- if (env->eflags & VM_MASK) {
- handle_vm86_trap(env, trapnr);
+ if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
-#endif
gen_signal(env, TARGET_SIGFPE, TARGET_FPE_INTDIV, env->eip);
break;
case EXCP01_DB:
case EXCP03_INT3:
-#ifndef TARGET_X86_64
- if (env->eflags & VM_MASK) {
- handle_vm86_trap(env, trapnr);
+ if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
-#endif
if (trapnr == EXCP01_DB) {
gen_signal(env, TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip);
} else {
@@ -298,12 +300,9 @@ void cpu_loop(CPUX86State *env)
break;
case EXCP04_INTO:
case EXCP05_BOUND:
-#ifndef TARGET_X86_64
- if (env->eflags & VM_MASK) {
- handle_vm86_trap(env, trapnr);
+ if (maybe_handle_vm86_trap(env, trapnr)) {
break;
}
-#endif
gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0);
break;
case EXCP06_ILLOP:
--
2.25.1
- [PATCH v4 02/24] linux-user/alpha: Set FPE_FLTUNK for gentrap ROPRAND, (continued)
- [PATCH v4 02/24] linux-user/alpha: Set FPE_FLTUNK for gentrap ROPRAND, Richard Henderson, 2021/12/20
- [PATCH v4 01/24] linux-user/alpha: Set TRAP_UNK for bugchk and unknown gentrap, Richard Henderson, 2021/12/20
- [PATCH v4 03/24] linux-user/alpha: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 04/24] linux-user/cris: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 06/24] linux-user/hppa: Use the proper si_code for PRIV_OPR, PRIV_REG, OVERFLOW, Richard Henderson, 2021/12/20
- [PATCH v4 07/24] linux-user: Remove TARGET_NSIGFPE, Richard Henderson, 2021/12/20
- [PATCH v4 05/24] linux-user/hppa: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 08/24] linux-user/hppa: Set FPE_CONDTRAP for COND, Richard Henderson, 2021/12/20
- [PATCH v4 09/24] linux-user/i386: Split out maybe_handle_vm86_trap,
Richard Henderson <=
- [PATCH v4 10/24] linux-user/i386: Use force_sig, force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 11/24] linux-user/m68k: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 12/24] linux-user/microblaze: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 14/24] linux-user/mips: Improve do_break, Richard Henderson, 2021/12/20
- [PATCH v4 15/24] linux-user/mips: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 16/24] target/mips: Extract break code into env->error_code, Richard Henderson, 2021/12/20
- [PATCH v4 13/24] linux-user/microblaze: Fix SIGFPE si_codes, Richard Henderson, 2021/12/20
- [PATCH v4 18/24] linux-user/openrisc: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 20/24] linux-user/riscv: Use force_sig_fault, Richard Henderson, 2021/12/20
- [PATCH v4 17/24] target/mips: Extract trap code into env->error_code, Richard Henderson, 2021/12/20