From patchwork Sun Aug 22 03:55:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 501415 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp1064795jab; Sat, 21 Aug 2021 21:11:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH7MWcgxCbOHD0ClrF1uh7q0HkLyNCEV1ZRSCLsURaN7YzMLTdVDlpxZEEoxIl8J/mqgZ0 X-Received: by 2002:a25:1fc5:: with SMTP id f188mr36321429ybf.375.1629605480990; Sat, 21 Aug 2021 21:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629605480; cv=none; d=google.com; s=arc-20160816; b=CNQOnXec6Y9O/PzD6aRv53v5p64UJCuKoj2TNb0OsnDDTR6j4BfFMnmuy0Da37Eevw Tlx7Z/1oKsbzQZ72sjcSKOiEZP8y1BnIM7GUEfBk4EVNb1TfZZJ0Vr/OtXuDvwZQ34NH Esq7HiiJ4KCLPozw70WRcdKzj0xdeEdU3sWAtvTiXfW6pNFOsECRdJ4l7F7HVkpRbLF7 FLrlCLc7JLvsakqp4Vm/1FTCsqkLtAjf1YjRY9kjs80zhvU0khdTn2m/ANecCLnFq07i 9aypd4C2A0sdcG2RXkJ15Xgoa/bId4Iwvhmlq7nQYTVhsPR8sf7kLT3dq9h9Sa8VJG3f 56TQ== 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=E12ujNLd6malnBc1e3jtI31Xz8aW+9wkArBoeKxPcr/KFVfLan6lbWljYqThnrhLYr XZiX8/LlMVVqTrDvxh3bMV1dL4esRiXDKUqnJ6/ByvdpW12dmBuemFK7y/T8unCf+voB +JcOH7BcoWowD4shemF3TPayJFIRuqzSfkIvmyd9Wna63ba5id5wf6Mpxz8D31kBLBYy La8WV9Eo3hj55ZXrnYW3FbM28OgVkWukm4mYlO1QMSvfLQO5M36vVIQCu14b0TlQ15qU 0ySab9ROadbFepioZtlnXuaco0braJDGBvB5MBQuSOM1OFKkiKndKlInLjwt1nGJsBCY Eohg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ml0s82Zd; 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 n2si10991621ybc.8.2021.08.21.21.11.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Aug 2021 21:11:20 -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=ml0s82Zd; 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]:51824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHepM-0002WX-Do for patch@linaro.org; Sun, 22 Aug 2021 00:11:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaQ-0007rW-2D for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:54 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:42786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaN-0000ht-Ca for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:53 -0400 Received: by mail-pj1-x102b.google.com with SMTP id mq2-20020a17090b3802b0290178911d298bso9907114pjb.1 for ; Sat, 21 Aug 2021 20:55:51 -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=ml0s82ZddlQ+EDgwGzqJngs/c9cXOYSbyW0bP5lupk5AKzJGoScFuh9IQSdNv732tu 3UzTLYNVh8WjoJfmkIxX/Hthqn5q5iMTSAs0kHL14jdqtD/aZ4+CTFzZ4KMc/710QzfF WMLzIUUpwWcx5MDzJ03TOL8S3v8VIQxYM+rtRC1jC/nPQoyP2uMlqxoswGz6HchHrt8u 8YMfHr1fDniHZKJgoxF8R0rLoIyB+0MQtv+SFMLQSx8wQoIgYP9nN6RW2EkjjYKBVVYn 61TbXMp3FRNijPYbmJcK5kd6Kw5b8YJZtfiL5YFezH2Fm7t0vtHiUqm7g+lUVQNw8xFx rvbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=uYzBl+IGCggqDUX3sf+bJEWqsXVAM87I8kJehWka9NWZCuUGr6064/Jyddfowl7WdI DwDVqOMxWmDwMI15ptQBKnwuU5pDfVqWPQ13Y53u7n9gzSv+RbmkynasdlFzmdiecJg2 iZ5vD8dP1SDRW3JmGSaDTOT5MTMtRmhegophFVzYfbATgLPdDpelOSohlX4BQEe1WG9b FY3IsrgjP+A1572vX8poo+QJWpvCnr/BTCSDY5jTzKXb92nGrwz2njrRCIfid8kB3HBc SWG1w9OAVxl1nJmsHoQNfXb0zDloVarTjloT6yOZUQrNBW5XQjKT8Iq3bu2OtBJbgl5L o1oA== X-Gm-Message-State: AOAM530Ml8xbWSPj5ZPgzZKPHWpcvkvix3gWaY7Pd0Ul1cEpKZrGssqt KVpwMrREE+ikDLxsOYK3xSeWCiokWycvlw== X-Received: by 2002:a17:902:b711:b029:11e:6480:258a with SMTP id d17-20020a170902b711b029011e6480258amr23135868pls.41.1629604550154; Sat, 21 Aug 2021 20:55:50 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 17/30] linux-user/i386: Split out maybe_handle_vm86_trap Date: Sat, 21 Aug 2021 20:55:24 -0700 Message-Id: <20210822035537.283193-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210822035537.283193-1-richard.henderson@linaro.org> References: <20210822035537.283193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: peter.maydell@linaro.org, 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 Reviewed-by: Peter Maydell 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: