From patchwork Sun Sep 19 01:57:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514265 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp887352jao; Sat, 18 Sep 2021 19:00:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYuxXGBziPx8zUf2sIzE4ANlupcdB4jevou5OgEOkB1MTVk881U2KbmNhuCDAwJuQtZoRX X-Received: by 2002:a25:c0c1:: with SMTP id c184mr21650313ybf.382.1632016856072; Sat, 18 Sep 2021 19:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632016856; cv=none; d=google.com; s=arc-20160816; b=bCSRA1B7HC68goYLlSb8A8PQ6KAg/FaGqTpeUOkvp6ZnDTpKXCnlsU/5Cewl41j6Hd 91fuiF8CN+z3o1keL9Tbfe5hVGLh0EazscY4mieydAt3PI3JWs6P/tp21bCZ0hvjT2Yz shx8h20F9O3j8FeblWoShmlykxR3ue7lJk7lhR6yw3/QoveT9sjecBGMGSVnqAb8ZUao 9M77H+VpI1avm9EbBAxFOakfu8+ZuZkHFXLPBitx50fxc1h2dkNFJzijThdBHXH2rfZ6 mI8Dwr4VqAJg4SYwKCVTOfbAJPoUvjjQnbnFKm4Rrd8CMQK+jhkJKTRICjB1D+RAO707 N6eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Aoy4O375ZO7hM1BTzhLh8wcId79QwPq349k/5KQ0lXY=; b=eR/V5kQWNACd19g8jZ1QGUapKI41LQ/gs0dSnKkd30sHhKr74J2rlFC+3sCY8uAj1z aAgfAsPxlHyJWLHJMr7cra+M56OtmmnJ4DAsI71kpG8zaVLx8nflhExM29n5lS6cBmN0 q+LQI4ZvtwxE5XDjKnnlMl+w7G7+37tgUetho31VRx6Jr0v3N+rLFcn7x9rJO1mDe8og dYRztDi3DsEbCzYpwv0ba4ZXTxopu6IVibQpmC5spbKdgga107qEV05rFPTOk5bWEc9N ZsyvJdJjW9Iy5R2/uPSDerufgDFBdt+HojfndFrY/Gpqml8Zo54FXNAB9jv1MAveDeOJ q9tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vuKBItTl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m63si2074104ybf.431.2021.09.18.19.00.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Sep 2021 19:00:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vuKBItTl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRm8U-0000pC-2r for patch@linaro.org; Sat, 18 Sep 2021 22:00:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRm5E-0003k1-Fv for qemu-devel@nongnu.org; Sat, 18 Sep 2021 21:57:32 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:46980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRm5C-00059V-Ux for qemu-devel@nongnu.org; Sat, 18 Sep 2021 21:57:32 -0400 Received: by mail-pg1-x52e.google.com with SMTP id m21so4540596pgu.13 for ; Sat, 18 Sep 2021 18:57:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Aoy4O375ZO7hM1BTzhLh8wcId79QwPq349k/5KQ0lXY=; b=vuKBItTl5fRtZomJl4ONFqne/3MYooY0LVMul61wrsf11dGSb+btqHv+pgFrA1dY4M UTi8vLHQzJFmOGtp5twaIqH4dizPIhAMFuDSJHPUWuDHEVeUok5b/VCX/9P/G+juMrIx u10UD9dMfxCxZpUGrxyQ7h02h9Fj4IMVRc+/4DLue6Kf/9urho4Z3KRHPQzzjUQUKIwO Ev213cqrcExpHq7sWhDm6cYnJkJTTJ0XzJ3c0Vw4J8F3ELKRIv6UKPea1a58mM59L9HQ zq2ZnybH7I5D0MjV5r2vRQS56e4sfEAgNCfUDeGD6jhjWuN8tGnFcHLfVJG6ZFXcvEZs vQQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Aoy4O375ZO7hM1BTzhLh8wcId79QwPq349k/5KQ0lXY=; b=uG0emNVSMz1aCni/0OLYaVy1mFEwY/LCl+o3hC/rtCmpyRNjwvIFdAFfDfGbIPvWTk SCHX832z0i8l/DCeC8toTjvo6fFmOBRngK5ELYUqS+GTar00aN2T9fG9yyYj6Hen1vut JPu0cH8xkD9EGmkZfKxLXsn46QmDYHj7bBIoQ+zhfgS7mqfsmKMnq0q1TEMQSNaob6Jl yELS3ErSetnEFez7xqdS6GmWK0vZXKnFLrI1SzkGIOpHIaDIzxEB9hFLtUxJkafkjosw lZIZRcKDkv4gIAoLMDOjNYTvI8sgT8AV9oT1zaeb+6gXSujrZzNDDjjGsRWzFWf7xgeB n5cg== X-Gm-Message-State: AOAM5309GrfJNoo4dgpikHib5BWN0odoN6h5iXCEHmNb/8nOjM6yEZUa h5Eek38fK7z0pmGamcO/lWhFEZBgV45AQA== X-Received: by 2002:a62:7f01:0:b0:43c:ecef:98dd with SMTP id a1-20020a627f01000000b0043cecef98ddmr18708951pfd.50.1632016648159; Sat, 18 Sep 2021 18:57:28 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id k14sm6747899pgg.92.2021.09.18.18.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Sep 2021 18:57:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/25] linux-user/i386: Split out maybe_handle_vm86_trap Date: Sat, 18 Sep 2021 18:57:03 -0700 Message-Id: <20210919015718.466207-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210919015718.466207-1-richard.henderson@linaro.org> References: <20210919015718.466207-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reduce the number of ifdefs within cpu_loop(). Signed-off-by: Richard Henderson --- linux-user/i386/cpu_loop.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) -- 2.25.1 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: