On 09/11/2018 10:57, Li Zhijian wrote:
On 11/9/2018 3:20 PM, Ingo Molnar wrote:Shouldn't this be 0x7fffffff?
* Li Zhijian <lizhijian@xxxxxxxxxxxxxx> wrote:thank a lots. that's amazing.
A 10 years old comment from hpa says:If the kernel initrd creation process creates an initrd whichExactly, it's a real problem.
is larger than 2GB and also claims that it can't be placed
with any part of it above 2GB, then that sounds like a bug
in the initrd creation process...
Add x86 maintainers and LKML:
The background is that QEMU want to support up to 4G initrd. but
linux header (
initrd_addr_max field) only allow 2G-1.
Is one of the below approaches reasonable:
1) change initrd_addr_max to 4G-1 directly
simply(arch/x86/boot/header.S)?
2) lie QEMU bootloader the initrd_addr_max is 4G-1 even though header
said 2G-1
3) any else
ÂÂ initrd_addr_max: .long 0x7fffffff
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # (Header version 0x0203 or
later)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # The highest safe address for
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # the contents of an initrd
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # The current kernel allows
up to 4 GB,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # but leave it at 2 GB to avoid
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # possible bootloader bugs.
To avoid the potential of bugs lurking in dozens of major and hundreds of
minor iterations of various Linux bootloaders I'd prefer a real solution
and extend it - because if there's a 2GB initrd for some weird reason
today there might be a 4GB one in two years.
The real solution would be to:Actually i just knew QEMU(Seabios + optionrom(linuxboot_dma.bin)) can
 - Extend the boot protocol with a 64-bit field, named initrd_addr64_max
ÂÂÂ or such.
 - We don't change the old field - but if the new field is set by new
ÂÂÂ kernels then new bootloaders can use that as a new initrd_addr64_max
ÂÂÂ value. (or reject to load the kernel if the address is too high.)
 - The kernel build should also emit a warning when building larger than
ÂÂÂ 2GB initrds, with a list of bootloaders that support the new
protocol.
support ~4GB initrd so far.
i just drafted at patch to add this field. could you have a look.
another patch which is to document initrd_addr64_max is ongoing.
commit db463ac9c1975f115d1ce2acb82d530c2b63b888
Author: Li Zhijian <lizhijian@xxxxxxxxxxxxxx>
Date:ÂÂ Fri Nov 9 17:24:14 2018 +0800
ÂÂÂ x86: Add header field initrd_addr64_max
ÂÂÂ ÂÂÂ Years ago, kernel had support load ~4GB initrd. But for some
weird reasons (
ÂÂÂ avoid possible bootloader bugs), it only allow leave initrd under
2GB address
ÂÂÂ space(see initrd_addr_max fild at arch/x86/boot/header.S).
ÂÂÂ ÂÂÂ So modern bootloaders have not chance to load >=2G initrd
previously.
ÂÂÂ ÂÂÂ To avoid the potential of bugs lurking in dozens of major and
hundreds of
ÂÂÂ minor iterations of various Linux bootloaders. Ingo suggests to add
a new field
ÂÂÂ initrd_addr64_max. If bootloader believes that it can load initrd to
=2GÂÂÂ address space, it can use initrd_addr64_max as the maximum loading
address in
ÂÂÂ stead of the old field initrd_addr_max.
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 4c881c8..5fc3ebe 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -300,7 +300,7 @@ _start:
ÂÂÂÂÂÂÂ # Part 2 of the header, from the old setup.S
 .ascii "HdrS" # header signature
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ .wordÂÂ 0x020eÂÂÂÂÂÂÂÂÂ # header version number (>= 0x0105)
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ .wordÂÂ 0x020fÂÂÂÂÂÂÂÂÂ # header version number (>= 0x0105)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # or else old loadlin-1.5 will
fail)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ .globl realmode_swtch
Ârealmode_swtch:ÂÂÂÂÂÂÂ .wordÂÂ 0, 0ÂÂÂÂÂÂÂÂÂÂÂ # default_switch, SETUPSEG
@@ -562,6 +562,12 @@ acpi_rsdp_addr:ÂÂÂÂÂÂÂÂÂÂÂ .quad 0
# 64-bit physical pointer to the
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # ACPI RSDP table, added
with
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # version 2.14
+#ifdef CONFIG_INITRD_SIZE_4GB
+initrd_addr64_max:ÂÂÂÂ .quad 0xffffffffÂÂÂÂÂÂÂ # allow ~4G initrd since
2.15
+#else
+initrd_addr64_max:ÂÂÂÂ .quad 0
And please update Documentation/x86/boot.txt
Juergen