[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 39/77] i386: allow to load initrd below 4 GB for rece
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 39/77] i386: allow to load initrd below 4 GB for recent linux |
Date: |
Mon, 4 Feb 2019 19:35:41 +0100 |
From: Li Zhijian <address@hidden>
Since linux commit: cf8fa920cb42 ("i386: handle an initrd in highmem (version
2)")
linux has supported initrd up to 4 GB, but the header field
ramdisk_max is still set to 2 GB to avoid "possible bootloader bugs".
When use '-kernel vmlinux -initrd initrd.cgz' to launch a VM,
the firmware(it could be linuxboot_dma.bin) helps to read initrd
contents into guest memory(below ramdisk_max) and jump to kernel.
that's similar with what bootloader does, like grub.
In addition, initrd_max is uint32_t simply because QEMU doesn't support
the 64-bit boot protocol (specifically the ext_ramdisk_image field).
Therefore here just limit initrd_max to UINT32_MAX simply as well to
allow initrd to be loaded below 4 GB.
NOTE: it's possible that linux protocol within [0x208, 0x20c]
supports up to 4 GB initrd as well.
CC: Paolo Bonzini <address@hidden>
CC: Richard Henderson <address@hidden>
CC: Eduardo Habkost <address@hidden>
CC: "Michael S. Tsirkin" <address@hidden>
CC: Marcel Apfelbaum <address@hidden>
Signed-off-by: Li Zhijian <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Reviewed-by: Stefano Garzarella <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/i386/pc.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 9664822..7d8f351 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1299,7 +1299,26 @@ static void load_linux(PCMachineState *pcms,
#endif
/* highest address for loading the initrd */
- if (protocol >= 0x203) {
+ if (protocol >= 0x20c &&
+ lduw_p(header+0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) {
+ /*
+ * Linux has supported initrd up to 4 GB for a very long time (2007,
+ * long before XLF_CAN_BE_LOADED_ABOVE_4G which was added in 2013),
+ * though it only sets initrd_max to 2 GB to "work around bootloader
+ * bugs". Luckily, QEMU firmware(which does something like bootloader)
+ * has supported this.
+ *
+ * It's believed that if XLF_CAN_BE_LOADED_ABOVE_4G is set, initrd can
+ * be loaded into any address.
+ *
+ * In addition, initrd_max is uint32_t simply because QEMU doesn't
+ * support the 64-bit boot protocol (specifically the ext_ramdisk_image
+ * field).
+ *
+ * Therefore here just limit initrd_max to UINT32_MAX simply as well.
+ */
+ initrd_max = UINT32_MAX;
+ } else if (protocol >= 0x203) {
initrd_max = ldl_p(header+0x22c);
} else {
initrd_max = 0x37ffffff;
--
1.8.3.1
- [Qemu-devel] [PULL 21/77] optionrom/pvh: load initrd from fw_cfg, (continued)
- [Qemu-devel] [PULL 21/77] optionrom/pvh: load initrd from fw_cfg, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 25/77] Revert "i386: Add CPUID bit for PCONFIG", Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 27/77] contrib/elf2dmp: fix elf.h including, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 15/77] pvh: Boot uncompressed kernel using direct boot ABI, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 37/77] hw/core/loader.c: Read as long as possible in load_image_size(), Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 40/77] docker: adjust Xen repository for CentOS 7, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 33/77] monitor: do not use QTAILQ_FOREACH_SAFE across critical sections, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 38/77] i386: import & use bootparam.h, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 36/77] unify len and addr type for memory/address APIs, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 34/77] crypto: finish removing TABs, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 39/77] i386: allow to load initrd below 4 GB for recent linux,
Paolo Bonzini <=
- [Qemu-devel] [PULL 35/77] ui: vnc: finish removing TABs, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 41/77] i386: hvf: Don't miss 16-bit displacement, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 43/77] scsi-generic: avoid possible out-of-bounds access to r->buf, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 42/77] gdbstub: Fix i386/x86_64 machine description and add control registers, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 48/77] vfio: move conditional up to hw/Makefile.objs, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 44/77] Remove deprecated -enable-hax option, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 46/77] arm: disable CONFIG_SERIAL_ISA, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 49/77] hw/pci-host/Makefile.objs: make CONFIGS clear for PCI EXPRESS, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 47/77] ide: split ioport registration to a separate file, Paolo Bonzini, 2019/02/04
- [Qemu-devel] [PULL 45/77] qemu-options: Remove deprecated "-virtioconsole" option, Paolo Bonzini, 2019/02/04