Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1352701rdh; Fri, 24 Nov 2023 10:21:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxUiVaIdiFqb+Fsg/N/7sBMudBf/+C2lEc/JO4EzM9SBtqyl4BWrIK80s4laWkyLlFQt17 X-Received: by 2002:a17:903:41c1:b0:1c9:fdf0:f69 with SMTP id u1-20020a17090341c100b001c9fdf00f69mr4020118ple.63.1700850108753; Fri, 24 Nov 2023 10:21:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700850108; cv=none; d=google.com; s=arc-20160816; b=C1l7cDiMlp/xsMfprDM+XHy6M29NIk2wX+X5eHr2n0gFdCLEJouvRiIysmZR2G4sKW t/iDDvbfa4f+D5EbCUd1A3ET72aOW/FHGUm7zIdE2jKoEh6Q87PoUJQFTWUbjANH0olB kwyBOaV2b9GCSIZau++7hh3nXUUXhc3oMx8MkseOvlGLzahIAFhuuuGppwRCBNp/CIv+ NpvsTVvAGpZqw+1NHc73lt5LREyW/ige0MKaOKaiCyb4mPnAE2MV14mnlS5GVyDJ2lGN ZhAukRdnka2vX+Z3OFSYCbLtey0Ltzf0O/P5F5qngUOWvOcFOAQDFCXONpLbOiUYsmud QRyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3EYGetV5tI7mK8COhpKhT1j3qfXhb0NVDO3D9/JpHzo=; fh=1OZ9RX9IKbqWI8zN0X3f6s2xqddPULldfl5vVKffLis=; b=Z1ZgB7i0MDOnwLTHPvJxjUuBwhjfKwzYzbh6hgoRHtB2cbolmSinesYXUyu2Wifqaq 6IxpJUGTfcFHRmURVKzyoxUKhASHPbpPQorHnYHc8OyBQu4194UOS99D7Ii6o3vuRDj8 /rdxbRawdQ2PUbXBWfqQPQeGzSd8+DMCQ1Kv8k2/B+FgSnBVxCtRSHMBJJdTGX9PqJlo bEMldoJqxlJRDtGdHh7ZDNdn1B1AbOQyVZEdHys3dtxgdw8VNxWhI54WTPrh5VSKlyf5 58g4ecjQ2NFCBETqvDiox/NvObhVvXEVY+38FclTZkkt9CHIfrdMc5MziD9hojqzd23b OiTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NpTYWCQc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z7-20020a170903018700b001cf576043fbsi4122405plg.575.2023.11.24.10.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 10:21:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NpTYWCQc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 70F54821149B; Fri, 24 Nov 2023 10:21:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230484AbjKXSV0 (ORCPT + 99 others); Fri, 24 Nov 2023 13:21:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjKXSVZ (ORCPT ); Fri, 24 Nov 2023 13:21:25 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C0241BFA for ; Fri, 24 Nov 2023 10:21:32 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3CF0C433C7; Fri, 24 Nov 2023 18:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700850092; bh=xi/B/K1H8OvKVsxH1/1c5JnIHvryKND5dQUNfJeOLY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NpTYWCQc4kFWOXmHMtKEgLlY5wKgKU/cEBbyuCxBj9/K/0UdB7z+8FyartXTlRDSI BJFcK41qX6KcyJ5WbXvJ8fh5fCCfWZaRedPNzPuYe1X9Y4PkDX0fslGDsm2e0rVhZI pJYLVn9ppfaQFzUK/+uIJsKd1ET/4YXlw6doSFes= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vanshidhar Konda , Darren Hart , Wim Van Sebroeck , Guenter Roeck , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 6.6 442/530] sbsa_gwdt: Calculate timeout with 64-bit math Date: Fri, 24 Nov 2023 17:50:08 +0000 Message-ID: <20231124172041.551376645@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124172028.107505484@linuxfoundation.org> References: <20231124172028.107505484@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 10:21:45 -0800 (PST) 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Darren Hart commit 5d6aa89bba5bd6af2580f872b57f438dab883738 upstream. Commit abd3ac7902fb ("watchdog: sbsa: Support architecture version 1") introduced new timer math for watchdog revision 1 with the 48 bit offset register. The gwdt->clk and timeout are u32, but the argument being calculated is u64. Without a cast, the compiler performs u32 operations, truncating intermediate steps, resulting in incorrect values. A watchdog revision 1 implementation with a gwdt->clk of 1GHz and a timeout of 600s writes 3647256576 to the one shot watchdog instead of 300000000000, resulting in the watchdog firing in 3.6s instead of 600s. Force u64 math by casting the first argument (gwdt->clk) as a u64. Make the order of operations explicit with parenthesis. Fixes: abd3ac7902fb ("watchdog: sbsa: Support architecture version 1") Reported-by: Vanshidhar Konda Signed-off-by: Darren Hart Cc: Wim Van Sebroeck Cc: Guenter Roeck Cc: linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: # 5.14.x Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/7d1713c5ffab19b0f3de796d82df19e8b1f340de.1695286124.git.darren@os.amperecomputing.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/sbsa_gwdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/watchdog/sbsa_gwdt.c +++ b/drivers/watchdog/sbsa_gwdt.c @@ -152,14 +152,14 @@ static int sbsa_gwdt_set_timeout(struct timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000); if (action) - sbsa_gwdt_reg_write(gwdt->clk * timeout, gwdt); + sbsa_gwdt_reg_write((u64)gwdt->clk * timeout, gwdt); else /* * In the single stage mode, The first signal (WS0) is ignored, * the timeout is (WOR * 2), so the WOR should be configured * to half value of timeout. */ - sbsa_gwdt_reg_write(gwdt->clk / 2 * timeout, gwdt); + sbsa_gwdt_reg_write(((u64)gwdt->clk / 2) * timeout, gwdt); return 0; }