[PATCH v1 04/10] bootm: add kexec ELF support

Sascha Hauer s.hauer at pengutronix.de
Thu May 17 00:01:06 PDT 2018


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 at 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.

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 |



More information about the barebox mailing list