|
|
f731ee |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f731ee |
From: Robert Elliott <elliott@hpe.com>
|
|
|
f731ee |
Date: Thu, 17 Dec 2015 10:53:32 -0600
|
|
|
f731ee |
Subject: [PATCH] lsefimmap: support persistent memory and other UEFI 2.5
|
|
|
f731ee |
features
|
|
|
f731ee |
|
|
|
f731ee |
This should accompany
|
|
|
f731ee |
76ce1de740 Translate UEFI persistent memory type
|
|
|
f731ee |
|
|
|
f731ee |
1. Add a string for the EfiPersistentMemory type 14 that was
|
|
|
f731ee |
added in UEFI 2.5.
|
|
|
f731ee |
|
|
|
f731ee |
2. Decode the memory attributes that were added in UEFI 2.5:
|
|
|
f731ee |
* NV (non-volatile)
|
|
|
f731ee |
* MORE_RELIABLE (higher reliable, e.g., mirrored memory in a system
|
|
|
f731ee |
with partial memory mirroring)
|
|
|
f731ee |
* RO (read-only)
|
|
|
f731ee |
|
|
|
f731ee |
3. Use proper IEC binary units (KiB, MiB, etc.) for power-of-two
|
|
|
f731ee |
values rather than misusing SI power-of-ten units (KB, MB, etc.)
|
|
|
f731ee |
|
|
|
f731ee |
4. The lsmmap command only decodes memory ranges sizes up to GiB scale
|
|
|
f731ee |
units. Persistent memory ranges will reach into the TiB scale.
|
|
|
f731ee |
Since 64-bit size field supports TiB, PiB, and EiB, decode all of
|
|
|
f731ee |
them for completeness.
|
|
|
f731ee |
|
|
|
f731ee |
5. In the lsefimmap command, rewrite the print statements to
|
|
|
f731ee |
* avoid rounding
|
|
|
f731ee |
* avoid a big nested if/else tree.
|
|
|
f731ee |
|
|
|
f731ee |
For example: In the sixth entry below, the value of 309MB implies
|
|
|
f731ee |
316416KB but is really reporting 316436KB.
|
|
|
f731ee |
|
|
|
f731ee |
Widen the size column to 6 digits to accommodate typical cases.
|
|
|
f731ee |
The worst case value would require 14 digits; if that happens,
|
|
|
f731ee |
let the columns get out of sync.
|
|
|
f731ee |
|
|
|
f731ee |
Old format:
|
|
|
f731ee |
Type Physical start - end #Pages Size Attributes
|
|
|
f731ee |
conv-mem 0000000000000000-0000000000092fff 00000093 588KB UC WC WT WB
|
|
|
f731ee |
reserved 0000000000093000-0000000000093fff 00000001 4KB UC WC WT WB
|
|
|
f731ee |
conv-mem 0000000000094000-000000000009ffff 0000000c 48KB UC WC WT WB
|
|
|
f731ee |
conv-mem 0000000000100000-000000000fffffff 0000ff00 255MB UC WC WT WB
|
|
|
f731ee |
BS-code 0000000010000000-0000000010048fff 00000049 292KB UC WC WT WB
|
|
|
f731ee |
conv-mem 0000000010049000-000000002354dfff 00013505 309MB UC WC WT WB
|
|
|
f731ee |
ldr-data 000000002354e000-000000003ecfffff 0001b7b2 439MB UC WC WT WB
|
|
|
f731ee |
BS-data 000000003ed00000-000000003ed7ffff 00000080 512KB UC WC WT WB
|
|
|
f731ee |
conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 705MB UC WC WT WB
|
|
|
f731ee |
reserved 000000006af60000-000000006b55ffff 00000600 6MB UC WC WT WB
|
|
|
f731ee |
BS-data 000000006b560000-000000006b560fff 00000001 4KB UC WC WT WB
|
|
|
f731ee |
RT-data 000000006b561000-000000006b5e1fff 00000081 516KB RT UC WC WT WB
|
|
|
f731ee |
BS-data 000000006b5e2000-000000006ecfafff 00003719 55MB UC WC WT WB
|
|
|
f731ee |
BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KB UC WC WT WB
|
|
|
f731ee |
conv-mem 000000006ecfc000-00000000711fafff 000024ff 36MB UC WC WT WB
|
|
|
f731ee |
BS-data 00000000711fb000-000000007128dfff 00000093 588KB UC WC WT WB
|
|
|
f731ee |
Unk 0d 0000000880000000-0000000e7fffffff 00600000 24GB UC WC WT WB NV
|
|
|
f731ee |
reserved 0000001680000000-0000001c7fffffff 00600000 24GB UC WC WT WB NV
|
|
|
f731ee |
|
|
|
f731ee |
New format:
|
|
|
f731ee |
Type Physical start - end #Pages Size Attributes
|
|
|
f731ee |
conv-mem 0000000000000000-0000000000092fff 00000093 588KiB UC WC WT WB
|
|
|
f731ee |
reserved 0000000000093000-0000000000093fff 00000001 4KiB UC WC WT WB
|
|
|
f731ee |
conv-mem 0000000000094000-000000000009ffff 0000000c 48KiB UC WC WT WB
|
|
|
f731ee |
conv-mem 0000000000100000-000000000fffffff 0000ff00 255MiB UC WC WT WB
|
|
|
f731ee |
BS-code 0000000010000000-0000000010048fff 00000049 292KiB UC WC WT WB
|
|
|
f731ee |
conv-mem 0000000010049000-000000002354dfff 00013505 316436KiB UC WC WT WB
|
|
|
f731ee |
ldr-data 000000002354e000-000000003ecfffff 0001b7b2 450248KiB UC WC WT WB
|
|
|
f731ee |
BS-data 000000003ed00000-000000003ed7ffff 00000080 512KiB UC WC WT WB
|
|
|
f731ee |
conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 722816KiB UC WC WT WB
|
|
|
f731ee |
reserved 000000006af60000-000000006b55ffff 00000600 6MiB UC WC WT WB
|
|
|
f731ee |
BS-data 000000006b560000-000000006b560fff 00000001 4KiB UC WC WT WB
|
|
|
f731ee |
RT-data 000000006b561000-000000006b5e1fff 00000081 516KiB RT UC WC WT WB
|
|
|
f731ee |
BS-data 000000006b5e2000-000000006ecfafff 00003719 56420KiB UC WC WT WB
|
|
|
f731ee |
BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KiB UC WC WT WB
|
|
|
f731ee |
conv-mem 000000006ecfc000-0000000071222fff 00002527 38044KiB UC WC WT WB
|
|
|
f731ee |
BS-data 0000000071223000-00000000712ddfff 000000bb 748KiB UC WC WT WB
|
|
|
f731ee |
persist 0000000880000000-0000000e7fffffff 00600000 24GiB UC WC WT WB NV
|
|
|
f731ee |
reserved 0000001680000000-0000001c7fffffff 00600000 24GiB UC WC WT WB NV
|
|
|
f731ee |
|
|
|
f731ee |
(cherry picked from commit c79c59f1295df8ea660f8a858f9532d76a5f67b7)
|
|
|
f731ee |
|
|
|
f731ee |
Resolves: rhbz#1288608
|
|
|
f731ee |
---
|
|
|
f731ee |
grub-core/commands/efi/lsefimmap.c | 47 +++++++++++++++++++++++++-------------
|
|
|
f731ee |
include/grub/efi/api.h | 3 +++
|
|
|
f731ee |
2 files changed, 34 insertions(+), 16 deletions(-)
|
|
|
f731ee |
|
|
|
f731ee |
diff --git a/grub-core/commands/efi/lsefimmap.c b/grub-core/commands/efi/lsefimmap.c
|
|
|
f731ee |
index 215b45bff80..c85ff7f366d 100644
|
|
|
f731ee |
--- a/grub-core/commands/efi/lsefimmap.c
|
|
|
f731ee |
+++ b/grub-core/commands/efi/lsefimmap.c
|
|
|
f731ee |
@@ -51,7 +51,7 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f731ee |
|
|
|
f731ee |
grub_printf
|
|
|
f731ee |
("Type Physical start - end #Pages "
|
|
|
f731ee |
- " Size Attributes\n");
|
|
|
f731ee |
+ " Size Attributes\n");
|
|
|
f731ee |
memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size);
|
|
|
f731ee |
for (desc = memory_map;
|
|
|
f731ee |
desc < memory_map_end;
|
|
|
f731ee |
@@ -74,7 +74,8 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f731ee |
"ACPI-nvs",
|
|
|
f731ee |
"MMIO ",
|
|
|
f731ee |
"IO-ports",
|
|
|
f731ee |
- "PAL-code"
|
|
|
f731ee |
+ "PAL-code",
|
|
|
f731ee |
+ "persist ",
|
|
|
f731ee |
};
|
|
|
f731ee |
if (desc->type < ARRAY_SIZE (types_str))
|
|
|
f731ee |
grub_printf ("%s ", types_str[desc->type]);
|
|
|
f731ee |
@@ -87,21 +88,29 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f731ee |
desc->physical_start + (desc->num_pages << 12) - 1,
|
|
|
f731ee |
desc->num_pages);
|
|
|
f731ee |
|
|
|
f731ee |
- size = desc->num_pages;
|
|
|
f731ee |
- size <<= (12 - 10);
|
|
|
f731ee |
- if (size < 1024)
|
|
|
f731ee |
- grub_printf (" %4" PRIuGRUB_UINT64_T "KB", size);
|
|
|
f731ee |
+ size = desc->num_pages << 12; /* 4 KiB page size */
|
|
|
f731ee |
+ /*
|
|
|
f731ee |
+ * Since size is a multiple of 4 KiB, no need to handle units
|
|
|
f731ee |
+ * of just Bytes (which would use a mask of 0x3ff).
|
|
|
f731ee |
+ *
|
|
|
f731ee |
+ * 14 characters would support the largest possible number of 4 KiB
|
|
|
f731ee |
+ * pages that are not a multiple of larger units (e.g., MiB):
|
|
|
f731ee |
+ * 17592186044415 (0xffffff_fffff000), but that uses a lot of
|
|
|
f731ee |
+ * whitespace for a rare case. 6 characters usually suffices;
|
|
|
f731ee |
+ * columns will be off if not, but this is preferable to rounding.
|
|
|
f731ee |
+ */
|
|
|
f731ee |
+ if (size & 0xfffff)
|
|
|
f731ee |
+ grub_printf (" %6" PRIuGRUB_UINT64_T "KiB", size >> 10);
|
|
|
f731ee |
+ else if (size & 0x3fffffff)
|
|
|
f731ee |
+ grub_printf (" %6" PRIuGRUB_UINT64_T "MiB", size >> 20);
|
|
|
f731ee |
+ else if (size & 0xffffffffff)
|
|
|
f731ee |
+ grub_printf (" %6" PRIuGRUB_UINT64_T "GiB", size >> 30);
|
|
|
f731ee |
+ else if (size & 0x3ffffffffffff)
|
|
|
f731ee |
+ grub_printf (" %6" PRIuGRUB_UINT64_T "TiB", size >> 40);
|
|
|
f731ee |
+ else if (size & 0xfffffffffffffff)
|
|
|
f731ee |
+ grub_printf (" %6" PRIuGRUB_UINT64_T "PiB", size >> 50);
|
|
|
f731ee |
else
|
|
|
f731ee |
- {
|
|
|
f731ee |
- size /= 1024;
|
|
|
f731ee |
- if (size < 1024)
|
|
|
f731ee |
- grub_printf (" %4" PRIuGRUB_UINT64_T "MB", size);
|
|
|
f731ee |
- else
|
|
|
f731ee |
- {
|
|
|
f731ee |
- size /= 1024;
|
|
|
f731ee |
- grub_printf (" %4" PRIuGRUB_UINT64_T "GB", size);
|
|
|
f731ee |
- }
|
|
|
f731ee |
- }
|
|
|
f731ee |
+ grub_printf (" %6" PRIuGRUB_UINT64_T "EiB", size >> 60);
|
|
|
f731ee |
|
|
|
f731ee |
attr = desc->attribute;
|
|
|
f731ee |
if (attr & GRUB_EFI_MEMORY_RUNTIME)
|
|
|
f731ee |
@@ -122,6 +131,12 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f731ee |
grub_printf (" RP");
|
|
|
f731ee |
if (attr & GRUB_EFI_MEMORY_XP)
|
|
|
f731ee |
grub_printf (" XP");
|
|
|
f731ee |
+ if (attr & GRUB_EFI_MEMORY_NV)
|
|
|
f731ee |
+ grub_printf (" NV");
|
|
|
f731ee |
+ if (attr & GRUB_EFI_MEMORY_MORE_RELIABLE)
|
|
|
f731ee |
+ grub_printf (" MR");
|
|
|
f731ee |
+ if (attr & GRUB_EFI_MEMORY_RO)
|
|
|
f731ee |
+ grub_printf (" RO");
|
|
|
f731ee |
|
|
|
f731ee |
grub_printf ("\n");
|
|
|
f731ee |
}
|
|
|
f731ee |
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
|
|
|
f731ee |
index 551d93e50a3..a6cce6e3395 100644
|
|
|
f731ee |
--- a/include/grub/efi/api.h
|
|
|
f731ee |
+++ b/include/grub/efi/api.h
|
|
|
f731ee |
@@ -49,6 +49,9 @@
|
|
|
f731ee |
#define GRUB_EFI_MEMORY_WP 0x0000000000001000LL
|
|
|
f731ee |
#define GRUB_EFI_MEMORY_RP 0x0000000000002000LL
|
|
|
f731ee |
#define GRUB_EFI_MEMORY_XP 0x0000000000004000LL
|
|
|
f731ee |
+#define GRUB_EFI_MEMORY_NV 0x0000000000008000LL
|
|
|
f731ee |
+#define GRUB_EFI_MEMORY_MORE_RELIABLE 0x0000000000010000LL
|
|
|
f731ee |
+#define GRUB_EFI_MEMORY_RO 0x0000000000020000LL
|
|
|
f731ee |
#define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000LL
|
|
|
f731ee |
|
|
|
f731ee |
#define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
|