Skip to content

Commit

Permalink
Make TOC partion Read-Only in all PNOR Layouts
Browse files Browse the repository at this point in the history
This commit ensures that the TOC(s) are all set to "read-only" via
the FFS flags for all PNOR files that are created.  It also does
the same for the "BACKUP_PART" and "OTHER_SIDE" partitions, if they
exist, as well.

Change-Id: I5698045b27630e2cb83f470193526ceea02c61d3
CQ:SW423354
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/68828
Reviewed-by: Marshall J. Wilks <mjwilks@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: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mabaiocchi authored and dcrowell77 committed Nov 27, 2018
1 parent 63a9aa5 commit 2ce1bf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/build/buildpnor/buildpnor.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2012,2017
# Contributors Listed Below - COPYRIGHT 2012,2018
# [+] International Business Machines Corp.
#
#
Expand Down Expand Up @@ -136,7 +136,10 @@
my $userflags1 = ($pnorLayout{metadata}{sides}{$sideId}{golden} eq "yes") ?
0x01 : 0x00;

#add a golden bit to the misc flags in userflag1
# Make the TOC Read-only
$userflags1 |= 0x40;

#add the golden and read-only bits to the misc flags in userflag1
$userflags1 = $userflags1 << 16;
trace(2, "$g_fpartCmd --target $pnorBinName --partition-offset $tocOffset --user 1 --name part --value $userflags1 --force");
system("$g_fpartCmd --target $pnorBinName --partition-offset $tocOffset --user 1 --name part --value $userflags1 --force");
Expand Down Expand Up @@ -373,6 +376,11 @@ sub addTOCInfo
my $otherSide = getOtherSide($sideId);
my $numOfTOCs = scalar keys %{$$i_pnorLayout{metadata}{sides}{$sideId}{toc}};

#Using userflags mark these sections read-only (0x40) and indicate that
#they are puesdo-partitions that should be skipped on code update (0x20)
my $userflags1 = 0x40 | 0x20;
$userflags1 = $userflags1 << 16;

#Adding an extra entry in the TOC that points to its backup TOC and other side's TOC (if other side exists).
#This is used to search for all the TOCs in PnorRP code. The idea is to create a link between the tocs such that
#if we can find one valid TOC, then we can look at its BACKUP_PART entry or OTHER_SIDE entry in the TOC to
Expand All @@ -388,9 +396,7 @@ sub addTOCInfo
system("$g_fpartCmd --target $i_pnorBinName --partition-offset $toc_offset --add --offset $backup_offset --size $physicalRegionSize --name $backup_part --flags 0x0");
die "ERROR: Call to add partition $backup_part failed. Aborting!" if ($?);

#indicate that this is a puesdo-partition and should be skipped on code update
my $userflags1 = 0x20;
$userflags1 = $userflags1 << 16;
#adding user flags
trace(1, "$g_fpartCmd --target $i_pnorBinName --partition-offset $toc_offset --user 1 --name $backup_part --value $userflags1 --force");
system("$g_fpartCmd --target $i_pnorBinName --partition-offset $toc_offset --user 1 --name $backup_part --value $userflags1 --force");
die "ERROR: Call to set BACKUP_PART as pseudo failed. Aborting!" if ($?);
Expand All @@ -404,7 +410,7 @@ sub addTOCInfo
system("$g_fpartCmd --target $i_pnorBinName --partition-offset $toc_offset --add --offset $otherSide_offset --size $physicalRegionSize --name $other_side --flags 0x0");
die "ERROR: Call to add partition $other_side failed. Aborting!" if($?);

#indicate that this is a puesdo-partition and should be skipped on code update
#adding user flags
trace(1, "$g_fpartCmd --target $i_pnorBinName --partition-offset $toc_offset --user 1 --name $other_side --value $userflags1 --force");
system("$g_fpartCmd --target $i_pnorBinName --partition-offset $toc_offset --user 1 --name $other_side --value $userflags1 --force");
die "ERROR: Call to set OTHER_SIDE as pseudo failed. Aborting!" if($?);
Expand Down
4 changes: 2 additions & 2 deletions src/usr/pnor/pnor_common.C
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC,
tmpId < PNOR::NUM_SECTIONS;
tmpId ++ )
{
TRACFCOMP(g_trac_pnor, "%s: secure=0x%.2X size=0x%.8X flash=0x%.8X ",
TRACFCOMP(g_trac_pnor, "%s: secure=0x%.2X size=0x%.8X flash=0x%.8X misc=0x%.2X",
PNOR::SectionIdToString(tmpId), o_TOC[tmpId].secure,
o_TOC[tmpId].size, o_TOC[tmpId].flashAddr);
o_TOC[tmpId].size, o_TOC[tmpId].flashAddr, o_TOC[tmpId].misc);
}

} while (0);
Expand Down

0 comments on commit 2ce1bf1

Please sign in to comment.