nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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