public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Tom Rini <trini@konsulko.com>
Cc: Marek Vasut <marex@denx.de>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	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	[thread overview]
Message-ID: <20230107215526.15009-1-pali@kernel.org> (raw)

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(+)

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;
-- 
2.20.1


             reply	other threads:[~2023-01-07 21:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 21:55 Pali Rohár [this message]
2023-01-08 16:53 ` [PATCH] common/memsize.c: Check for overflow in get_effective_memsize() only for mpc85xx Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230107215526.15009-1-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=marex@denx.de \
    --cc=patrick.delaunay@foss.st.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox