Skip to content

Commit ed9a65e

Browse files
committed
Merge tag 'tpmdd-v6.4-rc1-fix-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull tpm fix from Jarkko Sakkinen: "This fixes a critical bug in my first pull request. I fixed the cherry pick issue and tested with real hardare and libvirt/qemu plus swtpm" * tag 'tpmdd-v6.4-rc1-fix-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd: tpm: Re-enable TPM chip boostrapping non-tpm_tis TPM drivers
2 parents 58390c8 + 0c8862d commit ed9a65e

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

drivers/char/tpm/tpm-chip.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,19 @@ static int tpm_get_pcr_allocation(struct tpm_chip *chip)
605605
}
606606

607607
/*
608-
* tpm_chip_startup() - performs auto startup and allocates the PCRs
608+
* tpm_chip_bootstrap() - Boostrap TPM chip after power on
609609
* @chip: TPM chip to use.
610+
*
611+
* Initialize TPM chip after power on. This a one-shot function: subsequent
612+
* calls will have no effect.
610613
*/
611-
int tpm_chip_startup(struct tpm_chip *chip)
614+
int tpm_chip_bootstrap(struct tpm_chip *chip)
612615
{
613616
int rc;
614617

618+
if (chip->flags & TPM_CHIP_FLAG_BOOTSTRAPPED)
619+
return 0;
620+
615621
rc = tpm_chip_start(chip);
616622
if (rc)
617623
return rc;
@@ -624,9 +630,15 @@ int tpm_chip_startup(struct tpm_chip *chip)
624630
stop:
625631
tpm_chip_stop(chip);
626632

633+
/*
634+
* Unconditionally set, as driver initialization should cease, when the
635+
* boostrapping process fails.
636+
*/
637+
chip->flags |= TPM_CHIP_FLAG_BOOTSTRAPPED;
638+
627639
return rc;
628640
}
629-
EXPORT_SYMBOL_GPL(tpm_chip_startup);
641+
EXPORT_SYMBOL_GPL(tpm_chip_bootstrap);
630642

631643
/*
632644
* tpm_chip_register() - create a character device for the TPM chip
@@ -643,6 +655,10 @@ int tpm_chip_register(struct tpm_chip *chip)
643655
{
644656
int rc;
645657

658+
rc = tpm_chip_bootstrap(chip);
659+
if (rc)
660+
return rc;
661+
646662
tpm_sysfs_add_device(chip);
647663

648664
tpm_bios_log_setup(chip);

drivers/char/tpm/tpm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static inline void tpm_msleep(unsigned int delay_msec)
264264
delay_msec * 1000);
265265
};
266266

267-
int tpm_chip_startup(struct tpm_chip *chip);
267+
int tpm_chip_bootstrap(struct tpm_chip *chip);
268268
int tpm_chip_start(struct tpm_chip *chip);
269269
void tpm_chip_stop(struct tpm_chip *chip);
270270
struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip);

drivers/char/tpm/tpm_tis_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
11391139
init_waitqueue_head(&priv->read_queue);
11401140
init_waitqueue_head(&priv->int_queue);
11411141

1142-
rc = tpm_chip_startup(chip);
1142+
rc = tpm_chip_bootstrap(chip);
11431143
if (rc)
11441144
goto out_err;
11451145

include/linux/tpm.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,14 @@ enum tpm2_cc_attrs {
274274
#define TPM_VID_ATML 0x1114
275275

276276
enum tpm_chip_flags {
277-
TPM_CHIP_FLAG_TPM2 = BIT(1),
278-
TPM_CHIP_FLAG_IRQ = BIT(2),
279-
TPM_CHIP_FLAG_VIRTUAL = BIT(3),
280-
TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4),
281-
TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5),
277+
TPM_CHIP_FLAG_BOOTSTRAPPED = BIT(0),
278+
TPM_CHIP_FLAG_TPM2 = BIT(1),
279+
TPM_CHIP_FLAG_IRQ = BIT(2),
280+
TPM_CHIP_FLAG_VIRTUAL = BIT(3),
281+
TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4),
282+
TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5),
282283
TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = BIT(6),
283-
TPM_CHIP_FLAG_FIRMWARE_UPGRADE = BIT(7),
284+
TPM_CHIP_FLAG_FIRMWARE_UPGRADE = BIT(7),
284285
};
285286

286287
#define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)

0 commit comments

Comments
 (0)