[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 10/25] linux-user/i386: Split out maybe_handle_vm86_trap
From: |
Richard Henderson |
Subject: |
[PATCH v3 10/25] linux-user/i386: Split out maybe_handle_vm86_trap |
Date: |
Sat, 18 Sep 2021 18:57:03 -0700 |
Reduce the number of ifdefs within cpu_loop().
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 f813e87294..5866e98441 100644
--- a/linux-user/i386/cpu_loop.c
+++ b/linux-user/i386/cpu_loop.c
@@ -195,6 +195,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);
@@ -256,12 +267,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:
@@ -271,22 +279,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 {
@@ -295,12 +297,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 v3 00/25] linux-user: Clean up siginfo_t handling, Richard Henderson, 2021/09/18
- [PATCH v3 01/25] linux-user/arm: Use force_sig_fault(), Richard Henderson, 2021/09/18
- [PATCH v3 03/25] linux-user/alpha: Set TRAP_UNK for bugchk and unknown gentrap, Richard Henderson, 2021/09/18
- [PATCH v3 04/25] linux-user/alpha: Set FPE_FLTUNK for gentrap ROPRAND, Richard Henderson, 2021/09/18
- [PATCH v3 02/25] linux-user/aarch64: Use force_sig_fault(), Richard Henderson, 2021/09/18
- [PATCH v3 05/25] linux-user/alpha: Use force_sig_fault, Richard Henderson, 2021/09/18
- [PATCH v3 06/25] linux-user/cris: Use force_sig_fault, Richard Henderson, 2021/09/18
- [PATCH v3 10/25] linux-user/i386: Split out maybe_handle_vm86_trap,
Richard Henderson <=
- [PATCH v3 07/25] linux-user/hppa: Use force_sig_fault, Richard Henderson, 2021/09/18
- [PATCH v3 08/25] linux-user/hppa: Use the proper si_code for PRIV_OPR, PRIV_REG, OVERFLOW, Richard Henderson, 2021/09/18
- [PATCH v3 11/25] linux-user/i386: Use force_sig, force_sig_fault, Richard Henderson, 2021/09/18
- [PATCH v3 14/25] linux-user/microblaze: Fix SIGFPE si_codes, Richard Henderson, 2021/09/18
- [PATCH v3 09/25] linux-user/hppa: Set FPE_CONDTRAP for COND, Richard Henderson, 2021/09/18
- [PATCH v3 17/25] target/mips: Extract break code into env->error_code, Richard Henderson, 2021/09/18
- [PATCH v3 12/25] linux-user/m68k: Use force_sig_fault, Richard Henderson, 2021/09/18
- [PATCH v3 13/25] linux-user/microblaze: Use force_sig_fault, Richard Henderson, 2021/09/18
- [PATCH v3 16/25] linux-user/mips: Use force_sig_fault, Richard Henderson, 2021/09/18
- [PATCH v3 22/25] linux-user/s390x: Use force_sig_fault, Richard Henderson, 2021/09/18