Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/default_cs_tbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef struct
uint32 ComparisonValue; /**< \brief The Memory Integrity Value */
uint32 ByteOffset; /**< \brief Where a previous unfinished calc left off */
uint32 TempChecksumValue; /**< \brief The unfinished caluculation */
CFE_ResourceId_t ResourceID; /**< \brief ES identity of the application or library */
char Name[CFE_MISSION_MAX_API_LEN]; /**< \brief name of the app */
} CS_Res_App_Table_Entry_t;

Expand Down
6 changes: 6 additions & 0 deletions docs/cs_FunctionalRequirements.csv
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ Table Checksum Miscomparisons,CS4051,"When the CS Application is comparing a cal
,,2) increment the relevant Miscompare Counter,,,,,
,,3) Issue an event message to notify the user of the miscomparison,,,,,
Checksum State Order of Operations,CS4060,"When the CS Application is calculating checksums, the Checksum State of the table must be 'ENABLED' for an entry in the table to be checksummed, regardless of the state of ""Entry Checksum State""",,,"To ensure that individual entry checksum states are only acted upon when the overall checksumming for the table is enabled, maintaining a hierarchical control structure.",,
Application Reload Checksum Recovery,CS4070,"Before reading each checksum chunk for an Application Table entry naming an application or library, the CS Application shall resolve its Executive Services resource ID and valid code address and size, and shall:",,,"To recover from restarted or reloaded module instances without mixing their partial checksums or comparing against a prior instance baseline, while preserving corruption reporting for an unchanged instance.",nasa/CS#20; applies to background checksumming and commanded application baseline recomputation. Per-chunk lookup does not pin the module against concurrent unload.,
,,1) Record the first successfully resolved identity without reporting a reload.,,,,,
,,"2) On a changed previously recorded resource ID, discard the partial checksum and offset, invalidate the previous baseline, record the new identity, and issue an informational module/baseline-reset event without changing enable states.",,,,,
,,3) Establish a baseline after the first complete pass over the new instance and compare subsequent completed checksums against it as specified in CS4050.,,,,,
,,"4) On code address or size change with the same resource ID, restart the partial computation from offset zero while retaining the baseline.",,,,,
,,"5) On module lookup or address-validation failure, perform no CRC read, discard the partial checksum and offset, retain the last successfully resolved identity, range, and baseline, and report the failure for retry on a later attempt.",,,,,
User-Defined Memory Table,CS5000,"The CS Application shall provide a loadable User-Defined Memory Table containing at least 16 entries, each with the following parameters:",,,"To provide a configurable mechanism for defining and managing checksum parameters for user-defined memory regions, enabling flexible integrity checks.",Number of User-Defined Memory Table entries is configurable,
,,"1) ""Entry Checksum State""",,,,,
,,"2) ""Start Address""",,,,,
Expand Down
16 changes: 16 additions & 0 deletions docs/dox_src/cfs_cs.dox
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,22 @@

The format of a single entry in the Apps Results Table is defined by
#CS_Res_App_Table_Entry_t.

The ResourceID field records the ES identity of the application or library.
It precedes Name in the results entry; ground dump decoders must use the matching
results-table schema for this layout.
CS resolves this identity and the code range before each checksum chunk. If ES
reports a new identity, including a reload at the same address, CS discards the
partial checksum and old baseline and issues #CS_APP_RELOADED_INF_EID. The next
completed pass establishes the new instance's baseline. Initial discovery does
not issue a reload event. Changes to the code range under the same identity
restart the partial checksum but retain the baseline; a checksum mismatch alone
does not authorize a new baseline.

An unavailable module is skipped without reading its cached address. CS retains
its last identity and baseline and discards partial progress before retrying.
Resolving module information does not prevent a concurrent unload between the
query and the checksum read.
**/

/**
Expand Down
1 change: 1 addition & 0 deletions eds/cs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<Entry type="BASE_TYPES/uint32" name="ComparisonValue" shortDescription="The Memory Integrity Value" />
<Entry type="BASE_TYPES/uint32" name="ByteOffset" shortDescription="Where a previous unfinished calc left off" />
<Entry type="BASE_TYPES/uint32" name="TempChecksumValue" shortDescription="The unfinished caluculation" />
<Entry type="CFE_RESOURCEID/BaseType" name="ResourceID" shortDescription="ES identity of the application or library" />
<Entry type="BASE_TYPES/ApiName" name="Name" shortDescription="name of the app" />
</EntryList>
</ContainerDataType>
Expand Down
14 changes: 14 additions & 0 deletions fsw/inc/cs_eventids.h
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,20 @@
*/
#define CS_VAL_TABLES_DEF_TBL_LONG_NAME_ERR_EID 155

/**
* \brief CS Application Or Library Reload Baseline Reset Event ID
*
* \par Type: INFORMATION
*
* \par Cause:
*
* ES reports a different resource ID for a previously resolved application or
* library. CS discards its partial checksum and old baseline, and establishes a
* new baseline when checksumming the new instance completes. Initial discovery
* of an application or library does not generate this event.
*/
#define CS_APP_RELOADED_INF_EID 156

/**@}*/

