tpm: PCR allocate during PCR extend to disable the unsupported algorithms
authorRaymond Mao <raymond.mao@linaro.org>
Mon, 27 Jan 2025 14:58:50 +0000 (06:58 -0800)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Tue, 28 Jan 2025 06:58:41 +0000 (08:58 +0200)
During PCR extend process, if any unsupported algorithms are active,
try to use PCR allocate to inactivate them.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/tpm-v2.c

index aa02a9e..9ca7933 100644 (file)
@@ -344,7 +344,10 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm,
 
        if (!tpm2_check_active_banks(dev)) {
                log_err("Cannot extend PCRs if all the TPM enabled algorithms are not supported\n");
-               return -EINVAL;
+
+               ret = tpm2_pcr_allocate(dev, 0);
+               if (ret)
+                       return -EINVAL;
        }
        /*
         * Fill the command structure starting from the first buffer: