Skip to contentSkip to conversation

efi: kernel param for legacy NVDIMM support

PATCH In review Yigal Korman 2 participants 3 messages Jun 9, 2016 – Jun 10, 2016 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: kernel param for legacy NVDIMM support

The 'efi_legacy_pmem' parameter will convert EFI persistent memory range (type 14) into E820 legacy NVDIMM (type 12) memory range.

Background:

In contrast with the NVDIMM E820 types where we can clearly distinguish between old NVDIMMs (type-12) and ACPI 6.0 NVDIMMs (type-7), the EFI memory types for NVDIMMs are the same before ACPI 6.0 and after (type-14).
This means that old NVDIMMs under EFI aren't supported even though they work fine if booted with BIOS (E820).

So allow the user to explicitly request the kernel to identify NVDIMMs as legacy under EFI.

---
 Documentation/kernel-parameters.txt |  3 +++
 arch/x86/platform/efi/efi.c         | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
Documentation/kernel-parameters.txt +3 -0
index 9a53c92..58f2a9b 100644
@@ -394,6 +394,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	add_efi_memmap	[EFI; X86] Include EFI memory map in
 			kernel's map of available physical RAM.
 
+	efi_legacy_pmem	[EFI; X86] Convert EFI_PERSISTENT_MEMORY to E820_PRAM
+			and add it to E820 memmap for legacy NVDIMM support.
+
 	agp=		[AGP]
 			{ off | try_unsupported }
 			off: disable AGP support
arch/x86/platform/efi/efi.c +31 -0
index ad28540..5e82532 100644
@@ -78,6 +78,14 @@ static int __init setup_add_efi_memmap(char *arg)
 }
 early_param("add_efi_memmap", setup_add_efi_memmap);
 
+static int add_legacy_pmem __initdata;
+static int __init setup_add_legacy_pmem(char *arg)
+{
+	add_legacy_pmem = 1;
+	return 0;
+}
+early_param("efi_legacy_pmem", setup_add_legacy_pmem);
+
 static efi_status_t __init phys_efi_set_virtual_address_map(
 	unsigned long memory_map_size,
 	unsigned long descriptor_size,
@@ -191,6 +199,26 @@ static void __init do_add_efi_memmap(void)
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 }
 
+static void __init do_add_legacy_pmem(void)
+{
+	void *p;
+
+	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+		efi_memory_desc_t *md = p;
+
+		if (md->type == EFI_PERSISTENT_MEMORY) {
+			pr_info("Registering %lluMB as PRAM in E820\n",
+				(md->num_pages >> (20 - EFI_PAGE_SHIFT)));
+
+			e820_add_region(md->phys_addr,
+					md->num_pages << EFI_PAGE_SHIFT,
+					E820_PRAM);
+		}
+
+	}
+	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+}
+
 int __init efi_memblock_x86_reserve_range(void)
 {
 	struct efi_info *e = &boot_params.efi_info;
@@ -455,6 +483,9 @@ static int __init efi_memmap_init(void)
 	if (add_efi_memmap)
 		do_add_efi_memmap();
 
+	if (add_legacy_pmem)
+		do_add_legacy_pmem();
+
 	set_bit(EFI_MEMMAP, &efi.flags);
 
 	return 0;
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1465494142-1456010-1-git-send-email-yigal-/[email protected]

#2 lore raw
Quoted 12 lines · Yigal Korman

The 'efi_legacy_pmem' parameter will convert EFI persistent memory range (type 14) into E820 legacy NVDIMM (type 12) memory range.

Background:

In contrast with the NVDIMM E820 types where we can clearly distinguish between old NVDIMMs (type-12) and ACPI 6.0 NVDIMMs (type-7), the EFI memory types for NVDIMMs are the same before ACPI 6.0 and after (type-14).
This means that old NVDIMMs under EFI aren't supported even though they work fine if booted with BIOS (E820).

Quoted 3 lines

So allow the user to explicitly request the kernel to identify NVDIMMs as legacy under EFI.

I'm concerned with the potential for this command line parameter to collide with NFIT defined ranges. At a minimum it should confirm that there is not already an NFIT describing the same address ranges.

However, we have the ability to override / inject ACPI tables and methods from the kernel. Why not use that facility to custom craft an NFIT when the BIOS fails to provide one? That way EFI type-14 maintains a constant interpretation as just a reserved memory range with no other side effects.

A message that is not in the archive (sent off-list or not yet received): CAPcyv4i1cq7nqkp=auataYX7oMRFms2z1M94rFxq1fXGAcvHLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 14 lines · Dan Williams
Quoted 12 lines · Yigal Korman

The 'efi_legacy_pmem' parameter will convert EFI persistent memory range (type 14) into E820 legacy NVDIMM (type 12) memory range.

Background:

In contrast with the NVDIMM E820 types where we can clearly distinguish between old NVDIMMs (type-12) and ACPI 6.0 NVDIMMs (type-7), the EFI memory types for NVDIMMs are the same before ACPI 6.0 and after (type-14).
This means that old NVDIMMs under EFI aren't supported even though they work fine if booted with BIOS (E820).

Quoted 8 lines
Quoted 3 lines

So allow the user to explicitly request the kernel to identify NVDIMMs as legacy under EFI.

I'm concerned with the potential for this command line parameter to collide with NFIT defined ranges. At a minimum it should confirm that there is not already an NFIT describing the same address ranges.

That's a valid concern, but not related to this patch directly, the same might happen today when an 'memmap=XX!YY' kernel parameter collides with an NFIT on the same range.

Or, albeit a far fetched scenario, a platform vendor will decide to provide an NFIT for a non-ACPI 6.0 and leave the old E820 type-12.

Quoted 5 lines

However, we have the ability to override / inject ACPI tables and methods from the kernel. Why not use that facility to custom craft an NFIT when the BIOS fails to provide one? That way EFI type-14 maintains a constant interpretation as just a reserved memory range with no other side effects.

That might be an interesting way to implement memmap=XX!YY in general and can also replace the funny code in arch/x86/kernel/pmem.c.

But, it's more complex and probably has its own caveats, this patch is simpler and straight forward, providing direct value.

Thanks,
Yigal