mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
tpm: Keep the active PCRs in the chip private data
We have a lot of code trying to reason about the active TPM PCRs when creating an EventLog. Since changing the active banks can't be done on the fly and requires a TPM reset, let's store them in the chip private data instead. Upcoming patches will use this during the EventLog creation. Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
27
lib/tpm-v2.c
27
lib/tpm-v2.c
@@ -23,6 +23,27 @@
|
||||
|
||||
#include "tpm-utils.h"
|
||||
|
||||
static int tpm2_update_active_banks(struct udevice *dev)
|
||||
{
|
||||
struct tpm_chip_priv *priv = dev_get_uclass_priv(dev);
|
||||
struct tpml_pcr_selection pcrs;
|
||||
int ret, i;
|
||||
|
||||
ret = tpm2_get_pcr_info(dev, &pcrs);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
priv->active_bank_count = 0;
|
||||
for (i = 0; i < pcrs.count; i++) {
|
||||
if (!tpm2_is_active_bank(&pcrs.selection[i]))
|
||||
continue;
|
||||
priv->active_banks[priv->active_bank_count] = pcrs.selection[i].hash;
|
||||
priv->active_bank_count++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 tpm2_startup(struct udevice *dev, enum tpm2_startup_types mode)
|
||||
{
|
||||
const u8 command_v2[12] = {
|
||||
@@ -41,7 +62,7 @@ u32 tpm2_startup(struct udevice *dev, enum tpm2_startup_types mode)
|
||||
if (ret && ret != TPM2_RC_INITIALIZE)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
return tpm2_update_active_banks(dev);
|
||||
}
|
||||
|
||||
u32 tpm2_self_test(struct udevice *dev, enum tpm2_yes_no full_test)
|
||||
@@ -69,8 +90,10 @@ u32 tpm2_auto_start(struct udevice *dev)
|
||||
|
||||
rc = tpm2_self_test(dev, TPMI_YES);
|
||||
}
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return rc;
|
||||
return tpm2_update_active_banks(dev);
|
||||
}
|
||||
|
||||
u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw,
|
||||
|
||||
Reference in New Issue
Block a user