All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chintan Vankar <c-vankar@ti.com>
To: Tom Rini <trini@konsulko.com>,
	Siddharth Vadapalli <s-vadapalli@ti.com>, <nm@ti.com>,
	<afd@ti.com>, <vigneshr@ti.com>, <dannenberg@ti.com>,
	<srk@ti.com>
Cc: Sughosh Ganu <sughosh.ganu@linaro.org>, <joe.hershberger@ni.com>,
	<simon.k.r.goldschmidt@gmail.com>, <sjg@chromium.org>,
	<marex@denx.de>, <u-boot@lists.denx.de>
Subject: Re: [PATCH 01/10] board: ti: am62x: Init DRAM size in R5/A53 SPL
Date: Mon, 22 Apr 2024 16:46:04 +0530	[thread overview]
Message-ID: <8997eeb9-c5a7-4bc6-84c0-78693010ccc7@ti.com> (raw)
In-Reply-To: <20240417160446.GF1054907@bill-the-cat>



On 17/04/24 21:34, Tom Rini wrote:
> On Wed, Apr 17, 2024 at 05:48:31PM +0530, Sughosh Ganu wrote:
>> hi Chintan,
>>
>> On Wed, 17 Apr 2024 at 13:21, Chintan Vankar <c-vankar@ti.com> wrote:
>>>
>>>
>>>
>>> On 16/04/24 22:30, Tom Rini wrote:
>>>> On Tue, Apr 16, 2024 at 05:52:58PM +0530, Chintan Vankar wrote:
>>>>>
>>>>>
>>>>> On 12/04/24 03:37, Tom Rini wrote:
>>>>>> On Wed, Apr 03, 2024 at 06:18:01PM +0530, Chintan Vankar wrote:
>>>>>>>
>>>>>>>
>>>>>>> On 22/01/24 10:11, Siddharth Vadapalli wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> On 20/01/24 22:11, Tom Rini wrote:
>>>>>>>>> On Mon, Jan 15, 2024 at 01:42:51PM +0530, Siddharth Vadapalli wrote:
>>>>>>>>>> Hello Tom,
>>>>>>>>>>
>>>>>>>>>> On 12/01/24 18:56, Tom Rini wrote:
>>>>>>>>
>>>>>>>> ...
>>>>>>>>
>>>>>>>>>>> The list of conditionals in common/spl/spl.c::board_init_r() should be
>>>>>>>>>>> updated and probably use SPL_NET as the option to check for.
>>>>>>>>>>
>>>>>>>>>> Thank you for reviewing the patch and pointing this out. I wasn't aware of it. I
>>>>>>>>>> assume that you are referring to the following change:
>>>>>>>>>>
>>>>>>>>>>             if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) ||
>>>>>>>>>> -           IS_ENABLED(CONFIG_SPL_ATF))
>>>>>>>>>> +           IS_ENABLED(CONFIG_SPL_ATF) || IS_ENABLED(CONFIG_SPL_NET))
>>>>>>>>>>                     dram_init_banksize();
>>>>>>>>>>
>>>>>>>>>> I shall replace the current patch with the above change in the v2 series. Since
>>>>>>>>>> this is in the common section, is there a generic reason I could provide in the
>>>>>>>>>> commit message rather than the existing commit message which seems to be board
>>>>>>>>>> specific? Also, I hope that the above change will not cause regressions for
>>>>>>>>>> other non-TI devices. Please let me know.
>>>>>>>>>
>>>>>>>>> Yes, that's the area, and just note that networking also requires the
>>>>>>>>> DDR to be initialized.
>>>>>>>>>
>>>>>>>>
>>>>>>>> Thank you for confirming and providing your suggestion for the contents of the
>>>>>>>> commit message.
>>>>>>>>
>>>>>>> Following Tom's Suggestion of adding CONFIG_SPL_NET in common/spl/spl.c
>>>>>>> "dram_init_banksize()", the issue of fetching a file at SPL stage seemed
>>>>>>> to be fixed. However the commit "ba20b2443c29", which sets gd->ram_top
>>>>>>> for the very first time in "spl_enable_cache()" results in
>>>>>>> "arch_lmb_reserve()" function reserving memory region from Stack pointer
>>>>>>> at "0x81FFB820" to gd->ram_top pointing to "0x100000000". Previously
>>>>>>> when gd->ram_top was zero "arch_lmb_reserve()" was noop. Now using TFTP
>>>>>>> to fetch U-Boot image at SPL stage results in "tftp_init_load_addr()"
>>>>>>> function call that invokes "arch_lmb_reserve()" function, which reserves
>>>>>>> entire memory starting from Stack Pointer to gd->ram_top leaving no
>>>>>>> space to load U-Boot image via TFTP since TFTP loads files at pre
>>>>>>> configured memory address at "0x82000000".
>>>>>>>
>>>>>>> As a workaround for this issue, one solution we can propose is to
>>>>>>> disable the checks "lmb_get_free_size()" at SPL and U-Boot stage. For
>>>>>>> that we can define a new config option for LMB reserve checks as
>>>>>>> "SPL_LMB". This config will be enable by default for the backword
>>>>>>> compatibility and disable for our use case at SPL and U-Boot stage.
>>>>>>
>>>>>> The problem here is that we need LMB for booting an OS, which is
>>>>>> something we'll want in SPL in non-cortex-R cases too, which means this
>>>>>> platform, so that's a no-go. I think you need to dig harder and see if
>>>>>> you can correct the logic somewhere so that we don't over reserve?
>>>>>>
>>>>> Since this issue is due to function call "lmb_init_and_reserve()"
>>>>> function invoked from "tftp_init_load_addr()" function. This function
>>>>> is defined by Simon in commit "a156c47e39ad", which fixes
>>>>> "CVE-2018-18439" to prevent overwriting reserved memory. Simon, can you
>>>>> explain why do we need to call "lmb_init_and_reserve()" function here ?
>>>>
>>>> This is indeed a tricky area which is why Sughosh is looking in to
>>>> trying to re-work the LMB mechanic and we've had a few long threads
>>>> about it as well.
>>>>
>>>> I've honestly forgotten the use case you have here, can you please
>>>> remind us?
>>>>
>>> We are trying to boot AM62x using Ethernet for which we need to load
>>> binary files at SPL and U-Boot stage using TFTP. To store the file we
>>> need a free memory in RAM, specifically we are storing these files at
>>> 0x82000000. But we are facing an issue while loading the file since
>>> the memory area having an address 0x82000000 is reserved due to
>>> "lmb_init_and_reserve()" function call. This function is called in
>>> "tftp_init_load_addr()" function which is getting called exactly before
>>> we are trying to get the free memory area by calling
>>> "lmb_get_free_size()".
>>
>> I have no idea about your platform but I was wondering if there is any
>> particular importance of the load address of 0x82000000? It looks as
>> though the current location of the SP when arch_lmb_reserve() gets
>> called means that the load address is getting reserved for the U-Boot
>> image. Do you not have the option of loading the image at a lower
>> address instead?
> 
> Or using a higher address for SPL stack? You might be able to solve this
> just by re-examining which addresses (and RAM size limitations) need to
> be considered here.
> 

