From nobody Tue Nov 11 16:00:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044393; cv=none; d=zoho.com; s=zohoarc; b=e0pT1GJvsXqG8BLf1AOaCg8KYsC7poOaCdlXZ6PugbqEZKoPAypv1MhdhuqJdvbZMhHzwMRHFduvMX0gFuk2NhR81UEls8LK7bn8IZARii0U6a4MEuibS8NZcuoSWuFoSAG9ghh1gTbFuh1vPwo2nDjBXb8UUFlLv1LY5x2ADHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044393; h=Content-Type: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:ARC-Authentication-Results; bh=ctIy0/fcnqauCOzNWxkrBUxJpWmArUpudTjHaseJdhg=; b=B8z1ZiTVFcT+De+tZG8Z4Y5LPB3okps8VMeelfX1/sYY1JNsQ3e8y+ZL1q0vTndqIovDaHgo8j3qkQpC3ilRHKUr5gfY3rp4f88MfQtd1c46kyHHjV28dPpWRH/4UlejXxZHDhBkSsMUoupUOGMXxeylYl5Inl4sGC2au+EblsY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564044393251818.1030787039177; Thu, 25 Jul 2019 01:46:33 -0700 (PDT) Received: from localhost ([::1]:57226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZOS-0006xk-AM for importer@patchew.org; Thu, 25 Jul 2019 04:46:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50247) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMq-0000kB-0y for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMo-0000Ch-PP for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:51 -0400 Received: from mail.ispras.ru ([83.149.199.45]:57068) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMo-0000CT-DY for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:50 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 9717354006B; Thu, 25 Jul 2019 11:44:49 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:49 +0300 Message-ID: <156404428943.18669.15747009371169578935.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 7/8] icount: clean up cpu_can_io at the entry to the block X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk Most of IO instructions can be executed only at the end of the block in icount mode. Therefore translator can set cpu_can_io flag when translating the last instruction. But when the blocks are chained, then this flag is not reset and may remain set at the beginning of the next block. This patch resets the flag at the entry of any translation block, making I/O operations impossible by default. Signed-off-by: Pavel Dovgalyuk -- v2 changes: - reset can_do_io at the start of every TB (suggested by Paolo Bonzini) --- accel/tcg/cpu-exec.c | 1 - include/exec/gen-icount.h | 38 ++++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6c85c3ee1e..48272c781b 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -169,7 +169,6 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cp= u, TranslationBlock *itb) } #endif /* DEBUG_DISAS */ =20 - cpu->can_do_io =3D !use_icount; ret =3D tcg_qemu_tb_exec(env, tb_ptr); cpu->can_do_io =3D 1; last_tb =3D (TranslationBlock *)(ret & ~TB_EXIT_MASK); diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index f7669b6841..4004e6c9d0 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -7,6 +7,24 @@ =20 static TCGOp *icount_start_insn; =20 +static inline void gen_io_start(void) +{ + TCGv_i32 tmp =3D tcg_const_i32(1); + tcg_gen_st_i32(tmp, cpu_env, + offsetof(ArchCPU, parent_obj.can_do_io) - + offsetof(ArchCPU, env)); + tcg_temp_free_i32(tmp); +} + +static inline void gen_io_end(void) +{ + TCGv_i32 tmp =3D tcg_const_i32(0); + tcg_gen_st_i32(tmp, cpu_env, + offsetof(ArchCPU, parent_obj.can_do_io) - + offsetof(ArchCPU, env)); + tcg_temp_free_i32(tmp); +} + static inline void gen_tb_start(TranslationBlock *tb) { TCGv_i32 count, imm; @@ -40,6 +58,8 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_gen_st16_i32(count, cpu_env, offsetof(ArchCPU, neg.icount_decr.u16.low) - offsetof(ArchCPU, env)); + /* Disable I/O by default */ + gen_io_end(); } =20 tcg_temp_free_i32(count); @@ -57,22 +77,4 @@ static inline void gen_tb_end(TranslationBlock *tb, int = num_insns) tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED); } =20 -static inline void gen_io_start(void) -{ - TCGv_i32 tmp =3D tcg_const_i32(1); - tcg_gen_st_i32(tmp, cpu_env, - offsetof(ArchCPU, parent_obj.can_do_io) - - offsetof(ArchCPU, env)); - tcg_temp_free_i32(tmp); -} - -static inline void gen_io_end(void) -{ - TCGv_i32 tmp =3D tcg_const_i32(0); - tcg_gen_st_i32(tmp, cpu_env, - offsetof(ArchCPU, parent_obj.can_do_io) - - offsetof(ArchCPU, env)); - tcg_temp_free_i32(tmp); -} - #endif