Skip to content

Commit

Permalink
Dynamic ATTR Override support via debug interface
Browse files Browse the repository at this point in the history
  -Supported by debug tools (ecmd-debug-framework/Cronus)
    Only in istep mode and between isteps
    Requires HB to be running
  -Uses output of attributeOverride tool (same format as ATTR_TMP)
  -Introduces two new "debug" isteps
     255,4,set_attr_overrides
     255,5,clear_attr_overrides
  -Once istep is triggered Hostboot sends down address/size
    and the debug tool uses putmempba to push data to cache/mem.
    Then Hostboot consumes just like ATTR_TMP

Change-Id: I4ade7b85acac077a15bdb36bba1ef9df4263b428
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41271
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Prachi Gupta <pragupta@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
sannerd authored and dcrowell77 committed Jun 8, 2017
1 parent 4c586e2 commit f195e42
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 12 deletions.
55 changes: 52 additions & 3 deletions src/build/debug/Hostboot/Istep.pm
Expand Up @@ -97,6 +97,7 @@ my $opt_command = 0;
my $opt_list = 0;
my $opt_resume = 0;
my $opt_clear_trace = 0;
my $attr_bin_file = "";

my $command = "";

Expand Down Expand Up @@ -245,6 +246,12 @@ sub main
$opt_clear_trace = 1;
$options[$i] = "";
}
if ( m/^\-{0,2}attr_bin$/ )
{
$attr_bin_file = $args->{"attr_bin"};
$options[$i] = "";
}

} ## endfor

## if there's anything left after this, assume it is a single command
Expand Down Expand Up @@ -376,9 +383,10 @@ sub checkDebugBuf
{
my $SCRATCH_MBOX1 = 0x00050038;
my $SCRATCH_MBOX2 = 0x00050039;
my $MSG_TYPE_MASK = 0xFF00000000000000;
my $MSG_TYPE_TRACE = 0x0000000000000000;
my $MSG_TYPE_ATTR = 0x0100000000000000;
my $MSG_TYPE_MASK = 0xFF00000000000000;
my $MSG_TYPE_TRACE = 0x0000000000000000;
my $MSG_TYPE_ATTR = 0x0100000000000000;
my $MSG_TYPE_SET_ATTR = 0x0200000000000000;
my $dbgAddr = "";
my $dbgSize = "";

Expand Down Expand Up @@ -407,6 +415,10 @@ sub checkDebugBuf
{
handleAttrDump($buffAddr, $buffSize);
}
elsif ($msgType == $MSG_TYPE_SET_ATTR)
{
handleAttrOverride($buffAddr, $buffSize);
}

#Write 0 to let HB know we extracted buf and it can continue
::writeScom($SCRATCH_MBOX1, 8, 0x0);
Expand Down Expand Up @@ -481,6 +493,43 @@ sub handleAttrDump
}
}

## ---------------------------------------------------------------------------
## Push an ATTR override bin to memory
## ---------------------------------------------------------------------------
sub handleAttrOverride
{
my $buffAddr = shift;
my $buffSize = shift;

#Check to see if attr.bin file set
if ($attr_bin_file eq "")
{
::userDisplay "\nATTR BIN File not set,
use [--tool-options='attr_bin=<file> set_attr_overrides']\n";
exit 1;
}

#Open the file, get the size
my $attrBinFile;
open ($attrBinFile, '<', $attr_bin_file) or
die "Can't open '$attr_bin_file' $!";
my $size = -s $attr_bin_file;

#Check that file size is less than HB allocated size
if ($size > $buffSize)
{
::userDisplay "BIN file [$attr_bin_file] too big, $size vs $buffSize";
exit 1;
}

#Read in file data and actually write to mem
my $contents;
read($attrBinFile,$contents,$size);
::writeData($buffAddr, $size, $contents);
close $attrBinFile ;
}



## ---------------------------------------------------------------------------
## Dump environment variable specified.
Expand Down
6 changes: 2 additions & 4 deletions src/build/debug/ecmd-debug-framework.pl
Expand Up @@ -6,7 +6,7 @@
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2013,2016
# Contributors Listed Below - COPYRIGHT 2013,2017
# [+] International Business Machines Corp.
#
#
Expand Down Expand Up @@ -220,15 +220,13 @@ sub writeData

