From: Peter Mamonov <pmamonov@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org, Oleksij Rempel <linux@rempel-privat.de>
Subject: Re: [PATCH v1 04/10] bootm: add kexec ELF support
Date: Thu, 17 May 2018 12:51:41 +0300 [thread overview]
Message-ID: <20180517095140.7lflupvnaveumgjb@localhost.localdomain> (raw)
In-Reply-To: <20180517070106.lkorcut6qwmwx7qi@pengutronix.de>
On Thu, May 17, 2018 at 09:01:06AM +0200, Sascha Hauer wrote:
> On Thu, May 17, 2018 at 06:52:10AM +0200, Oleksij Rempel wrote:
> > Am 16.05.2018 um 23:34 schrieb Peter Mamonov:
> > > Hi!
> > >
> > > On Wed, May 16, 2018 at 06:42:27PM +0200, Oleksij Rempel wrote:
> > >> From: Antony Pavlov <antonynpavlov@gmail.com>
> > >>
> > >> +int kexec_load_bootm_data(struct image_data *data)
> > >> +{
> > >> + int ret;
> > >> + struct kexec_info info;
> > >> + char *cmdline;
> > >> + const char *t;
> > >> + size_t tlen;
> > >> + size_t fsize;
> > >> + char initrd_cmdline[40];
> > >> + int padded = 0;
> > >> +
> > >> + memset(&info, 0, sizeof(info));
> > >> +
> > >> + initrd_cmdline[0] = 0;
> > >> +
> > >> + ret = kexec_load_one_file(&info, data->os_file);
> > >> + if (IS_ERR_VALUE(ret)) {
> > >> + pr_err("Cannot load %s\n", data->os_file);
> > >> + return ret;
> > >> + }
> > >
> > > There is a potential problem here, which I actually hit some time ago. The
> > > following code places kernel arguments right after os image. This is perfectly
> > > fine in case of vmlinuX. However, if one boots a vmlinuZ image, there is no
> > > easily available knowledge of where the decompressed image will reside. In my
> > > case vmlinux' BSS overlapped with DTB and kernel cmdline segments and was
> > > zeroed at linux startup. This was fixed by adding an empty 4k segment at 128M,
> > > so further segments were allocated beyond 128M, far enough from the kernel
> > > lair:
> > >
> > > + /* FIXME: allocate 4k segment @ 0x8000000 (128M), so further
> > > + * segments will be allocated beyond this address. This prevents
> > > + * kernel parameters from being overwritten by the kernel startup code.
> > > + */
> > > + add_segment(&info, (void *)CKSEG0ADDR(0), 4 << 10, 0x8000000, 4 << 10);
> > >
> > > However this is an ad-hoc solution and, probably, find_unused_base() may take
> > > care of such cases.
> >
> > Yes, correct. This and some other issues would be fixed by porting this
> > part of the code to bootm_load_devicetree() + find_unused_base(). Since
> > my time budget is on the limit, I would prefer to mainline current state
> > of the code ("works for me" TM) and provide platform for testing and
> > cooperation.
>
> Can we at least detect that the image is a compressed one and bail out
> with an error? It would be a pity when someone else has to figure out
> this bug the hard way now that we already know that it exists.
I suggest to print a warning message, containing relevant addresses. Something
like this:
ACHTUNG: booting vmlinuZ image. Beware of overlaps of kernel arguments
and vmlinuX sections. List of kernel arguments:
cmdline @ XXXXXXXX-XXXXXXXX
dtb @ XXXXXXXX-XXXXXXXX
However I'm not sure if it is possible to distinguish vmlinuz from vmlinux
reliably, since both are just ELFs, though vmlinuz has only one section.
Moreover, I guess this issue applies to any form of compressed OS image, not
only vmlinuz. So, probably linux should take care about its arguments in
arch/mips/boot/compressed/head.S.
Regards,
Peter
>
> Sascha
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 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
next prev parent reply other threads:[~2018-05-17 9:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 16:42 [PATCH v1 00/10] provide ELF/KEXEC support for MIPS ath79 and malta Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 01/10] resource: add create_resource() helper function Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 02/10] port resource_overlaps() from kernel Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 03/10] filetype: add ELF type Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 04/10] bootm: add kexec ELF support Oleksij Rempel
2018-05-16 21:34 ` Peter Mamonov
2018-05-17 4:52 ` Oleksij Rempel
2018-05-17 7:01 ` Sascha Hauer
2018-05-17 9:51 ` Peter Mamonov [this message]
2018-05-16 16:42 ` [PATCH v1 05/10] MIPS: add kexec ELF loading support Oleksij Rempel
2018-05-17 9:56 ` Sascha Hauer
2018-05-17 10:07 ` Oleksij Rempel
2018-05-18 5:46 ` Sascha Hauer
2018-05-16 16:42 ` [PATCH v1 06/10] MIPS: ath79: enable kexec Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 07/10] MIPS: malta: " Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 08/10] MIPS: configs: add KEXEC=y to atheros devices Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 09/10] MIPS: configs: dptechnics-dpt-module: enable watchdog poller Oleksij Rempel
2018-05-16 16:42 ` [PATCH v1 10/10] MIPS: malta: update malta qemu defconfig Oleksij Rempel
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=20180517095140.7lflupvnaveumgjb@localhost.localdomain \
--to=pmamonov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=linux@rempel-privat.de \
--cc=s.hauer@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