aboutsummaryrefslogtreecommitdiff
path: root/hdata
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-03-28 15:06:44 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-03-30 19:37:48 +1100
commit15511cfb042075b5a0e0962f830c4143626546d2 (patch)
treed30a033a38383180f45efc6ce74cca969b990d53 /hdata
parent950577e5dddeb99c1ed5ad944a62faf93dc425e2 (diff)
downloadskiboot-15511cfb042075b5a0e0962f830c4143626546d2.zip
skiboot-15511cfb042075b5a0e0962f830c4143626546d2.tar.gz
skiboot-15511cfb042075b5a0e0962f830c4143626546d2.tar.bz2
hdat: ignore zero length reserves
Hostboot can export reserved regions with a length of zero and these should be ignored rather than being turned into reserved range. While we're here fix a memory leak by moving the "too large" region check to before we allocate space for the label. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hdata')
-rw-r--r--hdata/memory.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/hdata/memory.c b/hdata/memory.c
index b3d514e..b0cfec9 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -436,6 +436,21 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
start_addr = be64_to_cpu(hb_resv_mem->start_addr);
end_addr = be64_to_cpu(hb_resv_mem->end_addr);
+ /* Zero length regions are a normal, but should be ignored */
+ if (start_addr - end_addr == 0) {
+ prlog(PR_DEBUG, "MEM: Ignoring zero length range\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\n");
+ continue;
+ }
+
/* remove the HRMOR bypass bit */
start_addr &= ~HRMOR_BIT;
end_addr &= ~HRMOR_BIT;
@@ -451,23 +466,9 @@ 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\n");
- continue;
- }
-
mem_reserve_hw(label, start_addr, end_addr - start_addr);
}
}