[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 38/47] linuxboot: fix loading old kernels
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 38/47] linuxboot: fix loading old kernels |
Date: |
Mon, 15 Dec 2014 17:38:22 +0100 |
Old kernels that used high memory only allowed the initrd to be in the
first 896MB of memory. If you load the initrd above, they complain
that "initrd extends beyond end of memory".
In order to fix this, while not breaking machines with small amounts
of memory fixed by cdebec5 (linuxboot: compute initrd loading address,
2014-10-06), we need to distinguish two cases. If pc.c placed the
initrd at end of memory, use the new algorithm based on the e801
memory map. If instead pc.c placed the initrd at the maximum address
specified by the bzImage, leave it there.
The only interesting part is that the low-memory info block is now
loaded very early, in real mode, and thus the 32-bit address has
to be converted into a real mode segment. The initrd address is
also patched in the info block before entering real mode, it is
simpler that way.
This fixes booting the RHEL4.8 32-bit installation image with 1GB
of RAM.
Cc: address@hidden
Cc: address@hidden
Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>
---
pc-bios/linuxboot.bin | Bin 1024 -> 1024 bytes
pc-bios/optionrom/linuxboot.S | 37 +++++++++++++++++++++++++++----------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/pc-bios/linuxboot.bin b/pc-bios/linuxboot.bin
index
130103fb739228a6869aaf1b174b9d20c13378fc..923d1796fbc58f1a836c160be533d1cf697b7511
100644
GIT binary patch
delta 142
zcmZqRXyBNj#iGKj$vjbS<zxpYS+0XGSo#j68UEiPKG~5;c5)+=ut=jF8xu2AF_&7}
zaW);M|address@hidden|1U|HcrA)eEv?f|address@hidden
o^JH&address@hidden<!fu0k62VPqJWthB%=`*7=0A&s>tpET3
delta 89
zcmV-f0H*(d2!IHXDg?v=$pVossgsWZS(EMo83L>VlL-PJ0%li}!2uqVMgp}0xE7KA
v9R$Z_iNlfnG8kuOkAoNj003sV000004<f*f$d172nf;Rt1M`zm17HDDa`7NG
diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S
index 5bc0af0..ba821ab 100644
--- a/pc-bios/optionrom/linuxboot.S
+++ b/pc-bios/optionrom/linuxboot.S
@@ -76,7 +76,31 @@ boot_kernel:
copy_kernel:
- /* Compute initrd address */
+ /* Read info block in low memory (0x10000 or 0x90000) */
+ read_fw FW_CFG_SETUP_ADDR
+ shr $4, %eax
+ mov %eax, %es
+ xor %edi, %edi
+ read_fw_blob_addr32_edi(FW_CFG_SETUP)
+
+ cmpw $0x203, %es:0x206 // if protocol >= 0x203
+ jae 1f // have initrd_max
+ movl $0x37ffffff, %es:0x22c // else assume 0x37ffffff
+1:
+
+ /* Check if using kernel-specified initrd address */
+ read_fw FW_CFG_INITRD_ADDR
+ mov %eax, %edi // (load_kernel wants it in %edi)
+ read_fw FW_CFG_INITRD_SIZE // find end of initrd
+ add %edi, %eax
+ xor %es:0x22c, %eax // if it matches es:0x22c
+ and $-4096, %eax // (apart from padding for page)
+ jz load_kernel // then initrd is not at top
+ // of memory
+
+ /* pc.c placed the initrd at end of memory. Compute a better
+ * initrd address based on e801 data.
+ */
mov $0xe801, %ax
xor %cx, %cx
xor %dx, %dx
@@ -107,7 +131,9 @@ copy_kernel:
read_fw FW_CFG_INITRD_SIZE
subl %eax, %edi
andl $-4096, %edi /* EDI = start of initrd */
+ movl %edi, %es:0x218 /* put it in the header */
+load_kernel:
/* We need to load the kernel into memory we can't access in 16 bit
mode, so let's get into 32 bit mode, write the kernel and jump
back again. */
@@ -139,19 +165,10 @@ copy_kernel:
/* We're now running in 16-bit CS, but 32-bit ES! */
/* Load kernel and initrd */
- pushl %edi
read_fw_blob_addr32_edi(FW_CFG_INITRD)
read_fw_blob_addr32(FW_CFG_KERNEL)
read_fw_blob_addr32(FW_CFG_CMDLINE)
- read_fw FW_CFG_SETUP_ADDR
- mov %eax, %edi
- mov %eax, %ebx
- read_fw_blob_addr32_edi(FW_CFG_SETUP)
-
- /* Update the header with the initrd address we chose above */
- popl %es:0x218(%ebx)
-
/* And now jump into Linux! */
mov $0, %eax
mov %eax, %cr0
--
1.8.3.1
- [Qemu-devel] [PULL 25/47] cpu-exec: fix cpu_exec_nocache, (continued)
- [Qemu-devel] [PULL 25/47] cpu-exec: fix cpu_exec_nocache, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 28/47] icount: introduce cpu_get_icount_raw, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 29/47] cpu-exec: invalidate nocache translation if they are interrupted, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 30/47] timer: introduce new QEMU_CLOCK_VIRTUAL_RT clock, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 31/47] cpus: make icount warp behave well with respect to stop/cont, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 32/47] i386: do not cross the pages boundaries in replay mode, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 34/47] target-i386: add VME to all CPUs, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 33/47] pc: add 2.3 machine types, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 35/47] target-i386: add f16c and rdrand to Haswell and Broadwell, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 36/47] target-i386: add Ivy Bridge CPU model, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 38/47] linuxboot: fix loading old kernels,
Paolo Bonzini <=
- [Qemu-devel] [PULL 37/47] kvm/apic: fix 2.2->2.1 migration, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 39/47] serial: reset thri_pending on IER writes with THRI=0, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 40/47] serial: clean up THRE/TEMT handling, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 42/47] serial: only resample THR interrupt on rising edge of IER.THRI, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 41/47] serial: update LSR on enabling/disabling FIFOs, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 43/47] sdhci: Set a default frequency clock, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 44/47] sdhci: Remove class "virtual" methods, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 45/47] sdhci: Add "sysbus" to sdhci QOM types and methods, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 46/47] sdhci: Define SDHCI PCI ids, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 47/47] sdhci: Support SDHCI devices on PCI, Paolo Bonzini, 2014/12/15