trunksd: do not disable platform hierarchy on startup

Currently trunksd examines at startup the state of the TPM and
proceeds to disable Platform Hierarchy in case it was not disabled by
the firmware.

But the only case Platform Hierarchy is not disabled by the firmware
is when the device is booted in recovery mode, and TPM needs to be
available to recovering.

Let's not invoke TpmUtilityImpl::InitializeTpm() in the course of
trunksd initialization, introduce instead a function which would check
current state of the TPM and report warnings as appropriate.

Separate driver initialization and some basic checks into a private
function to be used by both InitializeTpm() and CheckState().

The only reason to report the state failure is failure to initialize
the driver.

TEST=verified that it is now possible to write into firmware and
     kernel spaces after stopping trunksd in recovery mode. It is
     still not possible to write into the spaces in normal and
     developer modes.

     It is still possible to login to a reef device running this new

Change-Id: I12114439d061a5419a63329871cb8027b1d89bbd
Signed-off-by: Vadim Bendebury <>
Reviewed-by: Darren Krahn <>
Reviewed-by: Andrey Pronin <>
(cherry picked from commit c06b57117c840a15e93dbe5cd34ce6c44f477ada)
6 files changed