From patchwork Tue Mar 13 22:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 10281227 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 EFD3A601A0 for ; Tue, 13 Mar 2018 23:34:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFCC928418 for ; Tue, 13 Mar 2018 23:34:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3792285CB; Tue, 13 Mar 2018 23:34:41 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 7E07A28418 for ; Tue, 13 Mar 2018 23:34:41 +0000 (UTC) Received: from localhost ([::1]:43537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtRI-0004fC-LS for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Mar 2018 19:34:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evsir-0006UY-0I for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evsin-0004Do-Pt for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:45 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:40563) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evsin-0004DG-KI for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:41 -0400 Received: by mail-wr0-x244.google.com with SMTP id s12so14667wre.7 for ; Tue, 13 Mar 2018 15:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dsy6/qBDo7N1pj+3YEWW/24s3ZMWabsCkcNkPA6O1+Y=; b=XgTWHG12MBDAEwdGUG3kYh+tIqBo8rFQzLAElXynTUwus0xlA/Dby2XdMe2OF5iR4Z Hq+Fcp8mW+KZ4QerZPTo/wMEdYOAuysEOfnyy8SKlDwAvk1VeABR0y3yjQhusOPCdoUh 2PvW1bmdrJnDl60cvnSVYAo5lnbpUFezHr1VAS+ali0jah598a2MC25XMuQtLU0yktmn Vy4jWSUsdvVhJVrKGjJETxYwRM8c8j0Ht1xW0FWevI/h4Ne6RwzxuUVyLg/RdPJUlOIX qqWSTublJOR4UdlzyqekHwHdE/N3UXXA0eMXNMW/ZcdCKF5zxNoejg+29vaCpRUP88UN m9xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dsy6/qBDo7N1pj+3YEWW/24s3ZMWabsCkcNkPA6O1+Y=; b=nCzVT6AVlc9RpJj69cOt3jJf6eVlmv61l8VN69gkkTXs4vlw+3cQ3bplC+VMm0JxUd JW/9C3CQkvbSn5Qr1z7G1SQGiXfYhp2JZefKKNCcaS/I7rSQx8S/9ScDqtt55GsW2oXt vp2ROAOZ+3ukqEYL6tyDJEGsoaw5rGlQAoUP65SWrEzXb23aMa+RQSnbKvcXdCWiDyWN BT6VX2vlr4sbUDEZoBFBkXNEDxm2eYc2+OjN6CzwhlJdYqAxCg5lZoyBFIUGAh0MRleB pzXwIfr/p23PejFKAU8KLlzpdJjiOvmTVMVM/l7eJM2bTmHJUfnkXcl3IlLaIcpQufPL Qv/A== X-Gm-Message-State: AElRT7G3WKgIyrBRLJ1sT9dV5/9aj3lrUYEvrJQdEtYNjg3GNWIJkTrr bHDMWIz5AdqHZG2dorXGESwwW7BM X-Google-Smtp-Source: AG47ELtsSpf1thJrjJ6LWRlLrr4Q4WblChFTp9fyTagwst43dYpwRuwtt0588B07D8u1XC0ciglRhg== X-Received: by 10.223.169.54 with SMTP id u51mr2028055wrc.232.1520981320215; Tue, 13 Mar 2018 15:48:40 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id x107sm1557951wrb.97.2018.03.13.15.48.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 15:48:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 23:47:14 +0100 Message-Id: <20180313224719.4954-65-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313224719.4954-1-pbonzini@redhat.com> References: <20180313224719.4954-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 64/69] replay: avoid recursive call of checkpoints 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: Pavel Dovgalyuk Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Pavel Dovgalyuk This patch adds a flag which denies recursive call of replay_checkpoint function. Checkpoints may be accompanied by the hardware events. When event is processed, virtual device may invoke timer modification functions that also invoke the checkpoint function. This leads to infinite loop. Signed-off-by: Pavel Dovgalyuk Message-Id: <20180227095305.1060.56463.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini Signed-off-by: Pavel Dovgalyuk --- replay/replay.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/replay/replay.c b/replay/replay.c index 90f98b7490..eae8daf18a 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -176,13 +176,24 @@ void replay_shutdown_request(ShutdownCause cause) bool replay_checkpoint(ReplayCheckpoint checkpoint) { bool res = false; + static bool in_checkpoint; assert(EVENT_CHECKPOINT + checkpoint <= EVENT_CHECKPOINT_LAST); - replay_save_instructions(); if (!replay_file) { return true; } + if (in_checkpoint) { + /* If we are already in checkpoint, then there is no need + for additional synchronization. + Recursion occurs when HW event modifies timers. + Timer modification may invoke the checkpoint and + proceed to recursion. */ + return true; + } + in_checkpoint = true; + + replay_save_instructions(); if (replay_mode == REPLAY_MODE_PLAY) { g_assert(replay_mutex_locked()); @@ -204,6 +215,7 @@ bool replay_checkpoint(ReplayCheckpoint checkpoint) res = true; } out: + in_checkpoint = false; return res; }