[Skiboot] [PATCH 02/14] hdat: Parse hostboot memory reservations from HDAT

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Thu Jan 12 17:37:28 AEDT 2017


On 01/12/2017 09:24 AM, Oliver O'Halloran wrote:
> From: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
>
> 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: Oliver O'Halloran <oohall at gmail.com>
> Cc: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
> ---
> Vasant, I dropped your Signed-off-by since this is pretty heavily
> modified from your v2. Can you review and give your S-o-b if you're OK
> with the changes?
> ---
>   hdata/memory.c     | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   hdata/test/stubs.c |  1 +
>   2 files changed, 58 insertions(+)
>
> diff --git a/hdata/memory.c b/hdata/memory.c
> index c6080917d134..745ce74d1dbb 100644
> --- a/hdata/memory.c
> +++ b/hdata/memory.c
> @@ -19,7 +19,9 @@
>   #include <vpd.h>
>   #include <ccan/str/str.h>
>   #include <libfdt/libfdt.h>
> +#include <mem_region.h>
>   #include <types.h>
> +#include <inttypes.h>
>
>   #include "spira.h"
>   #include "hdata.h"
> @@ -382,6 +384,59 @@ static void get_msareas(struct dt_node *root,
>   	}
>   }
>
> +#define HRMOR_BIT (1ul << 63)
> +
> +static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
> +{
> +	const struct msvpd_hb_reserved_mem *hb_resv_mem;
> +	u64 start_addr, end_addr, label_size;
> +	int unnamed = 0, count, i;
> +	char label[65];
> +
> +	/*
> +	 * XXX: Reservation names only exist on P9 and on P7/8 we get the
> +	 *      reserved ranges through the hostboot mini-FDT instead.
> +	 */
> +	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_size = be32_to_cpu(hb_resv_mem->label_size);
> +		start_addr = be64_to_cpu(hb_resv_mem->start_addr);
> +		end_addr = be64_to_cpu(hb_resv_mem->end_addr);
> +
> +		/* remove the HRMOR bypass bit */
> +		start_addr &= ~HRMOR_BIT;
> +		end_addr &= ~HRMOR_BIT;
> +
> +		if (label_size > 64)
> +			label_size = 64;
> +
> +		memcpy(label, hb_resv_mem->label, label_size);
> +		label[label_size] = '\0';
> +
> +		if (strlen(label) == 0)
> +			snprintf(label, 64, "hostboot-reserve-%d", unnamed++);
> +
> +		mem_reserve_hw(label, start_addr, end_addr - start_addr);

Actually my v2 had a issue which I had corrected locally.

mem_reserve_hw create new mem_region and region->name = label.

Hence I think we should allocate memory for label here.

-Vasant



More information about the Skiboot mailing list