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

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