After I added ifdef CONFIG_X86_64 LDFLAGS += $(call ld-option, -z max-page-size=0x1000) endif to arch/x86/Makefile, kernel won't boot and machine goes to BIOS immediately.
I believe this is a bug in our ELF parser that occurs when the output is larger than the input.
X86 Kconfig has config RANDOMIZE_BASE bool "Randomize the address of the kernel image (KASLR)" depends on RELOCATABLE default y ---help--- In support of Kernel Address Space Layout Randomization (KASLR), this randomizes the physical address at which the kernel image is decompressed and the virtual address where the kernel image is mapped, as a security feature that deters exploit attempts relying on knowledge of the location of kernel code internals. On 64-bit, the kernel physical and virtual addresses are randomized separately. The physical address will be anywhere between 16MB and the top of physical memory (up to 64TB). The virtual address will be randomized from 16MB up to 1GB (9 bits of entropy). Note that this also reduces the memory space available to kernel modules from 1.5GB to 1GB. On 32-bit, the kernel physical and virtual addresses are randomized together. They will be randomized from 16MB up to 512MB (8 bits of entropy). Entropy is generated using the RDRAND instruction if it is supported. If RDTSC is supported, its value is mixed into the entropy pool as well. If neither RDRAND nor RDTSC are supported, then entropy is read from the i8254 timer. The usable entropy is limited by the kernel being built using 2GB addressing, and that PHYSICAL_ALIGN must be at a minimum of 2MB. As a result, only 10 bits of entropy are ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Is this possible for linker to use 4KB page size? theoretically possible, but the implementations are further limited due to memory layouts. If unsure, say Y.
Also config PHYSICAL_ALIGN hex "Alignment value to which kernel should be aligned" default "0x200000" range 0x2000 0x1000000 if X86_32 range 0x200000 0x1000000 if X86_64 ---help--- This value puts the alignment restrictions on physical address where kernel is loaded and run from. Kernel is compiled for an address which meets above alignment restriction. If bootloader loads the kernel at a non-aligned address and CONFIG_RELOCATABLE is set, kernel will move itself to nearest address aligned to above value and run from there. If bootloader loads the kernel at a non-aligned address and CONFIG_RELOCATABLE is not set, kernel will ignore the run time load address and decompress itself to the address it has been compiled for and run from there. The address for which kernel is compiled already meets above alignment restrictions. Hence the end result is that kernel runs from a physical address meeting above alignment restrictions. On 32-bit this value must be a multiple of 0x2000. On 64-bit this value must be a multiple of 0x200000. Don't change this unless you know what you are doing.