[Skiboot] [RFC PATCH v7 07/12] hdata/memory.c: Parse HDAT for secure memory
Ryan Grimm
grimm at linux.ibm.com
Tue Jul 7 02:14:34 AEST 2020
The secure memory ranges are provided by the hostboot through HDAT.
Skiboot parses HDAT and creates secure-memory@ device tree nodes. The
secure-memory nodes set dev_type to "secure-memory" so the kernel
doesn't try to use them.
In the HDIF_ms_area_address_range structure, HDAT spec version 10.5, the
mirror attribute at offset 0x14 is renamed to memory attribute.
The memory attribute now defines byte 3 as secure memory whereas
previously it was reserved. The rest of the attribute is unchanged:
1st byte -> Range is Mirrorable
0x00 = false
0x01 = true
2nd byte -> Hardware Mirroring Algorithm
0x0A – Memory Mirroring algorithm for P9 systems
0xFF – Memory Mirroring Not Supported
3rd byte -> SMF Memory
0x00 = false
0x01 = true
4th byte -> Reserved
Signed-off-by: Ryan Grimm <grimm at linux.ibm.com>
---
hdata/memory.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/hdata/memory.c b/hdata/memory.c
index bd47fee4..9443f297 100755
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -32,7 +32,7 @@ struct HDIF_ms_area_address_range {
__be64 start;
__be64 end;
__be32 chip;
- __be32 mirror_attr;
+ __be32 memory_attr;
__be64 mirror_start;
__be32 controller_id;
__be32 phys_attr;
@@ -66,6 +66,9 @@ struct HDIF_ms_area_address_range {
#define MS_CONTROLLER_MCC_ID(id) GETFIELD(PPC_BITMASK32(8, 15), id)
#define MS_CONTROLLER_OMI_ID(id) GETFIELD(PPC_BITMASK32(16, 31), id)
+#define MS_ATTR_PEF PPC_BIT32(23)
+#define UV_SECURE_MEM_BIT PPC_BIT(15)
+
struct HDIF_ms_area_id {
__be16 id;
#define MS_PTYPE_RISER_CARD 0x8000
@@ -150,10 +153,10 @@ static bool add_address_range(struct dt_node *root,
chip_id = pcid_to_chip_id(be32_to_cpu(arange->chip));
prlog(PR_DEBUG, " Range: 0x%016llx..0x%016llx "
- "on Chip 0x%x mattr: 0x%x pattr: 0x%x status:0x%x\n",
+ "on Chip 0x%x memattr: 0x%08x pattr: 0x%x status:0x%x\n",
(long long)be64_to_cpu(arange->start),
(long long)be64_to_cpu(arange->end),
- chip_id, be32_to_cpu(arange->mirror_attr),
+ chip_id, be32_to_cpu(arange->memory_attr),
mem_type, mem_status);
/* reg contains start and length */
@@ -182,6 +185,13 @@ static bool add_address_range(struct dt_node *root,
return false;
}
+ if (be32_to_cpu(arange->memory_attr) & MS_ATTR_PEF) {
+ prlog(PR_DEBUG, "HDAT: Found secure memory\n");
+ name = "secure-memory";
+ dev_type = "secure-memory";
+ compat = "ibm,secure-memory";
+ }
+
if (be16_to_cpu(id->flags) & MS_AREA_SHARED) {
mem = dt_find_by_name_addr(dt_root, name, reg[0]);
if (mem) {
--
2.21.0
More information about the Skiboot
mailing list