i am using the 4.19.149 kernel on x86_64 platform running on centos6.2.my compile kernel configuration contains the following options:
CONFIG_PHYSICAL_START=0x1000000CONFIG_RELOCATABLE=yCONFIG_RANDOMIZE_BASE=y
my kernel command line is:
?> cat /proc/cmdlinero root=LABEL=/ rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=512M@0M nompath append="nmi_watchdog=2" printk.time=1 rd_NO_LVM rd_NO_DM dm_mod.use_blk_mq=y rcutree.kthread_prio=99 intel_pstate=enable intel_idle.max_cstate=0 processor.max_cstate=1 idle=halt console=tty0 console=ttyS0,38400n8d
so to summarize thing:
- i am requesting the kernel to allocate 512M for crashkernel at the low memory region.when looking in the kernel arch/x86/kernel/setup.c:i can see that for my configuration the memory the kernel tries allocating those 512M ar between 16M-896M:
#define CRASH_ALIGN (16 << 20)...# define CRASH_ADDR_LOW_MAX (896UL << 20)...static void __init reserve_crashkernel(void).... if (crash_base <= 0) { /* * Set CRASH_ADDR_LOW_MAX upper bound for crash memory, * as old kexec-tools loads bzImage below that, unless * "crashkernel=size[KMG],high" is specified. */ crash_base = memblock_find_in_range(CRASH_ALIGN, high ? CRASH_ADDR_HIGH_MAX : CRASH_ADDR_LOW_MAX, crash_size, CRASH_ALIGN); if (!crash_base) { pr_info("crashkernel reservation failed - No suitable area found.\n"); return; }```
- since i am using the CONFIG_RANDOMIZE_BASE option, on boot, before allocating the memory for thecrashkernel, the boot loader extract my kernel into randomize physical address.code at arch/x86/boot/compressed/kaslr.c
the problem is that once i a while, the randomize kernel address causes failure in allocating memory for the crashkernel.for example: on one of my reboots:
?> cat /proc/iomem00000000-00000fff : Reserved00001000-0009fbff : System RAM0009fc00-0009ffff : Reserved000a0000-000bffff : PCI Bus 0000:00000f0000-000fffff : Reserved 000f0000-000fffff : System ROM00100000-bfff9fff : System RAM 17000000-17c02fff : Kernel code 17c03000-183523ff : Kernel data 18883000-189fffff : Kernel bssbfffa000-bfffffff : Reservedc0000000-febfefff : PCI Bus 0000:00 febf7000-febf707f : 0000:00:03.0 febf8000-febf81ff : 0000:00:04.0 febf9000-febf91ff : 0000:00:05.0 febfa000-febfa1ff : 0000:00:06.0 febfb000-febfb1ff : 0000:00:07.0 febfc000-febfc1ff : 0000:00:08.0 febfd000-febfd1ff : 0000:00:09.0 febfe000-febfe03f : 0000:00:0a.0fec00000-fec003ff : IOAPIC 0fee00000-fee00fff : Local APICfffbc000-ffffffff : Reserved
in this example the kernel gets 368M-380M, which leaves no room for my 512M crashkernel memory (not from top to bottom - 896M-380M is not enough and not from bottom up 16M-368M is not enough).my questions are:
- this seems like a bug in the KASLR feature - is this a known issue ?
- is there a way to tell the KASLR to avoid randomizing the kernel address into the low memory region ? i can see that using the memmap command line parameter i can add memory regions which will achieve that, the problem is that those memmaps causes the allocation of the crashkernel to fail as well.thanks.