From nobody Wed Nov 12 21:51:56 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1574691907; cv=none; d=zohomail.com; s=zohoarc; b=DgtQV73Q4ogampQfTOatXvJ7yqMYoQPrC79+5BKJZL+WdM979BqdcPpxG9G/EYS4rehWw31IOoQ9w976yN2lIxbdEuCJLb45UiomOaVkVIEbHrNx/XQ5+PHwTWGvpVTwEYdzvdEbCIGwvKEh0+ADKJNFjviuUXtmprFI4Kuu5Lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574691907; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Q9K7FDwcudkW1g5GOF5F1lJt+vUcAx0jfRPTiA4vKxY=; b=az085xWjZO+epruptsz9Z++4Mifp3ZnJwDTPraE6lNVLcx7MkelAjusLfho1xQmLC7tLsiosvzemNs4qHe17iXkHprJSVa2odSDun+Eb2cptUiVthpbvpifx7YfO4EzV6ws19mP0RWV40gpBtBW0bNZh/M8FhDR/EMMaCEtTFTA= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574691907489295.38590950449156; Mon, 25 Nov 2019 06:25:07 -0800 (PST) Received: from localhost ([::1]:44550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZFIY-000640-9l for importer@patchew.org; Mon, 25 Nov 2019 09:25:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49612) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZFG3-0002wW-7E for qemu-devel@nongnu.org; Mon, 25 Nov 2019 09:22:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZF8B-0003GQ-No for qemu-devel@nongnu.org; Mon, 25 Nov 2019 09:14:28 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:41151) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iZF8A-0003Fn-DQ; Mon, 25 Nov 2019 09:14:22 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M2xjg-1iY9jS2T6q-003LmH; Mon, 25 Nov 2019 15:14:18 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH] mos6522: update counters when timer interrupts are off Date: Mon, 25 Nov 2019 15:14:14 +0100 Message-Id: <20191125141414.5015-1-laurent@vivier.eu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:VYEDlcsKVP3/7B9l90kM2a/1axH/kJjvkaolrdibdEdyf6qLXhp xFGO/fYmvFmmK0i7EqDwOuySNM8Xv8OiVyzrxsno8Cph3Pe9ryfTMnDNW1cIP0GkkAKnDFM r/5Ny0yjIIO2m6dN/pArfyGIUyTplJa/M9qPn22q/XmG694/nIkKUZvuG7+95hqBfViBpDN r12W5PDpXonyt1p1SsouQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:98vT1MKA7Rw=:G/CeE9NP3nfR9OA25WhckZ l5bM7SSZtHKETuKqaklGHOA2+QYC4kTCgYGb9b4w6mumjv6RDTmKv4QwmVOS+usxp8MCHbjmj +NYYGjq1T4kfp+oH0NvH5H5ZNtK8Armu1Su2Y5nUb58P3uSgWvGz2WC1Q7UJCcBThNq4BXfMA 4WDp9Ltc2wOMejeOnWKqflFLK/ymbHZNOEZuDm9GaLflPO75Zop93dnu6PlVCrob5ntUmSkba HCZJ7cA3rgkuIwhikFo/71QGDmNqkjZ0zG7NThVGwtTqiLrWGzcEcAJtTdbSWYLWk9mJUvnl+ p83h4Z8il813A5j9ANuGYoOqhVQv1ZkB47FjGx2AP84EdPIn48W00Gf1gCYWCViePG0zn1iat 1f+InBJK2OIPOpzDwIl1XOgKG0f00URhjcyoH35nZeRVAnvPsBee7uTivueFRjbv9wY4WOJy1 AjXhqZApz8UqVisdrftpxX7Nn9Gpd+8SaPSQ+QuZvDxxf8a/TdUOSna/SdsJqweCaakOQDv8m CpZoFGbKvyDdeA6P19j7/te7VfC8MAzhkUAKctCO8lMsq3FmPiOzTPzYGBn4y3o4q5lNvetgR ya+GdWBg+DYHIqUJ97QXIoXWXtCCoREiN34e1VCcv0L7vqnR3XkV0X8hNttY/jn1Y2aCTrsKn DhvupmQAUvU55vppaOMkdjqmw1AcdjhPtIA5wABsFKlsroUZt7J1z4t1pptPMjjM80/KkHnvR tCyBHAb6z90oapWvcxSpBCU+IWn/JR2L8/WbClIUGu8jt20bm3Cl+uOAqTqQtFnz3A4titpM5 2fNWodtf2n3hhOi1HbzbdHYUBVebL4wgGzpjBPxfzJgTM9yZ84HVLHjC3rxGqsM8AXihmhM7H BtcT3oTxXOUYwuKfV+jQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.135 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: Mark Cave-Ayland , Laurent Vivier , qemu-ppc@nongnu.org, Andrew Randrianasulu , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Even if the interrupts are off, counters must be updated because they are running anyway and kernel can try to read them (it's the case with g3beige kernel). Reported-by: Andrew Randrianasulu Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/misc/mos6522.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index aa3bfe1afd..cecf0be59e 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -113,6 +113,10 @@ static int64_t get_next_irq_time(MOS6522State *s, MOS6= 522Timer *ti, int64_t d, next_time; unsigned int counter; =20 + if (ti->frequency =3D=3D 0) { + return INT64_MAX; + } + /* current counter value */ d =3D muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ti->load_time, ti->frequency, NANOSECONDS_PER_SECOND); @@ -149,10 +153,10 @@ static void mos6522_timer1_update(MOS6522State *s, MO= S6522Timer *ti, if (!ti->timer) { return; } + ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); if ((s->ier & T1_INT) =3D=3D 0 || (s->acr & T1MODE) !=3D T1MODE_CONT) { timer_del(ti->timer); } else { - ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); timer_mod(ti->timer, ti->next_irq_time); } } @@ -163,10 +167,10 @@ static void mos6522_timer2_update(MOS6522State *s, MO= S6522Timer *ti, if (!ti->timer) { return; } + ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); if ((s->ier & T2_INT) =3D=3D 0) { timer_del(ti->timer); } else { - ti->next_irq_time =3D get_next_irq_time(s, ti, current_time); timer_mod(ti->timer, ti->next_irq_time); } } --=20 2.21.0