]> Git Repo - J-linux.git/commitdiff
Merge tag 'tpmdd-v6.4-rc1-fix-v2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <[email protected]>
Mon, 1 May 2023 17:37:37 +0000 (10:37 -0700)
committerLinus Torvalds <[email protected]>
Mon, 1 May 2023 17:37:37 +0000 (10:37 -0700)
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

1  2 
drivers/char/tpm/tpm-chip.c
drivers/char/tpm/tpm.h

index 80aaa10f436ec8de0ed9ace56a1d4f678a983427,9c0a6aad811400ca999ea861e7a1b7b620b0da1a..c10a4aa9737366f949d3fb0602971ef85ae3d5a6
@@@ -282,7 -282,7 +282,7 @@@ static void tpm_dev_release(struct devi
   *
   * Return: always 0 (i.e. success)
   */
 -static int tpm_class_shutdown(struct device *dev)
 +int tpm_class_shutdown(struct device *dev)
  {
        struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
  
@@@ -337,6 -337,7 +337,6 @@@ struct tpm_chip *tpm_chip_alloc(struct 
        device_initialize(&chip->dev);
  
        chip->dev.class = tpm_class;
 -      chip->dev.class->shutdown_pre = tpm_class_shutdown;
        chip->dev.release = tpm_dev_release;
        chip->dev.parent = pdev;
        chip->dev.groups = chip->groups;
@@@ -605,13 -606,19 +605,19 @@@ static int tpm_get_pcr_allocation(struc
  }
  
  /*
-  * tpm_chip_startup() - performs auto startup and allocates the PCRs
+  * tpm_chip_bootstrap() - Boostrap TPM chip after power on
   * @chip: TPM chip to use.
+  *
+  * Initialize TPM chip after power on. This a one-shot function: subsequent
+  * calls will have no effect.
   */
- int tpm_chip_startup(struct tpm_chip *chip)
+ int tpm_chip_bootstrap(struct tpm_chip *chip)
  {
        int rc;
  
+       if (chip->flags & TPM_CHIP_FLAG_BOOTSTRAPPED)
+               return 0;
        rc = tpm_chip_start(chip);
        if (rc)
                return rc;
  stop:
        tpm_chip_stop(chip);
  
+       /*
+        * Unconditionally set, as driver initialization should cease, when the
+        * boostrapping process fails.
+        */
+       chip->flags |= TPM_CHIP_FLAG_BOOTSTRAPPED;
        return rc;
  }
- EXPORT_SYMBOL_GPL(tpm_chip_startup);
+ EXPORT_SYMBOL_GPL(tpm_chip_bootstrap);
  
  /*
   * tpm_chip_register() - create a character device for the TPM chip
@@@ -643,6 -656,10 +655,10 @@@ int tpm_chip_register(struct tpm_chip *
  {
        int rc;
  
+       rc = tpm_chip_bootstrap(chip);
+       if (rc)
+               return rc;
        tpm_sysfs_add_device(chip);
  
        tpm_bios_log_setup(chip);
diff --combined drivers/char/tpm/tpm.h
index eaedf569219e67b47dec70c35ba124cc48c60945,f6c99b3f004589fe784e3c1b5d22b4bf60effa68..460bb85dd142cff8c001ce5f4c66e7fb82bca838
@@@ -256,7 -256,6 +256,7 @@@ int tpm1_get_pcr_allocation(struct tpm_
  unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
  int tpm_pm_suspend(struct device *dev);
  int tpm_pm_resume(struct device *dev);
 +int tpm_class_shutdown(struct device *dev);
  
  static inline void tpm_msleep(unsigned int delay_msec)
  {
                     delay_msec * 1000);
  };
  
- int tpm_chip_startup(struct tpm_chip *chip);
+ int tpm_chip_bootstrap(struct tpm_chip *chip);
  int tpm_chip_start(struct tpm_chip *chip);
  void tpm_chip_stop(struct tpm_chip *chip);
  struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip);
This page took 0.093168 seconds and 4 git commands to generate.