25.11.2015 02:52, Elliott, Robert (Persistent Memory) пишет:
> We've noticed that some combinations of grub and old linux kernels
> 
> end up interpreting the UEFI memory map EfiPersistentMemory type 14
> 
> (formerly a reserved value) as regular memory in the linux e820
> 
> table, causing silent data corruption on the NVDIMMs.  That occurs
> 
> even though grub prints this message suggesting everything is safe:
> 
>     Unknown memory type 14, considering reserved
> 
> 
> 
> In broken versions of grub, the code parsing the UEFI memory map
> 
> has a "default" case that falls through to the
> 
> GRUB_EFI_BOOT_SERVICES_DATA case, which marks the memory range
> 
> as GRUB_MEMORY_AVAILABLE and ends up in e820 as regular memory.
> 

Could you test if attached patch works for you (compile tested)?

From: Andrei Borzenkov <arvidj...@gmail.com>
Subject: [PATCH] efi: really mark memory of unknown type as reserved

9be4c45dbe3c877d1f4856e99ee15133c6cd2261 added switch case between
fall through cases, causing all memory regions of unknown type to be
marked as available.

Move default case into its own block and add explicit FALLTHROUGH
annotation.

Reported by Elliott, Robert (Persistent Memory) <elli...@hpe.com>

---
 grub-core/mmap/efi/mmap.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c
index a77efe8..6b5f5d8 100644
--- a/grub-core/mmap/efi/mmap.c
+++ b/grub-core/mmap/efi/mmap.c
@@ -73,6 +73,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
 		    GRUB_MEMORY_AVAILABLE, hook_data);
 	      break;
 	    }
+	  /* FALLTHROUGH */
 	case GRUB_EFI_RUNTIME_SERVICES_CODE:
 	  hook (desc->physical_start, desc->num_pages * 4096,
 		GRUB_MEMORY_CODE, hook_data);
@@ -83,10 +84,6 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
 		GRUB_MEMORY_BADRAM, hook_data);
 	  break;
 
-	default:
-	  grub_printf ("Unknown memory type %d, considering reserved\n",
-		       desc->type);
-
 	case GRUB_EFI_BOOT_SERVICES_DATA:
 	  if (!avoid_efi_boot_services)
 	    {
@@ -94,6 +91,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
 		    GRUB_MEMORY_AVAILABLE, hook_data);
 	      break;
 	    }
+	  /* FALLTHROUGH */
 	case GRUB_EFI_RESERVED_MEMORY_TYPE:
 	case GRUB_EFI_RUNTIME_SERVICES_DATA:
 	case GRUB_EFI_MEMORY_MAPPED_IO:
@@ -119,6 +117,13 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
 	  hook (desc->physical_start, desc->num_pages * 4096,
 		GRUB_MEMORY_NVS, hook_data);
 	  break;
+	default:
+	  grub_printf ("Unknown memory type %d, considering reserved\n",
+		       desc->type);
+	  hook (desc->physical_start, desc->num_pages * 4096,
+		GRUB_MEMORY_RESERVED, hook_data);
+	  break;
+
 	}
     }
 
-- 
tg: (f9d1b44..) u/efi-unknown-memory-type (depends on: master)
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to