grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: Re: grub causing NVDIMMs to be treated as normal memory
Date: Tue, 8 Dec 2015 20:15:43 +0300	[thread overview]
Message-ID: <5667103F.30304@gmail.com> (raw)
In-Reply-To: <94D0CD8314A33A4D9D801C0FE68B40295BE7E188@G4W3202.americas.hpqcorp.net>

03.12.2015 20:50, Elliott, Robert (Persistent Memory) пишет:
> From bd13098e80422444d60e08cb856093bf671df2bf Mon Sep 17 00:00:00 2001
> From: Robert Elliott <elliott@hpe.com>
> Date: Thu, 3 Dec 2015 11:38:36 -0600
> Subject: [PATCH 1/4] Translate UEFI persistent memory type
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> Define
> * GRUB_EFI_PERSISTENT_MEMORY (UEFI memory map type 14) per UEFI 2.5
> * GRUB_EFI_PMEM (E820 type 7) per ACPI 3.0
> * GRUB_EFI_PRAM (E820 unofficial type 12) per ACPI 3.0
> 

Well, ACPI talks about AddressRangePersistentMemory and "OEM defined".
Let's not confuse future hackers.

GRUB_MEMORY_PERSISTENT
GRUB_MEMORY_PERSISTENT_LEGACY

makes them obvious; PMEM and PRAM not. Neither PMEM nor PRAM are found
in ACPI spec.

> and translate GRUB_EFI_PERSISTENT_MEMORY to GRUB_EFI_PMEM in
> grub_efi_mmap_iterate().
> 
> Includes
> * adding the E820 names to lsmmap
> * handling the E820 types in make_efi_memtype()
> 
> Suggested-by: Vladimir 'П†-coder/phcoder' Serbinenko <phcoder@gmail.com>
> Suggested-by: Andrei Borzenkov <arvidjaar@gmail.com>
> ---
>  grub-core/commands/lsmmap.c |  2 ++
>  grub-core/mmap/efi/mmap.c   | 11 +++++++++++
>  include/grub/efi/api.h      |  1 +
>  include/grub/memory.h       |  2 ++
>  4 files changed, 16 insertions(+)
> 
> diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c
> index 4b504fd..1ff7276 100644
> --- a/grub-core/commands/lsmmap.c
> +++ b/grub-core/commands/lsmmap.c
> @@ -37,6 +37,8 @@ static const char *names[] =
>         is required to save accross hibernations.  */
>      [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"),
>      [GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"),
> +    [GRUB_MEMORY_PMEM] = N_("persistent memory"),
> +    [GRUB_MEMORY_PRAM] = N_("persistent memory (legacy)"),

visually "persistent RAM" and "persistent RAM (legacy)" aligns better
with surrounding text.

>      [GRUB_MEMORY_COREBOOT_TABLES] = N_("RAM holding coreboot tables"),
>      [GRUB_MEMORY_CODE] = N_("RAM holding firmware code")
>    };
> diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c
> index 900a4d6..5acd405 100644
> --- a/grub-core/mmap/efi/mmap.c
> +++ b/grub-core/mmap/efi/mmap.c
> @@ -118,6 +118,11 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
>  		GRUB_MEMORY_NVS, hook_data);
>  	  break;
>  
> +	case GRUB_EFI_PERSISTENT_MEMORY:
> +	  hook (desc->physical_start, desc->num_pages * 4096,
> +		GRUB_MEMORY_PMEM, hook_data);
> +	break;
> +
>  	default:
>  	  grub_printf ("Unknown memory type %d, considering reserved\n",
>  		       desc->type);
> @@ -147,6 +152,12 @@ make_efi_memtype (int type)
>        /* No way to remove a chunk of memory from EFI mmap.
>  	 So mark it as unusable. */
>      case GRUB_MEMORY_HOLE:
> +    /*
> +     * AllocatePages() does not support GRUB_EFI_PERSISTENT_MEMORY,
> +     * so no translation for GRUB_MEMORY_PMEM or GRUB_MEMORY_PRAM.
> +     */
> +    case GRUB_MEMORY_PMEM:
> +    case GRUB_MEMORY_PRAM:
>      case GRUB_MEMORY_RESERVED:
>        return GRUB_EFI_UNUSABLE_MEMORY;
>  
> diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
> index 24a05c5..2bbfe34 100644
> --- a/include/grub/efi/api.h
> +++ b/include/grub/efi/api.h
> @@ -476,6 +476,7 @@ enum grub_efi_memory_type
>      GRUB_EFI_MEMORY_MAPPED_IO,
>      GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
>      GRUB_EFI_PAL_CODE,
> +    GRUB_EFI_PERSISTENT_MEMORY,
>      GRUB_EFI_MAX_MEMORY_TYPE
>    };
>  typedef enum grub_efi_memory_type grub_efi_memory_type_t;
> diff --git a/include/grub/memory.h b/include/grub/memory.h
> index 083cfb6..1894c9d 100644
> --- a/include/grub/memory.h
> +++ b/include/grub/memory.h
> @@ -30,6 +30,8 @@ typedef enum grub_memory_type
>      GRUB_MEMORY_ACPI = 3,
>      GRUB_MEMORY_NVS = 4,
>      GRUB_MEMORY_BADRAM = 5,
> +    GRUB_MEMORY_PMEM = 7,
> +    GRUB_MEMORY_PRAM = 12,
>      GRUB_MEMORY_COREBOOT_TABLES = 16,
>      GRUB_MEMORY_CODE = 20,
>      /* This one is special: it's used internally but is never reported
> -- 2.4.3


Regarding efiemu - this is used in one very specific case - to boot OS X
kernel out of CSM emulation. It is unlikely we'll see persistent memory
on any platform where it is still needed; I doubt anyone can actually
test it, so it is probably better to leave it as is.


  reply	other threads:[~2015-12-08 17:15 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
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 [this message]
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=5667103F.30304@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).