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