Skip to content

Commit 15511cf

Browse files
oohalstewartsmith
authored andcommitted
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>
1 parent 950577e commit 15511cf

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

hdata/memory.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,21 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
436436
start_addr = be64_to_cpu(hb_resv_mem->start_addr);
437437
end_addr = be64_to_cpu(hb_resv_mem->end_addr);
438438

439+
/* Zero length regions are a normal, but should be ignored */
440+
if (start_addr - end_addr == 0) {
441+
prlog(PR_DEBUG, "MEM: Ignoring zero length range\n");
442+
continue;
443+
}
444+
445+
/*
446+
* Workaround broken HDAT reserve regions which are
447+
* bigger than 512MB
448+
*/
449+
if ((end_addr - start_addr) > 0x20000000) {
450+
prlog(PR_ERR, "MEM: Ignoring Bad HDAT reserve: too big\n");
451+
continue;
452+
}
453+
439454
/* remove the HRMOR bypass bit */
440455
start_addr &= ~HRMOR_BIT;
441456
end_addr &= ~HRMOR_BIT;
@@ -451,23 +466,9 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
451466
if (strlen(label) == 0)
452467
snprintf(label, 64, "hostboot-reserve-%d", unnamed++);
453468

469+
454470
prlog(PR_DEBUG, "MEM: Reserve '%s' %#" PRIx64 "-%#" PRIx64 " (type/inst=0x%08x)\n",
455471
label, start_addr, end_addr, be32_to_cpu(hb_resv_mem->type_instance));
456-
457-
if (start_addr == 0) {
458-
prlog(PR_DEBUG, "MEM: .. skipping\n");
459-
continue;
460-
}
461-
462-
/*
463-
* Workaround broken HDAT reserve regions which are
464-
* bigger than 512MB
465-
*/
466-
if ((end_addr - start_addr) > 0x20000000) {
467-
prlog(PR_ERR, "MEM: Ignoring Bad HDAT reserve: too big\n");
468-
continue;
469-
}
470-
471472
mem_reserve_hw(label, start_addr, end_addr - start_addr);
472473
}
473474
}

0 commit comments

Comments
 (0)