Skip to content

Commit

Permalink
Temp: Add debugging output
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanberger committed May 13, 2021
1 parent 2f2718e commit 1553604
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tpm2/Manufacture.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ TPM_Manufacture(

// Initialize the context slot mask for UINT16
s_ContextSlotMask = 0xffff; // libtpms added
fprintf(stderr, "%s: Initialized s_ContextSlotMask: 0x%04x\n", __func__, s_ContextSlotMask);
#if RUNTIME_SIZE_CHECKS
// Call the function to verify the sizes of values that result from different
// compile options.
Expand Down
1 change: 1 addition & 0 deletions src/tpm2/NVMarshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,7 @@ STATE_RESET_DATA_Unmarshal(STATE_RESET_DATA *data, BYTE **buffer, INT32 *size)
}
}
}
fprintf(stderr, "%s: Initialized s_ContextSlotMask to 0x%04x\n", __func__, s_ContextSlotMask);
}
if (rc == TPM_RC_SUCCESS) {
rc = UINT64_Unmarshal(&data->contextCounter, buffer, size);
Expand Down
6 changes: 6 additions & 0 deletions src/tpm2/Session.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ ContextIdSetOldest(
if(CONTEXT_SLOT_MASKED(entry - lowBits) <= smallest) // libtpms changed
{
smallest = CONTEXT_SLOT_MASKED(entry - lowBits); // libtpms changed
fprintf(stderr, "%s: smallest: 0x%x -> 0x%x\n", __func__, entry - lowBits, smallest);
s_oldestSavedSession = i;
}
}
Expand Down Expand Up @@ -144,6 +145,7 @@ SessionStartup(

// Initialize the context slot mask for UINT16
s_ContextSlotMask = 0xffff; // libtpms added
fprintf(stderr, "%s: Initialized s_ContextSlotMask: 0x%04x\n", __func__, s_ContextSlotMask);
}
return TRUE;
}
Expand Down Expand Up @@ -207,6 +209,8 @@ SequenceNumberForSavedContextIsValid(
pAssert(s_ContextSlotMask == 0xff || s_ContextSlotMask == 0xffff); // libtpms added

TPM_HANDLE handle = context->savedHandle & HR_HANDLE_MASK;
fprintf(stderr, "%s: MAX_CONTEXT_GAP = 0x%0lx\n", __func__, MAX_CONTEXT_GAP);
fprintf(stderr, "%s: context->sequence = 0x%0lx\n", __func__, context->sequence);
if(// Handle must be with the range of active sessions
handle >= MAX_ACTIVE_SESSIONS
// the array entry must be for a saved context
Expand Down Expand Up @@ -470,6 +474,7 @@ SessionContextSave(
// contextID value.
slotIndex = gr.contextArray[contextIndex] - 1;
// Set the contextID for the contextArray
fprintf(stderr, "%s: gr.contextCounter = 0x%0lx -> 0x%x\n", __func__, gr.contextCounter, CONTEXT_SLOT_MASKED(gr.contextCounter));
gr.contextArray[contextIndex] = CONTEXT_SLOT_MASKED(gr.contextCounter); // libtpms changed
// Increment the counter
gr.contextCounter++;
Expand Down Expand Up @@ -531,6 +536,7 @@ SessionContextLoad(
contextIndex = *handle & HR_HANDLE_MASK; // extract the index
// If there is only one slot left, and the gap is at maximum, the only session
// context that we can safely load is the oldest one.
fprintf(stderr, "%s: gr.contextCounter & s_contextSlotMask: 0x%x\n", __func__, CONTEXT_SLOT_MASKED(gr.contextCounter));
if(s_oldestSavedSession < MAX_ACTIVE_SESSIONS
&& s_freeSessionSlots == 1
&& CONTEXT_SLOT_MASKED(gr.contextCounter) == gr.contextArray[s_oldestSavedSession] // libtpms changed
Expand Down

0 comments on commit 1553604

Please sign in to comment.