mirror of
https://github.com/stefanberger/libtpms
synced 2026-01-19 18:56:55 +00:00
tpm2: Move time adjustments to end of VolatileState parsing
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
154fd97dc6
commit
77907030ce
@ -95,6 +95,18 @@ ClockGetTime(
|
||||
return time;
|
||||
}
|
||||
|
||||
/* ClockAdjustPostResume -- adjust time parameters post resume */
|
||||
#include "Tpm.h"
|
||||
void
|
||||
ClockAdjustPostResume(UINT64 backthen)
|
||||
{
|
||||
UINT64 now = ClockGetTime(CLOCK_REALTIME);
|
||||
INT64 timediff = now - backthen;
|
||||
|
||||
g_time += timediff;
|
||||
s_realTimePrevious += timediff;
|
||||
s_tpmTime += timediff;
|
||||
}
|
||||
|
||||
/* C.3.3. Simulator Functions */
|
||||
/* C.3.3.1. Introduction */
|
||||
|
||||
@ -2985,6 +2985,7 @@ VolatileState_Unmarshal(BYTE **buffer, INT32 *size)
|
||||
NV_HEADER hdr;
|
||||
BOOL needs_block;
|
||||
UINT16 array_size = 0;
|
||||
UINT64 backthen;
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = NV_HEADER_Unmarshal(&hdr, buffer, size,
|
||||
@ -3363,16 +3364,7 @@ skip_hardware_clock:
|
||||
rc = UINT32_Unmarshal(&s_adjustRate, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
UINT64 backthen, now;
|
||||
INT64 timediff;
|
||||
|
||||
rc = UINT64_Unmarshal(&backthen, buffer, size);
|
||||
now = ClockGetTime(CLOCK_REALTIME);
|
||||
|
||||
timediff = now - backthen;
|
||||
g_time += timediff;
|
||||
s_realTimePrevious += timediff;
|
||||
s_tpmTime += timediff;
|
||||
}
|
||||
|
||||
/* version 2 starts having indicator for next versions that we can skip;
|
||||
@ -3402,6 +3394,9 @@ skip_future_versions:
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
ClockAdjustPostResume(backthen);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -377,8 +377,9 @@ _plat__GetUnique(
|
||||
unsigned char *b // output buffer
|
||||
);
|
||||
|
||||
/* libtpms: ClockGetTime() needs to be public */
|
||||
/* libtpms: */
|
||||
#include <time.h>
|
||||
void ClockAdjustPostResume(UINT64 backthen);
|
||||
uint64_t ClockGetTime(clockid_t clk_id);
|
||||
|
||||
#endif // _PLATFORM_FP_H_
|
||||
|
||||
Loading…
Reference in New Issue
Block a user