From patchwork Mon Mar 6 00:39:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 659201 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp1575478wrb; Sun, 5 Mar 2023 16:53:02 -0800 (PST) X-Google-Smtp-Source: AK7set/SiqTv/iGRfg72aIzI5g65yTLdYMi0o7b/CJamKe8iYnKRaMZVfVysGFmA+Hcm2StjBMR1 X-Received: by 2002:a05:6214:21ee:b0:574:97e9:e21c with SMTP id p14-20020a05621421ee00b0057497e9e21cmr14011879qvj.4.1678063982190; Sun, 05 Mar 2023 16:53:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678063982; cv=none; d=google.com; s=arc-20160816; b=m0rBm5BqQ14bgDa5bIru1opxJRnVd57+7cgUzfVeibSGa1zyuugPiq1ioBt0v5jTNW rvbaFHT0e6NWznar7WNo/84tJT9R0sD4gDMVP+GWFHr25y4N+KPUdiR6E6GFFeWWN4Z3 qFvxlgWRHg1GDcHHOoZjrP5lTCJ+qQubtYCJZR0VL2DYByJbYBdEpVI6GZEOd0MGYGVg tk7t1BPhlepawjcpnDt7zWvq8vqJ5wyQN0qYu/NRnfOQdC/iO1ez1iZ13lMCXAq0hTU+ WtoCYdAV5ivYVI8Fd711Wdv9x0nPl/Ok+8zjqRpcyD2ctviZ7DBZOFezzfNV2foORTVO OZ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=EfH2DcSHcvy40colhOJL1T76EQ7m2RNJogelT3xw+qc=; b=FM8xcOEfaQajTKa1C1NBa7KeKoaCdUjflSH9iZd1nXMDgSDBH1r+iEl8Sv6GhLVuMt YEK/8O69U94wCpRCmJ6nHvBc93VzjcugnwfVfBOm4ME9aHv2mUfipBDoobavTtuJ8KzB Jat3h1HGD6Il/FIrMdA6c/xH9GbEvUkbbZE4luZDIRXNw+5TqwIWue3n0dr9kQMB6jMA G0m3ChHK8IUKuLFsNrsRSdNrwlHMyqmxRD4GSPW9mf8Ad4GNcvBeEKl2/N2bMnUiKkZT W0gR6Duf8fptrckNHuG3b7S3QtbYGkPq8bV+djuWlkGA3N27j20tnY+I3tcOza582WYq zhng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yi7cvP8c; 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 fh18-20020a0562141a1200b0056eadae1241si6347473qvb.358.2023.03.05.16.53.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Mar 2023 16:53:02 -0800 (PST) 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=yi7cvP8c; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYyyX-0004tV-3c; Sun, 05 Mar 2023 19:45:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYyxn-000302-0c for qemu-devel@nongnu.org; Sun, 05 Mar 2023 19:44:27 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pYyxi-0007HV-NX for qemu-devel@nongnu.org; Sun, 05 Mar 2023 19:44:25 -0500 Received: by mail-pg1-x535.google.com with SMTP id s18so4566795pgq.1 for ; Sun, 05 Mar 2023 16:44:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678063462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EfH2DcSHcvy40colhOJL1T76EQ7m2RNJogelT3xw+qc=; b=yi7cvP8cHsfQnidqlYI8H551BqksZbi0tWsiX8mSzu9jxJLssUX9WnNXzR2v7N4CAs rXwFhNoHHgj2m2QAJTdDYyBOnG+tZStvEfwYPgb1Y3JyZ/++I8julXCb8tipyB8yVYgG mTXPe+72z4y5j9SukqmvkBDG+qXWE84dqjce3NF85VET5v+cH9OPjgRN3lrsg86qUjL5 MpwaVYzN0mKpzWHD/zwq/KpJl3EFjc5Z936nvIDy87ZjZ+g/NFfIWF5xuBqZSn9eIVp9 wSTVmcsc6k/dKpY9l+jFANefY6Ysd95ePMeLMhyETQmDoGI1seopf2J/UTO2t7EMY/ru YE+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678063462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EfH2DcSHcvy40colhOJL1T76EQ7m2RNJogelT3xw+qc=; b=1xvgS6SI3AVIUmP8rLIqLSPfj95tAJj8+37B1YsAiGb39coG1spKsb+sAVgiL/oxPa +hwKVui7Ib7JEKuG3XvLKT4PdppFgq+GXcBN8O5PIlRWoQhEWU6furUNxVp2T9HTA9ON 9Rh39lXvogO4gvtXdGR2pGmFwXHmgzyuSEZmTvX3rje8guot8MmdCpOp4fPkzLMcWdw3 urxxXNji28tGP8TIPpDNe/qNgoKzTD4vqQB/RpcWmeF5XDl5ll/gjafyf3o/zZr5GFD5 6Ky7QtnzF4C/nO0HYMFISjiJivPot+hOylyOrhwY3Ib3Ru2fcnO/NP2Fiee3o7YrEGrb hIDQ== X-Gm-Message-State: AO0yUKXvDn9LbpINqxZX49vXJKt88EzjNaAH4NNZx9xa2ecu1v0Fy6JK 7JK9QTaAh78kVoJQGKJT19ZzpnVdt7BO033QGRflHw== X-Received: by 2002:aa7:9f81:0:b0:60b:81ae:c6d2 with SMTP id z1-20020aa79f81000000b0060b81aec6d2mr8901458pfr.27.1678063461943; Sun, 05 Mar 2023 16:44:21 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:87cc:49bb:2900:c08b]) by smtp.gmail.com with ESMTPSA id x52-20020a056a000bf400b005895f9657ebsm5045726pfu.70.2023.03.05.16.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 16:44:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 74/84] target/i386: Simplify POPF Date: Sun, 5 Mar 2023 16:39:44 -0800 Message-Id: <20230306003954.1866998-75-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306003954.1866998-1-richard.henderson@linaro.org> References: <20230306003954.1866998-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Compute the eflags write mask separately, leaving one call to the helper. Use tcg_constant_i32. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 55 ++++++++----------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 2f3842663d..fa422ebd0b 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -5226,52 +5226,19 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0x9d: /* popf */ gen_svm_check_intercept(s, SVM_EXIT_POPF); if (check_vm86_iopl(s)) { - ot = gen_pop_T0(s); + int mask = TF_MASK | AC_MASK | ID_MASK | NT_MASK; + if (CPL(s) == 0) { - if (dflag != MO_16) { - gen_helper_write_eflags(cpu_env, s->T0, - tcg_const_i32((TF_MASK | AC_MASK | - ID_MASK | NT_MASK | - IF_MASK | - IOPL_MASK))); - } else { - gen_helper_write_eflags(cpu_env, s->T0, - tcg_const_i32((TF_MASK | AC_MASK | - ID_MASK | NT_MASK | - IF_MASK | IOPL_MASK) - & 0xffff)); - } - } else { - if (CPL(s) <= IOPL(s)) { - if (dflag != MO_16) { - gen_helper_write_eflags(cpu_env, s->T0, - tcg_const_i32((TF_MASK | - AC_MASK | - ID_MASK | - NT_MASK | - IF_MASK))); - } else { - gen_helper_write_eflags(cpu_env, s->T0, - tcg_const_i32((TF_MASK | - AC_MASK | - ID_MASK | - NT_MASK | - IF_MASK) - & 0xffff)); - } - } else { - if (dflag != MO_16) { - gen_helper_write_eflags(cpu_env, s->T0, - tcg_const_i32((TF_MASK | AC_MASK | - ID_MASK | NT_MASK))); - } else { - gen_helper_write_eflags(cpu_env, s->T0, - tcg_const_i32((TF_MASK | AC_MASK | - ID_MASK | NT_MASK) - & 0xffff)); - } - } + mask |= IF_MASK | IOPL_MASK; + } else if (CPL(s) <= IOPL(s)) { + mask |= IF_MASK; } + if (dflag == MO_16) { + mask &= 0xffff; + } + + ot = gen_pop_T0(s); + gen_helper_write_eflags(cpu_env, s->T0, tcg_constant_i32(mask)); gen_pop_update(s, ot); set_cc_op(s, CC_OP_EFLAGS); /* abort translation because TF/AC flag may change */