[Skiboot] [PATCH 08/10] hdat: Add __packed to all HDAT structures and workaround HB reserve
Benjamin Herrenschmidt
benh at kernel.crashing.org
Thu Mar 9 11:45:41 AEDT 2017
Some HDAT structures aren't properly aligned. We were using __packed
on some but not others and got at least one wrong (HB reserve). This
adds it everywhere to avoid such problems.
However this then triggers another problem where HB gives us a
crazy range (0.256M) to reserve with no label, which triggers an
assertion failure later on in mem_regions.c.
So also add a test to skip any region starting at 0 until we can
undertand that better and have it fixed one way or another.
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
hdata/memory.c | 23 +++++++++++++----------
hdata/spira.h | 23 +++++++++++------------
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/hdata/memory.c b/hdata/memory.c
index 442d35c..b3d514e 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -31,11 +31,11 @@ struct HDIF_ram_area_id {
#define RAM_AREA_INSTALLED 0x8000
#define RAM_AREA_FUNCTIONAL 0x4000
__be16 flags;
-};
+} __packed;
struct HDIF_ram_area_size {
__be64 mb;
-};
+} __packed;
struct ram_area {
const struct HDIF_ram_area_id *raid;
@@ -48,7 +48,7 @@ struct HDIF_ms_area_address_range {
__be32 chip;
__be32 mirror_attr;
__be64 mirror_start;
-};
+} __packed;
struct HDIF_ms_area_id {
__be16 id;
@@ -62,7 +62,7 @@ struct HDIF_ms_area_id {
#define MS_AREA_SHARED 0x2000
__be16 flags;
__be16 share_id;
-};
+} __packed;
static struct dt_node *find_shared(struct dt_node *root, u16 id, u64 start, u64 len)
{
@@ -451,21 +451,24 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
if (strlen(label) == 0)
snprintf(label, 64, "hostboot-reserve-%d", unnamed++);
+ prlog(PR_DEBUG, "MEM: Reserve '%s' %#" PRIx64 "-%#" PRIx64 " (type/inst=0x%08x)\n",
+ label, start_addr, end_addr, be32_to_cpu(hb_resv_mem->type_instance));
+
+ if (start_addr == 0) {
+ prlog(PR_DEBUG, "MEM: .. skipping\n");
+ continue;
+ }
+
/*
* Workaround broken HDAT reserve regions which are
* bigger than 512MB
*/
if ((end_addr - start_addr) > 0x20000000) {
- prlog(PR_ERR, "MEM: Ignoring Bad HDAT reserve: too big "
- "'%s' %#" PRIx64 "-%#" PRIx64 "\n",
- label, start_addr, end_addr);
+ prlog(PR_ERR, "MEM: Ignoring Bad HDAT reserve: too big\n");
continue;
}
mem_reserve_hw(label, start_addr, end_addr - start_addr);
-
- prlog(PR_DEBUG, "MEM: Reserve '%s' %#" PRIx64 "-%#" PRIx64 "\n",
- label, start_addr, end_addr);
}
}
diff --git a/hdata/spira.h b/hdata/spira.h
index 01ce4cb..096ade6 100644
--- a/hdata/spira.h
+++ b/hdata/spira.h
@@ -217,7 +217,7 @@ struct proc_init_data {
struct spira_fru_id {
__be16 slca_index;
__be16 rsrc_id; /* formerly VPD port number */
-};
+} __packed;
/*
* The FRU operational status structure is used in several
@@ -228,7 +228,7 @@ struct spira_fru_op_status {
#define FRU_OP_STATUS_FLAG_USED 0x02 /* If 0 -> not used (redundant) */
#define FRU_OP_STATUS_FLAG_FUNCTIONAL 0x01 /* If 0 -> non-functional */
uint8_t reserved[3];
-};
+} __packed;
/*
* Move VPD related stuff to another file ...
@@ -262,7 +262,7 @@ struct spss_sp_impl {
#define SPSS_SP_IMPL_FLAGS_PRIMARY 0x2000
u8 chip_version;
u8 reserved;
-};
+} __packed;
/* Idata index 3 is deprecated */
@@ -406,7 +406,7 @@ struct iplparams_iplparams {
uint8_t core_config;
#define IPLPARAMS_CORE_NORMAL 0x00
#define IPLPARAMS_CORE_FUSE 0x01
-};
+} __packed;
/* Idata index 4: Platform Dump Descriptor */
#define IPLPARAMS_PLATFORM_DUMP 4
@@ -423,7 +423,7 @@ struct iplparams_dump {
__be32 act_hw_dump_sz;
__be32 max_sp_dump_sz;
__be32 plid;
-};
+} __packed;
/* Idata index 8: serial ports */
#define IPLPARMS_IDATA_SERIAL 8
@@ -480,14 +480,14 @@ struct msvpd_ms_addr_config {
__be64 max_possible_ms_address;
__be32 deprecated;
__be64 mirrorable_memory_starting_address;
-} __attribute__((packed));
+} __packed;
/* Idata index 1: Total configured mainstore */
#define MSVPD_IDATA_TOTAL_CONFIG_MS 1
struct msvpd_total_config_ms {
__be64 total_in_mb;
-};
+} __packed;
/* Idata index 2: Page mover and sync structure */
#define MSVPD_IDATA_PMOVER_SYNCHRO 2
@@ -508,8 +508,7 @@ struct msvpd_pmover_bsr_synchro {
__be64 pmover_addr;
__be64 bsr_addr;
__be64 xscom_addr;
-
-};
+} __packed;
/* Idata index 3: Memory Trace Array */
@@ -518,13 +517,13 @@ struct msvpd_pmover_bsr_synchro {
/* Idata index 5: Hostboot reserved memory address range */
#define MSVPD_IDATA_HB_RESERVED_MEM 5
struct msvpd_hb_reserved_mem {
- __be32 node_instance;
+ __be32 type_instance;
__be64 start_addr;
__be64 end_addr;
__be32 label_size;
uint8_t label[64];
__be64 reserved;
-};
+} __packed;
/* Child index 0: MS area child structure */
#define MSVPD_CHILD_MS_AREAS 0
@@ -908,7 +907,7 @@ struct sppaca_cpu_cache {
__be32 l2_cache_assoc_sets;
__be32 l35_dcache_size_kb;
__be32 l35_cache_line_size;
-};
+} __packed;
/* Idata index 6 : CPU Attributes */
#define SPPACA_IDATA_CPU_ATTR 6
--
2.9.3
More information about the Skiboot
mailing list