On Wed, Oct 9, 2019 at 11:45 PM Ard Biesheuvel <[email protected]> wrote: > > On Thu, 10 Oct 2019 at 01:19, Dan Williams <[email protected]> wrote: > > > > UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the > > interpretation of the EFI Memory Types as "reserved for a specific > > purpose". > > > > The proposed Linux behavior for specific purpose memory is that it is > > reserved for direct-access (device-dax) by default and not available for > > any kernel usage, not even as an OOM fallback. Later, through udev > > scripts or another init mechanism, these device-dax claimed ranges can > > be reconfigured and hot-added to the available System-RAM with a unique > > node identifier. This device-dax management scheme implements "soft" in > > the "soft reserved" designation by allowing some or all of the > > reservation to be recovered as typical memory. This policy can be > > disabled at compile-time with CONFIG_EFI_SOFT_RESERVE=n, or runtime with > > efi=nosoftreserve. > > > > This patch introduces 2 new concepts at once given the entanglement > > between early boot enumeration relative to memory that can optionally be > > reserved from the kernel page allocator by default. The new concepts > > are: > > > > - E820_TYPE_SOFT_RESERVED: Upon detecting the EFI_MEMORY_SP > > attribute on EFI_CONVENTIONAL memory, update the E820 map with this > > new type. Only perform this classification if the > > CONFIG_EFI_SOFT_RESERVE=y policy is enabled, otherwise treat it as > > typical ram. > > > > - IORES_DESC_SOFT_RESERVED: Add a new I/O resource descriptor for > > a device driver to search iomem resources for application specific > > memory. Teach the iomem code to identify such ranges as "Soft Reserved". > > > > A follow-on change integrates parsing of the ACPI HMAT to identify the > > node and sub-range boundaries of EFI_MEMORY_SP designated memory. For > > now, just identify and reserve memory of this type. > > > > Cc: <[email protected]> > > Cc: Borislav Petkov <[email protected]> > > Cc: Ingo Molnar <[email protected]> > > Cc: "H. Peter Anvin" <[email protected]> > > Cc: Darren Hart <[email protected]> > > Cc: Andy Shevchenko <[email protected]> > > Cc: Andy Lutomirski <[email protected]> > > Cc: Peter Zijlstra <[email protected]> > > Cc: Thomas Gleixner <[email protected]> > > Cc: Ard Biesheuvel <[email protected]> > > Reported-by: kbuild test robot <[email protected]> > > Reviewed-by: Dave Hansen <[email protected]> > > Signed-off-by: Dan Williams <[email protected]> > > For the EFI changes > > Acked-by: Ard Biesheuvel <[email protected]> > > although I must admit I don't follow the enum add_efi_mode logic 100%
I'm open to suggestions as I'm not sure it's the best possible organization. The do_add_efi_memmap() routine has the logic to translate EFI to E820, but unless "add_efi_memmap" is specified on the kernel command line the EFI memory map is ignored. For soft-reservation support I want to reuse do_add_efi_memmap(), but otherwise avoid any other side effects of considering the EFI map. What I'm missing is the rationale for why "add_efi_memmap" is required before considering the EFI memory map. If there is a negative side effect to always using the EFI map then the new "add_efi_mode" designation constrains it to just the soft-reservation case. It seems for historical reasons the full EFI memmap requires explicit opt-in: 200001eb140e x86 boot: only pick up additional EFI memmap if add_efi_memmap flag
