Hi Ilias, On Tue, 19 Jan 2021 at 01:24, Ilias Apalodimas <ilias.apalodi...@linaro.org> wrote: > > Hi Simon, > > On Sat, Jan 16, 2021 at 02:51:35PM -0700, Simon Glass wrote: > > Add support for this so that the TPM can be set up for use with > > Chromium OS verified boot. > > > > Signed-off-by: Simon Glass <s...@chromium.org> > > --- > > > > include/tpm-v2.h | 18 ++++++++++++++++++ > > lib/tpm-v2.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 62 insertions(+) > > > > diff --git a/include/tpm-v2.h b/include/tpm-v2.h > > index fab6b86ca2f..2766dc72a65 100644 > > --- a/include/tpm-v2.h > > +++ b/include/tpm-v2.h > > @@ -238,6 +238,7 @@ enum tpm2_command_codes { > > TPM2_CC_CLEAR = 0x0126, > > TPM2_CC_CLEARCONTROL = 0x0127, > > TPM2_CC_HIERCHANGEAUTH = 0x0129, > > + TPM2_CC_NV_DEFINE_SPACE = 0x012a, > > TPM2_CC_PCR_SETAUTHPOL = 0x012C, > > TPM2_CC_DAM_RESET = 0x0139, > > TPM2_CC_DAM_PARAMETERS = 0x013A, > > @@ -386,6 +387,23 @@ u32 tpm2_self_test(struct udevice *dev, enum > > tpm2_yes_no full_test); > > u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw, > > const ssize_t pw_sz); > > > > +/** > > + * Issue a TPM_NV_DefineSpace command > > + * > > + * This allows a space to be defined with given attributes and policy > > + * > > + * @dev TPM device > > + * @space_index index of the area > > + * @space_size size of area in bytes > > + * @nv_attributes TPM_NV_ATTRIBUTES of the area > > + * @nv_policy policy to use > > + * @nv_policy_size size of the policy > > + * @return return code of the operation > > + */ > > +u32 tpm2_nv_define_space(struct udevice *dev, u32 space_index, > > + size_t space_size, u32 nv_attributes, > > + const u8 *nv_policy, size_t nv_policy_size); > > + > > /** > > * Issue a TPM2_PCR_Extend command. > > * > > diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c > > index b148081afd7..22c56d475c8 100644 > > --- a/lib/tpm-v2.c > > +++ b/lib/tpm-v2.c > > @@ -80,6 +80,50 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const > > char *pw, > > return tpm_sendrecv_command(dev, command_v2, NULL, NULL); > > } > > > > +u32 tpm2_nv_define_space(struct udevice *dev, u32 space_index, > > + size_t space_size, u32 nv_attributes, > > + const u8 *nv_policy, size_t nv_policy_size) > > +{ > > + uint offset = 10 + 8 + 9 + 14; > > Can we have a comment and/or link to the documentation for what the offsets > mean. I know we lack the overall structures in U-Boot to calculate this > properly, but at least let's add some explanation of the offset, so anyone > reading the code can get a hint what to look for.
Unfortunately I missed this comment so I'm sending v2. Regards, Simon