From patchwork Thu Sep 28 19:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1840988 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=cmV4NsvX; 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 4RxP5j3CxJz1yp8 for ; Fri, 29 Sep 2023 05:42:49 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlwth-0007vn-M1; Thu, 28 Sep 2023 15:42:05 -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 1qlwtg-0007v5-OE for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:04 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlwtc-0007wN-Rt for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:04 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-690f7bf73ddso10547874b3a.2 for ; Thu, 28 Sep 2023 12:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695930119; x=1696534919; 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=Ujd1qr2cxmKKRJwbJe5azKA+HhGSxwUyFcBo+rqU3b0=; b=cmV4NsvXiGgLTljIM7wkEpTpK2Z9OsvPYWoGK2qFUL3ncyjfHC8vE8vnFrV30+Lym/ UvYXzuG8q4g6Gxq1tSYf8cpwQjcg5Yp0xWNxc++v4g+vuwNqZSSTxfHPHehvpW/Hx8NX XlqRZA7r6TE/eH6JrVhiuBh8wkzHhL0Jaj8cEXMzxU4GCABJNZZ48kvl9QoU15MAj1zH KT/llk5TWB7jY7PHlkzZ4xe50UGZDfvg7Ibv8rk7yXmxKigvDUryAY20shUoEkt16EDo NXQ0KPrA85jnEAgEVoJ9VttLfL9ZPoCNbc/TRaaBqzLDSIUJGqqv2YWxK5CTYcDy9mxF JlTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695930119; x=1696534919; 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=Ujd1qr2cxmKKRJwbJe5azKA+HhGSxwUyFcBo+rqU3b0=; b=t/h3y//F8Gw79DDTdkXHJ0wiwLvYvPIxBIDEADD9JfXoxrjGkhRH+tP8gvepXs9vVG LP0+VsN15L+NcztOaRHv+mKe7S4dPwG0Y2afTkBjqPAh4pJY69MfwYGnlOG3N4a6K+JO EYYOjQcaCkJFFiR+zxWR0dsj4L2lssmdYTp+DfZgytwhfZYIo4082osNZc8CwTdRYZBp 1ga25FmVeHSUbVG+B5EUXY8sxOP4y7Dwb0ZzaJySwJsgABrCForflHkeSuO0L18RF/dw FCjsDU3t15gPgXAO8Mpy3FMgmpKmnaGiLm9qkdgGylyy5R9leaFAxiTgfCmFqRGi1b5R 74EQ== X-Gm-Message-State: AOJu0YxnpzzxCkbd5hgrBoi+Q5RnMmzj6i583tNQBQB58uDQpHL5cFfC yVFKJtaWpYmGOUMzP67td8eLvyWEvd3fRl8oBco= X-Google-Smtp-Source: AGHT+IH+FjCgA5xN5ce7l5TxvacmnNIsqQa4/i4qzf3sT6WhrTBK22z1AELw8arm9ZzZjtIdtvXHoQ== X-Received: by 2002:a05:6a20:1609:b0:14b:887a:6d70 with SMTP id l9-20020a056a20160900b0014b887a6d70mr2012330pzj.15.1695930119236; Thu, 28 Sep 2023 12:41:59 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id x23-20020a170902821700b001b80d399730sm15273450pln.242.2023.09.28.12.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 12:41:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 1/6] accel/tcg: Avoid load of icount_decr if unused Date: Thu, 28 Sep 2023 12:41:51 -0700 Message-Id: <20230928194156.237351-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928194156.237351-1-richard.henderson@linaro.org> References: <20230928194156.237351-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 28 19:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1840985 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=cOXsYqun; 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 4RxP5722z3z1ypN for ; Fri, 29 Sep 2023 05:42:19 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlwtg-0007vD-U8; Thu, 28 Sep 2023 15:42:04 -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 1qlwtf-0007u8-6z for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:03 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlwtd-0007xA-Cp for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:02 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c7373cff01so8387035ad.1 for ; Thu, 28 Sep 2023 12:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695930120; x=1696534920; 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=ytGH6JE+ydbRM4358s66cugltU3Ll2YBV5fZ6EN4mvI=; b=cOXsYquntGSuWYRIER0dO1tukNE4WgcsDV+B7wnkd95r3444QZTMYqoBX7bJA9cS+k OjmNFXVO38G+dt0//w6UbhpYYifwgVfnkuTPPOXCao9AM6REOS88m17/iQvWPL4TbXdy 0tqHqECBKOIQZpFdCfsbIcSKYxPbKLnbiUjtCqpO5wXZ6riO3oMqitkNXO1h0mxEigTF Hjwxa1CRh/yk/Sc3NuvC+p/ssS1XsaPmxiBzGbNkIeQw+iDCVIgmwy9CQ7v2r1UNoQDr qe+uzEZ5vYO6bZG8TOgwdKQUY8Ukg1v8rX9+aOhI4V8pOsYmnQMHm6s9PPAeiBqoSeCG WkFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695930120; x=1696534920; 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=ytGH6JE+ydbRM4358s66cugltU3Ll2YBV5fZ6EN4mvI=; b=k8Shncawt1k1MHF3RWbtFX3owi7ep1mYaaVZgI7YEjizTJKMATinIc2dXnAXxiZ+3J dmm7cVgfRzb9BqD4gTRFTg22dvtr682TD4buF4jeeU0tSo/tq0io0O/h4sMQypM5yIeq FXTkOr555CmBoifJ45ByxfWNcuI4ZtRBd0ItpGoArV1h4QEpjkA4kZOFdzt0sSzhrfWv cZWf6LI08yFCvsiQ59t2Iu7IhvaknRQvLHIndxj/ZvTq3fTK8bjQ2Cmo16vIQNyfNaIq LGdzqYooDI2L4GfDd4clIGFPJtBhXRleUavwdx8lxCQpUmpFfYNYlKgyU9mofhJbCbGI SXDg== X-Gm-Message-State: AOJu0YwFiX6HkU0nlP0NDdFJFbJozZo8tF7fSSQ+jmb4A5xCd5daUN5j FTsbHI6chQLg9cAHUh/Ou82upFJe98peBup/XkY= X-Google-Smtp-Source: AGHT+IHpcUnZboLNERVX7ZGYu5YoOmQnCb52f7Pves3ocIKUEhPFPDZJFjJlFciJrRM8YrZsOUDVHA== X-Received: by 2002:a17:902:dad2:b0:1c7:2e8f:c3b5 with SMTP id q18-20020a170902dad200b001c72e8fc3b5mr3380815plx.20.1695930120071; Thu, 28 Sep 2023 12:42:00 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id x23-20020a170902821700b001b80d399730sm15273450pln.242.2023.09.28.12.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 12:41:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 2/6] accel/tcg: Hoist CF_MEMI_ONLY check outside translation loop Date: Thu, 28 Sep 2023 12:41:52 -0700 Message-Id: <20230928194156.237351-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928194156.237351-1-richard.henderson@linaro.org> References: <20230928194156.237351-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 28 19:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1840989 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=udjhRXya; 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 4RxP5t1FSSz1yp8 for ; Fri, 29 Sep 2023 05:42:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlwti-0007wG-I0; Thu, 28 Sep 2023 15:42:06 -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 1qlwtg-0007uV-C1 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:04 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlwte-0007xL-H3 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:04 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c63164a2b6so43963445ad.0 for ; Thu, 28 Sep 2023 12:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695930121; x=1696534921; 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=LstmnDMwNDQFVw3SQAKvu0MWGEv1hgOUR8OcXIkEB5k=; b=udjhRXyaR6+EP4YXXJSAjqxn94Wn/tjU0C4jbQYxmD8khm1rOBzeR3PUrsuJ02Hwq9 z47vMqZLm50ygMC06mYTOGER6MCYfYy7pnTPOn55yi3UqIzDwaVWvjep42S3Qu0mhZI7 2PQBBfJRHla986m2NQBRx9YRIFv5vyREJlGQsYDqZWo4Tb5AxV1ITDbIYeIX1tCPh9h6 KdceA81+HAxx4kKcMknIatTdsJfmDXbCqnxpiZqBksMZiHvQUVlvuItmrFtIMnmQWVdY bRIVUq4Y+1pyepANXpl0P6zA7ODuwzvr+bq75pjfnnbgOI9dfvOrVqecn7HGJNDqdB9Z odHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695930121; x=1696534921; 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=LstmnDMwNDQFVw3SQAKvu0MWGEv1hgOUR8OcXIkEB5k=; b=KtRu0IavGE+am+GhTJKmwXlV9wntXHDR5pIbuTFYP5wUXP8wgU2TOH+7gcji0s823J 0jRVMISY8npgdhitwmrqPWqzvuwrPvSXM7Q6I2BE9ng7UyJl33nbep7y+OamEiLja2Oz U946VSEorZwM1KJudqFiG8wDH+ye2+oaMIq0eERz0z1K7wWwhEuMpCC1If45OJXDaj6y 0X8vbGwW5aCpFDMH/99gadE8g8IRZ5ZvM+mN6pEcb5EIdlDtPKoCkSjTBBwo+L/4yPzb z4HNjW4kCV9CpN6AYSVuMqrmnLI2o7aiWLEeFFMHoDmvqZHgLICIt7nbRwfb1n/JwScJ zrog== X-Gm-Message-State: AOJu0YxXaGTxQzwehvwyFBZqjQiSJxIlndvrCb+A7W2emJueisA2JOFS 5nIGcQ6vb/4seDqV7pqQJTZ2EhHw8zv4ClywOMg= X-Google-Smtp-Source: AGHT+IGVeJgfXsbq/zF4oFQYIfEu2XzkxqVBSnzi/HtJPJ9San7nUweDj/qAujiuFs46Ote2ENVeRg== X-Received: by 2002:a17:902:e80e:b0:1c2:193e:1126 with SMTP id u14-20020a170902e80e00b001c2193e1126mr3180189plg.28.1695930120909; Thu, 28 Sep 2023 12:42:00 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id x23-20020a170902821700b001b80d399730sm15273450pln.242.2023.09.28.12.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 12:42:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 3/6] accel/tcg: Track current value of can_do_io in the TB Date: Thu, 28 Sep 2023 12:41:53 -0700 Message-Id: <20230928194156.237351-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928194156.237351-1-richard.henderson@linaro.org> References: <20230928194156.237351-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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. Reviewed-by: Philippe Mathieu-Daudé 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 28 19:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1840990 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=MIr6p1nz; 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 4RxP682Vpwz1yp8 for ; Fri, 29 Sep 2023 05:43:12 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlwtj-0007y4-LO; Thu, 28 Sep 2023 15:42:07 -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 1qlwti-0007vs-4j for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:06 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlwtf-0007xn-JL for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:05 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c724577e1fso34557915ad.0 for ; Thu, 28 Sep 2023 12:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695930122; x=1696534922; 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=t5+OWaefyNNMkLVduE/VRJ4ajnCIurTsfMfEZxbDqbs=; b=MIr6p1nzHUqHrWCyQaevbx0xjJ5ps6OCYkxetj6rqwDRETUNqGcJ6jpAG2m5f+9u7t 8I9kLr1GhTquXWFDv29jK4CivzsrZbzTGTh9RBE+8wqvZG3jGt576LZpFXNUIw7SwO5u 6oWUB0bJI4zfXEWebjEDFl6epmLdpmCJ3YsSNOgLxza2Cn9JIM+tzirtwoGCOUNwungM 1r1MeqLs/gD7xJH+tDk+0dwZpH4yMkHgIk02WFPcbOejxtRAOmQ9sIS7a2EKRWGmmWLe UbAxDWsfcM5862YmO9HheFbc+Xamh53HEFgHvnJJ2bPP+UPKA/MxxlwbKAoWWsy/Q8sW ulJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695930122; x=1696534922; 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=t5+OWaefyNNMkLVduE/VRJ4ajnCIurTsfMfEZxbDqbs=; b=OXIlW9m9QhXNpGIHLoxjjHBgi7OkS3uu1pTN0y51SCQ1VW1tvS33p3CEQgTmyOw7J9 QbsyvZUZpeNWkb4yXr9slMug2aFSkxgkIiQcCtRg/07N0zAaAQx6YizN0+wMLUkkScyQ r6FnmThTruaLgeyt2kfFYqvfGHsursekXEXTAYkNKjb2dxcJH0Or0/UDZNDCNXBz7I6Q vQ3Y2NIExNmh+ythB7SNvnjzSpJSoWHJggrk/ymSeuXtMlVHA0u+Jh4HUuGEXiNHR4LC 8+xWrsuUMmQfGwMeJURnL1x08Hok5tfrkjXVr3w19qe9rcuBGh6MYekZNz51eeZ1sC3g ldWg== X-Gm-Message-State: AOJu0YwCYNVG0LJ5/uWb3e0/g67MFmzfnPwoDxvyZXOH0Gc8s/vRDsdk gZWZ+Ak3swut1DwZ9dY5pPZi/PpqT3E6K9q2RXk= X-Google-Smtp-Source: AGHT+IE2cL82n53So+MqOZG6b5UrFbc9Z4gcZ7JqjB0DhfNCfeZL5HEHzq5De/pi8X33c2hY1rKMtQ== X-Received: by 2002:a17:903:22cd:b0:1c6:2dbb:e5f4 with SMTP id y13-20020a17090322cd00b001c62dbbe5f4mr1974648plg.26.1695930121905; Thu, 28 Sep 2023 12:42:01 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id x23-20020a170902821700b001b80d399730sm15273450pln.242.2023.09.28.12.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 12:42:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 4/6] accel/tcg: Improve setting of can_do_io at start of TB Date: Thu, 28 Sep 2023 12:41:54 -0700 Message-Id: <20230928194156.237351-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928194156.237351-1-richard.henderson@linaro.org> References: <20230928194156.237351-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 28 19:41:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1840984 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=wdM2an+v; 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 4RxP570xk8z1yp8 for ; Fri, 29 Sep 2023 05:42:19 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlwtk-0007yX-6d; Thu, 28 Sep 2023 15:42:08 -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 1qlwti-0007wW-Nb for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:06 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlwth-0007yW-4p for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:06 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c735473d1aso11371255ad.1 for ; Thu, 28 Sep 2023 12:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695930123; x=1696534923; 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=Pino+Pzpra8kDOPi8wLUPqIV+r06yGcltlj2T5gxEf8=; b=wdM2an+vUAPytuALdj2EXtNsEv4Um8Q4jpLk16ZgHxyMUd2wCoZtVPAOmUs+pnBDBK Klcb2Dkh6vO7ungXAzU1Xo6lDnmQBWgREFMR3p37p6TR7bYT6GNQpqyq01VCCfWz70uj N+yksgmX40emRnVDisNSpKpErAKRJmAdb5MBFFBo7Giv7x2szweSzkHd6TbwF8mo1UTj JdPpzHPiWXkDkKkxOdtVYMKVeia8123/M5Jc17sVudIaYsSWjrcas4OVP/rrpKvAJB4k YuUsaMkiMmAdIhQ4sS++tgCPATLAABj7Ht2yBugQaM2FAZbNQEGXMb5LYWohARywyQzu fhqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695930123; x=1696534923; 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=Pino+Pzpra8kDOPi8wLUPqIV+r06yGcltlj2T5gxEf8=; b=t6nK0a9ZKGSi+rDQKm83H5O8NxbZzMTQ8vmT02iEDEeEN6H/8dVnp2jdNMHQ9HR6xi FFIMHB9fPVENdrj48uVkAgAfHag4N6Cody6Hxm3o0XkARK6GK+1eW7ylwSkaI9yNaCpH +dzZRUsFbRxKf2EhIC08qtCiWu7tc8h6Onb+s17n+YM22YqcCMSOyLDtAQdNECjS4tPy Sq3xHtu2j8P+ZxMmWJDdwpZcP6O943LXS/kg+g0N1nRX3l2CxPNoD6Dzrl74XA29Tv+q PHQyF1cA/J5mCfyXfdMG2CBqVS1hPpdktbb8KMGW5umYI8ottvF0KJz7H/f/Uc2CzHuB sE0A== X-Gm-Message-State: AOJu0Yw7Sqfcu4B/fNekLF3ulEgZKhz4lYRbuOr9kfWv+TZ422GmQ212 Ls4GV7zpEXOO4ZqlycNHdy/8J9hw4o6dljmNZFk= X-Google-Smtp-Source: AGHT+IF1opDIjKq5IVIHCddXJX6mRxKoXA8mx6OdtJ6Jel4ohYFfrpcCASTiu4LgO8nwebTCfOI4iA== X-Received: by 2002:a17:903:2344:b0:1c5:6dbc:7938 with SMTP id c4-20020a170903234400b001c56dbc7938mr2397915plh.69.1695930122652; Thu, 28 Sep 2023 12:42:02 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id x23-20020a170902821700b001b80d399730sm15273450pln.242.2023.09.28.12.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 12:42:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 5/6] accel/tcg: Always set CF_LAST_IO with CF_NOIRQ Date: Thu, 28 Sep 2023 12:41:55 -0700 Message-Id: <20230928194156.237351-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928194156.237351-1-richard.henderson@linaro.org> References: <20230928194156.237351-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 28 19:41:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1840986 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=oi/9nNC4; 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 4RxP5J0Xrzz1yp8 for ; Fri, 29 Sep 2023 05:42:28 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlwtl-0007zZ-RI; Thu, 28 Sep 2023 15:42:09 -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 1qlwtj-0007yM-P3 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:07 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlwti-0007yy-2t for qemu-devel@nongnu.org; Thu, 28 Sep 2023 15:42:07 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c1e3a4a06fso100721845ad.3 for ; Thu, 28 Sep 2023 12:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695930124; x=1696534924; 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=MTgXBkn5TnELvpBo0aJHFhInTurB6cKNpUDk0rnkIf0=; b=oi/9nNC4hS4yX+wjbCkCeN/s10vg5Y5Gwa6wtLN1KWwJ2tf9Eucf7S+dUnn9Vk4hI6 PoFnV+jGCvwGeK6DLIf7KewT9WItnNMJcyGiDRHaxGG9q7qrnc0D/CqRBKAdadh8Srrg WVpLKjz9h5jZoq05SG1PjkuFVEwKXWW0VtXf6P8KnDa9Y0ljzaJfw/ynduHIg4/aYGQT A0e2SgSqiKdX069ocMCfyMUr8hl92RFnKonrEw2MDhP6mJr9FDMUc1c35BpDSQJ8i+1U XBUHR5Z//H3Eovf298yIEQmePchVTQ1AE+0sR/XjIP/eA2ehYR2irHtjLEXCaKVcnorY jD5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695930124; x=1696534924; 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=MTgXBkn5TnELvpBo0aJHFhInTurB6cKNpUDk0rnkIf0=; b=TnaolkGU/vIkav8Ns3bXGg/XEWiFb6yb4QMObeYNQ+XvAu5We/0Qg73BZenwpqJH2R 3ALKJ/OTHK01KkUa7nbF3VXS/rNfKi0SwR4tSHQE/mPCxXXx552GVvudHBmyjAF6m+R1 zaJzV87Dm7OXa9PU7qnZbYzAFVvBwId4mmS+/OwehkxZe59KiKkonYQGKHXHNxDEiJsD s+g6BdM6UYuViAcBiSazDy48KRHWZuk47XmMlAuyk73B4rJl4oVxYB9nsiWYVUNEqWoY JM8nfvJIbFKApB8iz49Icwr7MumVoXUs3mYRdwjssdsYFmQEF5RF3C0J/Sr1GDukU8my +2Mg== X-Gm-Message-State: AOJu0Yzfvxk98W8qzwMhOTYei+T0Z09EYzvX5p969O71rXTY+OcC0ieA ypxwUcDaeewcwQsYwkgHqH8ZQzW2GQlp44O54hI= X-Google-Smtp-Source: AGHT+IFjWcdR089jauWFuykjgLXd783I7ptZSSxaIXPeARYv94MEM5diWzECCkPG2Mqyq4Su9vCc0A== X-Received: by 2002:a17:902:b783:b0:1c6:1ac5:144c with SMTP id e3-20020a170902b78300b001c61ac5144cmr1767692pls.40.1695930123696; Thu, 28 Sep 2023 12:42:03 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id x23-20020a170902821700b001b80d399730sm15273450pln.242.2023.09.28.12.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 12:42:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 6/6] accel/tcg: Always require can_do_io Date: Thu, 28 Sep 2023 12:41:56 -0700 Message-Id: <20230928194156.237351-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928194156.237351-1-richard.henderson@linaro.org> References: <20230928194156.237351-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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);