Skip to content

Commit

Permalink
hdata: Reserve Trace Areas
Browse files Browse the repository at this point in the history
When hostboot is configured to setup in memory tracing it will reserve
some memory for use by the hardware tracing facility. We need to mark
these areas as off limits to the operating system and firmware.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
oohal authored and stewartsmith committed May 26, 2017
1 parent 36ec8dd commit daa269a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
47 changes: 47 additions & 0 deletions hdata/memory.c
Expand Up @@ -474,6 +474,51 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
}
}

static void parse_trace_reservations(struct HDIF_common_hdr *ms_vpd)
{
unsigned int size;
int count, i;

/*
* The trace arrays are only setup when hostboot is explicitly
* configured to enable them. We need to check and gracefully handle
* when they're not present.
*/

if (!HDIF_get_idata(ms_vpd, MSVPD_IDATA_TRACE_AREAS, &size) || !size) {
prlog(PR_DEBUG, "MS VPD: No trace areas found.");
return;
}

count = HDIF_get_iarray_size(ms_vpd, MSVPD_IDATA_TRACE_AREAS);
if (count <= 0) {
prlog(PR_DEBUG, "MS VPD: No trace areas found.");
return;
}

prlog(PR_INFO, "MS VPD: Found %d trace areas\n", count);

for (i = 0; i < count; i++) {
const struct msvpd_trace *trace_area;
u64 start, end;

trace_area = HDIF_get_iarray_item(ms_vpd,
MSVPD_IDATA_TRACE_AREAS, i, &size);

if (!trace_area)
return; /* shouldn't happen */

start = be64_to_cpu(trace_area->start) & ~HRMOR_BIT;
end = be64_to_cpu(trace_area->end) & ~HRMOR_BIT;

prlog(PR_INFO,
"MSVPD: Trace area: 0x%.16"PRIx64"-0x%.16"PRIx64"\n",
start, end);

mem_reserve_hwbuf("trace-area", start, end - start);
}
}

static bool __memory_parse(struct dt_node *root)
{
struct HDIF_common_hdr *ms_vpd;
Expand Down Expand Up @@ -524,6 +569,8 @@ static bool __memory_parse(struct dt_node *root)

get_hb_reserved_mem(ms_vpd);

parse_trace_reservations(ms_vpd);

prlog(PR_INFO, "MS VPD: Total MB of RAM: 0x%llx\n",
(long long)be64_to_cpu(tcms->total_in_mb));

Expand Down
5 changes: 5 additions & 0 deletions hdata/spira.h
Expand Up @@ -513,6 +513,11 @@ struct msvpd_pmover_bsr_synchro {
} __packed;

/* Idata index 3: Memory Trace Array */
#define MSVPD_IDATA_TRACE_AREAS 3
struct msvpd_trace {
__be64 start, end;
char reserved[16];
};

/* Idata index 4: UE Address Array */

Expand Down
1 change: 1 addition & 0 deletions hdata/test/stubs.c
Expand Up @@ -99,6 +99,7 @@ STUB(op_display);
STUB(fsp_preload_lid);
STUB(fsp_wait_lid_loaded);
STUB(fsp_adjust_lid_side);
STUB(backtrace);

/* Add HW specific stubs here */
static void noop_function(void) {}
Expand Down

0 comments on commit daa269a

Please sign in to comment.