diff mbox

efi: kernel param for legacy NVDIMM support

Message ID 1465494142-1456010-1-git-send-email-yigal@plexistor.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yigal Korman June 9, 2016, 5:42 p.m. UTC
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.

Signed-off-by: Yigal Korman <yigal@plexistor.com>
---
 Documentation/kernel-parameters.txt |  3 +++
 arch/x86/platform/efi/efi.c         | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

Comments

Dan Williams June 9, 2016, 8:27 p.m. UTC | #1
On Thu, Jun 9, 2016 at 10:42 AM, Yigal Korman <yigal@plexistor.com> wrote:
> 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.
>

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.
Yigal Korman June 10, 2016, 8:48 a.m. UTC | #2
On Thu, Jun 9, 2016 at 11:27 PM, Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Thu, Jun 9, 2016 at 10:42 AM, Yigal Korman <yigal@plexistor.com> wrote:
> > 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.
> >
>
> 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.

> 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
diff mbox

Patch

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 9a53c92..58f2a9b 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -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
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index ad28540..5e82532 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -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;