From nobody Sat Sep 26 22:14:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1788352120; cv=none; d=zohomail.com; s=zohoarc; b=NA3rj3gvk7H4dldJ12hD15CrIF73vMedh+yvOST5rt6LY5uMWGXzWgELvik2YwiyB/zAhz1jptzOXIocHe6igNcBsYpc2XZFGbRFEjuYweBh57fxOfv0b3vi2eoFq6wXjUSDIZMCsk10RQEosPHw7/xJR2WS1R+KBvb+0lrJYgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788352120; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N5rMCPVhjC068rQLLNDke/LvXpMq7YJ3+AEL8uMXIMc=; b=IPQc1RxEg70/WIA/2sFUOQCllsriVX/dpXJ4CkMwXVIxLouqjYg4/0vvAnDGMLgbEg3earqNOFEulXfnXdzWg2wvXcffWRWKRLVA50gzqSJpd9sGq6BNQK3uV/U8dbFuQHyLvGFfkbxblDBnwknhbZkw/hIKDXhjMQkSCXJd/SI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788352120781599.2261817678068; Wed, 2 Sep 2026 05:28:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1k4c-0006SM-35; Wed, 02 Sep 2026 08:28:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4Y-0006RD-IK for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4X-0004sw-0t for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:10 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-154-vMK76Q9xM-iM95PAaY3F_A-1; Wed, 02 Sept 2026 08:26:54 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CFEEC1953994; Wed, 2 Sep 2026 12:26:52 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2DF603000223; Wed, 2 Sep 2026 12:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N5rMCPVhjC068rQLLNDke/LvXpMq7YJ3+AEL8uMXIMc=; b=KY96nWllhaWRCmxal+gIMldqLB2W7cYxtAZM0AGtfvMLDYCuvSFaWgZGXWWUhn3ECyoJsq u9eUlJmHWUU5Z0D+aXk1n0RSR4A0a3yhiFWj1KjbP05u/V16Yy9nx1erQ3N7Nui+vc6gCx wjzpfC9lH8e6oUR3D0JawRqozpjNHl0= X-MC-Unique: vMK76Q9xM-iM95PAaY3F_A-1 X-Mimecast-MFC-AGG-ID: vMK76Q9xM-iM95PAaY3F_A_1788352013 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, leif.lindholm@oss.qualcomm.com, eauger@redhat.com, Eric Auger Subject: [PATCH 1/6] sbsa-gwdt: reduce code ident Date: Wed, 2 Sep 2026 14:26:41 +0200 Message-ID: <20260902122646.2848464-2-imammedo@redhat.com> In-Reply-To: <20260902122646.2848464-1-imammedo@redhat.com> References: <20260902122646.2848464-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1788352123429158500 Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Reviewed-by: Peter Maydell --- hw/watchdog/sbsa_gwdt.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c index 330a74798a..7cc5609b83 100644 --- a/hw/watchdog/sbsa_gwdt.c +++ b/hw/watchdog/sbsa_gwdt.c @@ -105,25 +105,27 @@ static void sbsa_gwdt_update_timer(SBSA_GWDTState *s,= WdtRefreshType rtype) =20 timer_del(s->timer); =20 - if (s->wcs & SBSA_GWDT_WCS_EN) { - /* - * Extract the upper 16 bits from woru & 32 bits from worl - * registers to construct the 48 bit offset value - */ - timeout =3D s->woru; - timeout <<=3D 32; - timeout |=3D s->worl; - timeout =3D muldiv64(timeout, NANOSECONDS_PER_SECOND, s->freq); - timeout +=3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - - if ((rtype =3D=3D EXPLICIT_REFRESH) || ((rtype =3D=3D TIMEOUT_REFR= ESH) && - (!(s->wcs & SBSA_GWDT_WCS_WS0)))) { - /* store the current timeout value into compare registers */ - s->wcvu =3D timeout >> 32; - s->wcvl =3D timeout; - } - timer_mod(s->timer, timeout); + if (!(s->wcs & SBSA_GWDT_WCS_EN)) { + return; + } + + /* + * Extract the upper 16 bits from woru & 32 bits from worl + * registers to construct the 48 bit offset value + */ + timeout =3D s->woru; + timeout <<=3D 32; + timeout |=3D s->worl; + timeout =3D muldiv64(timeout, NANOSECONDS_PER_SECOND, s->freq); + timeout +=3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + + if ((rtype =3D=3D EXPLICIT_REFRESH) || ((rtype =3D=3D TIMEOUT_REFRESH)= && + (!(s->wcs & SBSA_GWDT_WCS_WS0)))) { + /* store the current timeout value into compare registers */ + s->wcvu =3D timeout >> 32; + s->wcvl =3D timeout; } + timer_mod(s->timer, timeout); } =20 static void sbsa_gwdt_rwrite(void *opaque, hwaddr offset, uint64_t data, --=20 2.52.0 From nobody Sat Sep 26 22:14:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1788352121; cv=none; d=zohomail.com; s=zohoarc; b=l5z1CqHsbiLZ4543osz2lH8Dz1nTx0d3nEj8CCb2FidqUnHNVFQi1PhnoBbh8y42hci1GtSsgxZES9Y2icuqYWPvEMD1nMq5yfKAeLbqbzESDl5NV4VMISAYug9gZARRG24JBkj7Vpatwkzrw4N+jyiMV2yGJrl+Wq4J/EXKbMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788352121; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eKBO/P4CFlsgKJYOZav0we9gGt0rFWpDphExZfU1mpI=; b=K1mMHRhT/c8Hbte8k9JTLOv6tNasN3YQKQQvxJn2HQwvAf6SJUmCUX7OP8K3PUlqR4wqt2R0eQ562aUMllFb9iv+tVYMk6RpO3zU+FdFSVKZ09liFaxbQIbF7U5pz/jLAMRDiefL5RVGp9AzgVkRvyL6eQZ/9A+dUHPkhSWs+nA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788352121174661.6160923386036; Wed, 2 Sep 2026 05:28:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1k4X-0006Qf-PR; Wed, 02 Sep 2026 08:28:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4U-0006Pw-RK for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4T-0004rn-E8 for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:06 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-8-mr979pD7ObGW_5F9j6YNtw-1; Wed, 02 Sept 2026 08:26:55 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 85A8819344F7; Wed, 2 Sep 2026 12:26:54 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F9CA3000223; Wed, 2 Sep 2026 12:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eKBO/P4CFlsgKJYOZav0we9gGt0rFWpDphExZfU1mpI=; b=W458FbovMKca+14gh79dgwDVCvjcRha/CG6vBxjqMnInoW//n1H2/dpiLNZoteHq8knb3P vRcFJjFOe+r5FykRSySDzh0qoG1vWw/k8dj0/TrtOYHhmdM/c8+39Z6Jr3XNtxV8tHL2xY Op0Q2mW7boxGKitvLbTypeKfYk8gtYs= X-MC-Unique: mr979pD7ObGW_5F9j6YNtw-1 X-Mimecast-MFC-AGG-ID: mr979pD7ObGW_5F9j6YNtw_1788352014 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, leif.lindholm@oss.qualcomm.com, eauger@redhat.com Subject: [PATCH 2/6] arm: gwdt: consolidate clear WS0 and WS1 on explicit refresh Date: Wed, 2 Sep 2026 14:26:42 +0200 Message-ID: <20260902122646.2848464-3-imammedo@redhat.com> In-Reply-To: <20260902122646.2848464-1-imammedo@redhat.com> References: <20260902122646.2848464-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1788352123434158500 Current impl had logic scattered all over the place and WCS was implicitly cleared on WCS write. Consolidate clear action in one place under EXPLICIT_REFRESH condition. Signed-off-by: Igor Mammedov Reviewed-by: Peter Maydell --- hw/watchdog/sbsa_gwdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c index 7cc5609b83..2aa44573a7 100644 --- a/hw/watchdog/sbsa_gwdt.c +++ b/hw/watchdog/sbsa_gwdt.c @@ -105,6 +105,10 @@ static void sbsa_gwdt_update_timer(SBSA_GWDTState *s, = WdtRefreshType rtype) =20 timer_del(s->timer); =20 + if (rtype =3D=3D EXPLICIT_REFRESH) { + s->wcs &=3D ~(SBSA_GWDT_WCS_WS0 | SBSA_GWDT_WCS_WS1); + } + if (!(s->wcs & SBSA_GWDT_WCS_EN)) { return; } @@ -134,8 +138,6 @@ static void sbsa_gwdt_rwrite(void *opaque, hwaddr offse= t, uint64_t data, =20 trace_sbsa_gwdt_refresh_write(offset, data); if (offset =3D=3D SBSA_GWDT_WRR) { - s->wcs &=3D ~(SBSA_GWDT_WCS_WS0 | SBSA_GWDT_WCS_WS1); - sbsa_gwdt_update_timer(s, EXPLICIT_REFRESH); } else { qemu_log_mask(LOG_GUEST_ERROR, "bad address in refresh frame write= :" @@ -157,14 +159,12 @@ static void sbsa_gwdt_write(void *opaque, hwaddr offs= et, uint64_t data, =20 case SBSA_GWDT_WOR: s->worl =3D data; - s->wcs &=3D ~(SBSA_GWDT_WCS_WS0 | SBSA_GWDT_WCS_WS1); qemu_set_irq(s->irq, 0); sbsa_gwdt_update_timer(s, EXPLICIT_REFRESH); break; =20 case SBSA_GWDT_WORU: s->woru =3D data & SBSA_GWDT_WOR_MASK; - s->wcs &=3D ~(SBSA_GWDT_WCS_WS0 | SBSA_GWDT_WCS_WS1); qemu_set_irq(s->irq, 0); sbsa_gwdt_update_timer(s, EXPLICIT_REFRESH); break; --=20 2.52.0 From nobody Sat Sep 26 22:14:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1788352134; cv=none; d=zohomail.com; s=zohoarc; b=eGe8PCZf0DhOUV36+MoNdbrFcHra2+w1Jvdgfh5wgCX2U97QNXdds+Lfcnqt7PJsHwOA8hOJpZ0SWRd8JdMFS6a4VX2rbGwuqstBwWq880z5lG9ekFoCmz236MOxYDlIdiTsWFyvuGHXAONBBxO4DEHkL+Mum1J+6ZglDVXZgIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788352134; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2BwMO14EVESPgOIQPV2+HS2tSXE3S3XBWFrRFw8yLuE=; b=Y90YgWdenTNRTcAJKqs6wgAKyAo1TbT5KGA4jiWDFx7e6zrDkZhJlxwFjedkNv1jid2K99psronpGsDtxuKR25MpOIDKXG8fYeJ9heWb29imGiWR4S+6PfE5somWv6OX4MN21ux2kd0Cah2c3bGlRUiRqH99tv+MsRuRfa/0GsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788352134003479.80195902024; Wed, 2 Sep 2026 05:28:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1k4c-0006SO-49; Wed, 02 Sep 2026 08:28:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4Z-0006Rc-Dg for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4X-0004tO-RP for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:11 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-F0yr_UMWPYSfKLcT5EqisA-1; Wed, 02 Sept 2026 08:26:57 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 35CA8192DD51; Wed, 2 Sep 2026 12:26:56 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0D93A3000223; Wed, 2 Sep 2026 12:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2BwMO14EVESPgOIQPV2+HS2tSXE3S3XBWFrRFw8yLuE=; b=GJji9C3XgNNv122jqoBehRPPNCMGLtwKWrDlzfueN9gcJqogr0F1XvCTosW8jf9WMwnnPt SlkwdPJLK8kkz6Kd4Blpx1ZRcSzeY2bLQxkkpLinngB6sQ7XSKV5IaUa7D3/RbxMbjGYjL JZtT4CdQNo1Lb8lqTrizaemZ2nHRSa4= X-MC-Unique: F0yr_UMWPYSfKLcT5EqisA-1 X-Mimecast-MFC-AGG-ID: F0yr_UMWPYSfKLcT5EqisA_1788352016 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, leif.lindholm@oss.qualcomm.com, eauger@redhat.com Subject: [PATCH 3/6] arm: gwdt: simplify WCV update condition Date: Wed, 2 Sep 2026 14:26:43 +0200 Message-ID: <20260902122646.2848464-4-imammedo@redhat.com> In-Reply-To: <20260902122646.2848464-1-imammedo@redhat.com> References: <20260902122646.2848464-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1788352137785154100 Current code implements SBSA 5.0, revision 1 of the generic watchdog. Which requires WCV retain time when WS1 was triggered. towards that effect sbsa_gwdt_update_timer(), used condition (rtype =3D=3D TIMEOUT_REFRESH) && !(s->wcs & SBSA_GWDT_WCS_WS0) to make sure that WCV won't be updated on WS1. However that is dead code as sbsa_gwdt_timer_sysinterrupt() when signalling WS1, never calls sbsa_gwdt_update_timer(). Delete dead condition and add assert to make sure that sbsa_gwdt_update_timer() is never called unnoticed on WS1 path. Above change leaves us with always true remaining if condition: (rtype =3D=3D EXPLICIT_REFRESH) || (rtype =3D=3D TIMEOUT_REFRESH) drop it and update WCV unconditionaly. Signed-off-by: Igor Mammedov Reviewed-by: Peter Maydell --- hw/watchdog/sbsa_gwdt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c index 2aa44573a7..a9bf3f8312 100644 --- a/hw/watchdog/sbsa_gwdt.c +++ b/hw/watchdog/sbsa_gwdt.c @@ -123,12 +123,12 @@ static void sbsa_gwdt_update_timer(SBSA_GWDTState *s,= WdtRefreshType rtype) timeout =3D muldiv64(timeout, NANOSECONDS_PER_SECOND, s->freq); timeout +=3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); =20 - if ((rtype =3D=3D EXPLICIT_REFRESH) || ((rtype =3D=3D TIMEOUT_REFRESH)= && - (!(s->wcs & SBSA_GWDT_WCS_WS0)))) { - /* store the current timeout value into compare registers */ - s->wcvu =3D timeout >> 32; - s->wcvl =3D timeout; - } + g_assert(!(s->wcs & SBSA_GWDT_WCS_WS1)); + + /* store the current timeout value into compare registers */ + s->wcvu =3D timeout >> 32; + s->wcvl =3D timeout; + timer_mod(s->timer, timeout); } =20 --=20 2.52.0 From nobody Sat Sep 26 22:14:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1788352156; cv=none; d=zohomail.com; s=zohoarc; b=hdtfH8Dy1U2kchy5nRdRPiEsiSkEEOf4fSOm2+7ZgOIvbVDNxF6uyoXe9R/PP3hk6GuvXk/Ipgqwlnk4T4/NorNa2AMQeEtvAes9CvhqSbHWCWgoVduL/KGnPMuOvRWKAvIFaiYkj7SDGefCROcUEc3gQdGBwiUMV8p4zgguVHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788352156; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nTmlLnMyTw7vyUl+JIdD3NLOzd8/g0MoejD7oHwZt9Y=; b=OGG00Y8EYabMaZtSb9EsqBf8BSp6+UVQyYVZ8jjhC938t4D9ScEoK4ehGyT+NHRJiRM7FJ9Z7lOgsd3CWjqdPQpqWCc4Hy8m5wEeu/h1JLPJtsVHN2mYpezfupwrp0/69fMczYMpOZAij2xNk6QlxgUqCjZEZlILm3PvRwzvbOw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788352156286592.9031864716474; Wed, 2 Sep 2026 05:29:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1k4Z-0006RX-Cc; Wed, 02 Sep 2026 08:28:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4X-0006QT-Ch for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4V-0004sj-SO for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:09 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-JcRniLefNmG6iW0av0pBaA-1; Wed, 02 Sept 2026 08:26:58 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B26381800D8F; Wed, 2 Sep 2026 12:26:57 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8CA9F3000223; Wed, 2 Sep 2026 12:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nTmlLnMyTw7vyUl+JIdD3NLOzd8/g0MoejD7oHwZt9Y=; b=ixGLawSFEZnNF2Se5Ih4NoimVSNqISvy5oHtAi0dME3Eca1TzZMu4Si3UGVNlrFw4XzH/u IgfJP8lKMz0QaABd1XRLbwei9ER4PlOcj6UZgI7+qzL9fXMrLWtYEkZRc4AuRIJjaOWIH2 XrP2ufpgeN+d5Qoc/Coj/g8MQpbb3gA= X-MC-Unique: JcRniLefNmG6iW0av0pBaA-1 X-Mimecast-MFC-AGG-ID: JcRniLefNmG6iW0av0pBaA_1788352017 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, leif.lindholm@oss.qualcomm.com, eauger@redhat.com Subject: [PATCH 4/6] sbsa-gwdt: rename sbsa_gwdt_update_timer() to sbsa_gwdt_wor_update_timer() Date: Wed, 2 Sep 2026 14:26:44 +0200 Message-ID: <20260902122646.2848464-5-imammedo@redhat.com> In-Reply-To: <20260902122646.2848464-1-imammedo@redhat.com> References: <20260902122646.2848464-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1788352158583158500 The timer update helper computes the timeout from the WOR (watchdog offset register). Rename it to sbsa_gwdt_wor_update_timer() to make room for a separate WCV-based update helper added by a following patch. No functional change. Signed-off-by: Igor Mammedov Reviewed-by: Peter Maydell --- hw/watchdog/sbsa_gwdt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c index a9bf3f8312..1211f1ca65 100644 --- a/hw/watchdog/sbsa_gwdt.c +++ b/hw/watchdog/sbsa_gwdt.c @@ -99,7 +99,7 @@ static uint64_t sbsa_gwdt_read(void *opaque, hwaddr addr,= unsigned int size) return ret; } =20 -static void sbsa_gwdt_update_timer(SBSA_GWDTState *s, WdtRefreshType rtype) +static void sbsa_gwdt_wor_update_timer(SBSA_GWDTState *s, WdtRefreshType r= type) { uint64_t timeout =3D 0; =20 @@ -138,7 +138,7 @@ static void sbsa_gwdt_rwrite(void *opaque, hwaddr offse= t, uint64_t data, =20 trace_sbsa_gwdt_refresh_write(offset, data); if (offset =3D=3D SBSA_GWDT_WRR) { - sbsa_gwdt_update_timer(s, EXPLICIT_REFRESH); + sbsa_gwdt_wor_update_timer(s, EXPLICIT_REFRESH); } else { qemu_log_mask(LOG_GUEST_ERROR, "bad address in refresh frame write= :" " 0x%x\n", (int)offset); @@ -154,19 +154,19 @@ static void sbsa_gwdt_write(void *opaque, hwaddr offs= et, uint64_t data, case SBSA_GWDT_WCS: s->wcs =3D data & SBSA_GWDT_WCS_EN; qemu_set_irq(s->irq, 0); - sbsa_gwdt_update_timer(s, EXPLICIT_REFRESH); + sbsa_gwdt_wor_update_timer(s, EXPLICIT_REFRESH); break; =20 case SBSA_GWDT_WOR: s->worl =3D data; qemu_set_irq(s->irq, 0); - sbsa_gwdt_update_timer(s, EXPLICIT_REFRESH); + sbsa_gwdt_wor_update_timer(s, EXPLICIT_REFRESH); break; =20 case SBSA_GWDT_WORU: s->woru =3D data & SBSA_GWDT_WOR_MASK; qemu_set_irq(s->irq, 0); - sbsa_gwdt_update_timer(s, EXPLICIT_REFRESH); + sbsa_gwdt_wor_update_timer(s, EXPLICIT_REFRESH); break; =20 case SBSA_GWDT_WCV: @@ -205,7 +205,7 @@ static void sbsa_gwdt_timer_sysinterrupt(void *opaque) if (!(s->wcs & SBSA_GWDT_WCS_WS0)) { s->wcs |=3D SBSA_GWDT_WCS_WS0; trace_sbsa_gwdt_ws0_asserted(); - sbsa_gwdt_update_timer(s, TIMEOUT_REFRESH); + sbsa_gwdt_wor_update_timer(s, TIMEOUT_REFRESH); qemu_set_irq(s->irq, 1); } else { s->wcs |=3D SBSA_GWDT_WCS_WS1; --=20 2.52.0 From nobody Sat Sep 26 22:14:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1788352130; cv=none; d=zohomail.com; s=zohoarc; b=hi+L0C8S/L1ip4c91f04JkMIplXf2f7vts2uZtu4qGiCh8bn6UGgAgCfRat9SE2AA77A9lwu6bu4IIoNXR1rI21rio5n3HL0ucRJtrivBCNeYT5tnaOI95NvgFa7Ygc/OyFohQM1wJRsEKE66t+YUbWERdzUCsIZGDsIAFsRC/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788352130; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6FwNxnqOnBzLJoyDXwQFuQ68X47X5CSDm+eORTuw6vM=; b=aEL6rz1xEi+J2UjpzSgOFeTAs6p08tSYpqNXnWuVscBtgmp/urEZ5g/MoagPHTD0/5UAO6UHP1R/uDOVNpijuymkFCML/okY6xyAp98Tcz8oXuy7+Kfwe2s3cQL1V7UMaBnfIih1wJPjhjUjWJo9VD6LTDr7YOe6bc2z/zyDI70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788352130874963.4969842987749; Wed, 2 Sep 2026 05:28:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1k4k-0006TP-SF; Wed, 02 Sep 2026 08:28:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4a-0006S4-09 for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4Y-0004tY-83 for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:11 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-0pNmsET_N7G70XL127YHUA-1; Wed, 02 Sept 2026 08:27:01 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9D8DD1829E3E; Wed, 2 Sep 2026 12:26:59 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 15D343000223; Wed, 2 Sep 2026 12:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6FwNxnqOnBzLJoyDXwQFuQ68X47X5CSDm+eORTuw6vM=; b=QziZV6EYBOybcLTGN9rF7bMT9P3ZdsFbW28wWyESISq7IL9WvapwxsrphnaFG3sfF+Admw xGVMUgasizlepz3SVf86ydrt22OaSpsj+oGlir6TURvjBKV8YsUwrVqqyd2LSL/FYi2ywP VPy4in50q131YNc7iLcfMsB36RLOgJE= X-MC-Unique: 0pNmsET_N7G70XL127YHUA-1 X-Mimecast-MFC-AGG-ID: 0pNmsET_N7G70XL127YHUA_1788352020 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, leif.lindholm@oss.qualcomm.com, eauger@redhat.com Subject: [PATCH 5/6] sbsa-gwdt: don't arm timer for compare values above INT64_MAX Date: Wed, 2 Sep 2026 14:26:45 +0200 Message-ID: <20260902122646.2848464-6-imammedo@redhat.com> In-Reply-To: <20260902122646.2848464-1-imammedo@redhat.com> References: <20260902122646.2848464-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1788352132441158500 QEMU timer subsystem uses int64_t, so a WCV value with bit 63 set would overflow and cause the timer to fire immediately. The SBSA spec defines WCV as an unsigned 64-bit compare value, so such values are valid per spec and represent far-future deadlines (however unpractical). The current code is not affected: WCV writes don't reschedule the timer yet, so a guest-supplied compare value never reaches the timer API. The follow-up patch ("sbsa-gwdt: reschedule timer on direct WCV load") changes that, at which point an out-of-range WCV would overflow the timer. For example, Windows in GTDT mode writes WCV in two 32-bit halves while the watchdog is running: sbsa-gwdt_control_write [0x8] <- 0xffffffff # WOR (~4 sec) sbsa-gwdt_control_write [0x0] <- 0x1 # WCS enable sbsa-gwdt_control_write [0x14] <- 0xffffffff # WCVU (intermediate) sbsa-gwdt_control_write [0x10] <- 0xa906ca28 # WCVL sbsa-gwdt_control_write [0x14] <- 0xecb1 # WCVU (final) The intermediate WCVU write (0xffffffff) yields a WCV above INT64_MAX; once WCV writes arm the timer, this overflows QEMU's signed timer and fires immediately -- triggering WS0 =3D> WS1 =3D> reboot before the final WCVU write lands. Add the guard first, before the WCV rescheduling patch, so the tree stays bisectable. Instead of arming the timer with an unsupported deadline, leave it disarmed. This reuses hw/timer/sse-timer.c:sse_set_timer() (commit 0b8ceee822 "hw/timer/sse-timer: Model the SSE Subsystem System Timer"). Introduce a sbsa_gwdt_set_timer() helper for this and route the WOR-based timeout through it. Signed-off-by: Igor Mammedov Reviewed-by: Peter Maydell --- hw/watchdog/sbsa_gwdt.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c index 1211f1ca65..0a1d981072 100644 --- a/hw/watchdog/sbsa_gwdt.c +++ b/hw/watchdog/sbsa_gwdt.c @@ -99,6 +99,22 @@ static uint64_t sbsa_gwdt_read(void *opaque, hwaddr addr= , unsigned int size) return ret; } =20 +static void sbsa_gwdt_set_timer(SBSA_GWDTState *s, uint64_t deadline) +{ + /* + * WCV is an unsigned 64-bit compare value, but QEMUTimer stores the + * expiry as a signed int64_t. A deadline with bit 63 set would be seen + * as already expired and fire the watchdog immediately. Such a deadli= ne + * is unreachable within any guest runtime, so treat it as "never" and + * leave the timer disarmed instead. + */ + if (deadline <=3D INT64_MAX) { + timer_mod(s->timer, deadline); + } else { + timer_del(s->timer); + } +} + static void sbsa_gwdt_wor_update_timer(SBSA_GWDTState *s, WdtRefreshType r= type) { uint64_t timeout =3D 0; @@ -129,7 +145,7 @@ static void sbsa_gwdt_wor_update_timer(SBSA_GWDTState *= s, WdtRefreshType rtype) s->wcvu =3D timeout >> 32; s->wcvl =3D timeout; =20 - timer_mod(s->timer, timeout); + sbsa_gwdt_set_timer(s, timeout); } =20 static void sbsa_gwdt_rwrite(void *opaque, hwaddr offset, uint64_t data, --=20 2.52.0 From nobody Sat Sep 26 22:14:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1788352129; cv=none; d=zohomail.com; s=zohoarc; b=P4LnRtc0D6WRdxW/V3lt6sATICGhODl9ZN6pEq/ky8tGYjg5LwWhutCmso7znGSPrIfg3pYV6SK+FwE2OPwwBGdz9tXsaLibwZUMv6Qp45ZUx94HJ3Q/yJdRNzG37zG0ke/HDKdYrEmrCUYL3Gi5Eo/n2Gomi0VQGyYhK428BMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788352129; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r7oqY+FZMGLsBaeHNfEEOWl5GCdp9881hq1+4SwL6EQ=; b=VXq2ikQqeF2/ekx4kzf04Ss9GqIoptyzYwUr06/yBJ3fyqDE/7wfSXwZlsuJ65PCcaIaRJsk/3YT/VpcPA4wrROyPPQdWYk+DJPuQUngOJRm25NQi2yzGlPzaSxrN7pkwI2r81Kv4r2XdRz5VdI1HV3oglbBrSYPbBzqseUMp5Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788352129471543.3195249167825; Wed, 2 Sep 2026 05:28:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x1k4p-0006Ui-1D; Wed, 02 Sep 2026 08:28:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4Z-0006Rt-OQ for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x1k4Y-0004tT-65 for qemu-devel@nongnu.org; Wed, 02 Sep 2026 08:28:11 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-711-SBH_cxtuOU2uxA_Xzctf0Q-1; Wed, 02 Sept 2026 08:27:02 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2ABFF1921ED0; Wed, 2 Sep 2026 12:27:01 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 014903000223; Wed, 2 Sep 2026 12:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r7oqY+FZMGLsBaeHNfEEOWl5GCdp9881hq1+4SwL6EQ=; b=GuljDmGetLY1MsD8uEciyeGdMJYNfGvl9C7zAttRGAkYhqDGUcI2a2T0VqhIx5+fg+L746 eWtUasZh68FoyY8ooYXSsvYdz1Ovo3QAhcOSbGGoNNdAt9X5Xt9EFvOOsHl9/Ob8TX4zz9 HW1I9osYeJyCU1wlWyyzIk5i5VDhIx8= X-MC-Unique: SBH_cxtuOU2uxA_Xzctf0Q-1 X-Mimecast-MFC-AGG-ID: SBH_cxtuOU2uxA_Xzctf0Q_1788352021 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, leif.lindholm@oss.qualcomm.com, eauger@redhat.com Subject: [PATCH 6/6] sbsa-gwdt: reschedule timer on direct WCV load Date: Wed, 2 Sep 2026 14:26:46 +0200 Message-ID: <20260902122646.2848464-7-imammedo@redhat.com> In-Reply-To: <20260902122646.2848464-1-imammedo@redhat.com> References: <20260902122646.2848464-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1788352130381158500 According to spec[1]: "The compare value can either be loaded directly or indirectly on an explicit refresh or timeout refresh" QEMU accepts writes to WCV but doesn't reschedule the timer, which it should per the spec pseudo code: "TimeoutRefresh =3D ( SystemCounter [63:0] > CompareValue [63:0])" Fix it by updating the timer on WCV write. partialy[2] fixes Windows in GTDT mode, which never issues a WRR refresh. Instead, it programs WOR to ~4 sec, enables WCS, and immediately writes a large absolute value into WCV to push the timeout far into the future. Without this, QEMU ignores the WCV write, the short WOR expires, and the guest reboots unexpectedly. 1) Arm=C2=AE Server Base System Architecture 6.0 Platform Design Document DEN0029D 6.0 "A.2 Watchdog Operation" 2) under KVM system counter (CNTPCT) as read by guest apprears to produce host's value, so watchdog timeout effectively gets extended on host uptime offset. But that's a separate issue to be fixed. Signed-off-by: Igor Mammedov Reviewed-by: Peter Maydell --- hw/watchdog/sbsa_gwdt.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c index 0a1d981072..9ed109d6eb 100644 --- a/hw/watchdog/sbsa_gwdt.c +++ b/hw/watchdog/sbsa_gwdt.c @@ -148,6 +148,13 @@ static void sbsa_gwdt_wor_update_timer(SBSA_GWDTState = *s, WdtRefreshType rtype) sbsa_gwdt_set_timer(s, timeout); } =20 +static void sbsa_gwdt_wcv_update_timer(SBSA_GWDTState *s) +{ + if (s->wcs & SBSA_GWDT_WCS_EN) { + sbsa_gwdt_set_timer(s, (uint64_t)s->wcvu << 32 | s->wcvl); + } +} + static void sbsa_gwdt_rwrite(void *opaque, hwaddr offset, uint64_t data, unsigned size) { SBSA_GWDTState *s =3D SBSA_GWDT(opaque); @@ -187,10 +194,12 @@ static void sbsa_gwdt_write(void *opaque, hwaddr offs= et, uint64_t data, =20 case SBSA_GWDT_WCV: s->wcvl =3D data; + sbsa_gwdt_wcv_update_timer(s); break; =20 case SBSA_GWDT_WCVU: s->wcvu =3D data; + sbsa_gwdt_wcv_update_timer(s); break; =20 default: --=20 2.52.0