From nobody Mon Feb 9 17:39:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694713529; cv=none; d=zohomail.com; s=zohoarc; b=OgJ5OGeeST6iFmJ5lGnTbzrm9QFLYdswLzJyvOk985+WP/X32hBKib3vmGyp6WAbLkvqjfmM8yY29YuS1i1cBxZcVaPDGzJYnTkItr3G1S63MJ1A5coC5slWT2bjizXOHxxiJwvSWvfZVjiSQNy+pFNYxG2olI9LUtDpJlqOung= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694713529; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cb3D6IYlr6FrNnYuqfFzbMBO24dvl8EEYuTIpJQPqlk=; b=gyT1MZ/NMVr/vCCVjd+mJKAU/6+GVlHHr3FTDxw0SjsGCNuZZYrAboFKkqLefHYQDJQvDQt9kS5NIMQPJOepmpk0l22PM8Lj73b9iS5LsGNfFFvMCA/h8uBpQjOUKxVF6i/Nhe3V67LXe/yfqP2ZG+v4m29U1Kv8CDu/qXpMSpw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694713529546821.7053956218729; Thu, 14 Sep 2023 10:45:29 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFOU+jfh6IQkzwGl/6ZWU1AEHPpTtaU2bQ8YJ05YIdjEGbsbfEvPV4/t3UY4HUEgw0Gqm9RiA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694713530198100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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) =20 static TCGOp *gen_tb_start(uint32_t cflags) { - TCGv_i32 count =3D tcg_temp_new_i32(); + TCGv_i32 count =3D NULL; TCGOp *icount_start_insn =3D NULL; =20 - 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 =3D tcg_temp_new_i32(); + tcg_gen_ld_i32(count, cpu_env, + offsetof(ArchCPU, neg.icount_decr.u32) - + offsetof(ArchCPU, env)); + } =20 if (cflags & CF_USE_ICOUNT) { /* --=20 2.34.1 From nobody Mon Feb 9 17:39:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694713530; cv=none; d=zohomail.com; s=zohoarc; b=TYdhfJht/xZqU9FLoeXWUvQnKVMILlihdLquTUkFkV23K73O5et6QJlWnVtjxP+1nMXZr90OCsC+yWgOEUtxW5Vpq1524u5/hF+E+H6JCyHcmWm00hzFzWrfSn9Z9Vm6hUK1r+kMbf+uUmu2cEmRB+cm4jP6HH/8osYISqi4SqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694713530; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bgCEQn26u9cOavCqkRzqblhPRJruQuAIdfQLbzQ1zEg=; b=Akb8O+dYuMqq/4wqYdBGWXToMASmR81qcSNE6Rb2YI9DoVHKhQPAPDS5HNrQpWu/QExfbIwQCt44psl4nZcA2giG12lx+Iesr4W3paJ16WsibNdGXX2ieMFltyxFz1HofE51JAWTS4onQI9HpjjZtH7s1ZHE3hdsgZIhIosapSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694713530614158.64554182194365; Thu, 14 Sep 2023 10:45:30 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IHs6QF5maY85m/NSmUxFqQjf0h7LvQOjIt5eFOBrpMhn3jeouSEH/f5MYGg+PBoMw5ids8i2g== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694713532140100005 Content-Type: text/plain; charset="utf-8" The condition checked is loop invariant; check it only once. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D=3D DISAS_NEXT); /* no early exit */ =20 - plugin_enabled =3D 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 =3D plugin_gen_tb_start(cpu, db, true); + } else { + plugin_enabled =3D plugin_gen_tb_start(cpu, db, false); + } =20 while (true) { *max_insns =3D ++db->num_insns; @@ -176,12 +182,8 @@ void translator_loop(CPUState *cpu, TranslationBlock *= tb, int *max_insns, if (db->num_insns =3D=3D 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); =20 /* * We can't instrument after instructions that change control --=20 2.34.1 From nobody Mon Feb 9 17:39:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694713555; cv=none; d=zohomail.com; s=zohoarc; b=NBOQLOelAnS6jh72+Ql0IxrOx1oOhmZjIiG7kTFQ0Ut4OarinNJLIgYnV/M0sC8uZiVeRy2SlFQ9Q8Jsi8+sfXoya7SUoNtwP0RsdoDqjpzfmWwb4pOqdrepSG9AQLx3akwrFrCodCspqw+hZijz9CqC5VNKzdqHStxSquXC3Fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694713555; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eZFByCfKGTADNtDGu95XjFmCXbCT1Szs+6S6uuZ78J4=; b=KWWqzIeQgAajrppjFNfFXbpaVtHlxWdB0WIW2MRP+gJ1/YXtkosoxQ8XYwSmnjbtDO0w2TkcaozJ8c9L977FwrGM3Yjc0iKsu6a3+R+SvWFOZ+jJH6YeGP0V4/FwinPHoTyj/BVPMHlR2z/2//gLft1vZES+N9uN12HQUOJ84JE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694713555657777.669175476793; Thu, 14 Sep 2023 10:45:55 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IG7LNAwj/t8/b7pgfB7EumylPewmHV+jHtGMFKPu9w+7fu01B2Nti2vMcsxJKGZ7UY9lCK31w== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694713557764100003 Content-Type: text/plain; charset="utf-8" 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; =20 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" =20 -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 !=3D val) { + db->saved_can_do_io =3D val; + tcg_gen_st_i32(tcg_constant_i32(val), cpu_env, + offsetof(ArchCPU, parent_obj.can_do_io) - + offsetof(ArchCPU, env)); + } } =20 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 =3D=3D db->max_insns && (cflags & CF_LAST_IO)) { - /* Already started in translator_loop. */ - return true; - } =20 - gen_io_start(); + set_can_do_io(db, true); =20 /* * Ensure that this instruction will be the last in the TB. @@ -47,7 +46,7 @@ bool translator_io_start(DisasContextBase *db) return true; } =20 -static TCGOp *gen_tb_start(uint32_t cflags) +static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) { TCGv_i32 count =3D NULL; TCGOp *icount_start_insn =3D 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); } =20 return icount_start_insn; @@ -147,6 +143,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *t= b, int *max_insns, db->num_insns =3D 0; db->max_insns =3D *max_insns; db->singlestep_enabled =3D cflags & CF_SINGLE_STEP; + db->saved_can_do_io =3D -1; db->host_addr[0] =3D host_pc; db->host_addr[1] =3D NULL; =20 @@ -154,7 +151,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *t= b, int *max_insns, tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit */ =20 /* Start translating. */ - icount_start_insn =3D gen_tb_start(cflags); + icount_start_insn =3D gen_tb_start(db, cflags); ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit */ =20 @@ -181,7 +178,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *t= b, int *max_insns, the next instruction. */ if (db->num_insns =3D=3D 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); =20 --=20 2.34.1 From nobody Mon Feb 9 17:39:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694713575; cv=none; d=zohomail.com; s=zohoarc; b=ZpUlIAaUkRNcv9YYUDi+MqXCYRK0BnCGz4fS2y1zMRqOnqOiCUHs1PbwQiOPtFe/rYY8pHTIte8BOvinw9wlvR5oU6W3EaZ/fB/spDqlT0k05wyhWklPytvdX/Lr/mRMFPAGHNi4qc78E6z7RC7Ae2DtBTkRgffj1BXMSzvH7NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694713575; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sa7/YS9CoqDQehByb25wHU0vdLROTPpiwafKH90tB9I=; b=CnvjsmJAiw748z/IvBwEYYuHI7/3MnRsGwvqB0F+vK6HeL4WPZ8p7+oWMKlUjfEcKoWEIPvfVrF01iKItep+vqnovcvPSvTqsdcI6B/L3590KvlYCFVCwPdVwUGYLmqmS68hy2YkRutOuuxVQ2KaxHoz4Y3DY+UWaUZOmkJTQq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694713575190310.1145211147075; Thu, 14 Sep 2023 10:46:15 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IG94+fKOKuWBscpNIqXfaX3HtAgXM5tW3T7TwtTKJdlRYE6Tf2id+BxThzJP+Y1EBF74QbCJQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694713577281100003 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 =3D=3D 1 && (cflags & CF_LAST_IO)); } =20 return icount_start_insn; --=20 2.34.1 From nobody Mon Feb 9 17:39:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694713557; cv=none; d=zohomail.com; s=zohoarc; b=kfwXD3Cbc6jnOXSXDOTELJjnMrPJL9HGCUsXClnZx6QYY8uZHUN1tdB2Ujz0LCV3l6wV7VDXwF6BHdQCkj1HmepHRG5g5FLwjQKrZgVJx4uJsKgRC8Ec1UelEeAqVZ9x9TJZNynS/HlAaDkRTCdiXSb6oDFtNRjOdVqDXUR2opc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694713557; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8PvdEJV3jhqsKSWl/RxX9U8TRziNTQDBkGzBSJuHzFo=; b=m9y/uwacZXfxCmDBFSeT9aZIr+LojkPL45SKWizNYzQCQbyQnN+PuBEnBKoOtSZnfMmPNljOmF4MohXNP0zeN+JJ0NW1BTFnaFDzBT2vFyyFMFz4pVPfYDJs1BswLhNCEB3ZLGc8ws/llsABGVhRfXE6tGzqRgCE2RxN3kCLD30= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694713557387977.5323977097788; Thu, 14 Sep 2023 10:45:57 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IHJPEKTUUKcc7vPH+EHU5DIsAZsiYa2FJeLuNK/Od/4/7CssrY1DUavJ6i/448KZ1wtUYgbKg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694713557879100005 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 =3D= =3D 0) { /* Execute just one insn to trigger exception pending in the l= og */ cpu->cflags_next_tb =3D (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 ad= dr, uintptr_t pc) if (current_tb_modified) { /* Force execution of one insn next time. */ CPUState *cpu =3D current_cpu; - cpu->cflags_next_tb =3D 1 | CF_NOIRQ | curr_cflags(current_cpu); + cpu->cflags_next_tb =3D + 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_col= lection *pages, if (current_tb_modified) { page_collection_unlock(pages); /* Force execution of one insn next time. */ - current_cpu->cflags_next_tb =3D 1 | CF_NOIRQ | curr_cflags(current= _cpu); + current_cpu->cflags_next_tb =3D + 1 | CF_LAST_IO | CF_NOIRQ | curr_cflags(current_cpu); mmap_unlock(); cpu_loop_exit_noexc(current_cpu); } --=20 2.34.1 From nobody Mon Feb 9 17:39:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694713577; cv=none; d=zohomail.com; s=zohoarc; b=B2HLfNZy08OBBCrSe+63QdpO00QJrNTLIEO9KhABsoE5I2LJE4Qo6U670bo2Wzgw1KI9JhNL44ioPAmTIMW7DezU84zXV+E8lQTOUe9R3GSkH1Gpd4aejbCms3xzm01N74yXFownDDqYp68IUq7JgVJ340BKVGElmoBr9jvkPSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694713577; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V3EVonE9eg3BvfVh3vmTdOCW0800wHk+spI7M9DnBuQ=; b=Ul9f0JtBxHA8ET7j+XIFmZXiglJgFnq6RAClhDpmgKX2V0TRdDzggy2sCxpfUlkoBiB9EHHE9GtgChNogBNUGBR4PjZipfcTCzGj6sor9taDLwHY0C/LzP9dsyw4plbA8pgjmUSkyyzNan+JrMFFotai+5vpijvqAjFlZhR+0uE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694713577881807.0592963252698; Thu, 14 Sep 2023 10:46:17 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGe4Jg7kZH4CxDUbvq4+axBoeQIfi0TXRKzVr0LlH081zNQ4T4gN6El7NR4PiP+RmfEk1N85g== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694713580168100007 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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) =20 bool translator_io_start(DisasContextBase *db) { - uint32_t cflags =3D tb_cflags(db->tb); - - if (!(cflags & CF_USE_ICOUNT)) { - return false; - } - set_can_do_io(db, true); =20 /* @@ -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 =3D=3D 1 && (cflags & CF_LAST_IO)); } =20 + /* + * 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 =3D=3D 1 && (cflags & CF_LAST_IO)); + return icount_start_insn; } =20 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 =3D 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); --=20 2.34.1