summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/attrrp.C
diff options
context:
space:
mode:
authorChristian Geddes <crgeddes@us.ibm.com>2018-05-03 16:35:08 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2018-06-02 16:10:29 -0400
commit17d1f78337ea7f5bfbb0ee727e63495dd7bb437b (patch)
tree539d51896e9e422751e5acb1a705fb46aaf7578d /src/usr/targeting/attrrp.C
parent1d21270b627aaef8b43aff215fa626ff0d36347d (diff)
downloadtalos-hostboot-17d1f78337ea7f5bfbb0ee727e63495dd7bb437b.tar.gz
talos-hostboot-17d1f78337ea7f5bfbb0ee727e63495dd7bb437b.zip
Refactor re-init of targeting data during MPIPL/HBRT startup
There are a couple of things we have to do to targets/attrs when we either transition from Hostboot->HBRT or from HBRT->Hostboot during an MPIPL. These include resetting all of the mutex attrs so they are in the unlocked state and updating the pointer which PEER_TARGET stores as a value to reflect the change in the memory mapping. For both of these tasks we need to loop through all of the targets.This refactor allows both these tasks to be done in the same loop. Change-Id: I23614bba11b2c9eabb97a7ddc7a53937f83dc131 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/58316 Reviewed-by: Martin Gloff <mgloff@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Benjamin J. Weisenbeck <bweisenb@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/targeting/attrrp.C')
-rwxr-xr-xsrc/usr/targeting/attrrp.C175
1 files changed, 97 insertions, 78 deletions
diff --git a/src/usr/targeting/attrrp.C b/src/usr/targeting/attrrp.C
index defe5ceed..9ba04090a 100755
--- a/src/usr/targeting/attrrp.C
+++ b/src/usr/targeting/attrrp.C
@@ -101,6 +101,14 @@ namespace TARGETING
break;
}
+ // Now that the VMM blocks have been created we must set
+ // the appropriate R/W permissions
+ l_errl = this->editPagePermissions(ALL_SECTION_TYPES, DEFAULT_PERMISSIONS);
+ if (l_errl)
+ {
+ break;
+ }
+
// Spawn daemon thread.
task_create(&AttrRP::startMsgServiceTask, this);
@@ -649,69 +657,113 @@ namespace TARGETING
}
- errlHndl_t AttrRP::createVmmSections()
+ errlHndl_t AttrRP::editPagePermissions(uint8_t i_type, uint32_t i_permission)
{
errlHndl_t l_errl = NULL;
-
+ int rc;
+ uint32_t l_perm = i_permission;
do
{
- // Allocate message queue for VMM requests.
- iv_msgQ = msg_q_create();
-
- // register it so it can be discovered by istep 21 and thus allow
- // secure runtime preparation of persistent r/w attributes
- int rc = msg_q_register(iv_msgQ, ATTRRP_MSG_Q);
-
- assert(rc == 0, "Bug! Unable to register message queue");
-
// Create VMM block for each section, assign permissions.
for (size_t i = 0; i < iv_sectionCount; ++i)
{
- uint64_t l_perm = 0;
- switch(iv_sections[i].type)
+ if(i_permission == DEFAULT_PERMISSIONS)
{
- case SECTION_TYPE_PNOR_RO:
- l_perm = READ_ONLY;
- break;
-
- case SECTION_TYPE_PNOR_RW:
- l_perm = WRITABLE | WRITE_TRACKED;
- break;
+ switch(iv_sections[i].type)
+ {
+ case SECTION_TYPE_PNOR_RO:
+ l_perm = READ_ONLY;
+ break;
- case SECTION_TYPE_HEAP_PNOR_INIT:
- l_perm = WRITABLE;
- break;
+ case SECTION_TYPE_PNOR_RW:
+ l_perm = WRITABLE | WRITE_TRACKED;
+ break;
- case SECTION_TYPE_HEAP_ZERO_INIT:
- case SECTION_TYPE_HB_HEAP_ZERO_INIT:
- l_perm = WRITABLE | ALLOCATE_FROM_ZERO;
- break;
+ case SECTION_TYPE_HEAP_PNOR_INIT:
+ l_perm = WRITABLE;
+ break;
- default:
+ case SECTION_TYPE_HEAP_ZERO_INIT:
+ case SECTION_TYPE_HB_HEAP_ZERO_INIT:
+ l_perm = WRITABLE | ALLOCATE_FROM_ZERO;
+ break;
- /*@
- * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid TARG_CREATE_VMM_SECTIONS
- * @reasoncode TARG_RC_UNHANDLED_ATTR_SEC_TYPE
- * @userdata1 Section type
- *
- * @devdesc Found unhandled attribute section type
- * @custdesc FW error, unexpected Attribute section type
- */
- const bool hbSwError = true;
- l_errl = new ErrlEntry(ERRL_SEV_UNRECOVERABLE,
- TARG_CREATE_VMM_SECTIONS,
- TARG_RC_UNHANDLED_ATTR_SEC_TYPE,
- iv_sections[i].type,
- 0, hbSwError);
- break;
+ default:
+
+ /*@
+ * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid TARG_EDIT_PAGE_PERMISSIONS
+ * @reasoncode TARG_RC_UNHANDLED_ATTR_SEC_TYPE
+ * @userdata1 Section type
+ *
+ * @devdesc Found unhandled attribute section type
+ * @custdesc FW error, unexpected Attribute section type
+ */
+ const bool hbSwError = true;
+ l_errl = new ErrlEntry(ERRL_SEV_UNRECOVERABLE,
+ TARG_EDIT_PAGE_PERMISSIONS,
+ TARG_RC_UNHANDLED_ATTR_SEC_TYPE,
+ iv_sections[i].type,
+ 0, hbSwError);
+ break;
+ }
+ }
+ if( i_type == ALL_SECTION_TYPES || i_type == iv_sections[i].type)
+ {
+ rc = mm_set_permission(reinterpret_cast<void*>(
+ iv_sections[i].vmmAddress),
+ iv_sections[i].size,
+ l_perm);
}
- if(l_errl)
+ if (rc)
{
+ /*@
+ * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid TARG_EDIT_PAGE_PERMISSIONS
+ * @reasoncode TARG_RC_MM_PERM_FAIL
+ * @userdata1 vAddress attempting to allocate.
+ * @userdata2 (kernel-rc << 32) | (Permissions)
+ *
+ * @devdesc While attempting to set permissions on
+ * a virtual memory block for an attribute
+ * section, the kernel returned an error.
+ *
+ * @custdesc Kernel failed to set permissions on
+ * virtual memory block
+ */
+ const bool hbSwError = true;
+ l_errl = new ErrlEntry(ERRL_SEV_UNRECOVERABLE,
+ TARG_EDIT_PAGE_PERMISSIONS,
+ TARG_RC_MM_PERM_FAIL,
+ iv_sections[i].vmmAddress,
+ TWO_UINT32_TO_UINT64(rc, l_perm),
+ hbSwError);
break;
}
+ }
+ } while(0);
+ return l_errl;
+ }
+ errlHndl_t AttrRP::createVmmSections()
+ {
+ errlHndl_t l_errl = NULL;
+
+ do
+ {
+ // Allocate message queue for VMM requests.
+ iv_msgQ = msg_q_create();
+
+ // register it so it can be discovered by istep 21 and thus allow
+ // secure runtime preparation of persistent r/w attributes
+ int rc = msg_q_register(iv_msgQ, ATTRRP_MSG_Q);
+
+ assert(rc == 0, "Bug! Unable to register message queue");
+
+ // Create VMM block for each section, assign permissions.
+ for (size_t i = 0; i < iv_sectionCount; ++i)
+ {
int rc = 0;
msg_q_t l_msgQ = iv_msgQ;
@@ -750,8 +802,6 @@ namespace TARGETING
if(iv_sections[i].type == SECTION_TYPE_PNOR_RW)
{
- // TODO RTC:164480 For MPIPL we need to map the RW section
- // in real memory to virtual address of the section in PNOR
/*
* Register this memory range to be FLUSHed during
* a shutdown.
@@ -760,37 +810,6 @@ namespace TARGETING
reinterpret_cast<void*>(iv_sections[i].vmmAddress),
iv_sections[i].size,ATTR_PRIORITY);
}
-
- rc = mm_set_permission(reinterpret_cast<void*>(
- iv_sections[i].vmmAddress),
- iv_sections[i].size,
- l_perm);
-
- if (rc)
- {
- /*@
- * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid TARG_CREATE_VMM_SECTIONS
- * @reasoncode TARG_RC_MM_PERM_FAIL
- * @userdata1 vAddress attempting to allocate.
- * @userdata2 (kernel-rc << 32) | (Permissions)
- *
- * @devdesc While attempting to set permissions on
- * a virtual memory block for an attribute
- * section, the kernel returned an error.
- *
- * @custdesc Kernel failed to set permissions on
- * virtual memory block
- */
- const bool hbSwError = true;
- l_errl = new ErrlEntry(ERRL_SEV_UNRECOVERABLE,
- TARG_CREATE_VMM_SECTIONS,
- TARG_RC_MM_PERM_FAIL,
- iv_sections[i].vmmAddress,
- TWO_UINT32_TO_UINT64(rc, l_perm),
- hbSwError);
- break;
- }
} // End iteration through each section
if(l_errl)
OpenPOWER on IntegriCloud