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: 1834365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=la3VoVzm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rml8p535mz1yhd for ; Fri, 15 Sep 2023 03:45:30 +1000 (AEST) 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-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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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: 1834366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=MDiFtmxG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rml8q49wxz1yhn for ; Fri, 15 Sep 2023 03:45:31 +1000 (AEST) 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-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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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: 1834367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=aJ2TCnIq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rml9H2755z1yhd for ; Fri, 15 Sep 2023 03:45:55 +1000 (AEST) 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-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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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: 1834369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=kmMCnoq5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rml9g6Mk8z1yhd for ; Fri, 15 Sep 2023 03:46:15 +1000 (AEST) 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-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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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: 1834368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=oE8Z0mf6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rml9L1kqhz1yhd for ; Fri, 15 Sep 2023 03:45:58 +1000 (AEST) 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-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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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: 1834370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZZp/rgAH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rml9k4WYtz1yhd for ; Fri, 15 Sep 2023 03:46:18 +1000 (AEST) 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-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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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);