tpm2: Clean up the NV_LIST_TERMINATOR structure

Clean up code around the NV_LIST_TERMINATOR structure. It's not
an array of bytes or UINT32s, but a UINT32 followed by a UINT64.
This commit is contained in:
Stefan Berger 2017-03-22 19:36:27 -04:00
parent 00f85ac180
commit 468f0f3d96
2 changed files with 6 additions and 3 deletions

View File

@ -119,7 +119,10 @@ typedef struct {
current value of s_maxCounter which is a 64-bit value. The structure is defined as an array of 3
UINT32 values so that there is no padding between the UINT32 list end marker and the UIT64m()
maxCounter value. */
typedef UINT32 NV_LIST_TERMINATOR[3];
typedef struct {
UINT32 reserved;
UINT64 maxCount;
} __attribute__((packed)) NV_LIST_TERMINATOR;
/* 5.14.3 Orderly RAM Values */
/* The following defines are for accessing orderly RAM values. This is the initialize for the RAM
reference iterator. */

View File

@ -225,13 +225,13 @@ NvWriteNvListEnd(
)
{
// Marker is initialized with zeros
BYTE listEndMarker[sizeof(NV_LIST_TERMINATOR)] = {0};
NV_LIST_TERMINATOR listEndMarker = {0};
UINT64 maxCount = NvReadMaxCount();
//
// This is a constant check that can be resolved at compile time.
cAssert(sizeof(UINT64) <= sizeof(NV_LIST_TERMINATOR) - sizeof(UINT32));
// Copy the maxCount value to the marker buffer
MemoryCopy(&listEndMarker[sizeof(UINT32)], &maxCount, sizeof(UINT64));
listEndMarker.maxCount = maxCount;
pAssert(end + sizeof(NV_LIST_TERMINATOR) <= s_evictNvEnd);
// Write it to memory
NvWrite(end, sizeof(NV_LIST_TERMINATOR), &listEndMarker);