From patchwork Tue Feb 7 06:50:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 9559275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F93F60216 for ; Tue, 7 Feb 2017 06:50:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3653C2654B for ; Tue, 7 Feb 2017 06:50:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ADFD28138; Tue, 7 Feb 2017 06:50:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 595C42654B for ; Tue, 7 Feb 2017 06:50:53 +0000 (UTC) Received: from localhost ([::1]:52315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cazc4-0001p1-Gm for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Feb 2017 01:50:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cazbn-0001ok-Ai for qemu-devel@nongnu.org; Tue, 07 Feb 2017 01:50:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cazbk-00011p-9J for qemu-devel@nongnu.org; Tue, 07 Feb 2017 01:50:35 -0500 Received: from mail.ispras.ru ([83.149.199.45]:40462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cazbk-00011M-2D for qemu-devel@nongnu.org; Tue, 07 Feb 2017 01:50:32 -0500 Received: from PASHAISP (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 8A41D540068; Tue, 7 Feb 2017 09:50:28 +0300 (MSK) From: "Pavel Dovgalyuk" To: Date: Tue, 7 Feb 2017 09:50:30 +0300 Message-ID: <002701d2810e$7929bf30$6b7d3d90$@ru> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdKBDnjqfqMVVimyTZGrCkcrvrcDag== Content-Language: ru X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH] replay: check icount in cpu exec loop X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 'Paolo Bonzini' , 'Pavel Dovgalyuk' Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds check to break cpu loop when icount expires without setting the TB_EXIT_ICOUNT_EXPIRED flag. It happens when there is no available translated blocks and all instructions were executed. In icount replay mode unnecessary tb_find will be called (which may cause an exception) and execution will be non-deterministic. This patch should be applied over Paolo's series: https://www.mail-archive.com/qemu-devel@nongnu.org/msg426058.html Signed-off-by: Pavel Dovgalyuk --- cpu-exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpu-exec.c b/cpu-exec.c index 3838eb8..5cef8bc 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -519,7 +519,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } /* Finally, check if we need to exit to the main loop. */ - if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt())) { + if (unlikely(atomic_read(&cpu->exit_request) + || (use_icount && cpu->icount_decr.u16.low + cpu->icount_extra == 0))) { atomic_set(&cpu->exit_request, 0); cpu->exception_index = EXCP_INTERRUPT; return true;