my $putmemcmd = "putmempba";
if( $memMode =~ /adu/ ) { $putmemcmd = "putmemproc"; }
my $command = sprintf(
"$putmemcmd -n%d -p%d -cft -fb %s %x -quiet -mode inj > %s",
my $command = sprintf("%s -n%d -p%d -fb %s %x -quiet -mode inj > %s",
$putmemcmd,
$node,
$proc,
$filename,
$addr,
$debugfile);
::userDisplay($command);
if (system($command) != 0)
{
system("cat $debugfile");
Expand Down
17 changes: 17 additions & 0 deletions src/include/usr/fapi2/plat_attr_override_sync.H
Expand Up @@ -226,6 +226,23 @@ public:
*/
void triggerAttrSync();

/**
* @brief This function will clear all attribute overrides in effect.
* This function is called by the debug interface
*
*/
void clearAttrOverrides();

/**
* @brief This function will allow the debug interface to set
* attribut overrides "dynamically" at any point in the IPL
* between isteps. The debug interface is used to process
* the attributes in the same format as the ATTR_TMP and ATTR_PERM
* PNOR partition binary blobs
*
*/
void dynSetAttrOverrides();

/**
* @brief This function actually sends the FAPI Sync tank attributes
* across the debug interface
Expand Down
14 changes: 13 additions & 1 deletion src/include/usr/isteps/spless_255list.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -64,6 +64,8 @@ namespace INITSERVICE
const uint8_t CTL_CONT_TRACE_ENABLE = 0x01;
const uint8_t FLUSH_TRACE_BUFS = 0x02;
const uint8_t DUMP_FAPI_ATTR = 0x03;
const uint8_t SET_ATTR_OVERRIDES = 0x04;
const uint8_t CLEAR_ATTR_OVERRIDES = 0x05;


const TaskInfo g_istep255[] = {
Expand All @@ -87,6 +89,16 @@ namespace INITSERVICE
NULL,
{ NONE, EXT_IMAGE, IPL_NOOP, false }
},
{
ISTEPNAME(255,4, "set_attr_overrides"),
NULL,
{ NONE, EXT_IMAGE, IPL_NOOP, false }
},
{
ISTEPNAME(255,5, "clear_attr_overrides"),
NULL,
{ NONE, EXT_IMAGE, IPL_NOOP, false }
},
};

const DepModInfo g_istep255Dependancies = {
Expand Down
3 changes: 2 additions & 1 deletion src/include/usr/util/utilmbox_scratch.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -60,6 +60,7 @@ namespace Util

MSG_TYPE_TRACE = 0x00,
MSG_TYPE_ATTRDUMP = 0x01,
MSG_TYPE_ATTROVERRIDE = 0x02,

};

Expand Down
4 changes: 4 additions & 0 deletions src/include/usr/vmmconst.h
Expand Up @@ -102,6 +102,10 @@
#define VMM_VADDR_SBE_UPDATE (3 * GIGABYTE)
#define VMM_SBE_UPDATE_SIZE (900 * KILOBYTE)
#define VMM_VADDR_SBE_UPDATE_END (VMM_VADDR_SBE_UPDATE + VMM_SBE_UPDATE_SIZE)
/** Debug Comm Channel is at 3.5GB, uses 32KB */
#define VMM_VADDR_DEBUG_COMM ((3 * GIGABYTE) + (500 * MEGABYTE))
#define VMM_DEBUG_COMM_SIZE (32 * KILOBYTE)
#define VMM_VADDR_DEBUG_COMM_END (VMM_VADDR_DEBUG_COMM + VMM_DEBUG_COMM_SIZE)

/** Attribute Resource Provider */
// Note: Not simplified to make it easier to extract with the PNOR targeting
Expand Down
123 changes: 121 additions & 2 deletions src/usr/fapi2/plat_attr_override_sync.C
Expand Up @@ -37,6 +37,8 @@
#include <string.h>
#include <vector>
#include <sys/msg.h>
#include <sys/mm.h>
#include <errno.h>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <mbox/mboxif.H>
Expand All @@ -48,6 +50,7 @@
#include <fapi2AttrSyncData.H>
#include <fapi2_attribute_service.H>
#include <util/utilmbox_scratch.H>
#include <plat_utils.H>

namespace fapi2
{
Expand Down Expand Up @@ -736,20 +739,33 @@ void AttrOverrideSync::triggerAttrSync()
l_attrs[i].iv_dims[1] * l_attrs[i].iv_dims[2] *
l_attrs[i].iv_dims[3];

//Get the data
//Get the data -- limit this to ATTR less than 1K in size
//otherwise can cause memory fragmentation in cache contained HB.
//Specifically this is to weed out the WOF_TABLE_DATA (128K)
if(l_bytes > KILOBYTE)
{
FAPI_INF("triggerAttrSync: ATTR %x bigger [%x] than 1K... skipping",
l_bytes);
continue;
}
l_buf = reinterpret_cast<uint8_t *>(realloc(l_buf, l_bytes));
ReturnCode l_rc =
rawAccessAttr(
static_cast<fapi2::AttributeId>(l_attrs[i].iv_attrId),
l_fapiTarget, &l_buf[0]);

// Write the attribute to the SyncAttributeTank to sync to Cronus
if(l_rc == FAPI2_RC_SUCCESS)
errlHndl_t l_pErr = fapi2::rcToErrl(l_rc);
if(!l_pErr)
{
iv_syncTank.setAttribute(l_attrs[i].iv_attrId, l_fType,
l_pos, l_unitPos, l_node, 0,
l_bytes, l_buf);
}
else
{
delete l_pErr; //Debug tool, ignore errors
}
}
}

Expand All @@ -759,6 +775,109 @@ void AttrOverrideSync::triggerAttrSync()
sendFapiAttrSyncs();
}

