From patchwork Tue Jul 28 14:10:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 247225 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp567183ilg; Tue, 28 Jul 2020 07:10:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWXa8AHL7Ci2PcGOqbljEPMavk3V/4+TuRqv8hHxe48LGYlZIh8ZR7MK1DsKA6T29O4FwO X-Received: by 2002:ab0:65c3:: with SMTP id n3mr6513827uaq.100.1595945455290; Tue, 28 Jul 2020 07:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595945455; cv=none; d=google.com; s=arc-20160816; b=QmFdyX3t4a7pQ1sZuO0f7lt0ueD3wQhqRkNUK0dK+ECYtXQxtM+loRW2zbDU/oZCG6 AEYeO+QxxbWx0zf+/hJrgCksKV34upI8/+/VwNgR15S0GwWPXr9vASNtlcYewjl7Kt9W E4lxRsBMwyWyQkGZF8I+UbMGGl9LLUm7goqOMn8UrbBIQ8Ol23EquKlxRQHsaJCa9Gm9 6uHxSHm+EGW2y+lMlx8p1ffrZER5VcyYtoxMXAVqx/gME0KGf8EuphHWyhE7XawpdkNL ZJOD3QSObuZXLfAjgJWLCVsK/fYV/Z0qU9r3kQPvfpNTTux933pBxN0bOczDiBRoUIuN 257g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Bs/LPxHzL/OGO5wpdwqQ/5KO2ACTK4oqT2PKMk5ANuA=; b=CvSNC0e2O0W1tOdF1smvUFXCyQ9sBGYH+Gt5McoGY1jtRpnwk+/QSL7EKovYt4VO4U WsAHrCHGFyDjYD1cVOYpWvYoiwNT3gFWzYkFFSbl+UQnCvxVkCIaBvSEDID+oZBCsdXe Yz7MHEDXF/3rc/C7GFyC5hcO9U4DcjF3LjUfMcXQgOm82yAb5dnyhJMnmMaaarNwywhr VmDFNMh5dg9Om1Kc2VLpA3e9KusdZaxyG6DHTwaJ0BL7j8IEpG0jsRo+5+7wDxpk9BEJ JFOuDbsIKUJBVJCvwyBqbkrYxVOimdJGfhCpQ+acUZKStLfDmrQq32qrePDjDGFKzGLh 1o5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TDsBtBmu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18si536282vse.148.2020.07.28.07.10.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jul 2020 07:10:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TDsBtBmu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0QJi-0003KN-Le for patch@linaro.org; Tue, 28 Jul 2020 10:10:54 -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) 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-Received: by 2002:a5d:4687:: with SMTP id u7mr26835670wrq.357.1595945408262; Tue, 28 Jul 2020 07:10:08 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn?= =?utf-8?b?w6ll?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- include/sysemu/cpus.h | 2 ++ softmmu/cpus.c | 13 +++++++++++++ util/qemu-timer.c | 16 ++++++++++++++++ stubs/Makefile.objs | 1 + 4 files changed, 32 insertions(+) -- 2.20.1 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; +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 == 2; } +/* Handler for reaching the end of time */ +void qemu_handle_outa_time(void) +{ + static bool reported = false; + if (runstate_is_running()) { + if (!reported) { + error_report("ran out of time, suspending emulation"); + reported = true; + } + vm_stop(RUN_STATE_PAUSED); + } +} + /* * Subsection for warp timer migration is optional, because may not be created */ 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 = 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 == INT64_MAX) { + qemu_handle_outa_time(); + goto out; + } + qemu_mutex_lock(&timer_list->active_timers_lock); while ((ts = 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 += blk-commit-all.o stub-obj-y += cmos.o +stub-obj-y += cpus.o stub-obj-y += cpu-get-clock.o stub-obj-y += cpu-get-icount.o stub-obj-y += dump.o From patchwork Tue Jul 28 14:10:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 247226 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp568551ilg; Tue, 28 Jul 2020 07:12:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9y1fRWhSR4ACv/oKSqeEYpaMKOiYAJsOVkDZc4bTmnnMvL47MTsHeCIoJTjk1BrJpoKt+ X-Received: by 2002:a25:4b01:: with SMTP id y1mr39129243yba.395.1595945545549; Tue, 28 Jul 2020 07:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595945545; cv=none; d=google.com; s=arc-20160816; b=KlxVJaZEvXTYI3UeIpjL+ug7hTfDpkYyYvZDQ9+j0e0Vpm5eSxitRbp6xb2shrIihI 8uzsdmZF99DQj5ZCx+87iic2+fTPtCS4GoZKF+6QoKCwl/axxEAzqqVOmw1ZUoB+vcRs tubYWZmvgp4QO8jvu9d0znhwmQLCTB+iV8bqUBcG119Z3dh6Me/a8esjJOw6hkfe1U6J 3o+R/C2ltMG0AK61lKy7hZaEifp+NkMfAt5McpjGVdxCKBwdMQaYhoV4xVMUuEjNKdXN BcGvOolxPI+je8XeA7JDgoHwMVtJrWdT2zQZKLYUWEkUULCJdB7XfGVJHkb+p5iow2js DK+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=4coBDICnjHJO+AJICY4wzMsyHlEruM/1bvobKPsXPTA=; b=09Ii2i7NBtQH50lqu0PTYCkyT6PKrKUMH6Rk4XqBe6POoD9Ecfn+XlZRfTfH4/wiY7 KSvDtPr0DLzDDwM7TfmPWKHroPyOEqpHGCNQrUekyl+9MeDxqtUiHYk7r7NmTXP/RVeV xZMr+7axjk4TuJtyDTerST2wRjfSpdT74V5S//5dyPSjwdKVuM6us9IJ3ljeyJTDewUq VEAIbaCkpofW5uhbfF73JIG+LCFGrNAeLB5EGEF1zZ6CLO5npaJ+0RIHt96RpPx19iGs w61C0IofMuIo0y1/0WmNgYSsaFEQP3ZiT6clPqHNMo4LsS4GjEZaIrYIlZHCrc3y778n Co3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dYZPggY7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p130si13673323yba.266.2020.07.28.07.12.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jul 2020 07:12:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dYZPggY7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0QLB-0005h3-2t for patch@linaro.org; Tue, 28 Jul 2020 10:12:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0QJ3-0003IP-LQ for qemu-devel@nongnu.org; Tue, 28 Jul 2020 10:10:13 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:53488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k0QJ1-0006d3-85 for qemu-devel@nongnu.org; Tue, 28 Jul 2020 10:10:13 -0400 Received: by mail-wm1-x344.google.com with SMTP id g8so6292744wmk.3 for ; Tue, 28 Jul 2020 07:10:10 -0700 (PDT) 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=4coBDICnjHJO+AJICY4wzMsyHlEruM/1bvobKPsXPTA=; b=dYZPggY7lsW49vbrtQdmKjaQ8xpn0PQZa72334VqZQ3VVeLHNoijNQT5oqCPuU3Bz8 98bxGIWga9rHDLLIePKzv4IIqUw4qhOYCTa70qArtodXh3qpFqiaP68fFx0+JSID2uO7 4DVarl2xpInoRl7p/7DvGGGL+A3YH1LcveEXqXLfQThbknSHBvcDAgjahvVIVpAiSBfa APz5a9F1IcTwzOhuRisazTbE2p41QL57Drn1MhO72XlpIcqOHOJD7QdnVoks7DSrHsEa mdruOB9HcagxNaN87Z9vV7jcSztFP2es1H6wyiV+xWfJD0bKV/a+orZfqlWx710k5a3S gmZQ== 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=4coBDICnjHJO+AJICY4wzMsyHlEruM/1bvobKPsXPTA=; b=BCAA30mfC5caRauSl/bVecSalmjOH27DOOdNMJNGXmppmqS+S7Lascxt8GDQv5Cwxq uAq88mkPofwqCOUY2bWQSuOpAa4GD9JqZNWC2BIYlKzlNITAqc4S/y8Ju9LRsZlM6iNo 6VyA759I3XhWNV5tWZVY8/5EHxxPHM+fYGCw/pv1PP2pw00NDbNhO/+fK15k3yHwRgPU duEIxGk43eOucQhlrKuEqqj+uU4fAr/K6MR6IFXvNukTkmdZaY+fwsIYwTMKR4pXkp9s lkt7yMJHTXv/MTLKjSw1Y92VQtJhC4GXP/1OD5RFrqG+XcRIiSjkP2yozlkujATsfS5b XL5Q== X-Gm-Message-State: AOAM532LE6E58jlZd5SRJOipnOw4sSsfEFDJAqeln+omD3MgrNzo3zKm QlkpplGBZKhu/4fB/wyg8O20bA== X-Received: by 2002:a1c:2e07:: with SMTP id u7mr4501732wmu.52.1595945409623; Tue, 28 Jul 2020 07:10:09 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h199sm4584938wme.42.2020.07.28.07.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 07:10:08 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A4BF71FF8C; Tue, 28 Jul 2020 15:10:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 2/2] target/arm: only set the nexttick timer if !ISTATUS Date: Tue, 28 Jul 2020 15:10:05 +0100 Message-Id: <20200728141005.28664-3-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 Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x344.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=unavailable 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: Peter Maydell , boost.lists@gmail.com, victor.clement@openwide.fr, "open list:ARM TCG CPUs" , pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Otherwise we have an unfortunate interaction with -count sleep=off which means we fast forward time when we don't need to. The easiest way to trigger it was to attach to the gdbstub and place a break point at the timers IRQ routine. Once the timer fired setting the next event at INT_MAX then qemu_start_warp_timer would skip to the end. Signed-off-by: Alex Bennée --- target/arm/helper.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index c69a2baf1d3..ec1b84cf0fd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2683,7 +2683,7 @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) uint64_t count = gt_get_countervalue(&cpu->env); /* Note that this must be unsigned 64 bit arithmetic: */ int istatus = count - offset >= gt->cval; - uint64_t nexttick; + uint64_t nexttick = 0; int irqstate; gt->ctl = deposit32(gt->ctl, 2, 1, istatus); @@ -2692,21 +2692,30 @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) qemu_set_irq(cpu->gt_timer_outputs[timeridx], irqstate); if (istatus) { - /* Next transition is when count rolls back over to zero */ - nexttick = UINT64_MAX; + /* + * The IRQ status of the timer will persist until: + * - CVAL is changed or + * - ENABLE is changed + * + * There is no point re-arming the timer for some far + * flung future - currently it just is. + */ + timer_del(cpu->gt_timer[timeridx]); } else { /* Next transition is when we hit cval */ nexttick = gt->cval + offset; - } - /* Note that the desired next expiry time might be beyond the - * signed-64-bit range of a QEMUTimer -- in this case we just - * set the timer for as far in the future as possible. When the - * timer expires we will reset the timer for any remaining period. - */ - if (nexttick > INT64_MAX / gt_cntfrq_period_ns(cpu)) { - timer_mod_ns(cpu->gt_timer[timeridx], INT64_MAX); - } else { - timer_mod(cpu->gt_timer[timeridx], nexttick); + + /* + * It is possible the next tick is beyond the + * signed-64-bit range of a QEMUTimer but currently the + * timer system doesn't support a run time of more the 292 + * odd years so we set it to INT_MAX in this case. + */ + if (nexttick > INT64_MAX / gt_cntfrq_period_ns(cpu)) { + timer_mod_ns(cpu->gt_timer[timeridx], INT64_MAX); + } else { + timer_mod(cpu->gt_timer[timeridx], nexttick); + } } trace_arm_gt_recalc(timeridx, irqstate, nexttick); } else {