From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1a1ew9-0008Pb-O8 for mharc-grub-devel@gnu.org; Wed, 25 Nov 2015 13:37:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1ew7-0008PU-DX for grub-devel@gnu.org; Wed, 25 Nov 2015 13:37:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1ew3-0004Ej-Ah for grub-devel@gnu.org; Wed, 25 Nov 2015 13:36:59 -0500 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:33596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1ew3-0004EQ-2R for grub-devel@gnu.org; Wed, 25 Nov 2015 13:36:55 -0500 Received: by lfaz4 with SMTP id z4so71288538lfa.0 for ; Wed, 25 Nov 2015 10:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type; bh=HZgLuIfjc43fJpVgQmJnaQw/iDS6QwibmcvDBG3uxLI=; b=XzOJp8jJUQNAl6+njmdiw5AILA9vCaBWEHV232sEhO+PedT+3yN5cMS7DinxHM1RNX i/mw68jyedNUEcmfZvJhphzdWiZUKSqSDuVA1g0acCLT6xNNqVjbJsrwwuX1EzOaR8R1 HEB6bExWnAStFX05dhfJnxaQRc3l7UuheOlx7SN4hRY8AbtBOTZb96TD39YJdpX0AV4y zKkYiCbV+bkVYota/aUpHvkOZ67S3M4Ax7OLU1zs4zujoAA5RwwR2MeAApKOS8g3M+iK B6QwFYeyLGBZoWgM4J6gspm+bIJEtrcTMtGoqjcX3SI5zDjPSmZ3r0Lp31XeNInRcLJp HPqA== X-Received: by 10.112.36.130 with SMTP id q2mr16213233lbj.24.1448476614001; Wed, 25 Nov 2015 10:36:54 -0800 (PST) Received: from [192.168.1.41] (ppp91-76-25-247.pppoe.mtu-net.ru. [91.76.25.247]) by smtp.gmail.com with ESMTPSA id aa4sm3144128lbc.10.2015.11.25.10.36.52 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Nov 2015 10:36:53 -0800 (PST) Subject: Re: grub causing NVDIMMs to be treated as normal memory To: The development of GNU GRUB , "dan.j.williams@intel.com" , "linux-nvdimm@lists.01.org" References: <94D0CD8314A33A4D9D801C0FE68B40295BE539AF@G9W0745.americas.hpqcorp.net> From: Andrei Borzenkov Message-ID: <5655FFC3.9030603@gmail.com> Date: Wed, 25 Nov 2015 21:36:51 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <94D0CD8314A33A4D9D801C0FE68B40295BE539AF@G9W0745.americas.hpqcorp.net> Content-Type: multipart/mixed; boundary="------------050603020206080701000506" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c07::22f Cc: "Knippers, Linda" , "Kani, Toshimitsu" X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2015 18:37:00 -0000 This is a multi-part message in MIME format. --------------050603020206080701000506 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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)? --------------050603020206080701000506 Content-Type: text/x-patch; name="efi-unknown-memory-type.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="efi-unknown-memory-type.patch" From: Andrei Borzenkov 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) --- 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) --------------050603020206080701000506--