//******************************************************************************
void AttrOverrideSync::clearAttrOverrides()
{
#ifndef __HOSTBOOT_RUNTIME
// Debug Channel is clearing all attribute overrides.
FAPI_INF("Debug Channel CLEAR_ALL_OVERRIDES");
iv_overrideTank.clearAllAttributes();
TARGETING::Target::theTargOverrideAttrTank().clearAllAttributes();
#endif
}

//******************************************************************************
void AttrOverrideSync::dynSetAttrOverrides()
{
#ifndef __HOSTBOOT_RUNTIME
errlHndl_t err = NULL;
int64_t rc = 0;

do
{
// Create a memory block to serve as Debug Comm channel
// NOTE: using mm_alloc_block since this code is running before we
// have mainstore and we must have contiguous blocks of memory for
// Cronus putmempba
rc = mm_alloc_block( NULL,
reinterpret_cast<void*>
(VMM_VADDR_DEBUG_COMM),
VMM_DEBUG_COMM_SIZE);
if(rc == -EALREADY)
{
//-EALREADY inidciates the block is already mapped -- ignore
rc = 0;
}

if( rc )
{
// This is a debug interface, just emit trace and exit
FAPI_ERR("dynSetAttrOverrides() - "
"Error from mm_alloc_block : rc=%d", rc );
break;
}

rc = mm_set_permission(reinterpret_cast<void*>
(VMM_VADDR_DEBUG_COMM),
VMM_DEBUG_COMM_SIZE,
WRITABLE | ALLOCATE_FROM_ZERO);
if( rc )
{
// This is a debug interface, just emit trace and exit
FAPI_ERR("dynSetAttrOverrides() - "
"Error from mm_set_permission : rc=%d", rc );
break;
}

//Now masquerade this at the ATTR_TMP PNOR section so the underlying
//ATTR override and bin file can be used as is
PNOR::SectionInfo_t l_sectionInfo;
l_sectionInfo.id = PNOR::ATTR_TMP;
l_sectionInfo.name = "ATTR_TMP";
l_sectionInfo.vaddr = VMM_VADDR_DEBUG_COMM;
l_sectionInfo.flashAddr = 0xFFFFFFFF; //Not used
l_sectionInfo.size = VMM_DEBUG_COMM_SIZE;
l_sectionInfo.eccProtected = false;
l_sectionInfo.sha512Version = false;
l_sectionInfo.sha512perEC = false;
l_sectionInfo.readOnly = true;
l_sectionInfo.reprovision = false;
l_sectionInfo.secure = false;


//Send debug message to tool to update memory
//Must clear data to actually alloction phys pages
memset (reinterpret_cast<void*>(VMM_VADDR_DEBUG_COMM), 0xFF,
VMM_DEBUG_COMM_SIZE);
uint64_t l_addr =
mm_virt_to_phys(reinterpret_cast<void*>(VMM_VADDR_DEBUG_COMM));
FAPI_INF("virt[%llx] phys[%llx]", VMM_VADDR_DEBUG_COMM, l_addr);
Util::writeDebugCommRegs(Util::MSG_TYPE_ATTROVERRIDE,
l_addr,
VMM_DEBUG_COMM_SIZE);


FAPI_INF("init: processing dynamic overrides");
err = TARGETING::getAttrOverrides(l_sectionInfo, NULL);
if (err)
{
FAPI_ERR("Failed getAttrOverrides from dyanmic set");
errlCommit(err, HWPF_COMP_ID);
break;
}
}while(0);

// Attempt to clean up after ourselves. Ignore errors on cleanup
// path in debug interface
//release all pages in page block
rc = mm_remove_pages(RELEASE, reinterpret_cast<void*>(VMM_VADDR_DEBUG_COMM),
VMM_DEBUG_COMM_SIZE);
rc = mm_set_permission(reinterpret_cast<void*>(VMM_VADDR_DEBUG_COMM),
VMM_DEBUG_COMM_SIZE, NO_ACCESS | ALLOCATE_FROM_ZERO);
#endif
}


//******************************************************************************
void AttrOverrideSync::setAttrActionsFunc(const AttributeId i_attrId,
const Target<TARGET_TYPE_ALL>& i_pTarget,
Expand Down
10 changes: 9 additions & 1 deletion src/usr/initservice/istepdispatcher/sptask.C
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -116,6 +116,14 @@ void handleControlCmd( SPLessCmd & io_cmd )
fapi2::theAttrOverrideSync().triggerAttrSync();
break;

case SET_ATTR_OVERRIDES:
fapi2::theAttrOverrideSync().dynSetAttrOverrides();
break;

case CLEAR_ATTR_OVERRIDES:
fapi2::theAttrOverrideSync().clearAttrOverrides();
break;

default:
#ifdef CONFIG_CONSOLE_OUTPUT_PROGRESS
CONSOLE::displayf(NULL, "Unknown control command %02x", io_cmd.substep);
Expand Down

0 comments on commit f195e42

Please sign in to comment.