Tom,

We changed SPL_STACK_R_ADDR to higher address as you suggested here and
observe that the memory area which was getting reserved by
"lmb_init_and_reserve()" function, when SPL_STACK_R_ADDR was 0x82000000,
is from 0x81FFB820 to gd->ram_top, but when SPL_STACK_R_ADDR is changed
to 0x83000000, stack pointer is pointing to 0x82FFB810 and reserving a
memory area till gd->ram_top. Since memory address 0x82000000 is not
there in reserved memory area region U-Boot proper is successfully
getting fetched and we are able to boot.

Can it be considered of changing "SPL_STACK_R_ADDR" independently for
Ethernet Boot feature ?

  parent reply	other threads:[~2024-04-22 11:16 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12  6:47 [PATCH 00/10] Add support for Ethernet Boot on SK-AM62 Siddharth Vadapalli
2024-01-12  6:47 ` [PATCH 01/10] board: ti: am62x: Init DRAM size in R5/A53 SPL Siddharth Vadapalli
2024-01-12 12:26   ` Nishanth Menon
2024-01-12 12:31     ` Siddharth Vadapalli
2024-01-12 12:40       ` Nishanth Menon
2024-01-12 13:26   ` Tom Rini
2024-01-15  8:12     ` Siddharth Vadapalli
2024-01-20 16:41       ` Tom Rini
2024-01-22  4:41         ` Siddharth Vadapalli
2024-04-03 12:48           ` Chintan Vankar
2024-04-11 22:07             ` Tom Rini
2024-04-16 12:22               ` Chintan Vankar
2024-04-16 17:00                 ` Tom Rini
2024-04-17  7:50                   ` Chintan Vankar
2024-04-17 12:18                     ` Sughosh Ganu
2024-04-17 16:04                       ` Tom Rini
2024-04-18 10:38                         ` Chintan Vankar
2024-04-18 12:00                           ` Sughosh Ganu
2024-04-19 10:34                             ` Chintan Vankar
2024-04-19 11:34                               ` Sughosh Ganu
2024-04-19 11:52                                 ` Chintan Vankar
2024-04-19 12:00                                   ` Sughosh Ganu
2024-04-18 18:13                           ` Tom Rini
2024-04-22 11:16                         ` Chintan Vankar [this message]
2024-04-22 15:03                           ` Tom Rini
2024-01-12  6:47 ` [PATCH 02/10] firmware: ti_sci: Add No-OP for "RX_FL_CFG" Siddharth Vadapalli
2024-01-12  6:47 ` [PATCH 03/10] soc: ti: k3-navss-ringacc: Initialize base address of ring cfg registers Siddharth Vadapalli
2024-01-16 11:43   ` Roger Quadros
2024-04-24 12:52     ` Chintan Vankar
2024-01-12  6:47 ` [PATCH 04/10] soc: ti: k3-navss-ringacc: Fix reset ring API Siddharth Vadapalli
2024-01-12  6:47 ` [PATCH 05/10] dma: ti: k3-udma: Add support for native configuration of chan/flow Siddharth Vadapalli
2024-01-12  6:47 ` [PATCH 06/10] arm: mach-k3: am62: Update SoC autogenerated data to enable Ethernet Boot Siddharth Vadapalli
2024-01-12 12:28   ` Nishanth Menon
2024-01-12  6:47 ` [PATCH 07/10] arm: mach-k3: am625_init: Probe AM65 CPSW NUSS Siddharth Vadapalli
2024-01-12 12:30   ` Nishanth Menon
2024-01-22 10:19     ` Chintan Vankar
2024-01-23 20:57       ` Nishanth Menon
2024-02-27 11:24         ` Chintan Vankar
2024-01-12  6:47 ` [PATCH 08/10] configs: am62: Add configs for enabling ETHBOOT in R5SPL Siddharth Vadapalli
2024-01-12 12:31   ` Nishanth Menon
2024-01-12 12:38     ` Siddharth Vadapalli
2024-01-12  6:47 ` [PATCH 09/10] configs: am62x_evm_a53_defconfig: Enable configs required for Ethboot Siddharth Vadapalli
2024-01-12 12:33   ` Nishanth Menon
2024-01-12 12:39     ` Siddharth Vadapalli
2024-01-12  6:47 ` [PATCH 10/10] arm: dts: k3-am625-r5-sk: Enable DM services for main_pktdma Siddharth Vadapalli
2024-01-12 12:32 ` [PATCH 00/10] Add support for Ethernet Boot on SK-AM62 Nishanth Menon
2024-01-12 12:36   ` Siddharth Vadapalli
2024-01-12 12:42     ` Nishanth Menon
2024-01-12 12:47       ` Siddharth Vadapalli
2024-01-12 13:01         ` Nishanth Menon
2024-01-15  8:16           ` Siddharth Vadapalli

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=8997eeb9-c5a7-4bc6-84c0-78693010ccc7@ti.com \
    --to=c-vankar@ti.com \
    --cc=afd@ti.com \
    --cc=dannenberg@ti.com \
    --cc=joe.hershberger@ni.com \
    --cc=marex@denx.de \
    --cc=nm@ti.com \
    --cc=s-vadapalli@ti.com \
    --cc=simon.k.r.goldschmidt@gmail.com \
    --cc=sjg@chromium.org \
    --cc=srk@ti.com \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.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.