Skip to content

Commit

Permalink
hdata: Cleanup get_hb_reserved_mem
Browse files Browse the repository at this point in the history
- Use macro for label size
- Replace malloc with array

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Reviewed-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
Vasant Hegde authored and stewartsmith committed Sep 13, 2018
1 parent 2fba868 commit 70a7a3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
14 changes: 5 additions & 9 deletions hdata/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,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_LABEL_SIZE + 1];

/*
* XXX: Reservation names only exist on P9 and on P7/8 we get the
Expand Down Expand Up @@ -642,20 +642,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_LABEL_SIZE)
label_size = HB_RESERVE_MEM_LABEL_SIZE;

memset(label, 0, HB_RESERVE_MEM_LABEL_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));
Expand Down
3 changes: 2 additions & 1 deletion hdata/spira.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,15 @@ struct msvpd_trace {

/* Idata index 5: Hostboot reserved memory address range */
#define MSVPD_IDATA_HB_RESERVED_MEM 5
#define HB_RESERVE_MEM_LABEL_SIZE 64
struct msvpd_hb_reserved_mem {
#define MSVPD_HBRMEM_RANGE_TYPE PPC_BITMASK32(0,7)
#define HBRMEM_CONTAINER_VERIFICATION_CODE 0x3
__be32 type_instance;
__be64 start_addr;
__be64 end_addr;
__be32 label_size;
uint8_t label[64];
uint8_t label[HB_RESERVE_MEM_LABEL_SIZE];
uint8_t rw_perms;
#define HB_RESERVE_READABLE 0x80
#define HB_RESERVE_WRITEABLE 0x40
Expand Down

0 comments on commit 70a7a3f

Please sign in to comment.