Blame SOURCES/0061-grub-core-kern-i386-coreboot-mmap.c-Filter-out-0xa00.patch

6b3c76
From 22a8b7bb4c77ba1ef1833e0dae052c108180250f Mon Sep 17 00:00:00 2001
a85e8e
From: Vladimir Serbinenko <phcoder@gmail.com>
a85e8e
Date: Fri, 28 Feb 2014 09:47:57 +0100
6b3c76
Subject: [PATCH 061/261] * grub-core/kern/i386/coreboot/mmap.c: Filter out
a85e8e
 0xa0000-0x100000 region.
a85e8e
a85e8e
---
d41074
 ChangeLog                           |  5 +++++
6b3c76
 grub-core/kern/i386/coreboot/mmap.c | 38 +++++++++++++++++++++++++++++++------
a85e8e
 2 files changed, 37 insertions(+), 6 deletions(-)
a85e8e
6b3c76
diff --git a/ChangeLog b/ChangeLog
6b3c76
index be41aa51f..4f6f6d6d3 100644
6b3c76
--- a/ChangeLog
6b3c76
+++ b/ChangeLog
6b3c76
@@ -1,3 +1,8 @@
6b3c76
+2014-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
6b3c76
+
6b3c76
+	* grub-core/kern/i386/coreboot/mmap.c: Filter out 0xa0000-0x100000
6b3c76
+	region.
6b3c76
+
6b3c76
 2014-02-20  Vladimir Serbinenko  <phcoder@gmail.com>
6b3c76
 
6b3c76
 	* grub-core/disk/ahci.c: Ignore NPORTS field and rely on PI
a85e8e
diff --git a/grub-core/kern/i386/coreboot/mmap.c b/grub-core/kern/i386/coreboot/mmap.c
6b3c76
index 119797551..4d29f6b7d 100644
a85e8e
--- a/grub-core/kern/i386/coreboot/mmap.c
a85e8e
+++ b/grub-core/kern/i386/coreboot/mmap.c
a85e8e
@@ -44,18 +44,44 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data)
a85e8e
   mem_region =
a85e8e
     (mem_region_t) ((long) table_item +
a85e8e
 			       sizeof (struct grub_linuxbios_table_item));
a85e8e
-  while ((long) mem_region < (long) table_item + (long) table_item->size)
a85e8e
+  for (; (long) mem_region < (long) table_item + (long) table_item->size;
a85e8e
+       mem_region++)
a85e8e
     {
a85e8e
-      if (ctx->hook (mem_region->addr, mem_region->size,
a85e8e
+      grub_uint64_t start = mem_region->addr;
a85e8e
+      grub_uint64_t end = mem_region->addr + mem_region->size;
a85e8e
+      /* Mark region 0xa0000 - 0x100000 as reserved.  */
a85e8e
+      if (start < 0x100000 && end >= 0xa0000
a85e8e
+	  && mem_region->type == GRUB_MACHINE_MEMORY_AVAILABLE)
a85e8e
+	{
a85e8e
+	  if (start < 0xa0000
a85e8e
+	      && ctx->hook (start, 0xa0000 - start,
a85e8e
+			    /* Multiboot mmaps match with the coreboot mmap
a85e8e
+			       definition.  Therefore, we can just pass type
a85e8e
+			       through.  */
a85e8e
+			    mem_region->type,
a85e8e
+			    ctx->hook_data))
a85e8e
+	    return 1;
a85e8e
+	  if (start < 0xa0000)
a85e8e
+	    start = 0xa0000;
a85e8e
+	  if (start >= end)
a85e8e
+	    continue;
a85e8e
+
a85e8e
+	  if (ctx->hook (start, (end > 0x100000 ? 0x100000 : end) - start,
a85e8e
+			 GRUB_MEMORY_RESERVED,
a85e8e
+			 ctx->hook_data))
a85e8e
+	    return 1;
a85e8e
+	  start = 0x100000;
a85e8e
+
a85e8e
+	  if (end <= start)
a85e8e
+	    continue;
a85e8e
+	}
a85e8e
+      if (ctx->hook (start, end - start,
a85e8e
 		     /* Multiboot mmaps match with the coreboot mmap
a85e8e
 		        definition.  Therefore, we can just pass type
a85e8e
 		        through.  */
a85e8e
-		     (((mem_region->type <= GRUB_MACHINE_MEMORY_BADRAM) && (mem_region->type >= GRUB_MACHINE_MEMORY_AVAILABLE))
a85e8e
-		      || mem_region->type == GRUB_MEMORY_COREBOOT_TABLES) ? mem_region->type : GRUB_MEMORY_RESERVED,
a85e8e
+		     mem_region->type,
a85e8e
 		     ctx->hook_data))
a85e8e
 	return 1;
a85e8e
-
a85e8e
-      mem_region++;
a85e8e
     }
a85e8e
 
a85e8e
   return 0;
6b3c76
-- 
6b3c76
2.13.5
6b3c76