Issue in u-boot; TFTP error: trying to overwrite reserved memory...
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello together,
I was trying to build u-boot and spl for the arm target and tried to boot via usb-ethernet.
I found an issue with one of the commit made in the early 2019,
http://patchwork.ozlabs.org/patch/1024795/
When using this CONFIG_LMB the max_size or the *lmb_get_free_size(&lmb, load_addr); *returns 0, no matter what.
And it triggers the following error,
*TFTP error: trying to overwrite reserved memory...*
I did a quick fix by adding *#undef CONFIG_LMB* in the file, *net/tftp.c*
So, I would like to know why this doesn’t work as it was working before applying this patch ?
Best regards,
*Moses Christopher*
Hi,
Quoted 11 lines · Moses Christopher
Hello together,
I was trying to build u-boot and spl for the arm target and tried to boot via usb-ethernet. I found an issue with one of the commit made in the early 2019,
http://patchwork.ozlabs.org/patch/1024795/When using this
CONFIG_LMBthemax_sizeor thelmb_get_free_size(&lmb, load_addr); returns 0, no matter what. And it triggers the following error,
TFTP error: trying to overwrite reserved memory...
I did a quick fix by adding #undefCONFIG_LMBin the file,net/tftp.c
So, I would like to know why this doesn’t work as it was working before applying this patch ?
Can you add "#define DEBUG" as the first line in 'lib/lmb.c'? That should give you debug
output when lmb is used.
The lmb code works by getting the RAM size, adding reserved areas and then only allowing allocations in non-reserved areay. However, the RAM size is not fully used
depending on some config options and/or environment variables. There's possibly something wrong in your configuration around that.
Regards,
Simon
Quoted 3 lines
Best regards,
Moses Christopher
Hi Simon,
Thanks for the prompt reply.
On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, <
[email protected]> wrote:
Hi,
Quoted 3 lines · Moses Christopher
Hello together,
I was trying to build u-boot and spl for the arm target and tried to boot
via usb-ethernet.
Quoted 4 lines
I found an issue with one of the commit made in the early 2019,
http://patchwork.ozlabs.org/patch/1024795/When using this
CONFIG_LMBthemax_sizeor the lmb_get_free_size(&lmb,
load_addr); returns 0, no matter what.
Quoted 4 lines
And it triggers the following error,
TFTP error: trying to overwrite reserved memory...
I did a quick fix by adding #undefCONFIG_LMBin the file,net/tftp.cSo, I would like to know why this doesn’t work as it was working before
applying this patch ?
Can you add "#define DEBUG" as the first line in 'lib/lmb.c'? That should give you debug
output when lmb is used.
I did add DEBUG macro to lmb.c but the function having the debug messages isn't getting called. I suppose it was from fs/fs.c
FYI,
I'm trying to load SPL and uboot on RAM, using USB-ETH. Also the environment is not stored separately, neither the device tree.
The lmb code works by getting the RAM size, adding reserved areas and then only
allowing allocations in non-reserved areay. However, the RAM size is not fully used
depending on some config options and/or environment variables. There's possibly
something wrong in your configuration around that.
Because, earlier to this patch, net/tftp.c isn't actually checking for the reserved memory regions and is able to download the files properly on the RAM and it works. I know, that's not a good approach, hence you've made the necessary changes to correct it.
Could you kindly provide me some information, where I can read more about the reserved memory regions and how exactly some region is treated as reserved region ?
Also, it'd be great if you could provide some information related to the configuration of Reserved and free addresses of RAM.
Thank you for your patience and time.
Regards,
Simon
Quoted 3 lines
Best regards,
Moses Christopher
Best regards,
Moses Christopher
Quoted 24 lines · Moses Christopher
Hi Simon,
Thanks for the prompt reply.
On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, <[email protected]> wrote:
Hi,
Quoted 11 lines · Moses Christopher
Hello together,
I was trying to build u-boot and spl for the arm target and tried to boot via usb-ethernet. I found an issue with one of the commit made in the early 2019,
http://patchwork.ozlabs.org/patch/1024795/When using this
CONFIG_LMBthemax_sizeor thelmb_get_free_size(&lmb, load_addr); returns 0, no matter what. And it triggers the following error,
TFTP error: trying to overwrite reserved memory...
I did a quick fix by adding #undefCONFIG_LMBin the file,net/tftp.c
So, I would like to know why this doesn’t work as it was working before applying this patch ?
Quoted 6 lines
Can you add "#define DEBUG" as the first line in '
lib/lmb.c'? That should give you debug
output when lmb is used.I did add DEBUG macro to
lmb.cbut the function having the debug messages isn't getting called. I suppose it was fromfs/fs.c
Right, tftp.c is missing the call to that funcftion. Could you add the call to 'lmb_dump_all(&lmb);'
right below 'lmb_init_and_reserve()' in tftp.c?
That should give you the output required. And while at it, tell us what 'load_addr' is set to
(by adding a printf in tftp.c, too).
Thanks,
Simon
Quoted 29 lines
FYI,
I'm trying to load SPL and uboot on RAM, using USB-ETH. Also the environment is not stored separately, neither the device tree.The lmb code works by getting the RAM size, adding reserved areas and then only allowing allocations in non-reserved areay. However, the RAM size is not fully used
depending on some config options and/or environment variables. There's possibly something wrong in your configuration around that.Because, earlier to this patch,
net/tftp.cisn't actually checking for the reserved memory regions and is able to download the files properly on the RAM and it works. I know, that's not a good approach, hence you've made the necessary changes to correct it.Could you kindly provide me some information, where I can read more about the reserved memory regions and how exactly some region is treated as reserved region ?
Also, it'd be great if you could provide some information related to the configuration of Reserved and free addresses of RAM.
Thank you for your patience and time.
Regards,
SimonQuoted 3 lines
Best regards,
Moses ChristopherBest regards,
Moses Christopher
Quoted 42 lines · Simon Goldschmidt,
Quoted 7 lines · Moses Christopher
Hi Simon,
Thanks for the prompt reply.
On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, <
Quoted 8 lines · simon.k.r.goldschmidt at gmail.com> wrote:
Hi,
Quoted 3 lines · Moses Christopher
Hello together,
I was trying to build u-boot and spl for the arm target and tried to
boot via usb-ethernet.
Quoted 4 lines
Quoted 4 lines
I found an issue with one of the commit made in the early 2019,
http://patchwork.ozlabs.org/patch/1024795/When using this
CONFIG_LMBthemax_sizeor the lmb_get_free_size(&lmb,
load_addr); returns 0, no matter what.Quoted 4 lines
Quoted 4 lines
And it triggers the following error,
TFTP error: trying to overwrite reserved memory...
I did a quick fix by adding #undefCONFIG_LMBin the file,net/tftp.cSo, I would like to know why this doesn’t work as it was workingbefore applying this patch ?
Quoted 7 lines
Can you add "#define DEBUG" as the first line in '
lib/lmb.c'? That should give you debug
output when lmb is used.I did add DEBUG macro to
lmb.cbut the function having the debugmessages isn't getting called. I suppose it was from
fs/fs.cRight,
tftp.cis missing the call to that funcftion. Could you add the call to 'lmb_dump_all(&lmb);'
right below 'lmb_init_and_reserve()' intftp.c?
Quoted 7 lines
That should give you the output required. And while at it, tell us what '
load_addr' is set to
(by adding a printf intftp.c, too).Thanks,
Simon
Thanks for your patience and time.
Please find the log below,
DHCP client bound to address 172.17.0.2 (1285 ms)
Using usb_ether device
TFTP from server 172.17.0.1; our IP address is 172.17.0.2
Filename 'u-boot.img'.
*lmb_dump_all:*
* memory.cnt = 0x0*
* memory.size = 0xx*
* reserved.cnt = 0x0*
* reserved.size = 0xx*
*load_addr: 0x82000000*
TFTP error: trying to overwrite reserved memory...
Problem booting with BOOTP
*In my u-boot it shows the DRAM size properly as 256MiB*
*So, do I need to configure my RAM size in SPL stage as well, such that SPL is aware of the memory size ?*
Quoted 39 lines
Quoted 3 lines
FYI,
I'm trying to load SPL and uboot on RAM, using USB-ETH. Also theenvironment is not stored separately, neither the device tree.
Quoted 3 lines
The lmb code works by getting the RAM size, adding reserved areas and
then only
Quoted 3 lines
allowing allocations in non-reserved areay. However, the RAM size is not fully used
depending on some config options and/or environment variables. There'spossibly
Quoted 4 lines
something wrong in your configuration around that.
Because, earlier to this patch,
net/tftp.cisn't actually checking forthe reserved memory regions and is able to download the files properly on the RAM and it works. I know, that's not a good approach, hence you've made the necessary changes to correct it.
Quoted 2 lines
Could you kindly provide me some information, where I can read more
about the reserved memory regions and how exactly some region is treated as reserved region ?
Quoted 2 lines
Also, it'd be great if you could provide some information related to the
configuration of Reserved and free addresses of RAM.
Quoted 12 lines
Thank you for your patience and time.
Regards,
SimonQuoted 3 lines
Best regards,
Moses ChristopherBest regards,
Moses Christopher
Quoted 82 lines · Moses Christopher
Quoted 38 lines · Simon Goldschmidt,
Quoted 24 lines · Moses Christopher
Hi Simon,
Thanks for the prompt reply.
On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, <[email protected]> wrote:
Hi,
Quoted 11 lines · Moses Christopher
Hello together,
I was trying to build u-boot and spl for the arm target and tried to boot via usb-ethernet. I found an issue with one of the commit made in the early 2019,
http://patchwork.ozlabs.org/patch/1024795/When using this
CONFIG_LMBthemax_sizeor thelmb_get_free_size(&lmb, load_addr); returns 0, no matter what. And it triggers the following error,
TFTP error: trying to overwrite reserved memory...
I did a quick fix by adding #undefCONFIG_LMBin the file,net/tftp.c
So, I would like to know why this doesn’t work as it was working before applying this patch ?Quoted 6 lines
Can you add "#define DEBUG" as the first line in '
lib/lmb.c'? That should give you debug
output when lmb is used.I did add DEBUG macro to
lmb.cbut the function having the debug messages isn't getting called. I suppose it was fromfs/fs.cRight,
tftp.cis missing the call to that funcftion. Could you add the call to 'lmb_dump_all(&lmb);'
right below 'lmb_init_and_reserve()' intftp.c?Quoted 6 lines
That should give you the output required. And while at it, tell us what '
load_addr' is set to
(by adding a printf intftp.c, too).Thanks,
SimonThanks for your patience and time.
Please find the log below,
DHCP client bound to address 172.17.0.2 (1285 ms)
Using
usb_etherdeviceTFTP from server 172.17.0.1; our IP address is 172.17.0.2
Filename 'u-boot.img'.
lmb_dump_all:memory.cnt = 0x0 memory.size = 0xx reserved.cnt = 0x0 reserved.size = 0xx
load_addr:0x82000000TFTP error: trying to overwrite reserved memory...
Quoted 7 lines
Problem booting with BOOTP
In my u-boot it shows the DRAM size properly as 256MiB
So, do I need to configure my RAM size in SPL stage as well, such that SPL is aware of the memory size ?
Ehrm, are you doing this from SPL?
You need the RAM size for 'lmb_init_and_reserve()' to read, yes. Otherwise it can't know
where to safely allocate things.
Regards,
Simon
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
FYI,
I'm trying to load SPL and uboot on RAM, using USB-ETH. Also the environment is not stored separately, neither the device tree.The lmb code works by getting the RAM size, adding reserved areas and then only allowing allocations in non-reserved areay. However, the RAM size is not fully used
depending on some config options and/or environment variables. There's possibly something wrong in your configuration around that.Because, earlier to this patch,
net/tftp.cisn't actually checking for the reserved memory regions and is able to download the files properly on the RAM and it works. I know, that's not a good approach, hence you've made the necessary changes to correct it.Could you kindly provide me some information, where I can read more about the reserved memory regions and how exactly some region is treated as reserved region ?
Also, it'd be great if you could provide some information related to the configuration of Reserved and free addresses of RAM.
Thank you for your patience and time.
Regards,
SimonQuoted 3 lines
Best regards,
Moses ChristopherBest regards,
Moses Christopher
Quoted 95 lines · Simon Goldschmidt,
Quoted 4 lines · Moses Christopher
On Wed, 11 Sep, 2019, 10:32 AM Simon Goldschmidt, <
Quoted 10 lines · simon.k.r.goldschmidt at gmail.com> wrote:
Quoted 10 lines
Quoted 7 lines · Moses Christopher
Hi Simon,
Thanks for the prompt reply.
On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, <
Quoted 8 lines · simon.k.r.goldschmidt at gmail.com> wrote:
Quoted 8 lines
Quoted 8 lines
Hi,
Quoted 3 lines · Moses Christopher
Hello together,
I was trying to build u-boot and spl for the arm target and tried
to boot via usb-ethernet.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I found an issue with one of the commit made in the early 2019,
http://patchwork.ozlabs.org/patch/1024795/When using this
CONFIG_LMBthemax_sizeor the
lmb_get_free_size(&lmb, load_addr); returns 0, no matter what.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
And it triggers the following error,
TFTP error: trying to overwrite reserved memory... I did a quick fix by adding #undefCONFIG_LMBin the file,
net/tftp.cQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
So, I would like to know why this doesn’t work as it was working
before applying this patch ?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Can you add "#define DEBUG" as the first line in '
lib/lmb.c'? That should give you debug
output when lmb is used.I did add DEBUG macro to
lmb.cbut the function having the debugmessages isn't getting called. I suppose it was from
fs/fs.cQuoted 49 lines
Quoted 11 lines
Right,
tftp.cis missing the call to that funcftion. Could you add the call to 'lmb_dump_all(&lmb);'
right below 'lmb_init_and_reserve()' intftp.c?That should give you the output required. And while at it, tell us what '
load_addr' is set to
(by adding a printf intftp.c, too).Thanks,
SimonThanks for your patience and time.
Please find the log below,
DHCP client bound to address 172.17.0.2 (1285 ms)
Using
usb_etherdeviceTFTP from server 172.17.0.1; our IP address is 172.17.0.2
Filename 'u-boot.img'.
lmb_dump_all:memory.cnt = 0x0 memory.size = 0xx reserved.cnt = 0x0 reserved.size = 0xx
load_addr:0x82000000TFTP error: trying to overwrite reserved memory...
Problem booting with BOOTP
Quoted 7 lines
Quoted 3 lines
In my u-boot it shows the DRAM size properly as 256MiB
So, do I need to configure my RAM size in SPL stage as well, such that
SPL is aware of the memory size ?
Ehrm, are you doing this from SPL?
Yes, SPL loads u-boot onto the DRAM from Network, when the NAND is empty.
By flashing the same MLO and u-boot binaries onto the NAND, and then doing *dhcp
MLO *from u-boot prompt gives the following log,
Using usb_ether device
TFTP from server 172.17.0.1; our IP address is 172.17.0.2 Filename 'MLO'.
*lmb_dump_all:*
*memory.cnt = 0x1memory.size = 0x0memory.reg[0x0].base = 0x80000000.size = 0x10000000reserved.cnt = 0x1reserved.size = 0x0reserved.reg[0x0].base = 0x8df2ab98.size = 0x20d5468*load_addr: 0x80200000
Quoted 8 lines
You need the RAM size for '
lmb_init_and_reserve()' to read, yes. Otherwise it can't know
where to safely allocate things.Regards,
Simon
Would you think, SPL should also do the same or is this valid only for u-boot ?
Because, during SPL stage, the RAM would be mostly free anyway, so would you think, we can just use this lmb check only for u-boot but not for SPL ?
Regards,
Moses Christopher
Quoted 43 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
FYI,
I'm trying to load SPL and uboot on RAM, using USB-ETH. Also theenvironment is not stored separately, neither the device tree.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The lmb code works by getting the RAM size, adding reserved areas and
then only
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
allowing allocations in non-reserved areay. However, the RAM size is not fully used
depending on some config options and/or environment variables.There's possibly
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
something wrong in your configuration around that.
Because, earlier to this patch,
net/tftp.cisn't actually checkingfor the reserved memory regions and is able to download the files properly on the RAM and it works. I know, that's not a good approach, hence you've made the necessary changes to correct it.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Could you kindly provide me some information, where I can read more
about the reserved memory regions and how exactly some region is treated as reserved region ?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Also, it'd be great if you could provide some information related to
the configuration of Reserved and free addresses of RAM.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Thank you for your patience and time.
Regards,
SimonQuoted 3 lines
Best regards,
Moses ChristopherBest regards,
Moses Christopher
Quoted 128 lines · Moses Christopher
On Wed, 11 Sep, 2019, 4:43 PM Simon Goldschmidt,
<[email protected]
<mailto:[email protected]>> wrote:On Wed, Sep 11, 2019 at 11:44 AM Moses Christopher <moseschristopherb at gmail.com <mailto:[email protected]>> wrote: > > > > On Wed, 11 Sep, 2019, 10:32 AM Simon Goldschmidt, <[email protected] <mailto:[email protected]>> wrote: >> >> On Mon, Sep 9, 2019 at 11:29 AM Moses Christopher >> <[email protected] <mailto:[email protected]>> wrote: >> > >> > Hi Simon, >> > >> > >> > Thanks for the prompt reply. >> > >> > On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, <[email protected] <mailto:[email protected]>> wrote: >> > >> > Hi, >> > >> > On Thu, Sep 5, 2019 at 4:14 PM Moses Christopher >> > <[email protected] <mailto:[email protected]>> wrote: >> > > Hello together, >> > > >> > > I was trying to build u-boot and spl for the arm target and tried to boot via usb-ethernet. >> > > I found an issue with one of the commit made in the early 2019, >> > > http://patchwork.ozlabs.org/patch/1024795/ >> > > >> > > When using this CONFIG_LMB the max_size or the lmb_get_free_size(&lmb, load_addr); returns 0, no matter what. >> > > And it triggers the following error, >> > > TFTP error: trying to overwrite reserved memory... >> > > I did a quick fix by adding #undef CONFIG_LMB in the file, net/tftp.c >> > > So, I would like to know why this doesn’t work as it was working before applying this patch ? >> > >> > Can you add "#define DEBUG" as the first line in 'lib/lmb.c'? That >> > should give you debug >> > output when lmb is used. >> > >> > >> > I did add DEBUG macro to lmb.c but the function having the debug messages isn't getting called. I suppose it was from fs/fs.c >> >> Right, tftp.c is missing the call to that funcftion. Could you add the >> call to 'lmb_dump_all(&lmb);' >> right below 'lmb_init_and_reserve()' in tftp.c? >> >> That should give you the output required. And while at it, tell us >> what 'load_addr' is set to >> (by adding a printf in tftp.c, too). >> >> Thanks, >> Simon > > > Thanks for your patience and time. > > Please find the log below, > > > > DHCP client bound to address 172.17.0.2 (1285 ms) > > Using usb_ether device > > TFTP from server 172.17.0.1; our IP address is 172.17.0.2 > > Filename 'u-boot.img'. > > lmb_dump_all: > > memory.cnt = 0x0 > > memory.size = 0xx > > > > reserved.cnt = 0x0 > > reserved.size = 0xx > > load_addr: 0x82000000 > > > > TFTP error: trying to overwrite reserved memory... > > Problem booting with BOOTP > > > > In my u-boot it shows the DRAM size properly as 256MiB > > So, do I need to configure my RAM size in SPL stage as well, such that SPL is aware of the memory size ? Ehrm, are you doing this from SPL?Yes, SPL loads u-boot onto the DRAM from Network, when the NAND is empty.
By flashing the same MLO and u-boot binaries onto the NAND, and then doing *dhcp MLO *from u-boot prompt gives the following log,
Using
usb_etherdevice
TFTP from server 172.17.0.1; our IP address is 172.17.0.2 Filename 'MLO'.
*lmb_dump_all:**
memory.cnt =0x1
memory.size =0x0
memory.reg[0x0].base =0x80000000
.size =0x10000000
Quoted 5 lines
reserved.cnt =
0x1
reserved.size =0x0
reserved.reg[0x0].base =0x8df2ab98
.size = 0x20d5468*load_addr:0x80200000
OK, so that works for a start ;-)
Quoted 7 lines
You need the RAM size for '
lmb_init_and_reserve()' to read, yes. Otherwise it can't know
where to safely allocate things.
Quoted 6 lines
Regards,
SimonWould you think, SPL should also do the same or is this valid only for u-boot ?
Yes, SPL should do the same.
Quoted 3 lines
Because, during SPL stage, the RAM would be mostly free anyway, so would you think, we can just use this lmb check only for u-boot but not for SPL ?
No. SPL still needs this check. On some platforms, SPL runs with BSS, stack or heap in RAM when executing this, so this is still an attack vector that should be prevented.
Even if SPL does not use DRAM (only SRAM), we still have to check that we only write into valid DRAM addresses. E.g. a file larger than the DRAM would write to whatever comes next in the address range...
Which platform are you running this on, does SPL use a devicetree? In any case, you need your SPL to provide the valid RAM range.
Regards,
Simon
Quoted 48 lines
Regards,
Moses Christopher>
>
>>
>> >
>> > FYI,
>> > I'm trying to load SPL and uboot on RAM, using USB-ETH. Also
the environment is not stored separately, neither the device tree.
>> >
>> >
>> > The lmb code works by getting the RAM size, adding reserved
areas and then only
>> > allowing allocations in non-reserved areay. However, the RAM
size is
>> > not fully used
>> > depending on some config options and/or environment variables.
There's possibly
>> > something wrong in your configuration around that. >> >
>> >
>> > Because, earlier to this patch,net/tftp.cisn't actually
checking for the reserved memory regions and is able to download the files properly on the RAM and it works. I know, that's not a good approach, hence you've made the necessary changes to correct it.
>> >
>> > Could you kindly provide me some information, where I can read
more about the reserved memory regions and how exactly some region is treated as reserved region ?
>> >
>> > Also, it'd be great if you could provide some information
related to the configuration of Reserved and free addresses of RAM.
>> >
>> > Thank you for your patience and time.
>> >
>> > Regards,
>> > Simon
>> >
>> > >
>> > > Best regards,
>> > > Moses Christopher
>> >
>> > Best regards,
>> > Moses Christopher
Quoted 163 lines · Simon Goldschmidt,
Quoted 30 lines · Moses Christopher
On Wed, 11 Sep, 2019, 4:43 PM Simon Goldschmidt,
<[email protected]
<mailto:[email protected]>> wrote:On Wed, Sep 11, 2019 at 11:44 AM Moses Christopher <moseschristopherb at gmail.com <mailto:[email protected]>> wrote: > > > > On Wed, 11 Sep, 2019, 10:32 AM Simon Goldschmidt, <[email protected] <mailto:[email protected]>> wrote: >> >> On Mon, Sep 9, 2019 at 11:29 AM Moses Christopher >> <[email protected] <mailto:[email protected]>> wrote: >> > >> > Hi Simon, >> > >> > >> > Thanks for the prompt reply. >> > >> > On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, <[email protected] <mailto:[email protected]>> wrote: >> > >> > Hi, >> >Quoted 8 lines
>> > On Thu, Sep 5, 2019 at 4:14 PM Moses Christopher >> > <[email protected] <mailto:[email protected]>> wrote: >> > > Hello together, >> > > >> > > I was trying to build u-boot and spl for the arm target and tried to boot via usb-ethernet. >> > > I found an issue with one of the commit made in the early2019,
Quoted 4 lines
>> > > http://patchwork.ozlabs.org/patch/1024795/
>> > >
>> > > When using thisCONFIG_LMBthemax_sizeor the
lmb_get_free_size(&lmb, load_addr); returns 0, no matter what.Quoted 8 lines
>> > > And it triggers the following error,
>> > > TFTP error: trying to overwrite reserved memory... >> > > I did a quick fix by adding #undefCONFIG_LMBin the file,
net/tftp.c
>> > > So, I would like to know why this doesn’t work as it was
working before applying this patch ?
>> >
>> > Can you add "#define DEBUG" as the first line in 'lib/lmb.c'?That
Quoted 5 lines
>> > should give you debug
>> > output when lmb is used.
>> >
>> >
>> > I did add DEBUG macro tolmb.cbut the function having theQuoted 8 lines
debug messages isn't getting called. I suppose it was from
fs/fs.c
>>
>> Right,tftp.cis missing the call to that funcftion. Could you
add the
>> call to 'lmb_dump_all(&lmb);'
>> right below 'lmb_init_and_reserve()' intftp.c?
>>
>> That should give you the output required. And while at it, tellus
Quoted 65 lines
>> what 'load_addr' is set to >> (by adding a printf in tftp.c, too). >> >> Thanks, >> Simon > > > Thanks for your patience and time. > > Please find the log below, > > > > DHCP client bound to address 172.17.0.2 (1285 ms) > > Using usb_ether device > > TFTP from server 172.17.0.1; our IP address is 172.17.0.2 > > Filename 'u-boot.img'. > > lmb_dump_all: > > memory.cnt = 0x0 > > memory.size = 0xx > > > > reserved.cnt = 0x0 > > reserved.size = 0xx > > load_addr: 0x82000000 > > > > TFTP error: trying to overwrite reserved memory... > > Problem booting with BOOTP > > > > In my u-boot it shows the DRAM size properly as 256MiB > > So, do I need to configure my RAM size in SPL stage as well, such that SPL is aware of the memory size ? Ehrm, are you doing this from SPL?Yes, SPL loads u-boot onto the DRAM from Network, when the NAND is empty.
By flashing the same MLO and u-boot binaries onto the NAND, and then doing *dhcp MLO *from u-boot prompt gives the following log,
Using
usb_etherdevice
TFTP from server 172.17.0.1; our IP address is 172.17.0.2 Filename 'MLO'.
*lmb_dump_all:**
memory.cnt =0x1
memory.size =0x0
memory.reg[0x0].base =0x80000000
.size =0x10000000Quoted 5 lines
reserved.cnt =
0x1
reserved.size =0x0
reserved.reg[0x0].base =0x8df2ab98
.size = 0x20d5468*load_addr:0x80200000OK, so that works for a start ;-)
Quoted 7 lines
You need the RAM size for '
lmb_init_and_reserve()' to read, yes. Otherwise it can't know
where to safely allocate things.Quoted 6 lines
Regards,
SimonWould you think, SPL should also do the same or is this valid only for u-boot ?
Yes, SPL should do the same.
Quoted 3 lines
Because, during SPL stage, the RAM would be mostly free anyway, so would you think, we can just use this lmb check only for u-boot but not for
SPL ?
Quoted 8 lines
No. SPL still needs this check. On some platforms, SPL runs with BSS, stack or heap in RAM when executing this, so this is still an attack vector that should be prevented.
Even if SPL does not use DRAM (only SRAM), we still have to check that we only write into valid DRAM addresses. E.g. a file larger than the DRAM would write to whatever comes next in the address range...
Ah, that really makes sense. Sorry, if I'm asking too many basic questions.
Which platform are you running this on, does SPL use a devicetree? In
Quoted 2 lines
any case, you need your SPL to provide the valid RAM range.
I'm using TI's AM335x based custom board, yes the SPL has the minimal devicetree embedded.
If I understand it correctly, I've to configure my RAM information properly such that the SPL is able to get the RAM size, reserved size, free size, etc..,
Thanks again for you patience and time.
Regards,
Moses Christopher
Quoted 52 lines
Regards,
SimonQuoted 48 lines
Regards,
Moses Christopher>
>
>>
>> >
>> > FYI,
>> > I'm trying to load SPL and uboot on RAM, using USB-ETH. Also
the environment is not stored separately, neither the device tree.
>> >
>> >
>> > The lmb code works by getting the RAM size, adding reserved
areas and then only
>> > allowing allocations in non-reserved areay. However, the RAM
size is
>> > not fully used
>> > depending on some config options and/or environment variables.
There's possibly
>> > something wrong in your configuration around that. >> >
>> >
>> > Because, earlier to this patch,net/tftp.cisn't actually
checking for the reserved memory regions and is able to download the files properly on the RAM and it works. I know, that's not a good approach, hence you've made the necessary changes to correct it.
>> >
>> > Could you kindly provide me some information, where I can read
more about the reserved memory regions and how exactly some region is treated as reserved region ?
>> >
>> > Also, it'd be great if you could provide some information
related to the configuration of Reserved and free addresses of RAM.
>> >
>> > Thank you for your patience and time.
>> >
>> > Regards,
>> > Simon
>> >
>> > >
>> > > Best regards,
>> > > Moses Christopher
>> >
>> > Best regards,
>> > Moses Christopher
Quoted 204 lines · Moses Christopher
On Wed, 11 Sep, 2019, 9:12 PM Simon Goldschmidt,
<[email protected]
<mailto:[email protected]>> wrote:On 11.09.19 20:59, Moses Christopher wrote:
>
> On Wed, 11 Sep, 2019, 4:43 PM Simon Goldschmidt,
> <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>> wrote:
>
> On Wed, Sep 11, 2019 at 11:44 AM Moses Christopher
> <[email protected]
<mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>>
> wrote:
> >
> >
> >
> > On Wed, 11 Sep, 2019, 10:32 AM Simon Goldschmidt, > <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>> wrote:
> >>
> >> On Mon, Sep 9, 2019 at 11:29 AM Moses Christopher > >> <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>> wrote:
> >> >
> >> > Hi Simon,
> >> >
> >> >
> >> > Thanks for the prompt reply.
> >> >
> >> > On Fri, 6 Sep, 2019, 8:13 AM Simon Goldschmidt, > <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>> wrote:
> >> >
> >> > Hi,
> >> >
> >> > On Thu, Sep 5, 2019 at 4:14 PM Moses Christopher > >> > <[email protected]
<mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>> wrote:
> >> > > Hello together,
> >> > >
> >> > > I was trying to build u-boot and spl for the arm
target and
> tried to boot via usb-ethernet.
> >> > > I found an issue with one of the commit made in the
early 2019,
> >> > > http://patchwork.ozlabs.org/patch/1024795/
> >> > >
> >> > > When using thisCONFIG_LMBthemax_sizeor the > lmb_get_free_size(&lmb,load_addr); returns 0, no matter what. > >> > > And it triggers the following error,
> >> > > TFTP error: trying to overwrite reserved memory... > >> > > I did a quick fix by adding #undefCONFIG_LMBin the
file,
> net/tftp.c
> >> > > So, I would like to know why this doesn’t work as it was > working before applying this patch ?
> >> >
> >> > Can you add "#define DEBUG" as the first line in
'lib/lmb.c'? That
> >> > should give you debug
> >> > output when lmb is used.
> >> >
> >> >
> >> > I did add DEBUG macro tolmb.cbut the function having the > debug messages isn't getting called. I suppose it was from
fs/fs.c
> >>
> >> Right,tftp.cis missing the call to that funcftion.
Could you
> add the
> >> call to 'lmb_dump_all(&lmb);'
> >> right below 'lmb_init_and_reserve()' intftp.c? > >>
> >> That should give you the output required. And while at
it, tell us
> >> what 'load_addr' is set to
> >> (by adding a printf intftp.c, too).
> >>
> >> Thanks,
> >> Simon
> >
> >
> > Thanks for your patience and time.
> >
> > Please find the log below,
> >
> >
> >
> > DHCP client bound to address 172.17.0.2 (1285 ms) > >
> > Usingusb_etherdevice
> >
> > TFTP from server 172.17.0.1; our IP address is 172.17.0.2 > >
> > Filename 'u-boot.img'.
> >
> >lmb_dump_all:
> >
> > memory.cnt =0x0
> >
> > memory.size = 0xx
> >
> >
> >
> > reserved.cnt =0x0
> >
> > reserved.size = 0xx
> >
> >load_addr:0x82000000
> >
> >
> >
> > TFTP error: trying to overwrite reserved memory... > >
> > Problem booting with BOOTP
> >
> >
> >
> > In my u-boot it shows the DRAM size properly as 256MiB > >
> > So, do I need to configure my RAM size in SPL stage as
well, such
> that SPL is aware of the memory size ?
>
> Ehrm, are you doing this from SPL?
>
>
> Yes, SPL loads u-boot onto the DRAM from Network, when the NAND
is empty.
>
> By flashing the same MLO and u-boot binaries onto the NAND, and then > doing *dhcp MLO *from u-boot prompt gives the following log, >
> Usingusb_etherdevice
> TFTP from server 172.17.0.1; our IP address is 172.17.0.2 > Filename 'MLO'.
> *lmb_dump_all:**
> memory.cnt =0x1
> memory.size =0x0
> memory.reg[0x0].base =0x80000000
> .size =0x10000000
>
> reserved.cnt =0x1
> reserved.size =0x0
> reserved.reg[0x0].base =0x8df2ab98
> .size = 0x20d5468*
>load_addr:0x80200000OK, so that works for a start ;-)
>
>
>
> You need the RAM size for 'lmb_init_and_reserve()' to read, yes. > Otherwise it can't know
> where to safely allocate things.
>
> Regards,
> Simon
>
>
> Would you think, SPL should also do the same or is this valid
only for
> u-boot ?Yes, SPL should do the same.
>
> Because, during SPL stage, the RAM would be mostly free anyway,
so would
> you think, we can just use this lmb check only for u-boot but not
for SPL ?No. SPL still needs this check. On some platforms, SPL runs with BSS, stack or heap in RAM when executing this, so this is still an attack vector that should be prevented.
Even if SPL does not use DRAM (only SRAM), we still have to check that we only write into valid DRAM addresses. E.g. a file larger than the DRAM would write to whatever comes next in the address range...
Ah, that really makes sense. Sorry, if I'm asking too many basic questions.
Which platform are you running this on, does SPL use a devicetree? In any case, you need your SPL to provide the valid RAM range.
Quoted 6 lines
I'm using TI's AM335x based custom board, yes the SPL has the minimal devicetree embedded.
If I understand it correctly, I've to configure my RAM information properly such that the SPL is able to get the RAM size, reserved size, free size, etc..,
Yes. I would have expected that to come from the devicetree though...
I'd appreciate if you could come back here with a solution what exactly was missing to get it running, if only for the archives that other users find the result.
Regards,
Simon
Quoted 67 lines
Thanks again for you patience and time.
Regards,
Moses ChristopherRegards,
Simon>
> Regards,
> Moses Christopher
>
> >
>
> >
> >>
> >> >
> >> > FYI,
> >> > I'm trying to load SPL and uboot on RAM, using USB-ETH.
Also
> the environment is not stored separately, neither the device
tree.
> >> >
> >> >
> >> > The lmb code works by getting the RAM size, adding reserved > areas and then only
> >> > allowing allocations in non-reserved areay. However,
the RAM
> size is
> >> > not fully used
> >> > depending on some config options and/or environment
variables.
> There's possibly
> >> > something wrong in your configuration around that. > >> >
> >> >
> >> > Because, earlier to this patch,net/tftp.cisn't actually > checking for the reserved memory regions and is able to
download the
> files properly on the RAM and it works. I know, that's not a good > approach, hence you've made the necessary changes to correct it. > >> >
> >> > Could you kindly provide me some information, where I
can read
> more about the reserved memory regions and how exactly some
region
> is treated as reserved region ?
> >> >
> >> > Also, it'd be great if you could provide some information > related to the configuration of Reserved and free addresses
of RAM.
> >> >
> >> > Thank you for your patience and time.
> >> >
> >> > Regards,
> >> > Simon
> >> >
> >> > >
> >> > > Best regards,
> >> > > Moses Christopher
> >> >
> >> > Best regards,
> >> > Moses Christopher
>