Skip to content

Commit 72d0556

Browse files
dgibsonJarkko Sakkinen
authored andcommitted
tpm: ibmvtpm: Wait for ready buffer before probing for TPM2 attributes
The tpm2_get_cc_attrs_tbl() call will result in TPM commands being issued, which will need the use of the internal command/response buffer. But, we're issuing this *before* we've waited to make sure that buffer is allocated. This can result in intermittent failures to probe if the hypervisor / TPM implementation doesn't respond quickly enough. I find it fails almost every time with an 8 vcpu guest under KVM with software emulated TPM. To fix it, just move the tpm2_get_cc_attrs_tlb() call after the existing code to wait for initialization, which will ensure the buffer is allocated. Fixes: 18b3670 ("tpm: ibmvtpm: Add support for TPM2") Signed-off-by: David Gibson <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 82efeb1 commit 72d0556

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/char/tpm/tpm_ibmvtpm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,20 +683,20 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
683683
if (rc)
684684
goto init_irq_cleanup;
685685

686-
if (!strcmp(id->compat, "IBM,vtpm20")) {
687-
chip->flags |= TPM_CHIP_FLAG_TPM2;
688-
rc = tpm2_get_cc_attrs_tbl(chip);
689-
if (rc)
690-
goto init_irq_cleanup;
691-
}
692-
693686
if (!wait_event_timeout(ibmvtpm->crq_queue.wq,
694687
ibmvtpm->rtce_buf != NULL,
695688
HZ)) {
696689
dev_err(dev, "CRQ response timed out\n");
697690
goto init_irq_cleanup;
698691
}
699692

693+
if (!strcmp(id->compat, "IBM,vtpm20")) {
694+
chip->flags |= TPM_CHIP_FLAG_TPM2;
695+
rc = tpm2_get_cc_attrs_tbl(chip);
696+
if (rc)
697+
goto init_irq_cleanup;
698+
}
699+
700700
return tpm_chip_register(chip);
701701
init_irq_cleanup:
702702
do {

0 commit comments

Comments
 (0)