[Skiboot] [PATCH v2 1/2] hdata: Cleanup get_hb_reserved_mem

Oliver oohall at gmail.com
Fri Sep 7 12:16:36 AEST 2018


On Thu, Sep 6, 2018 at 10:41 PM, Vasant Hegde
<hegdevasant at linux.vnet.ibm.com> wrote:
> - Use macro for label size
> - Replace malloc with array
>
> Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
> ---
>  hdata/memory.c | 14 +++++---------
>  hdata/spira.h  |  3 ++-
>  2 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/hdata/memory.c b/hdata/memory.c
> index ecce881d1..743ffadd4 100644
> --- a/hdata/memory.c
> +++ b/hdata/memory.c
> @@ -596,7 +596,7 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
>         u64 start_addr, end_addr, label_size;
>         struct dt_node *node;
>         int count, i;
> -       char *label;
> +       char label[HB_RESERVE_MEM_LABLE_SIZE + 1];
>
>         /*
>          * XXX: Reservation names only exist on P9 and on P7/8 we get the
> @@ -640,20 +640,16 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
>                 /* remove the HRMOR bypass bit */
>                 start_addr &= ~HRMOR_BIT;
>                 end_addr &= ~HRMOR_BIT;
> -               if (label_size > 64)
> -                       label_size = 64;
> -
> -               label = malloc(label_size+1);
> -               assert(label);
> +               if (label_size > HB_RESERVE_MEM_LABLE_SIZE)
> +                       label_size = HB_RESERVE_MEM_LABLE_SIZE;
>
> +               memset(label, 0, HB_RESERVE_MEM_LABLE_SIZE + 1);
>                 memcpy(label, hb_resv_mem->label, label_size);
>                 label[label_size] = '\0';
>
>                 /* Unnamed reservations are always broken. Ignore them. */
> -               if (strlen(label) == 0) {
> -                       free(label);
> +               if (strlen(label) == 0)
>                         continue;
> -               }
>
>                 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));
> diff --git a/hdata/spira.h b/hdata/spira.h
> index ef2aec257..3a63bf610 100644
> --- a/hdata/spira.h
> +++ b/hdata/spira.h
> @@ -541,6 +541,7 @@ struct msvpd_trace {
>
>  /* Idata index 5: Hostboot reserved memory address range */
>  #define MSVPD_IDATA_HB_RESERVED_MEM    5

> +#define HB_RESERVE_MEM_LABLE_SIZE      64

LABEL not LABLE

>  struct msvpd_hb_reserved_mem {
>  #define MSVPD_HBRMEM_RANGE_TYPE        PPC_BITMASK32(0,7)
>  #define HBRMEM_CONTAINER_VERIFICATION_CODE     0x3
> @@ -548,7 +549,7 @@ struct msvpd_hb_reserved_mem {
>         __be64          start_addr;
>         __be64          end_addr;
>         __be32          label_size;
> -       uint8_t         label[64];
> +       uint8_t         label[HB_RESERVE_MEM_LABLE_SIZE];
>         uint8_t         rw_perms;
>  #define HB_RESERVE_READABLE 0x80
>  #define HB_RESERVE_WRITEABLE 0x40
> --
> 2.14.3
>

good cleanup otherwise

Reviewed-by: Oliver O'Halloran <oohall at gmail.com>


More information about the Skiboot mailing list