]> git.proxmox.com Git - mirror_qemu.git/commit
hw/arm/boot: Further improve initrd positioning code
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 22 Jul 2019 15:18:04 +0000 (16:18 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 26 Jul 2019 15:17:56 +0000 (16:17 +0100)
commit67505c114e6acc26f3a1a2b74833c61b6a34ff95
treeea85ccdfd9d85e97ecd0ce33d4ac22a77ceaa0d9
parentd5fef92f6aa4e3287e5383e87777b20df9ded69c
hw/arm/boot: Further improve initrd positioning code

In commit e6b2b20d9735d4ef we made the boot loader code try to avoid
putting the initrd on top of the kernel.  However the expression used
to calculate the start of the initrd:

    info->initrd_start = info->loader_start +
        MAX(MIN(info->ram_size / 2, 128 * 1024 * 1024), kernel_size);

incorrectly uses 'kernel_size' as the offset within RAM of the
highest address to avoid.  This is incorrect because the kernel
doesn't start at address 0, but slightly higher than that.  This
means that we can still incorrectly end up overlaying the initrd on
the kernel in some cases, for example:

* The kernel's image_size is 0x0a7a8000
* The kernel was loaded at   0x40080000
* The end of the kernel is   0x4A828000
* The DTB was loaded at      0x4a800000

To get this right we need to track the actual highest address used
by the kernel and use that rather than kernel_size. We already
set image_low_addr and image_high_addr for ELF images; set them
also for the various other image types we support, and then use
image_high_addr as the lowest allowed address for the initrd.
(We don't use image_low_addr, but we set it for consistency
with the existing code path for ELF files.)

Fixes: e6b2b20d9735d4ef
Reported-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Message-id: 20190722151804.25467-3-peter.maydell@linaro.org
hw/arm/boot.c