All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>,
	"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Cc: "Knippers, Linda" <linda.knippers@hpe.com>,
	"Kani, Toshimitsu" <toshi.kani@hpe.com>
Subject: Re: grub causing NVDIMMs to be treated as normal memory
Date: Wed, 25 Nov 2015 21:36:51 +0300	[thread overview]
Message-ID: <5655FFC3.9030603@gmail.com> (raw)
In-Reply-To: <94D0CD8314A33A4D9D801C0FE68B40295BE539AF@G9W0745.americas.hpqcorp.net>

[-- Attachment #1: Type: text/plain, Size: 811 bytes --]

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)?


[-- Attachment #2: efi-unknown-memory-type.patch --]
[-- Type: text/x-patch, Size: 2044 bytes --]

From: Andrei Borzenkov <arvidjaar@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) <elliott@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)

  parent reply	other threads:[~2015-11-25 18:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24 23:52 grub causing NVDIMMs to be treated as normal memory Elliott, Robert (Persistent Memory)
2015-11-25 14:08 ` Andrei Borzenkov
2015-11-25 16:51   ` Dan Williams
2015-11-25 17:04   ` Elliott, Robert (Persistent Memory)
2015-11-25 17:07   ` Seth Goldberg
2015-11-25 18:36 ` Andrei Borzenkov [this message]
2015-11-26  0:12   ` Elliott, Robert (Persistent Memory)
2015-11-26  3:30     ` Andrei Borzenkov
2015-11-26  6:15       ` Elliott, Robert (Persistent Memory)
2015-11-26 16:55         ` Andrei Borzenkov
2015-11-26 23:24           ` Elliott, Robert (Persistent Memory)
2015-11-27  3:58             ` Andrei Borzenkov
2015-11-27  6:22               ` Elliott, Robert (Persistent Memory)
2015-11-27 11:08                 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-11-27 11:48                   ` Andrei Borzenkov
2015-11-27 13:55                     ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-11-27 17:23                       ` Andrei Borzenkov
2015-11-28  6:41                   ` Elliott, Robert (Persistent Memory)
2015-12-01  0:25                     ` Elliott, Robert (Persistent Memory)
2015-12-03 17:50                     ` Elliott, Robert (Persistent Memory)
2015-12-08 17:15                       ` Andrei Borzenkov
2015-12-09  6:37                         ` Elliott, Robert (Persistent Memory)
2015-12-29 17:17                     ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5655FFC3.9030603@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=grub-devel@gnu.org \
    --cc=linda.knippers@hpe.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=toshi.kani@hpe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.