[PATCH 5/8] tpm: sandbox: Allow init of TPM in a different phase

Ilias Apalodimas ilias.apalodimas at linaro.org
Tue Jun 7 10:48:52 CEST 2022


Hi Simon, 

On Mon, Feb 28, 2022 at 05:11:22PM -0700, Simon Glass wrote:
> At present the emulator assumes that the TPM is inited in the same phase
> where it is used. But in fact SPL may init the TPM, so we don't want to
> complain when U-Boot proper later uses it. Remove this check.
> 
> It might be best to save this information into the device state for the
> TPM, so that we can make sure the TPM was inited at some point. For now,
> this seems good enough.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
>  drivers/tpm/tpm2_tis_sandbox.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c
> index ac6eb14353..c26f5d35ab 100644
> --- a/drivers/tpm/tpm2_tis_sandbox.c
> +++ b/drivers/tpm/tpm2_tis_sandbox.c
> @@ -366,8 +366,10 @@ static int sandbox_tpm2_check_readyness(struct udevice *dev, int command)
>  
>  		break;
>  	default:
> -		if (!tpm->tests_done)
> -			return TPM2_RC_NEEDS_TEST;
> +		/* Skip this, since the startup may have happened in SPL
> +		 * if (!tpm->tests_done)
> +		 *    return TPM2_RC_NEEDS_TEST;
> +		 */


This looks reasonable.  On top of that the TPM will return 'already
initialized' if someone tries to do that after SPL, so we should be safe.

>  
>  		break;
>  	}
> -- 
> 2.35.1.574.g5d30c73bfb-goog
> 

Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>



More information about the U-Boot mailing list