#endif
52 changes: 37 additions & 15 deletions fsw/src/cs_compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ CFE_Status_t CS_RefreshTableData(CS_LocalChecksumState_t *State, CFE_TBL_HandleI
* Local helper function
*
*-----------------------------------------------------------------*/
CFE_Status_t CS_RefreshAppSizeAndAddr(CS_LocalChecksumState_t *State, const char *AppName)
CFE_Status_t CS_RefreshAppSizeAndAddr(CS_LocalChecksumState_t *State, const char *AppName, CFE_ResourceId_t *ResolvedID)
{
CFE_ResourceId_t ResourceID;
CFE_ES_AppInfo_t AppInfo;
Expand Down Expand Up @@ -334,6 +334,7 @@ CFE_Status_t CS_RefreshAppSizeAndAddr(CS_LocalChecksumState_t *State, const char
State->TotalSize = CFE_ES_MEMOFFSET_TO_SIZET(AppInfo.CodeSize);
State->BufferAddr = CFE_ES_MEMADDRESS_TO_PTR(AppInfo.CodeAddress);
State->CurrOffset = 0;
*ResolvedID = ResourceID;
}
else
{
Expand Down Expand Up @@ -473,29 +474,43 @@ CFE_Status_t CS_ComputeApp(CS_Res_App_Table_Entry_t *ResultsEntry, uint32 *Compu
{
CFE_Status_t Status;
CS_LocalChecksumState_t State;
CFE_ResourceId_t ResourceID;
bool SameResource;

memset(&State, 0, sizeof(State));

State.BufferAddr = CFE_ES_MEMADDRESS_TO_PTR(ResultsEntry->StartAddress);
State.TotalSize = ResultsEntry->NumBytesToChecksum;
State.CurrOffset = ResultsEntry->ByteOffset;

if (State.BufferAddr == NULL || CS_IsChecksumComplete(&State))
{
Status = CS_RefreshAppSizeAndAddr(&State, ResultsEntry->Name);
}
else
{
/* Already got address and size, resume where left off */
State.ResultBuffer = ResultsEntry->TempChecksumValue;
Status = CFE_SUCCESS;
}
/* Resolve every chunk: ES may reload an app between calls, even at the same address.
* This query does not prevent a concurrent unload while the chunk is being read. */
Status = CS_RefreshAppSizeAndAddr(&State, ResultsEntry->Name, &ResourceID);

if (Status == CFE_SUCCESS)
{
SameResource = CFE_ResourceId_Equal(ResultsEntry->ResourceID, ResourceID);

if (!SameResource && CFE_ResourceId_IsDefined(ResultsEntry->ResourceID))
{
/* A new ES identity authorizes a new baseline; a CRC mismatch alone does not. */
ResultsEntry->ComputedYet = false;
ResultsEntry->ComparisonValue = 0;

CFE_EVS_SendEvent(CS_APP_RELOADED_INF_EID,
CFE_EVS_EventType_INFORMATION,
"App %s reloaded, baseline reset",
ResultsEntry->Name);
}

if (SameResource && ResultsEntry->StartAddress == (cpuaddr)State.BufferAddr
&& ResultsEntry->NumBytesToChecksum == State.TotalSize)
{
State.CurrOffset = ResultsEntry->ByteOffset;
State.ResultBuffer = ResultsEntry->TempChecksumValue;
}
/* A changed range under the same identity restarts the pass, retaining the baseline. */

CS_DoChecksumChunk(&State);

/* Export all values to resume next time */
ResultsEntry->ResourceID = ResourceID;
ResultsEntry->TempChecksumValue = State.ResultBuffer;
ResultsEntry->StartAddress = (cpuaddr)State.BufferAddr;
ResultsEntry->ByteOffset = State.CurrOffset;
Expand All @@ -507,6 +522,13 @@ CFE_Status_t CS_ComputeApp(CS_Res_App_Table_Entry_t *ResultsEntry, uint32 *Compu
/* Check against the previous value, if applicable */
Status = CS_CheckOrUpdateReference(&State, &ResultsEntry->ComputedYet, &ResultsEntry->ComparisonValue);
} /* end if got module id ok */
else
{
/* Retry from the beginning after an unresolved interval. Retain the last identity
* and baseline so the next successful lookup can detect a reload. */
ResultsEntry->ByteOffset = 0;
ResultsEntry->TempChecksumValue = 0;
}

*DoneWithEntry = CS_IsChecksumComplete(&State);

Expand Down
9 changes: 7 additions & 2 deletions fsw/src/cs_compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ CFE_Status_t CS_ComputeTables(CS_Res_Tables_Table_Entry_t *ResultsEntry, uint32
*
* \par Description
* Computes checksums up to MaxBytesPerCycle bytes every call. This
* function is used to compute checksums for applications.
* function resolves the current application or library identity and code
* range on every call. A new ES resource ID discards the partial checksum
* and baseline and issues #CS_APP_RELOADED_INF_EID. The next completed pass
* establishes the baseline for the new instance. A range change under the
* same ID restarts the partial checksum without replacing the baseline.
*
* \par Assumptions, External Events, and Notes:
* None
* The ES information query does not prevent a concurrent module unload
* between resolving the code address and reading the checksum chunk.
*
* \param [in] ResultsEntry A pointer to the entry in a table
* that we want to compute the
Expand Down
Loading
Loading