From patchwork Thu Sep 14 17:44:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 722573 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp527480wro; Thu, 14 Sep 2023 10:45:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHe/tR134e3S8I3yVm6u6iHdEg3855tHv+MISwenp05TGkyC8rpNFBmA8D13BXAmwiZ9u42 X-Received: by 2002:a05:620a:1987:b0:76c:c601:367f with SMTP id bm7-20020a05620a198700b0076cc601367fmr6868826qkb.36.1694713529212; Thu, 14 Sep 2023 10:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713529; cv=none; d=google.com; s=arc-20160816; b=UTmbtqxa0W5WiU8bZnkgx69uKT5UBnqgWbmvhabI/aR3psUOZvuFEwOqyv+GY66st1 lGXbkAjnDBSO6iYyNtL0mLuejVf6tKK5I0kXwooGD77MSaWE5N65xSS811RvKcAy1WVZ +XHCK2X/5QaE9GbcRM2Yl1f3vd7bz/+zuTxhCwFcRbOvqZqbCMxRh569eG3i7BaO7f5C zT1wnBtiZIf0kETiefLaNGrfMpBP9BxLatkDUAL9zJcSNSWAwdxaq2HZu5KZxJrLld51 sqBMUR07wsvIgDHB7A4LBlEL9PTXenZiHCst3Sc3yE7iVt5WMhygKhYd7lYgQC+K3PBt Wxdw== 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=cb3D6IYlr6FrNnYuqfFzbMBO24dvl8EEYuTIpJQPqlk=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=FsH3xIWDU5IBf7TtyvGGUt26Qgyi6y4AhxGREbMnUpv1nQU0SJCRiCKYYFh0kGILFn lDGzWYIIM9K4WuyV4KjiXgp0nor5EQu4uTe1uTn8vyPU6J2ZaM3Ks1TDcpbyybh0MVZw jzgcJ8z+Y19rDvlNgUUHy7Cnpd561WZNJkqB9YmbO2WI1r8ymjCVC83s8BIVTEDejyXL 4TlnOLi7nKAgFE4FzdlULEzRyMF5h6jW7yLUih9+Sq9jUJHvZsYjVruZNvMvvNKhNi0V hhn2lIkp7D7kdUo8vKgfCK3sXKrUM8e2zzE5DW/vrSt4qFzXcXBUMdLBPV5GUR+Um+ne AjTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=la3VoVzm; 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 f9-20020ac87f09000000b00413613e4d4dsi1261113qtk.218.2023.09.14.10.45.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2023 10:45:29 -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=la3VoVzm; 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 1qgqOR-0000d0-Un; Thu, 14 Sep 2023 13:44:44 -0400 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 1qgqOQ-0000bj-1P for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:42 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgqOO-0006yf-6b for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:41 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fb6fd2836so1106112b3a.0 for ; Thu, 14 Sep 2023 10:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694713478; x=1695318278; darn=nongnu.org; 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=cb3D6IYlr6FrNnYuqfFzbMBO24dvl8EEYuTIpJQPqlk=; b=la3VoVzmanelI08fi9wr2QWMmRfqryf0RoUTGFnplj9pmEd8A1ygTjWAIIP/2xxmuJ M51icUZ3jrVN5BWm2aj5TZd8VhDAS9ovq5eF0cvghilTFFfad6eC66aNyVjo410tYmfQ CllDqO0Ow7EUlt+SPzCYSdfOQpR5j3NNislhjmkEQuFaacRPUD+bY+iUc9Ji7BU2fbfB Cxa+eSGzKvPIZY1WfMECUnQLLaOfSaCMtHEhkZB3x98KwjyqfoUIe/ZNxSCRYNpDDjah /8iCis0YinIR9SCZIA5CQS3hqrHtrVVkwsvhgTTVoTbrBqF6p9g/NDPMxv9sLt7k1zko d8/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694713478; x=1695318278; 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=cb3D6IYlr6FrNnYuqfFzbMBO24dvl8EEYuTIpJQPqlk=; b=cPxbC2C4fBfck6CRgdN8NkQSR56FfkP2zJUW06p3qw/KimecsYz0ELHTGH/3SpD8cT iROFmAdYSVx5bn6VB62olIp8zO3M7llu8pmBJnpkHGyRoCciB4Ke6jyVz+TCTCeDudUg lnuMt6Sk3HtXhfr1JolwKlwKOxQgKAFEfs9IoYNjPKuPoKDHAQr6msclTMPy/7d1GzqP AtY1DIr2Qi3x0LRLYTHrAPMzUicPsyImk5qMzpFm5w7UR0FWK5sGytPaCcwLbQqlNX7D lOFGtfg3wCa+37PbMKVtJc8Hia8Mk2aL4qZtueaL//YR18MRq0IQUlPftUhQyrS4F13t ixzQ== X-Gm-Message-State: AOJu0YzOkZBd5EScj0bh8RFuRQx3YuI5Jj5qwbpxGeWoSIX8OcFDNv2a 03W0NYpsUVGnnnuBSCkNUeFFhoTmDDXgdx2kQA0= X-Received: by 2002:a05:6a20:8e22:b0:158:7fdf:66df with SMTP id y34-20020a056a208e2200b001587fdf66dfmr6037635pzj.18.1694713478490; Thu, 14 Sep 2023 10:44:38 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id w17-20020aa78591000000b0068c5bd3c3b4sm1588933pfn.206.2023.09.14.10.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:44:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 1/6] accel/tcg: Avoid load of icount_decr if unused Date: Thu, 14 Sep 2023 10:44:31 -0700 Message-Id: <20230914174436.1597356-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914174436.1597356-1-richard.henderson@linaro.org> References: <20230914174436.1597356-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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 With CF_NOIRQ and without !CF_USE_ICOUNT, the load isn't used. Avoid emitting it. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/translator.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 1a6a5448c8..a3983019a5 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -49,12 +49,15 @@ bool translator_io_start(DisasContextBase *db) static TCGOp *gen_tb_start(uint32_t cflags) { - TCGv_i32 count = tcg_temp_new_i32(); + TCGv_i32 count = NULL; TCGOp *icount_start_insn = NULL; - tcg_gen_ld_i32(count, cpu_env, - offsetof(ArchCPU, neg.icount_decr.u32) - - offsetof(ArchCPU, env)); + if ((cflags & CF_USE_ICOUNT) || !(cflags & CF_NOIRQ)) { + count = tcg_temp_new_i32(); + tcg_gen_ld_i32(count, cpu_env, + offsetof(ArchCPU, neg.icount_decr.u32) - + offsetof(ArchCPU, env)); + } if (cflags & CF_USE_ICOUNT) { /* From patchwork Thu Sep 14 17:44:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 722574 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp527487wro; Thu, 14 Sep 2023 10:45:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVazthpEhg4hqbqNCxw18poxw/PmXGXiVzKARnmKkidipTTcb4zCZVWlPCiVvVVkPp6We/ X-Received: by 2002:ac8:5d15:0:b0:403:66f7:ae66 with SMTP id f21-20020ac85d15000000b0040366f7ae66mr8066880qtx.13.1694713530139; Thu, 14 Sep 2023 10:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713530; cv=none; d=google.com; s=arc-20160816; b=muFZo1YVpE1CBkXqKWp0SA8lnlGoQEAsKp5IhX45Rwz2FevCTY9DM90oL2kzer3ivV qGDZU44KC6JLEkBKHNjbMYSVqbvkF5Kl/41+2q7dy5sLD9ZE7GgwOgjs/x5h4y4+ow+H fNz8zeoPqzZhEnoOhKEtTRSsUS1I5qWdf0MkXnUGdZAnWdTeNamet7Os3eqpjMqwBFV0 f6Euilp+5W4Kn0wSJWOWOxB9h9MlzvxKpbatwKCJfTUq/d26u4PSB7dGp2FL4Cyaxr1g UQ5KuB/8kLPHzVlgdrNIKMnLf8v0URkYI4agq1Ywd17UUVfLah7qRHszU2T6iOXWruE+ GKAg== 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=bgCEQn26u9cOavCqkRzqblhPRJruQuAIdfQLbzQ1zEg=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=D1cTkmKyffqgmb3YPKu53z7MrMr7bLYWcYERbaMIHcTZB5SjpdLxt39t6U/BdnEToe B62Q46lApu2mv1LqIyWufRBHoPC/4cZyOLSneXGggPH48o+Va+JAd3qU7d86ggMBr6Hx isur3H2Lb38Ie5XVBpgyWf+pB2hOPlL3VR64kUl4Edol7oV2BiItDUS/oL2FsYQ5xCxd E0/Gz8P/dGkoAf0yotoRNZ0KRvA/XSZ/LVruBPdXyTQ6p9wZlKLntY32f8RXKdvivZY0 UYjjWx0L0YjHAtPb1hX1cKEdaoW1YkaqO8TJKU98aVLG+NkEZY+ZTB73gvyu0P8RzhJQ dFyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MDiFtmxG; 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 d19-20020a05622a05d300b0040ff1b4ba5fsi1242652qtb.729.2023.09.14.10.45.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2023 10:45:30 -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=MDiFtmxG; 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 1qgqOT-0000ds-U3; Thu, 14 Sep 2023 13:44:45 -0400 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 1qgqOR-0000cs-FS for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:43 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgqOP-0006yy-6e for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:43 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-68fb71ded6dso998113b3a.0 for ; Thu, 14 Sep 2023 10:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694713479; x=1695318279; darn=nongnu.org; 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=bgCEQn26u9cOavCqkRzqblhPRJruQuAIdfQLbzQ1zEg=; b=MDiFtmxG/VbbRVIHQ8wtvyw5adaY+/CBt8uMMAg5VpN/TF7BZu2Us0wmu1L6QzBOfd OlvhMnQWYOjYk0yz7vHD+aXH2+IaPDhRizmsaQJjSTP5yNyJezlWZc1daCzGGH2hLwBT yVyFNDPWGtsz0Dr9krhHW9YBBJcu5lQRCNpCnglTJYsL6OoGJ06g2sDFOxetaHWSTROm QnTK5Ww4iVZ9mtoi0nCisfxW82UrCn8DbYeNK2FPKGwJLydm5v+1LiS7g2mKlYTcsmQS 6Lgb0rcvM/Gpryd393+6L1gj9OIvA2ZTCuYWEr54sZDr62C2P2ji+QS4WJzJL8TasP2A dFTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694713479; x=1695318279; 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=bgCEQn26u9cOavCqkRzqblhPRJruQuAIdfQLbzQ1zEg=; b=CsvM0RQXW7Qy6M1Gk8bUJxGFrNn2f0eWvI13+LmU7t2Z+L59m7CfPCHmGFz8QEO7Jg FXXFRxjzK56MAx6qF9+2gaoDHCszjFYklRiYyDtvaoA3c2fnucjKCvAC1Mzjl80xRiIM bQF/1JURPSjZBFkC6pocXEjw7+uSaIITR95T4PKqzEVkXMtE/Hw20akJ/G62CemABcCx gnKagkBKpfkDciccXnhKUAlNpfOxSQvF8KuK8xxL7Ihb54lGFLYZveDWfIhyerSLTj/p gCiNDdsc/OMCFxO4j1Qjpa1jlaaNESZuHCZ6r+rwwbprb6RTxbH/VENzkp/AhkZBg4zy BPAQ== X-Gm-Message-State: AOJu0YyUouD7/3gE/+YUXayrFYraXpFMylkLlBrGhyjNNe2ThSD1r+io rtYRdWJi7QMoIZELSXSkaj5tgK/SXaDn9BrBhjI= X-Received: by 2002:a05:6a00:851:b0:68e:2d59:b1f3 with SMTP id q17-20020a056a00085100b0068e2d59b1f3mr7473449pfk.13.1694713479363; Thu, 14 Sep 2023 10:44:39 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id w17-20020aa78591000000b0068c5bd3c3b4sm1588933pfn.206.2023.09.14.10.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:44:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 2/6] accel/tcg: Hoist CF_MEMI_ONLY check outside translation loop Date: Thu, 14 Sep 2023 10:44:32 -0700 Message-Id: <20230914174436.1597356-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914174436.1597356-1-richard.henderson@linaro.org> References: <20230914174436.1597356-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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 The condition checked is loop invariant; check it only once. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/translator.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index a3983019a5..b6ab9f3d33 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -158,7 +158,13 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ - plugin_enabled = plugin_gen_tb_start(cpu, db, cflags & CF_MEMI_ONLY); + if (cflags & CF_MEMI_ONLY) { + /* We should only see CF_MEMI_ONLY for io_recompile. */ + assert(cflags & CF_LAST_IO); + plugin_enabled = plugin_gen_tb_start(cpu, db, true); + } else { + plugin_enabled = plugin_gen_tb_start(cpu, db, false); + } while (true) { *max_insns = ++db->num_insns; @@ -176,12 +182,8 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) { /* Accept I/O on the last instruction. */ gen_io_start(); - ops->translate_insn(db, cpu); - } else { - /* we should only see CF_MEMI_ONLY for io_recompile */ - tcg_debug_assert(!(cflags & CF_MEMI_ONLY)); - ops->translate_insn(db, cpu); } + ops->translate_insn(db, cpu); /* * We can't instrument after instructions that change control From patchwork Thu Sep 14 17:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 722575 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp527692wro; Thu, 14 Sep 2023 10:45:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfzTUv/Zi18izfgbimeG1dtKgxcY9SAjkpXdISYp4IDEPPqbc4Ch/AUujIYIO7xwdtxEzf X-Received: by 2002:a05:6808:1404:b0:3a9:c2d6:41e7 with SMTP id w4-20020a056808140400b003a9c2d641e7mr8016296oiv.54.1694713554063; Thu, 14 Sep 2023 10:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713554; cv=none; d=google.com; s=arc-20160816; b=K5b1Reu8bm7J9ZZSPGC0fWVVQ+C9DXMHBsqkEYzTwK4a6uurqpBmyUaqZlQ+ugejOx gAo+SaQBx+ifZordPod/VAShRHo421DFF2xiwd4hTJI1GskOjROqAyPDRhsm6Zgg/Hpc wyIMwPYTEdxaOkwLc9KoI6xCCsM9nugy4O+SXpI3uM+JO1q1Pq6+vGKz/XkPXeP14Yam 0VbFoB8ntROEWhGtJEKiM4XKBIUFt7IQfU/DLNLJ5LRMWJ7NOifRGeaRxCiHdEetjx4A uDL232EiuYQ3RR48VyhmkNygtBeLzUfu3yuzxTVQA1K3JrlhS0Z5vhbHGLhwmfOSLh0z Sy5g== 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=eZFByCfKGTADNtDGu95XjFmCXbCT1Szs+6S6uuZ78J4=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=Gh//xOw2tCPcMUaD40F9gti4eJzCR1xhNJ7kIsK7qNyflz+MGUQo5rjXka8DBXGPK4 Fy/IaT0KWblIBJ2zc8GMLtM4XsstATwxHGXhXw4juL99ZtY0ofL2eZn7lGYNf9Fb2h8+ /FBoJ8R5j5DQa1IfDfp9SJnC8ZrHkitnwAnqZlQjvh5+xF5Cj7Iq06w5Hp5p7BPoNYE5 yCG6nt17L927OocVM0itvt/WlR20Ubr6RIFw6xXAUxbWhzv+CxY62UJgQuufSwr4RPLb Awyhk97E7sklmpTgsxCTkweWlKxP3NJMW5E93Itd4EFEI0WjCsUKL7bOM1M9ubnCL/YJ vz6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aJ2TCnIq; 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 c18-20020ac85a92000000b004135f9ae6c0si1231942qtc.660.2023.09.14.10.45.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2023 10:45:54 -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=aJ2TCnIq; 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 1qgqOW-0000ib-No; Thu, 14 Sep 2023 13:44:48 -0400 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 1qgqOS-0000dP-6F for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:44 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgqOQ-0006zD-CA for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:43 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68fbd31d9ddso1018252b3a.0 for ; Thu, 14 Sep 2023 10:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694713480; x=1695318280; darn=nongnu.org; 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=eZFByCfKGTADNtDGu95XjFmCXbCT1Szs+6S6uuZ78J4=; b=aJ2TCnIqdgdKBlXsY6BgfJM5a5tRHfQyDBtlTEtro2qgmK4sFS99BCYIz6Se66tDUB kxH7jjoVaH8oyUQxsEVcqxeT0UJmnXLFaZbraufmLKCcr7LWaUEixz1X1JBvJbL/YRUm 0hBybyshnx09YXhp3IIXGWVi1BjlZ6V5QyzPB4PwFJ6dxSXn7czHsSf0tmB3TaekSFZX p0dnuDf5AYg5IhST8++/6lYG+g8/fi5DJGur8+RJbmgfuIN9QNPTZGElc3ZEc26scKA7 xJZ0U21ie8t3Qci+rqa3DVhuqFeoBr0w8bC5vJOmnJbV5Odb7u2gVCPIe0vcD5k+nwAz XczA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694713480; x=1695318280; 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=eZFByCfKGTADNtDGu95XjFmCXbCT1Szs+6S6uuZ78J4=; b=c74Y4riWiKgCQa0NauIrjXhEhHmc4E8FGSQ550l/wIUEhFSQ6VwfKKqnFfVq8lKro9 cZhERgG32JnAb+uH6VQ4SRHF+fY5xqBanMjPy1i76kFlr7W/261xxu7f6CtpJbrQHPQD Iwd81CW1QblledNvdhB//qiRGk2SgOer5tzaVBDDJY9bhzzkizXO98/edd9ZUhp9ee/n 7ToVgYwm7dGFOsFB9EQ6jyoqXW9tdhDVFxA7N5XJngWnBxfqeqFop/KMdmYMqLNfLyAg TgQoBQMrLDOYs0/Jcn9wN7nD+ZsFLh0pv4sMoP99MiUjxqb1ErPJ+yPY0KOXToS/G0Zc QawA== X-Gm-Message-State: AOJu0Yy5bZcNdwTUaZwyoNYvDvy9def3Vox/YY/yKPIQFLkFMHnB2P+z sqBaZwSxwX7kPovXl9LE38An6uhVRMzvT4bnBDw= X-Received: by 2002:a05:6a00:b93:b0:68a:4bef:5f9a with SMTP id g19-20020a056a000b9300b0068a4bef5f9amr8350146pfj.0.1694713480628; Thu, 14 Sep 2023 10:44:40 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id w17-20020aa78591000000b0068c5bd3c3b4sm1588933pfn.206.2023.09.14.10.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:44:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 3/6] accel/tcg: Track current value of can_do_io in the TB Date: Thu, 14 Sep 2023 10:44:33 -0700 Message-Id: <20230914174436.1597356-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914174436.1597356-1-richard.henderson@linaro.org> References: <20230914174436.1597356-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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 Simplify translator_io_start by recording the current known value of can_do_io within DisasContextBase. Signed-off-by: Richard Henderson --- include/exec/translator.h | 2 ++ accel/tcg/translator.c | 31 ++++++++++++++----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/exec/translator.h b/include/exec/translator.h index 4e17c4f401..9d9e980819 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -72,6 +72,7 @@ typedef enum DisasJumpType { * @num_insns: Number of translated instructions (including current). * @max_insns: Maximum number of instructions to be translated in this TB. * @singlestep_enabled: "Hardware" single stepping enabled. + * @saved_can_do_io: Known value of cpu->neg.can_do_io, or -1 for unknown. * * Architecture-agnostic disassembly context. */ @@ -83,6 +84,7 @@ typedef struct DisasContextBase { int num_insns; int max_insns; bool singlestep_enabled; + int8_t saved_can_do_io; void *host_addr[2]; } DisasContextBase; diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index b6ab9f3d33..850d82e26f 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -16,11 +16,14 @@ #include "tcg/tcg-op-common.h" #include "internal.h" -static void gen_io_start(void) +static void set_can_do_io(DisasContextBase *db, bool val) { - tcg_gen_st_i32(tcg_constant_i32(1), cpu_env, - offsetof(ArchCPU, parent_obj.can_do_io) - - offsetof(ArchCPU, env)); + if (db->saved_can_do_io != val) { + db->saved_can_do_io = val; + tcg_gen_st_i32(tcg_constant_i32(val), cpu_env, + offsetof(ArchCPU, parent_obj.can_do_io) - + offsetof(ArchCPU, env)); + } } bool translator_io_start(DisasContextBase *db) @@ -30,12 +33,8 @@ bool translator_io_start(DisasContextBase *db) if (!(cflags & CF_USE_ICOUNT)) { return false; } - if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) { - /* Already started in translator_loop. */ - return true; - } - gen_io_start(); + set_can_do_io(db, true); /* * Ensure that this instruction will be the last in the TB. @@ -47,7 +46,7 @@ bool translator_io_start(DisasContextBase *db) return true; } -static TCGOp *gen_tb_start(uint32_t cflags) +static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) { TCGv_i32 count = NULL; TCGOp *icount_start_insn = NULL; @@ -91,12 +90,9 @@ static TCGOp *gen_tb_start(uint32_t cflags) * cpu->can_do_io is cleared automatically here at the beginning of * each translation block. The cost is minimal and only paid for * -icount, plus it would be very easy to forget doing it in the - * translator. Doing it here means we don't need a gen_io_end() to - * go with gen_io_start(). + * translator. */ - tcg_gen_st_i32(tcg_constant_i32(0), cpu_env, - offsetof(ArchCPU, parent_obj.can_do_io) - - offsetof(ArchCPU, env)); + set_can_do_io(db, false); } return icount_start_insn; @@ -147,6 +143,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, db->num_insns = 0; db->max_insns = *max_insns; db->singlestep_enabled = cflags & CF_SINGLE_STEP; + db->saved_can_do_io = -1; db->host_addr[0] = host_pc; db->host_addr[1] = NULL; @@ -154,7 +151,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ /* Start translating. */ - icount_start_insn = gen_tb_start(cflags); + icount_start_insn = gen_tb_start(db, cflags); ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ @@ -181,7 +178,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, the next instruction. */ if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) { /* Accept I/O on the last instruction. */ - gen_io_start(); + set_can_do_io(db, true); } ops->translate_insn(db, cpu); From patchwork Thu Sep 14 17:44:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 722577 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp527845wro; Thu, 14 Sep 2023 10:46:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHf/SXSHUZepXIad4YOb91QjY8jx7DqQxSgzmCRspk17IpiwB422DnyOP67CYIjSfnBZw+W X-Received: by 2002:a05:620a:1aa9:b0:76c:e0c5:2f6c with SMTP id bl41-20020a05620a1aa900b0076ce0c52f6cmr7184041qkb.38.1694713574932; Thu, 14 Sep 2023 10:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713574; cv=none; d=google.com; s=arc-20160816; b=tQlt/34pq/H4PvOzgzH/ncJIBxD74GxNBpydwau4CfK9QnGh6bBxc+8KtoQam2BU4W gMB6l7JHNTzR9Vjy7g6WA98/VY69LGC6uHdiHolRa1P73ziJXby8Y4NLf+j4BGEwqBMc 0v3gKYD3yxvQsgZHYX3V43PPCvdAA8Ls73EjnNEq5rQ+yx3vGM/sMY31KHk8WRsHK7Me zy5jcZBamj+8bKOkO6SOOxrlfCRyXmea/Z08BR/lBxbfrdpM2XVlBbbTKuBa7va3194B vh4uqxUrnrGB5qUJ0jB9oX8a84+AZdFzRlR3B6oCjWAXgoOsRfpIyZusd9CnomWsY2F/ g+Ug== 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=Sa7/YS9CoqDQehByb25wHU0vdLROTPpiwafKH90tB9I=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=gQjY6ct4t8nUtjBAukBcbzMNS1TNs3/EvLT9Jk86V+36980JQZu4EpR/9eGltoc48w zBjD73QkKpXNSwX0Kcg6aVZdijOPCJ+0CfxKNMrXacRN4LZvGaLoGZsnudutaDpywQ2L ppCx13DPRGR7kScCtWSWjSDqe0QGZ+5OdcFFCUEEd1HkAAyVgtioSQuqJgqQqyT8y00c dNKegddra37dlEJ4Dw8rxyN8ROWF3ruIEX/OC8SqGWEtnNyZWHrIpHndas6U+OfnqOCY vCgRa+rvKHexsfn819KIRK3FbWj3XelTHNX/X7DMnjnSXytzL/GZequyclIfwBvENpGD oRmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kmMCnoq5; 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 bq19-20020a05620a469300b00773a83f4736si634014qkb.585.2023.09.14.10.46.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2023 10:46:14 -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=kmMCnoq5; 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 1qgqOY-0000jt-PP; Thu, 14 Sep 2023 13:44:50 -0400 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 1qgqOT-0000eo-TR for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:45 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgqOR-0006zu-7F for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:44 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68fbd5cd0ceso1010345b3a.1 for ; Thu, 14 Sep 2023 10:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694713482; x=1695318282; darn=nongnu.org; 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=Sa7/YS9CoqDQehByb25wHU0vdLROTPpiwafKH90tB9I=; b=kmMCnoq5aucO6SfslxSP2dVjrPoq5jPfshQJtjSpx/q3UYnx6GMqKlSQSRqyP97zEh XayUnuh9sQs7gXI54nkZJfHOgG7ibYFUwdGqQordUhN2uMrK8pPCTuGhIVn7T6vuc14W qcW0Kk/E5do5uP5g2IcraEccqsq1xQXetzWzAvLJrwN7oyIr5ANSa0hiGGCqhyITJA9X Muaay8fR892yGziG2/sNwDJc/jSMIhcgLU2n81ONqLJ2a9C0TUMeK4TpjUxfOvOoWtBZ jMJg5hv91jFK89yAbGoe6B1v5EqPT1v1F8w2fliDdrvIgEIr0SCI1cf7BwogvEZY3Zkc kSuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694713482; x=1695318282; 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=Sa7/YS9CoqDQehByb25wHU0vdLROTPpiwafKH90tB9I=; b=IXX0TwJAjqeeUIQZ5qRRbzdZZRn8PBuSqCGK5jDDVokBzeiIdVfw/kqrFvTAG7ByOA 0ido7mERxReZuVmxbEXjbrBW4COrhodH6orct+PGeAmk34AdngcnyD+7yzM/5DQ6meSf +7fe4Upk3PxgQ0jzz6hxBsmXFmwg1B6E6ScUqLhS/RY3omsc01G3ZhliVALsnL0TIb8i IKfkwkIWqCQqYaooIdMUruU76BGnWkwFy++JTU46AAFPj+OsSOR5f2tGkwhm8ZCme6Qf B7h2bQIpvdeo6+qqJi2ycjRrysdDqwwBr5ZaupCRKL9csU+dpzGmdiv8KMsy1ilI6OYs a+Tw== X-Gm-Message-State: AOJu0YyWfgsc+lfqTxWaI5zyEik5PF4RmPJtltlK1xTHwyiGEd6IxS5d q9sF7LAZMz7MIIYEyt8/Bi7lFgAJkYwDQe0UX4w= X-Received: by 2002:a05:6a21:3d85:b0:131:a21:9f96 with SMTP id bj5-20020a056a213d8500b001310a219f96mr5571738pzc.6.1694713481744; Thu, 14 Sep 2023 10:44:41 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id w17-20020aa78591000000b0068c5bd3c3b4sm1588933pfn.206.2023.09.14.10.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:44:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 4/6] accel/tcg: Improve setting of can_do_io at start of TB Date: Thu, 14 Sep 2023 10:44:34 -0700 Message-Id: <20230914174436.1597356-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914174436.1597356-1-richard.henderson@linaro.org> References: <20230914174436.1597356-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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 Initialize can_do_io to true if this the TB has CF_LAST_IO and will consist of a single instruction. This avoids a set to 0 followed immediately by a set to 1. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/translator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 850d82e26f..dd507cd471 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -87,12 +87,12 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) offsetof(ArchCPU, neg.icount_decr.u16.low) - offsetof(ArchCPU, env)); /* - * cpu->can_do_io is cleared automatically here at the beginning of + * cpu->can_do_io is set automatically here at the beginning of * each translation block. The cost is minimal and only paid for * -icount, plus it would be very easy to forget doing it in the * translator. */ - set_can_do_io(db, false); + set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO)); } return icount_start_insn; From patchwork Thu Sep 14 17:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 722576 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp527712wro; Thu, 14 Sep 2023 10:45:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEpzB5V8EwiJBKFgJq9/xa0MKWc4cG8VFmzd3iUrkFBGAYb7sM1Al3P/5rreJi+zEPwYGo X-Received: by 2002:a05:620a:2907:b0:76f:a86:65bd with SMTP id m7-20020a05620a290700b0076f0a8665bdmr7901186qkp.53.1694713556982; Thu, 14 Sep 2023 10:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713556; cv=none; d=google.com; s=arc-20160816; b=whK0nQL8SfNPLlgQ8P2dGHNBgxuYyLQ1eAX6kc4alaTcx4T5g1+uBFu48tQrRQNlZM NO0OrHWNBrp7it0xGSJbQWdjXOQM7SPtOPT1lrJwBXpbY7UMK5fZPbraK0Iw9eSHEjoY 9PqqEDS9No248G8xt68qR1lBOuEi1q81rohZNFYw49jmksVuI/Be14t7tFTnNDn3NNk/ y0QjlYba6z/8G8sKDWyR2ydyg3zldtvXy5bGHJ1+fEpStZV3Gz6PanWoMSJkl7YQSx/q LQslv9OTbbRlcd7dzCNvfo3uZTJI1cAiBrT/KHzVrTcqXIoLSOL+h+/c763muhejYke5 fT0Q== 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=8PvdEJV3jhqsKSWl/RxX9U8TRziNTQDBkGzBSJuHzFo=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=mntWpDqfUkZ3rerFCyADLGR/8w4gMwsXnxwLrzecqc2jQ7CcE5T4K89htflKsJ+jHB VN4LI22iiJtOxT4HVaUsDyfojTEOknntRfMRj3YR39rtgLquHa2PhfOQPG8TEw1Axwrp ufxV+a+FXY4xsXtxQm5RAcwwvxo1PJI61Jc7yjLj18eIAsM23itaGSNkOy2kfgMTXJfp UnNWpM8OIUd+dZKqiAIOE0CTqbRcU6ML6li8WqSVz3XSZTcaNreGx5Rx1LTJUoqgeciR 1YSdNnk0Cc5iGPGivxDsWJJmd0tsMF1mPq9l9FXsL53IC0zLSVD2sj4M8Yz1/L/SfsuC mImA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oE8Z0mf6; 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 b17-20020a05620a04f100b00770728e885bsi1194092qkh.316.2023.09.14.10.45.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2023 10:45: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=oE8Z0mf6; 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 1qgqOZ-0000kw-DE; Thu, 14 Sep 2023 13:44:51 -0400 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 1qgqOV-0000fW-5q for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:47 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgqOS-00070L-1j for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:46 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68a3ced3ec6so1114565b3a.1 for ; Thu, 14 Sep 2023 10:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694713482; x=1695318282; darn=nongnu.org; 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=8PvdEJV3jhqsKSWl/RxX9U8TRziNTQDBkGzBSJuHzFo=; b=oE8Z0mf6l+c1eGu4vpXVRgO9kLwQVxzGGS5q7Zc03PDV98VDZs5NlYAgmyOvfVEFXp M97SswfZ1pkofCUqdLXTEkkt0B0s0J0Bs1LwZjR1kAA8ZTyJVRsu5FGRm+6FJJWkTJg8 BgZ/Rhm4lywot/fe1BLcwzHsd2Vv2+fLCOJuLQEKvfKYFq/Pn83PUv+5b2bh37WkX9Zr uyRSaQJhIxPAYLGmY09uPh0j+mdaeked7DL+tTNF2njuvHspgvKUqFS1HY4s4PisACc/ fLDCI9sTZVH1T7B/vkf6JBv2Nlks2lEJl2V+kfCw+C0hY5RxYQq+l5vQT/5byq65vlDh whiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694713482; x=1695318282; 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=8PvdEJV3jhqsKSWl/RxX9U8TRziNTQDBkGzBSJuHzFo=; b=lrrDog9jjQNeuMLpE5GtdzzlIHV86pfXPYWj0Xw1G0V3yW/nYo1E2BhdMwAk4Hlh3H PcZpSgrlE9a7mkkyj/P4lCw/cr9LnBA1zAq2utnTPtAywSVQ4niPQ13/SlzB4G3tP0RG y0wgXO+12Ewsu17eM6k/Xz+KbLpU21qU7i7WUJL3y3Jqm90LVkQ/FL4z0Dzu2XF7ASOD PKK3FkK/HD4xKQkuzsNmwFRXBR0jg0zUBZMU7pmArrbLtAWzuqBhY/HJo/9IykLl/YQH GPGtNvdi7zxLsfEeNW+xxz7pHKkpfTOwR4ipcCC5CBhiOg+bm0iQLSWXifr4HeXzhoBY VGUA== X-Gm-Message-State: AOJu0Yzn+uL9R6YD8CLa9fF06KWQm3QsqjWJN6Q54Qyjkm0qAy2BrQe4 o37PIkjTKlbYIDYqhjHWDJRAz+5ygXHjchtMBKk= X-Received: by 2002:a05:6a21:6d84:b0:132:a85f:b20c with SMTP id wl4-20020a056a216d8400b00132a85fb20cmr7422194pzb.38.1694713482655; Thu, 14 Sep 2023 10:44:42 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id w17-20020aa78591000000b0068c5bd3c3b4sm1588933pfn.206.2023.09.14.10.44.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:44:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 5/6] accel/tcg: Always set CF_LAST_IO with CF_NOIRQ Date: Thu, 14 Sep 2023 10:44:35 -0700 Message-Id: <20230914174436.1597356-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914174436.1597356-1-richard.henderson@linaro.org> References: <20230914174436.1597356-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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 Without this we can get see loops through cpu_io_recompile, in which the cpu makes no progress. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/cpu-exec.c | 2 +- accel/tcg/tb-maint.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index e2c494e75e..c724e8b6f1 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -720,7 +720,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) { /* Execute just one insn to trigger exception pending in the log */ cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT) - | CF_NOIRQ | 1; + | CF_LAST_IO | CF_NOIRQ | 1; } #endif return false; diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 32ae8af61c..0c3e227409 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -1083,7 +1083,8 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc) if (current_tb_modified) { /* Force execution of one insn next time. */ CPUState *cpu = current_cpu; - cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); + cpu->cflags_next_tb = + 1 | CF_LAST_IO | CF_NOIRQ | curr_cflags(current_cpu); return true; } return false; @@ -1153,7 +1154,8 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, if (current_tb_modified) { page_collection_unlock(pages); /* Force execution of one insn next time. */ - current_cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); + current_cpu->cflags_next_tb = + 1 | CF_LAST_IO | CF_NOIRQ | curr_cflags(current_cpu); mmap_unlock(); cpu_loop_exit_noexc(current_cpu); } From patchwork Thu Sep 14 17:44:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 722578 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp527858wro; Thu, 14 Sep 2023 10:46:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFz+PfGB/Q+tmuPbG8dglu9m/Kc9gCITWpG16ZpZowrV3nUHUtRK6Kc4jD1oGEUV+3R+UoG X-Received: by 2002:a05:620a:cc8:b0:767:b196:e88 with SMTP id b8-20020a05620a0cc800b00767b1960e88mr5129681qkj.42.1694713577590; Thu, 14 Sep 2023 10:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713577; cv=none; d=google.com; s=arc-20160816; b=f98aWfyH727Azdrgh6HzwfuxAKcaeZY4qa90eT38TWwJrJYlbL/JEGWTSYPi8XSxce UJjCYVaj7C6E48mC1E114yONQPwm8EDtd7YR0DK1xrNHs2fZKO65f/GqM7ctn5yLY25J 3iiIbfmNIdZAkWUcDoaa/X9Z9SgwUibpYWLyWOVrM7igNZi3J8A32R+j03n6FfHdc5DW tSGdMTZ098V8K85jc7SQg/LS86d7hJ4BD3D655+8fow+4qJBiym2EESB/9eQoLcntYjw Ooc8s+anqY4Ps8bEN2eDDSLJyMHlugG7HRYj19NGRcH86oI8AX4QCh8TRxZpYTTaMOQc nL8g== 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=V3EVonE9eg3BvfVh3vmTdOCW0800wHk+spI7M9DnBuQ=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=ItuQHkICw+mxqMQNsOC/VUvLZDuC7614QWD2IlR17ITiIPCwTuEYJNyth5ryD3Vnfz LXM9lxcRtncOS93oKLxfazEdM+7eYlRcL6fVenui4XTkioHczH07tuPenvYedbCsSBDr cw+V2NUA1SAJJZ2oWADlgASpWlfa/Hs4Tg5bl8KKyIkAK59MEtmJbw+xj9SUNOyMyXgu nUCPQVqh3tmgYgwiMmxHYrwlx8YtfN6YBlwQTr5QdOPov3drKoXhxdsTq5xoIjYr8nEC vU9s2d+3wSNr40OA7KGvfYDC9dYbqahrTtN5xv0uSu/oDe/Y1Acd2vJTKjnPHgKKFV0Y KPiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZZp/rgAH"; 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 j11-20020a05620a288b00b0076da43af035si1231489qkp.733.2023.09.14.10.46.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2023 10:46:17 -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="ZZp/rgAH"; 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 1qgqOY-0000jM-6x; Thu, 14 Sep 2023 13:44:50 -0400 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 1qgqOV-0000hJ-Gt for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:47 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgqOT-00070k-Lc for qemu-devel@nongnu.org; Thu, 14 Sep 2023 13:44:47 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-68fc9a4ebe9so1101030b3a.2 for ; Thu, 14 Sep 2023 10:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694713484; x=1695318284; darn=nongnu.org; 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=V3EVonE9eg3BvfVh3vmTdOCW0800wHk+spI7M9DnBuQ=; b=ZZp/rgAH9B3AR3Ht6cfoY0zEF+7PypQMQfFiT3h8rbpfNOUGiIM+0uwfX9C11nIgKv xQNI7Rrl2rsXLBMLZor4TgYzNxgf7RzywpfSS69KHvO2FWH4eSdYTR5gr36tpLZhMxw/ rDoCBf+c0I3ZalhjkqtnO5gpad35RuZzlRZj+MAElhrRoVhL7TV3LYnDNpFYKFc4gw41 vOyA3kLF9VaPYXWn+VQ76+v2GHH9MSYO8eGG6/qLY54zQw8QuIgHMcBFhU+gEGYoMPCw AJMVUGQ6jhuexh0APuRDOXPkYluL8V1VXKnuoUA4djEmmn7bElrUukKIdxpLOM9kwY0/ pvhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694713484; x=1695318284; 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=V3EVonE9eg3BvfVh3vmTdOCW0800wHk+spI7M9DnBuQ=; b=hzIa0uB0AY/BD350/aBDsXTC7IbT0/k5WuhwL/qor1hfstN6gHpGAkc/HM/Y9fsI5O xuvpde3qR7lVo3ZoZhbFL5E/kwj8fuE3QbIg12psX3DnyDc0QnCJUbo8q/yVxqjD7eAw FwUPADAAZ6B9N4jW/mWwyJF8Ss1KRPCchx/IcuaFBkt1iF7WkNHKzGGhJcpLdwR7Y5qK cvQq2gq5itQJ0ppTKUVUZD7yEsV/LCyAgZ92I1waz/yteq+x9iOQP94b9ZUJuU5m1cKv 1hfC/lzkVYCkANcF866EGohFjqjlRh/VTOFAGjEcFHVGtY9Rhrmc1/kLhn50atLSa/N4 2B7A== X-Gm-Message-State: AOJu0YzSTPeaYaU1QYYghwbalogAtX20dt5gUKBuvCOOm5QD/xst9Pz5 t7CBjTfOLvsqOMCF+l4Qx1u7l4oRtFFiMhjXv5E= X-Received: by 2002:a05:6a00:998:b0:68e:2d9d:b0cc with SMTP id u24-20020a056a00099800b0068e2d9db0ccmr7487846pfg.6.1694713483670; Thu, 14 Sep 2023 10:44:43 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id w17-20020aa78591000000b0068c5bd3c3b4sm1588933pfn.206.2023.09.14.10.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:44:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 6/6] accel/tcg: Always require can_do_io Date: Thu, 14 Sep 2023 10:44:36 -0700 Message-Id: <20230914174436.1597356-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914174436.1597356-1-richard.henderson@linaro.org> References: <20230914174436.1597356-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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 Require i/o as the last insn of a TranslationBlock always, not only with icount. This is required for i/o that alters the address space, such as a pci config space write. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1866 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/translator.c | 20 +++++++------------- target/mips/tcg/translate.c | 1 - 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index dd507cd471..358214d526 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -28,12 +28,6 @@ static void set_can_do_io(DisasContextBase *db, bool val) bool translator_io_start(DisasContextBase *db) { - uint32_t cflags = tb_cflags(db->tb); - - if (!(cflags & CF_USE_ICOUNT)) { - return false; - } - set_can_do_io(db, true); /* @@ -86,15 +80,15 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) tcg_gen_st16_i32(count, cpu_env, offsetof(ArchCPU, neg.icount_decr.u16.low) - offsetof(ArchCPU, env)); - /* - * cpu->can_do_io is set automatically here at the beginning of - * each translation block. The cost is minimal and only paid for - * -icount, plus it would be very easy to forget doing it in the - * translator. - */ - set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO)); } + /* + * cpu->can_do_io is set automatically here at the beginning of + * each translation block. The cost is minimal, plus it would be + * very easy to forget doing it in the translator. + */ + set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO)); + return icount_start_insn; } diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index 9bb40f1849..593fc80458 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -11212,7 +11212,6 @@ static void gen_branch(DisasContext *ctx, int insn_bytes) /* Branches completion */ clear_branch_hflags(ctx); ctx->base.is_jmp = DISAS_NORETURN; - /* FIXME: Need to clear can_do_io. */ switch (proc_hflags & MIPS_HFLAG_BMASK_BASE) { case MIPS_HFLAG_FBNSLOT: gen_goto_tb(ctx, 0, ctx->base.pc_next + insn_bytes);