security/tpm/tcg-2.0: Handle TPM_RC_NV_RANGE return code

As per the TPM spec, if offset and the size field of data add to a value
that is greater than the dataSize field of the NV Index referenced by
nvIndex, the TPM shall return an error (TPM_RC_NV_RANGE). Handle the TPM
error and map it to an appropriate vboot error.

BUG=None
TEST=Build and boot to OS in Guybrush.

Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Change-Id: I8b403e2f33cc1368065cc21f73df1102695f73eb
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59134
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
Karthikeyan Ramasubramanian 2021-11-10 17:43:45 -07:00 committed by Karthik Ramasubramanian
parent e1095496e1
commit 2e445ad1af
3 changed files with 5 additions and 0 deletions

View File

@ -242,6 +242,9 @@ uint32_t tlcl_read(uint32_t index, void *data, uint32_t length)
case TPM_RC_CR50_NV_UNDEFINED:
return TPM_E_BADINDEX;
case TPM_RC_NV_RANGE:
return TPM_E_RANGE;
default:
return TPM_E_READ_FAILURE;
}

View File

@ -144,6 +144,7 @@ struct tpm_header {
/* Values copied from tpm2/tpm_types.h */
#define RC_VER1 0x100
#define TPM_RC_INITIALIZE ((TPM_RC)(RC_VER1 + 0x000))
#define TPM_RC_NV_RANGE ((TPM_RC)(RC_VER1 + 0x046))
#define TPM_RC_NV_UNINITIALIZED ((TPM_RC)(RC_VER1 + 0x04A))
/*

View File

@ -41,5 +41,6 @@
#define TPM_E_INVALID_ARG ((uint32_t)0x0000500c)
#define TPM_E_HASH_ERROR ((uint32_t)0x0000500d)
#define TPM_E_NO_SUCH_COMMAND ((uint32_t)0x0000500e)
#define TPM_E_RANGE ((uint32_t)0x0000500f)
#endif /* TSS_ERRORS_H_ */