qemu-patch-raspberry4/hw
Peter Maydell 67505c114e hw/arm/boot: Further improve initrd positioning code
In commit e6b2b20d97 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: e6b2b20d97
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
2019-07-26 16:17:56 +01:00
..
9pfs xen: Import other xen/io/*.h 2019-06-24 10:42:30 +01:00
acpi hw/acpi: extract acpi_add_rom_blob() 2019-06-16 16:16:52 -04:00
adc Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
alpha hw: Replace global smp variables with MachineState for all remaining archs 2019-07-05 17:08:03 -03:00
arm hw/arm/boot: Further improve initrd positioning code 2019-07-26 16:17:56 +01:00
audio Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
block hw/block/pflash_cfi02: Rewrite a fall through comment 2019-07-23 11:31:07 +02:00
bt Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
char xen: Import other xen/io/*.h 2019-06-24 10:42:30 +01:00
core pl031: Correctly migrate state when using -rtc clock=host 2019-07-15 14:17:04 +01:00
cpu general: Replace global smp variables with smp machine properties 2019-07-05 17:07:36 -03:00
cris Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
display hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO 2019-07-15 14:17:03 +01:00
dma pl330: fix vmstate description 2019-07-26 15:40:27 +01:00
gpio Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
hppa hw: Replace global smp variables with MachineState for all remaining archs 2019-07-05 17:08:03 -03:00
hyperv Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
i2c hw/i2c/bitbang_i2c: Use in-place rather than malloc'd bitbang_i2c_interface struct 2019-07-03 10:51:35 +02:00
i386 i386/acpi: show PCI Express bus on pxb-pcie expanders 2019-07-25 04:17:35 -04:00
ide Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
input stellaris_input: Fix vmstate description of buttons field 2019-07-26 16:17:56 +01:00
intc ioapic: kvm: Skip route updates for masked pins 2019-07-25 04:17:35 -04:00
ipack Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
ipmi Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
isa Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
lm32 hw/lm32/Kconfig: Milkymist One provides a USB 1.1 Controller 2019-07-15 20:58:37 +02:00
m68k Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
mem Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
microblaze Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
mips hw: Replace global smp variables with MachineState for all remaining archs 2019-07-05 17:08:03 -03:00
misc hw/misc/aspeed_xdma: New device 2019-07-01 17:29:00 +01:00
moxie Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
net sunhme: ensure that RX descriptor ring overflow is indicated to client driver 2019-07-02 22:49:08 +01:00
nios2 Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
nvram Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
openrisc hw: Replace global smp variables with MachineState for all remaining archs 2019-07-05 17:08:03 -03:00
pci pcie: minor cleanups for slot control/status 2019-07-01 09:17:30 -04:00
pci-bridge xio3130_downstream: typo fix 2019-07-12 10:56:26 -04:00
pci-host i.mx7d: pci: Update PCI IRQ mapping to match HW 2019-07-01 17:28:59 +01:00
pcmcia Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
ppc machine: show if CLI option '-numa node,mem' is supported in QAPI schema 2019-07-05 17:08:03 -03:00
rdma Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
riscv hw/riscv: Load OpenSBI as the default firmware 2019-07-18 14:18:45 -07:00
s390x s390x/pci: add some fallthrough annotations 2019-07-18 11:29:50 +02:00
scsi virtio-scsi: fixed virtio_scsi_ctx_check failed when detaching scsi disk 2019-07-24 11:21:53 +02:00
sd sd: Fix out-of-bounds assertions 2019-06-21 13:25:29 +02:00
semihosting semihosting: split console_out into string and char versions 2019-06-12 17:53:22 +01:00
sh4 Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
smbios machine: Refactor smp-related call chains to pass MachineState 2019-07-05 17:07:36 -03:00
sparc hw: Replace global smp variables with MachineState for all remaining archs 2019-07-05 17:08:03 -03:00
sparc64 hw: Replace global smp variables with MachineState for all remaining archs 2019-07-05 17:08:03 -03:00
ssi hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO 2019-07-15 14:17:03 +01:00
timer pl031: Correctly migrate state when using -rtc clock=host 2019-07-15 14:17:04 +01:00
tpm tpm_emulator: Translate TPM error codes to strings 2019-07-25 11:37:10 -04:00
tricore Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
unicore32 target/unicore32: Use env_cpu, env_archcpu 2019-06-10 07:03:42 -07:00
usb hw/usb/Kconfig: USB_XHCI_NEC requires USB_XHCI 2019-07-15 20:58:37 +02:00
vfio vfio-ccw: Test vfio_set_irq_signaling() return value 2019-07-08 12:10:37 +02:00
virtio virtio-balloon: free pbp more aggressively 2019-07-25 11:19:25 -04:00
watchdog aspeed: Link SCU to the watchdog 2019-07-01 17:29:00 +01:00
xen xen: Import other xen/io/*.h 2019-06-24 10:42:30 +01:00
xenpv xen: Replace few mentions of xend by libxl 2019-01-14 13:45:40 +00:00
xtensa hw: Replace global smp variables with MachineState for all remaining archs 2019-07-05 17:08:03 -03:00
Kconfig semihosting: introduce CONFIG_SEMIHOSTING 2019-05-28 10:28:50 +01:00
Makefile.objs Makefile: do not repeat $(CONFIG_SOFTMMU) in hw/Makefile.objs 2019-07-15 20:58:37 +02:00