From patchwork Sat Jan 7 21:55:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1722760 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ew0f1Hry; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NqDbF1SNxz23g0 for ; Sun, 8 Jan 2023 08:57:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3778E85377; Sat, 7 Jan 2023 22:57:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ew0f1Hry"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D5A9854DF; Sat, 7 Jan 2023 22:57:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 23C518545F for ; Sat, 7 Jan 2023 22:57:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 488A460BFA; Sat, 7 Jan 2023 21:57:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85B26C433EF; Sat, 7 Jan 2023 21:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673128651; bh=qrNsJSO0B2bftvoZeSXbLWGX0VwoOaOH+uMXVPPNzfA=; h=From:To:Cc:Subject:Date:From; b=ew0f1HrybOGqm5HoQ+TsWTBUg7mPH6M46t0ihk8174YRm3nhy96EqPg7WfmVOjk1y hikRx35ZRwZwnayvmbZ0bJ3HQAl2y3LPwKscGOEhfuU0cINFZeraciJuxjlJRlnQxb R5ku3OHUYZQmPIB9k4tjuW9gal/E6bkPYi0BMaN+//rAprHTSfA3UP0PcKNt/thxmX +UQ7YayrOZ1qnPsguKcX84ij852FPhVHrXHNILXYyi0x51LvH07FlNcvLUXcGywP4y hCSmjcft00FguqGbBEYctW7ZycsGDKUOw+P54nu3QEJwTxnQqn+ubj4N/TcZjOzZGj lyEv6j8YxQBAw== Received: by pali.im (Postfix) id E24F1ADB; Sat, 7 Jan 2023 22:57:28 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Tom Rini Cc: Marek Vasut , Patrick Delaunay , u-boot@lists.denx.de Subject: [PATCH] common/memsize.c: Check for overflow in get_effective_memsize() only for mpc85xx Date: Sat, 7 Jan 2023 22:55:26 +0100 Message-Id: <20230107215526.15009-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This reverts commit 777aaaa706bc ("common/memsize.c: Fix get_effective_memsize() to check for overflow") for non-mpc85xx platforms. The changes to this generic function, which is intended to help with 32bit platforms with large amounts of memory has unintended side effects (which in turn lead to boot failures) on other platforms which were previously functional. For now do overflow check only for powerpc mpc85xx platform. It is needed to prevent crashing of P1/P2 boards with 4GB DDR module in 32-bit mode. Fixes: 777aaaa706bc ("common/memsize.c: Fix get_effective_memsize() to check for overflow") Signed-off-by: Pali Rohár --- common/memsize.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/memsize.c b/common/memsize.c index 3c80ad2c8346..54a6416717a3 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -96,6 +96,7 @@ phys_size_t __weak get_effective_memsize(void) { phys_size_t ram_size = gd->ram_size; +#ifdef CONFIG_MPC85xx /* * Check for overflow and limit ram size to some representable value. * It is required that ram_base + ram_size must be representable by @@ -105,6 +106,7 @@ phys_size_t __weak get_effective_memsize(void) */ if (gd->ram_base + ram_size < gd->ram_base) ram_size = ((phys_size_t)~0xfffULL) - gd->ram_base; +#endif #ifndef CONFIG_MAX_MEM_MAPPED return ram_size;