[Skiboot] [PATCH v2 09/12] hdat: Parse hostboot memory reservations from HDAT

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Thu Jan 5 16:57:00 AEDT 2017


On 12/20/2016 11:52 AM, Stewart Smith wrote:
> Vasant Hegde <hegdevasant at linux.vnet.ibm.com> writes:
>> Hostboot reserves some memory and passes via HDAT. This patch
>> adds code to parse node reservation details and marks it as
>> REGION_HW_RESERVED. Later mem_region_add_dt_reserved() populates
>> DT entry.
>>
>> Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
>> ---
>>   hdata/memory.c     | 38 ++++++++++++++++++++++++++++++++++++++
>>   hdata/test/stubs.c |  1 +
>>   2 files changed, 39 insertions(+)
>>
>> diff --git a/hdata/memory.c b/hdata/memory.c
>> index a8b9955..aade3be 100644
>> --- a/hdata/memory.c
>> +++ b/hdata/memory.c
>> @@ -19,6 +19,7 @@
>>   #include <vpd.h>
>>   #include <ccan/str/str.h>
>>   #include <libfdt/libfdt.h>
>> +#include <mem_region.h>
>>   #include <types.h>
>>
>>   #include "spira.h"
>> @@ -383,6 +384,41 @@ static void get_msareas(struct dt_node *root,
>>   	}
>>   }
>>
>> +static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
>> +{
>> +	char *label;
>> +	int count, i;
>> +	uint64_t len;
>> +	const struct msvpd_hb_reserved_mem *hb_resv_mem;
>> +
>> +	if (proc_gen < proc_gen_p9)
>> +		return;
>> +
>> +	count = HDIF_get_iarray_size(ms_vpd, MSVPD_IDATA_HB_RESERVED_MEM);
>> +	if (count <= 0) {
>> +		prerror("MS VPD: No hostboot reserved memory found\n");
>> +		return;
>> +	}
>> +
>> +	for (i = 0; i < count; i++) {
>> +		hb_resv_mem = HDIF_get_iarray_item(ms_vpd,
>> +						   MSVPD_IDATA_HB_RESERVED_MEM,
>> +						   i, NULL);
>> +		if (!CHECK_SPPTR(hb_resv_mem))
>> +			continue;
>> +
>> +		label = zalloc(be32_to_cpu(hb_resv_mem->label_size) + 1);
>> +		assert(label);
>> +		memcpy(label, hb_resv_mem->label,
>> +		       be32_to_cpu(hb_resv_mem->label_size));
>
> Could you also check the sanity of label_size ? We know it's <=64 (or

Yes. will fix in next iteration.

> <64 - it'd be good to get clarification on this, or check the spec that
> for such strings they *are* null terminated).

Spec doesn't explicitly mention about ending with NULL char. Hence I assume its 
<= 64. Anyway I will cross check with Venkatesh.


>
>> +		len = be64_to_cpu(hb_resv_mem->end_addr) -
>> +			be64_to_cpu(hb_resv_mem->start_addr);
>> +		mem_reserve_hw(label,
>> +			       be64_to_cpu(hb_resv_mem->start_addr), len);
>> +		free(label);
>> +	}
>> +}
>> +
>>   static bool __memory_parse(struct dt_node *root)
>>   {
>>   	struct HDIF_common_hdr *ms_vpd;
>> @@ -431,6 +467,8 @@ static bool __memory_parse(struct dt_node *root)
>>
>>   	get_msareas(root, ms_vpd);
>>
>> +	get_hb_reserved_mem(ms_vpd);
>> +
>>   	prlog(PR_INFO, "MS VPD: Total MB of RAM: 0x%llx\n",
>>   	       (long long)be64_to_cpu(tcms->total_in_mb));
>>
>> diff --git a/hdata/test/stubs.c b/hdata/test/stubs.c
>> index 9687b31..735813f 100644
>> --- a/hdata/test/stubs.c
>> +++ b/hdata/test/stubs.c
>
> Speaking of tests - any outlook on some test HDAT to check this new
> code? I'd prefer to hold off merging until we have a HDAT dump to test
> with.

Sure. I will try to grab HDAT dump and post it . So that we will have sample to 
compare with.


-Vasant

>



More information about the Skiboot mailing list