From: Lukasz Majewski <lukma@denx.de>
To: Tom Rini <trini@konsulko.com>,
Patrick Delaunay <patrick.delaunay@foss.st.com>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Marek Vasut <marex@denx.de>
Cc: Sughosh Ganu <sughosh.ganu@linaro.org>,
Simon Glass <sjg@chromium.org>,
uboot-stm32@st-md-mailman.stormreply.com, u-boot@lists.denx.de,
Lukasz Majewski <lukma@denx.de>
Subject: [PATCH] ARM: stm32mp: Correct sign extension for memory address in dram_bank_mmu_setup()
Date: Sat, 10 May 2025 08:52:56 +0200 [thread overview]
Message-ID: <20250510065256.267546-1-lukma@denx.de> (raw)
On a system based on stm32mp157c, with 1GiB SDRAM (starting from
0xC0000000) and CONFIG_PHYS_64BIT enabled (so the phys_addr_t becomes
'unsigned long long') the mainline u-boot hangs.
It is caused by marking for this memory region the TLB entry as invalid
in the dram_bank_mmu_setup().
To be more specific the condition of 'addr >= gd->ram_top' is met
in this case.
The reason for it is that the 'addr' variable in that function has sign
extension from 'int' typed i automatic variable:
addr = i << MMU_SECTION_SHIFT;
For example i = 0xc01 causes addr = 0xffffffffc0000000 as int typed i
variable (with MSB bit set) is sign extended to unsigned long long addr.
The proposed fix is to change i type from 'int' to 'unsigned int', so the
sign extension will not take place and addr = 0xc0000000, which is smaller
than gd->ram_top = 0x100000000.
This change shall be safe as i shall not be negative as it represents the
SDRAM areas (in granularity of 1MiB areas).
Fixes: 25fb58e88aba ("ARM: stm32mp: Fix dram_bank_mmu_setup() for LMB located above ram_top")
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
arch/arm/mach-stm32mp/stm32mp1/cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
index d5eaf6711b6..0ed5eda47d0 100644
--- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c
+++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
@@ -51,7 +51,7 @@ u32 get_bootauth(void)
void dram_bank_mmu_setup(int bank)
{
struct bd_info *bd = gd->bd;
- int i;
+ unsigned int i;
phys_addr_t start;
phys_addr_t addr;
phys_size_t size;
--
2.39.5
next reply other threads:[~2025-05-10 6:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-10 6:52 Lukasz Majewski [this message]
2025-05-11 20:57 ` [PATCH] ARM: stm32mp: Correct sign extension for memory address in dram_bank_mmu_setup() Marek Vasut
2025-05-12 8:25 ` Lukasz Majewski
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=20250510065256.267546-1-lukma@denx.de \
--to=lukma@denx.de \
--cc=marex@denx.de \
--cc=patrice.chotard@foss.st.com \
--cc=patrick.delaunay@foss.st.com \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-stm32@st-md-mailman.stormreply.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.