From nobody Sat Nov 15 20:08:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1595947605; cv=none; d=zohomail.com; s=zohoarc; b=IXmXv/CQl2N1bCtN7Ma8QJ+cpf+/gJBVsHdOqSncwkRkXIPRnUJojzXoL0pHCLTKduU+vw3EgCbzgDyRFkDW3ReRGPs8hgmuvE3U4h8wl3lY6/zKZ/F56jGqCAeIgxarwARnzytIJjSSOXxou8AidwZp4SVuhfQGH+UY95cynXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595947605; 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; bh=Bs/LPxHzL/OGO5wpdwqQ/5KO2ACTK4oqT2PKMk5ANuA=; b=DfOCErihjxpFW5tuvFgy00ZZczG/VsZYOdFz2tkb4J9fGcY+cva/WmNhFfEW+5XrMO/EupP3665N9duu3tDCxzE7lfoDXXSF/Rie74GeRHUiIJmOzUqnn1FGzNpwxvhI/Odfc+rjbeGdL5LxQaQ6Dh5j1I0gI5J6Cofaqe/11iw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1595947605845823.0203514669813; Tue, 28 Jul 2020 07:46:45 -0700 (PDT) Received: from localhost ([::1]:33370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0QKA-0004SF-1v for importer@patchew.org; Tue, 28 Jul 2020 10:11:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0QJ3-0003IM-Hd for qemu-devel@nongnu.org; Tue, 28 Jul 2020 10:10:13 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k0QIz-0006cu-QF for qemu-devel@nongnu.org; Tue, 28 Jul 2020 10:10:13 -0400 Received: by mail-wr1-x442.google.com with SMTP id r4so15478605wrx.9 for ; Tue, 28 Jul 2020 07:10:09 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v29sm18527824wrv.51.2020.07.28.07.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 07:10:06 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8EB461FF87; Tue, 28 Jul 2020 15:10:05 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bs/LPxHzL/OGO5wpdwqQ/5KO2ACTK4oqT2PKMk5ANuA=; b=TDsBtBmu70dmODvkhtTeb1aH9ZnYtsMFJyCr7wo7IOuPZOI82C+63EescHYXdDRIOd 7E1CdNNIQQ05lUjxgawnDpYlL8oEJwzX0TVYAWQPihDPXw9e7h6SejnLwaS+C5H247sm vwZzriasAg+qk2KXewaKqH7dycIkYiynQ+IiU9S1BTcIywfc904bZ4jjZL7/HRibvMRf 75I18CtMlUWaV84oqN3kD2Ud0QeypiKrXx/v++kMz3NXACs4xyw8v+LsNsmLMXKKMVpX tMxmCtuh7ZroZpRUcTqNaxX4MEVlq9s2GDkAhHbZkWqdrS7OtBCdbp9v4+MiCz+g5dQn bz3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bs/LPxHzL/OGO5wpdwqQ/5KO2ACTK4oqT2PKMk5ANuA=; b=LNy1Qz8jghl/ICEymGTzOCEB1xX9JecZ6v7O9efYv4FIMs/DBi8TpiBThd9efIYyhX pfJYqocF8Ygh/UT+PL5C1SL+Xfx4X0FI4xMDVSNbn4KDm5PMGRtBFKOBJxJ3xlCznfgm EqesoqU1dGblng54FURGnUf4I6yL7yS3a8a5XQ1T/TZxOlcN4V6538rL8mEKkBkkY4Zm q8i/1Wy8tAck4UG+Uy+YCFdB3yP1vzM38QZOFn38uul5MqVx29g2cS1vXHawIZVO9aTn 5GwD1s9l+AhZfV44lcy438PLImDSAFDxXszRfBbuXgs+YwpAL6YRm8X2+xaaL0hL2avv 3yqA== X-Gm-Message-State: AOAM530vaa75MglgXJw+fFNlJ84bH5iXetZxyjJXxiuzYtjkYY1YeYvg ckVYGkqE+9RYrqWRDArFenNhrQ== X-Google-Smtp-Source: ABdhPJzZ8f5Ky6acy6VQI23uTwNNjxp8z04jWKr85pksPj9N9r/ljm7s1fOdjDdx7Y2OWsJkDwiqpg== X-Received: by 2002:a5d:4687:: with SMTP id u7mr26835670wrq.357.1595945408262; Tue, 28 Jul 2020 07:10:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 1/2] qemu-timer: gracefully handle the end of time Date: Tue, 28 Jul 2020 15:10:04 +0100 Message-Id: <20200728141005.28664-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200728141005.28664-1-alex.bennee@linaro.org> References: <20200728141005.28664-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: boost.lists@gmail.com, victor.clement@openwide.fr, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The previous behaviour was rather user hostile as timers set for INT64_MAX would continually re-arm leaving the system locked in a loop and the console unavailable. With this patch we detect the situation and gracefully suspend the machine. NB: we need a proper fix before the 23rd century. Signed-off-by: Alex Benn=C3=A9e --- include/sysemu/cpus.h | 2 ++ softmmu/cpus.c | 13 +++++++++++++ util/qemu-timer.c | 16 ++++++++++++++++ stubs/Makefile.objs | 1 + 4 files changed, 32 insertions(+) diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index 3c1da6a0183..7da3a5b60b5 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -15,6 +15,8 @@ void configure_icount(QemuOpts *opts, Error **errp); extern int use_icount; extern int icount_align_option; =20 +void qemu_handle_outa_time(void); + /* drift information for info jit command */ extern int64_t max_delay; extern int64_t max_advance; diff --git a/softmmu/cpus.c b/softmmu/cpus.c index a802e899abb..46b6f346370 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -657,6 +657,19 @@ static bool shift_state_needed(void *opaque) return use_icount =3D=3D 2; } =20 +/* Handler for reaching the end of time */ +void qemu_handle_outa_time(void) +{ + static bool reported =3D false; + if (runstate_is_running()) { + if (!reported) { + error_report("ran out of time, suspending emulation"); + reported =3D true; + } + vm_stop(RUN_STATE_PAUSED); + } +} + /* * Subsection for warp timer migration is optional, because may not be cre= ated */ diff --git a/util/qemu-timer.c b/util/qemu-timer.c index f62b4feecdb..06f6818eb3d 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -540,6 +540,22 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) * done". */ current_time =3D qemu_clock_get_ns(timer_list->clock->type); + + /* + * Check to see if we have run out of time. Most of our time + * sources are nanoseconds since epoch (some time around the fall + * of Babylon 5, the start of the Enterprises five year mission + * and just before the arrival of the great evil ~ 2262CE). + * Although icount based time is ns since the start of emulation + * it is able to skip forward if the device is sleeping (think IoT + * device with a very long heartbeat). Either way we don't really + * handle running out of time so lets catch it and report it here. + */ + if (current_time =3D=3D INT64_MAX) { + qemu_handle_outa_time(); + goto out; + } + qemu_mutex_lock(&timer_list->active_timers_lock); while ((ts =3D timer_list->active_timers)) { if (!timer_expired_ns(ts, current_time)) { diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index d42046afe4e..d363d8b551b 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -1,5 +1,6 @@ stub-obj-y +=3D blk-commit-all.o stub-obj-y +=3D cmos.o +stub-obj-y +=3D cpus.o stub-obj-y +=3D cpu-get-clock.o stub-obj-y +=3D cpu-get-icount.o stub-obj-y +=3D dump.o --=20 2.20.1