Blame SOURCES/0194-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch

6b3c76
From 178c4edc23c209630f22fbd3c6397c49284b4bad Mon Sep 17 00:00:00 2001
a85e8e
From: Robert Elliott <elliott@hpe.com>
a85e8e
Date: Fri, 22 Jan 2016 13:32:30 +0100
6b3c76
Subject: [PATCH 194/261] efiemu: Handle persistent RAM and unknown possible
6b3c76
 future additions.
a85e8e
a85e8e
(cherry picked from commit ae3b83a4d4df75a01198a2fed7542391e7c449e0)
a85e8e
a85e8e
Resolves: rhbz#1288608
a85e8e
---
a85e8e
 grub-core/efiemu/mm.c | 25 ++++++++++++++++++++++---
a85e8e
 1 file changed, 22 insertions(+), 3 deletions(-)
a85e8e
a85e8e
diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c
6b3c76
index d4a4f3aad..13af4ad0d 100644
a85e8e
--- a/grub-core/efiemu/mm.c
a85e8e
+++ b/grub-core/efiemu/mm.c
a85e8e
@@ -99,7 +99,8 @@ grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
a85e8e
   grub_size_t align_overhead;
a85e8e
   struct grub_efiemu_memrequest *ret, *cur, *prev;
a85e8e
   /* Check that the request is correct */
a85e8e
-  if (type >= GRUB_EFI_MAX_MEMORY_TYPE || type <= GRUB_EFI_LOADER_CODE)
a85e8e
+  if (type <= GRUB_EFI_LOADER_CODE || type == GRUB_EFI_PERSISTENT_MEMORY ||
a85e8e
+	type >= GRUB_EFI_MAX_MEMORY_TYPE)
a85e8e
     return -2;
a85e8e
 
a85e8e
   /* Add new size to requested size */
a85e8e
@@ -166,6 +167,13 @@ efiemu_alloc_requests (void)
a85e8e
       GRUB_EFI_MEMORY_MAPPED_IO,
a85e8e
       GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
a85e8e
       GRUB_EFI_PAL_CODE
a85e8e
+
a85e8e
+      /*
a85e8e
+       * These are not allocatable:
a85e8e
+       * GRUB_EFI_RESERVED_MEMORY_TYPE
a85e8e
+       * GRUB_EFI_PERSISTENT_MEMORY
a85e8e
+       * >= GRUB_EFI_MAX_MEMORY_TYPE
a85e8e
+       */
a85e8e
     };
a85e8e
 
a85e8e
   /* Compute total memory needed */
a85e8e
@@ -402,6 +410,10 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
a85e8e
 	return grub_efiemu_add_to_mmap (addr, size,
a85e8e
 					GRUB_EFI_ACPI_MEMORY_NVS);
a85e8e
 
a85e8e
+      case GRUB_MEMORY_PRAM:
a85e8e
+      case GRUB_MEMORY_PMEM:
a85e8e
+	return grub_efiemu_add_to_mmap (addr, size,
a85e8e
+					GRUB_EFI_PERSISTENT_MEMORY);
a85e8e
       default:
a85e8e
 	grub_dprintf ("efiemu",
a85e8e
 		      "Unknown memory type %d. Assuming unusable\n", type);
a85e8e
@@ -445,7 +457,7 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
a85e8e
       case GRUB_EFI_MEMORY_MAPPED_IO:
a85e8e
       case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
a85e8e
       case GRUB_EFI_PAL_CODE:
a85e8e
-      case GRUB_EFI_MAX_MEMORY_TYPE:
a85e8e
+      default:
a85e8e
 	hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
a85e8e
 	      GRUB_MEMORY_RESERVED, hook_data);
a85e8e
 	break;
a85e8e
@@ -468,6 +480,12 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
a85e8e
 	hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
a85e8e
 	      GRUB_MEMORY_NVS, hook_data);
a85e8e
 	break;
a85e8e
+
a85e8e
+      case GRUB_EFI_PERSISTENT_MEMORY:
a85e8e
+	hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
a85e8e
+	      GRUB_MEMORY_PMEM, hook_data);
a85e8e
+	break;
a85e8e
+
a85e8e
       }
a85e8e
 
a85e8e
   return 0;
a85e8e
@@ -503,7 +521,8 @@ grub_efiemu_mmap_sort_and_uniq (void)
a85e8e
       [GRUB_EFI_ACPI_MEMORY_NVS] = 3,
a85e8e
       [GRUB_EFI_MEMORY_MAPPED_IO] = 4,
a85e8e
       [GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE] = 4,
a85e8e
-      [GRUB_EFI_PAL_CODE] = 4
a85e8e
+      [GRUB_EFI_PAL_CODE] = 4,
a85e8e
+      [GRUB_EFI_PERSISTENT_MEMORY] = 4
a85e8e
     };
a85e8e
 
a85e8e
   int i, j, k, done;
6b3c76
-- 
6b3c76
2.13.5
6b3c76