mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Clément Leger" <cleger@kalray.eu>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH v3 0/7] elf: add better bootm support
Date: Wed, 29 Apr 2020 10:55:47 +0200 (CEST)	[thread overview]
Message-ID: <1607721324.18161455.1588150547040.JavaMail.zimbra@kalray.eu> (raw)
In-Reply-To: <20200429083455.wpx47lw74dd6tpni@pengutronix.de>

Hi Oleksij,

----- On 29 Apr, 2020, at 10:34, Oleksij Rempel o.rempel@pengutronix.de wrote:

> Hi Clement,
> 
> i tested you patches on my MIPS board. I get following ooops:
> ===============================================================================
> barebox@DPTechnics DPT-Module:/ iomem
> 0x00000000 - 0xffffffff (size 0x00000000) iomem
>  0x18020000 - 0x18020013 (size 0x00000014) 18020000.uart@18020000.of
>  0x18040000 - 0x18040033 (size 0x00000034) 18040000.gpio@18040000.of
>  0x18050000 - 0x180500ff (size 0x00000100) 18050000.pll-controller@18050000.of
>  0x18060008 - 0x1806000f (size 0x00000008) 18060008.wdt@18060008.of
>  0x18070000 - 0x180700ff (size 0x00000100) 19000000.ethernet@19000000.of
>  0x19000000 - 0x190001ff (size 0x00000200) 19000000.ethernet@19000000.of
>  0x1f000000 - 0x1f00000f (size 0x00000010) 1f000000.spi@1f000000.of
>  0x80000000 - 0x83ffffff (size 0x04000000) kseg0_ram0
>    0x80000000 - 0x80007fff (size 0x00008000) vector
>    0x83788000 - 0x8378ffff (size 0x00008000) stack
>    0x83790000 - 0x83f8ffff (size 0x00800000) malloc space
>    0x83f90000 - 0x83fe66df (size 0x000566e0) barebox
>    0x83fe66e0 - 0x83feb0bf (size 0x000049e0) barebox data
>    0x83ff30c0 - 0x83ff5fe7 (size 0x00002f28) bss
> barebox@DPTechnics DPT-Module:/ boot net
> Booting entry 'net'
> eth0: DHCP client bound to address 192.168.26.229
> Entry Point:  00000000
> 
> Loading ELF '/mnt/tftp/ore-linux-dpt-module'
> Loading devicetree from '/mnt/tftp/ore-oftree-dpt-module'
> Starting application at 0x80000000, dts 0x837c325c...
> 
> Ooops, TLB miss on load or ifetch!
> 
> $ 0   : 00000000 00000020 00000000 80010000
> $ 4   : fffffffe 83a80000 00010000 00008000
> $ 8   : 83790008 8379b440 8379b440 8379b5ec
> $12   : 83790000 00010000 00000060 00000011
> $16   : 837c3728 ffffffea 83a80000 80000000
> $20   : 00000000 00000000 00000000 00000000
> $24   : 00000000 00000000
> $28   : 83e6c000 8378fc30 83fdfa20 83fd55cc
> Hi    : 00063c6c
> Lo    : 60000000
> epc   : 00000000
> ra    : 83fd55cc
> Status: 10000002
> Cause : 40008008
> Config: 80208483
> 
> ### ERROR ### Please RESET the board ###
> ===============================================================================
> 
> The same test without patches looks like this:
> rebox@DPTechnics DPT-Module:/ boot net
> Booting entry 'net'
> eth0: DHCP client bound to address 192.168.26.229
> 
> Loading ELF '/mnt/tftp/ore-linux-dpt-module'
> Loading devicetree from '/mnt/tftp/ore-oftree-dpt-module'
> Starting application at 0x80980000, dts 0x837c2e54...
> [    0.000000] Linux version 5.7.0-rc1-rt7-00316-g9b716caac68c9
> (ptxdist@ptxdist) (gcc version 9.2.1 20191130 (OSELAS.Toolchain-2019.09.1
> 9-20191130), GNU ld (GNU Binutils) 2.32) #1 PREEMPT 2020-04-23T06:16:46+00:00
> [    0.000000] printk: bootconsole [early0] enabled
> [
> 
> The main difference is:
> Starting application at 0x80980000, dts 0x837c2e54... <<- works
> Starting application at 0x80000000, dts 0x837c325c... <<- oops

Ok I got it, the error come from the fact that elf->entry is initialized
in load_elf_image_phdr but used before that. I will send a V4 to fix this.
It worked on our elf loader since the code is loaded at 0x0 and the entry
point is at 0 :/.
I will fix that by initializing elf->entry in elf_open instead of elf_load.

BTW, if you have an elf that I can try, since I already built a mips 
barbeox, I will be able to test it on qemu.

Thanks for testing,

Clément

> 
> Even with applied patch to protect exception vectore code, we still
> overwriting it:
>    0x80000000 - 0x80007fff (size 0x00008000) vector
> 
> Any ideas?
> 
> On Tue, Apr 28, 2020 at 09:50:53AM +0200, Clement Leger wrote:
>> Currently, when booting an elf file using "bootm /dev/mtdx", bootm will
>> simply pass the file to the bootm and the read done on it will read the
>> entire flash partition. This series starts by some cleanup and then add an
>> elf_open function to load the elf file size only based on the elf header.
>> A special handling for the elf file is also added in bootm data to allow
>> using directly the elf file structure. Finally the mips bootm is modified
>> to use bootm_load_os directly instead of manual elf loading.
>> 
>> Changes v2 -> v3
>>  - Integrate elf loading in bootm_load_os
>>  - Add patch to remove now unused elf_load_image/elf_release_image
>>  - Use malloc instead of xmalloc and check return value
>> 
>> Changes v1 -> v2
>>  - Add BOOTM_ELF config to select elf support and add checks in code
>>  - Add an elf_get_mem_size function to avoid computing elf size in bootm.c
>>  - Use xmalloc and read_full in elf_open instead of xzalloc/read
>>  - Fix data->elf NULL reset
>>  - Remove elf struct entirely from mips bootm code
>> 
>> Clement Leger (7):
>>   common: elf: add computation of elf boundaries
>>   common: elf: fix warning on 32 bits architectures
>>   common: elf: split init to be reused from other function
>>   common: elf: add elf_open, elf_close and elf_load
>>   common: bootm: add support for elf file loading
>>   mips: lib: bootm: use bootm elf loading capabilities
>>   common: elf: remove elf_load_image/elf_release_image
>> 
>>  arch/mips/lib/bootm.c |  31 +++++-------
>>  common/Kconfig        |   8 ++++
>>  common/bootm.c        |  33 +++++++++++++
>>  common/elf.c          | 107 ++++++++++++++++++++++++++++++++++++------
>>  include/bootm.h       |   3 ++
>>  include/elf.h         |  16 ++++++-
>>  6 files changed, 161 insertions(+), 37 deletions(-)
>> 
>> --
>> 2.17.1
>> 
>> 
>> _______________________________________________
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
>> 
> 
> --
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2020-04-29  8:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  7:50 Clement Leger
2020-04-28  7:50 ` [PATCH v3 1/7] common: elf: add computation of elf boundaries Clement Leger
2020-04-28  7:50 ` [PATCH v3 2/7] common: elf: fix warning on 32 bits architectures Clement Leger
2020-04-28  7:50 ` [PATCH v3 3/7] common: elf: split init to be reused from other function Clement Leger
2020-04-28  7:50 ` [PATCH v3 4/7] common: elf: add elf_open, elf_close and elf_load Clement Leger
2020-04-28  7:50 ` [PATCH v3 5/7] common: bootm: add support for elf file loading Clement Leger
2020-04-28  7:50 ` [PATCH v3 6/7] mips: lib: bootm: use bootm elf loading capabilities Clement Leger
2020-04-28  7:51 ` [PATCH v3 7/7] common: elf: remove elf_load_image/elf_release_image Clement Leger
2020-04-29  8:34 ` [PATCH v3 0/7] elf: add better bootm support Oleksij Rempel
2020-04-29  8:55   ` Clément Leger [this message]

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=1607721324.18161455.1588150547040.JavaMail.zimbra@kalray.eu \
    --to=cleger@kalray.eu \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.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