diff mbox series

common/memsize.c: Check for overflow in get_effective_memsize() only for mpc85xx

Message ID 20230107215526.15009-1-pali@kernel.org
State Accepted
Commit d1f4b090dd17ee11373859f2c91af94bf254af7a
Delegated to: Tom Rini
Headers show
Series common/memsize.c: Check for overflow in get_effective_memsize() only for mpc85xx | expand

Commit Message

Pali Rohár Jan. 7, 2023, 9:55 p.m. UTC
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 <pali@kernel.org>
---
 common/memsize.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Tom Rini Jan. 8, 2023, 4:53 p.m. UTC | #1
On Sat, Jan 07, 2023 at 10:55:26PM +0100, Pali Rohár wrote:

> 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 <pali@kernel.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

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;