* [PATCH] xilinx: common: change bootm_size to not go beyond ram_top
@ 2022-01-19 22:52 Ricardo Salveti
2022-01-20 7:33 ` Michal Simek
0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Salveti @ 2022-01-19 22:52 UTC (permalink / raw)
To: u-boot; +Cc: michal.simek, igor.opaniuk
The available ram can be limited by ram_top as that depends on the
reserved memory nodes provided by the device-tree (via
board_get_usable_ram_top), so make sure to respect ram_top when setting
up bootm_size to avoid overlapping reserved memory regions (e.g. memory
used by OP-TEE).
The same logic is available in env_get_bootm_size when bootm_size is
not defined by the default environment.
Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
---
board/xilinx/common/board.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 78a5d0efa86..4928fab2c96 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -389,6 +389,9 @@ int board_late_init_xilinx(void)
if (CONFIG_IS_ENABLED(ARCH_ZYNQ) || CONFIG_IS_ENABLED(MICROBLAZE))
bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M));
+ if (gd->ram_base + bootm_size > gd->ram_top)
+ bootm_size = gd->ram_top - gd->ram_base;
+
ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xilinx: common: change bootm_size to not go beyond ram_top
2022-01-19 22:52 [PATCH] xilinx: common: change bootm_size to not go beyond ram_top Ricardo Salveti
@ 2022-01-20 7:33 ` Michal Simek
2022-01-20 16:20 ` Ricardo Salveti
0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2022-01-20 7:33 UTC (permalink / raw)
To: Ricardo Salveti, u-boot; +Cc: michal.simek, igor.opaniuk
On 1/19/22 23:52, Ricardo Salveti wrote:
> The available ram can be limited by ram_top as that depends on the
> reserved memory nodes provided by the device-tree (via
> board_get_usable_ram_top), so make sure to respect ram_top when setting
> up bootm_size to avoid overlapping reserved memory regions (e.g. memory
> used by OP-TEE).
>
> The same logic is available in env_get_bootm_size when bootm_size is
> not defined by the default environment.
>
> Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
> ---
> board/xilinx/common/board.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
> index 78a5d0efa86..4928fab2c96 100644
> --- a/board/xilinx/common/board.c
> +++ b/board/xilinx/common/board.c
> @@ -389,6 +389,9 @@ int board_late_init_xilinx(void)
> if (CONFIG_IS_ENABLED(ARCH_ZYNQ) || CONFIG_IS_ENABLED(MICROBLAZE))
> bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M));
>
> + if (gd->ram_base + bootm_size > gd->ram_top)
> + bootm_size = gd->ram_top - gd->ram_base;
> +
> ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
>
> ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
Isn't it easier to directly setup bootm_size like this?
phys_size_t bootm_size = gd->ram_top - gd->ram_base;
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xilinx: common: change bootm_size to not go beyond ram_top
2022-01-20 7:33 ` Michal Simek
@ 2022-01-20 16:20 ` Ricardo Salveti
0 siblings, 0 replies; 3+ messages in thread
From: Ricardo Salveti @ 2022-01-20 16:20 UTC (permalink / raw)
To: Michal Simek; +Cc: u-boot, michal.simek, igor.opaniuk
On Thu, Jan 20, 2022 at 4:33 AM Michal Simek <monstr@monstr.eu> wrote:
> On 1/19/22 23:52, Ricardo Salveti wrote:
> > The available ram can be limited by ram_top as that depends on the
> > reserved memory nodes provided by the device-tree (via
> > board_get_usable_ram_top), so make sure to respect ram_top when setting
> > up bootm_size to avoid overlapping reserved memory regions (e.g. memory
> > used by OP-TEE).
> >
> > The same logic is available in env_get_bootm_size when bootm_size is
> > not defined by the default environment.
> >
> > Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
> > ---
> > board/xilinx/common/board.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
> > index 78a5d0efa86..4928fab2c96 100644
> > --- a/board/xilinx/common/board.c
> > +++ b/board/xilinx/common/board.c
> > @@ -389,6 +389,9 @@ int board_late_init_xilinx(void)
> > if (CONFIG_IS_ENABLED(ARCH_ZYNQ) || CONFIG_IS_ENABLED(MICROBLAZE))
> > bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M));
> >
> > + if (gd->ram_base + bootm_size > gd->ram_top)
> > + bootm_size = gd->ram_top - gd->ram_base;
> > +
> > ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
> >
> > ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
>
> Isn't it easier to directly setup bootm_size like this?
>
> phys_size_t bootm_size = gd->ram_top - gd->ram_base;
Yup, that should work better, will send a v2.
Thanks,
--
Ricardo Salveti
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-20 16:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 22:52 [PATCH] xilinx: common: change bootm_size to not go beyond ram_top Ricardo Salveti
2022-01-20 7:33 ` Michal Simek
2022-01-20 16:20 ` Ricardo Salveti
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.