Blame SOURCES/0192-Translate-UEFI-persistent-memory-type.patch

6b3c76
From 378daa8a4be1f8789d53a0656e511f72df01a423 Mon Sep 17 00:00:00 2001
a85e8e
From: Robert Elliott <elliott@hpe.com>
a85e8e
Date: Thu, 3 Dec 2015 11:38:36 -0600
6b3c76
Subject: [PATCH 192/261] Translate UEFI persistent memory type
a85e8e
MIME-Version: 1.0
a85e8e
Content-Type: text/plain; charset=UTF-8
a85e8e
Content-Transfer-Encoding: 8bit
a85e8e
a85e8e
Define
a85e8e
* GRUB_EFI_PERSISTENT_MEMORY (UEFI memory map type 14) per UEFI 2.5
a85e8e
* GRUB_MEMORY_PERSISTENT (E820 type 7) per ACPI 3.0
a85e8e
* GRUB_MEMORY_PERSISTENT_LEGACY (E820 unofficial type 12) per ACPI 3.0
a85e8e
a85e8e
and translate GRUB_EFI_PERSISTENT_MEMORY to GRUB_MEMORY_PERSISTENT in
a85e8e
grub_efi_mmap_iterate().
a85e8e
a85e8e
Includes
a85e8e
* adding the E820 names to lsmmap
a85e8e
* handling the E820 types in make_efi_memtype()
a85e8e
a85e8e
Suggested-by: Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com>
a85e8e
Suggested-by: Andrei Borzenkov <arvidjaar@gmail.com>
a85e8e
(cherry picked from commit 76ce1de740f202985ffd7b2e980cf34c75a2dac3)
a85e8e
a85e8e
Resolves: rhbz#1288608
a85e8e
---
a85e8e
 grub-core/commands/lsmmap.c |  2 ++
a85e8e
 grub-core/mmap/efi/mmap.c   | 12 ++++++++++++
a85e8e
 include/grub/efi/api.h      |  1 +
a85e8e
 include/grub/memory.h       |  2 ++
a85e8e
 4 files changed, 17 insertions(+)
a85e8e
a85e8e
diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c
6b3c76
index 4b504fd28..816ee47d1 100644
a85e8e
--- a/grub-core/commands/lsmmap.c
a85e8e
+++ b/grub-core/commands/lsmmap.c
a85e8e
@@ -37,6 +37,8 @@ static const char *names[] =
a85e8e
        is required to save accross hibernations.  */
a85e8e
     [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"),
a85e8e
     [GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"),
a85e8e
+    [GRUB_MEMORY_PERSISTENT] = N_("persistent RAM"),
a85e8e
+    [GRUB_MEMORY_PERSISTENT_LEGACY] = N_("persistent RAM (legacy)"),
a85e8e
     [GRUB_MEMORY_COREBOOT_TABLES] = N_("RAM holding coreboot tables"),
a85e8e
     [GRUB_MEMORY_CODE] = N_("RAM holding firmware code")
a85e8e
   };
a85e8e
diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c
6b3c76
index 900a4d659..bd495a184 100644
a85e8e
--- a/grub-core/mmap/efi/mmap.c
a85e8e
+++ b/grub-core/mmap/efi/mmap.c
a85e8e
@@ -118,6 +118,11 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
a85e8e
 		GRUB_MEMORY_NVS, hook_data);
a85e8e
 	  break;
a85e8e
 
a85e8e
+	case GRUB_EFI_PERSISTENT_MEMORY:
a85e8e
+	  hook (desc->physical_start, desc->num_pages * 4096,
a85e8e
+		GRUB_MEMORY_PERSISTENT, hook_data);
a85e8e
+	break;
a85e8e
+
a85e8e
 	default:
a85e8e
 	  grub_printf ("Unknown memory type %d, considering reserved\n",
a85e8e
 		       desc->type);
a85e8e
@@ -147,6 +152,13 @@ make_efi_memtype (int type)
a85e8e
       /* No way to remove a chunk of memory from EFI mmap.
a85e8e
 	 So mark it as unusable. */
a85e8e
     case GRUB_MEMORY_HOLE:
a85e8e
+    /*
a85e8e
+     * AllocatePages() does not support GRUB_EFI_PERSISTENT_MEMORY,
a85e8e
+     * so no translation for GRUB_MEMORY_PERSISTENT or
a85e8e
+     * GRUB_MEMORY_PERSISTENT_LEGACY.
a85e8e
+     */
a85e8e
+    case GRUB_MEMORY_PERSISTENT:
a85e8e
+    case GRUB_MEMORY_PERSISTENT_LEGACY:
a85e8e
     case GRUB_MEMORY_RESERVED:
a85e8e
       return GRUB_EFI_UNUSABLE_MEMORY;
a85e8e
 
a85e8e
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
6b3c76
index 029ee92f5..551d93e50 100644
a85e8e
--- a/include/grub/efi/api.h
a85e8e
+++ b/include/grub/efi/api.h
a85e8e
@@ -431,6 +431,7 @@ enum grub_efi_memory_type
a85e8e
     GRUB_EFI_MEMORY_MAPPED_IO,
a85e8e
     GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
a85e8e
     GRUB_EFI_PAL_CODE,
a85e8e
+    GRUB_EFI_PERSISTENT_MEMORY,
a85e8e
     GRUB_EFI_MAX_MEMORY_TYPE
a85e8e
   };
a85e8e
 typedef enum grub_efi_memory_type grub_efi_memory_type_t;
a85e8e
diff --git a/include/grub/memory.h b/include/grub/memory.h
6b3c76
index 083cfb680..6da114a1b 100644
a85e8e
--- a/include/grub/memory.h
a85e8e
+++ b/include/grub/memory.h
a85e8e
@@ -30,6 +30,8 @@ typedef enum grub_memory_type
a85e8e
     GRUB_MEMORY_ACPI = 3,
a85e8e
     GRUB_MEMORY_NVS = 4,
a85e8e
     GRUB_MEMORY_BADRAM = 5,
a85e8e
+    GRUB_MEMORY_PERSISTENT = 7,
a85e8e
+    GRUB_MEMORY_PERSISTENT_LEGACY = 12,
a85e8e
     GRUB_MEMORY_COREBOOT_TABLES = 16,
a85e8e
     GRUB_MEMORY_CODE = 20,
a85e8e
     /* This one is special: it's used internally but is never reported
6b3c76
-- 
6b3c76
2.13.5
6b3c76