Skip to content

Draft: misc: memscav: memory scavenger driver

Upstream Status: RHEL-only
JIRA: https://issues.redhat.com/browse/RHEL-29694

memscav is a work-around to achieve better boot times on ARM64 platforms until
a more suitable solution is available. It might work on other architectures,
but its use may not be interesting there.

Initializing the memory takes a significant amount of time for various reasons.
On ARM64 platforms, with RODATA_FULL_DEFAULT_ENABLED=y (default), initializing
the linear mappings can take a significant amount of time (~0.1GB/ms on various
platforms tested). This is often overlooked as it happens before time_init()
initializes the clocksource used by the printk() class of output for their
timestamps.

Degrading RODATA_FULL_DEFAULT_ENABLED=y (rodata=full) to rodata=on raises
safety, potentially security, concerns as the linear mappings may end up with
different protections than later created mappings to the same physical memory.
Notably loaded kernel modules, BPF, etc which may allocate regions that are
then updated to ROX, to which another RW mapping will still exist in the
linear-map.

The compromise is therefor between boot speed and safety/security.

This module attempts to dodge this compromise by abusing the mem= kernel
argument to restrain the kernel from using all the memory reported in the
memory map, while offering an interface to recover the hidden memory later,
when time is no longer of the essence. It behaves similarly to
ARCH_MEMORY_PROBE, but uses the memory map passed to the kernel through either
device-tree of EFI memory map to only add existing memory by size rather than
memblocks at arbitrary physical addresses.

Signed-off-by: Eric Chanudet echanude@redhat.com

Merge request reports