Skip to contentSkip to conversation

tpm/tpm_crb: Enable TPM CRB interface for ARM64

PATCH Superseded Jiandi An 2 participants 6 messages Mar 17, 2017 – Mar 24, 2017 4 messages not in the archive

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jiandi An

author
#0 lore raw

v3 cover tpm/tpm_crb: Enable TPM CRB interface for ARM64

TCG ACPI Specification Family "1.2" and "2.0" Version 1.2 Revision 8 introduces a new start method (type 11) for ARM64, along with platform specific parameters for this new start method. This new start method invokes a Secure Monitor Call to request the firmware to execute or cancel a TPM 2.0 command.

v3 Change Log:
- Added start method specific parameter offset define
- Moved tpm_crb_smc definition to tpm_crb.c
- Removed platform_params union from acpi_table_tpm2
- Removed clutter on length calculation of acpi_table_tpm2 caused by changing size of acpi_table_tpm2

Jiandi An (2):
ACPICA: Update TPM2 ACPI table
tpm/tpm_crb: Enable TPM CRB interface for ARM64

 drivers/char/tpm/Kconfig   |  2 +-
 drivers/char/tpm/tpm_crb.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
 include/acpi/actbl2.h      |  3 +++
 3 files changed, 66 insertions(+), 3 deletions(-)
Signature · 8 lines
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
author
#2 lore raw

PATCH v3 1/2 ACPICA: Update TPM2 ACPI table

In reply to a message not in the archive

TCG ACPI Specification Family "1.2" and "2.0" Version 1.2 Revision 8 introduces new start method for ARM SMC.

- Add new start method (type 11) for ARM SMC
- Add start method specific parameters for ARM SMC start method

---
 include/acpi/actbl2.h | 3 +++
 1 file changed, 3 insertions(+)
include/acpi/actbl2.h +3 -0
index 7aee9fb..2b4af07 100644
@@ -1294,6 +1294,9 @@ struct acpi_table_tpm2 {
 #define ACPI_TPM2_MEMORY_MAPPED                     6
 #define ACPI_TPM2_COMMAND_BUFFER                    7
 #define ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD  8
+#define ACPI_TPM2_COMMAND_BUFFER_WITH_SMC          11
+
+#define ACPI_TPM2_START_METHOD_PARAMETER_OFFSET    52
 
 /*******************************************************************************
  *
Signature · 8 lines
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
author
#3 lore raw

PATCH v3 2/2 tpm/tpm_crb: Enable TPM CRB interface for ARM64

In reply to a message not in the archive

This enables TPM Command Response Buffer interface driver for ARM64 and implements an ARM specific TPM CRB start method that invokes a Secure Monitor Call (SMC) to request the TrustZone Firmware to execute or cancel a TPM 2.0 command.

In ARM, TrustZone security extensions enable a secure software environment with Secure Monitor mode. A Secure Monitor Call (SMC) is used to enter the Secure Monitor mode and perform a Secure Monitor service to communicate with TrustZone firmware which has control over the TPM hardware.

---
 drivers/char/tpm/Kconfig   |  2 +-
 drivers/char/tpm/tpm_crb.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 3 deletions(-)
drivers/char/tpm/Kconfig +1 -1
index d520ac5..a3035220 100644
@@ -136,7 +136,7 @@ config TCG_XEN
 
 config TCG_CRB
 	tristate "TPM 2.0 CRB Interface"
-	depends on X86 && ACPI
+	depends on ACPI
 	---help---
 	  If you have a TPM security chip that is compliant with the
 	  TCG CRB 2.0 TPM specification say Yes and it will be accessible
drivers/char/tpm/tpm_crb.c +62 -2

118 lines not on this page · raw message

Signature · 8 lines
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#5 lore raw
In reply to a message not in the archive
Quoted 5 lines · Jiandi An

This enables TPM Command Response Buffer interface driver for ARM64 and implements an ARM specific TPM CRB start method that invokes a Secure Monitor Call (SMC) to request the TrustZone Firmware to execute or cancel a TPM 2.0 command.

Quoted 7 lines

In ARM, TrustZone security extensions enable a secure software environment with Secure Monitor mode. A Secure Monitor Call (SMC) is used to enter the Secure Monitor mode and perform a Secure Monitor service to communicate with TrustZone firmware which has control over the TPM hardware.

Does not compile.

/Jarkko

Quoted 154 lines
---
 drivers/char/tpm/Kconfig   |  2 +-
 drivers/char/tpm/tpm_crb.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 3 deletions(-)
drivers/char/tpm/Kconfig +1 -1
index d520ac5..a3035220 100644
@@ -136,7 +136,7 @@ config TCG_XEN
 
 config TCG_CRB
 	tristate "TPM 2.0 CRB Interface"
-	depends on X86 && ACPI
+	depends on ACPI
 	---help---
 	  If you have a TPM security chip that is compliant with the
 	  TCG CRB 2.0 TPM specification say Yes and it will be accessible
drivers/char/tpm/tpm_crb.c +62 -2
index cb6fb13..f8a5470 100644
@@ -20,6 +20,9 @@
 #include <linux/rculist.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
+#ifdef CONFIG_ARM64
+#include <linux/arm-smccc.h>
+#endif
 #include "tpm.h"
 
 #define ACPI_SIG_TPM2 "TPM2"
@@ -73,6 +76,7 @@ enum crb_status {
 enum crb_flags {
 	CRB_FL_ACPI_START	= BIT(0),
 	CRB_FL_CRB_START	= BIT(1),
+	CRB_FL_CRB_SMC_START	= BIT(2),
 };
 
 struct crb_priv {
@@ -82,6 +86,15 @@ struct crb_priv {
 	u8 __iomem *cmd;
 	u8 __iomem *rsp;
 	u32 cmd_size;
+	u32 smc_func_id;
+};
+
+struct tpm2_crb_smc {
+	u32 interrupt;
+	u8 interrupt_flags;
+	u8 op_flags;
+	u16 reserved2;
+	u32 smc_func_id;
 };
 
 /**
@@ -101,7 +114,8 @@ struct crb_priv {
  */
 static int __maybe_unused crb_go_idle(struct device *dev, struct crb_priv *priv)
 {
-	if (priv->flags & CRB_FL_ACPI_START)
+	if ((priv->flags & CRB_FL_ACPI_START) ||
+	    (priv->flags & CRB_FL_CRB_SMC_START))
 		return 0;
 
 	iowrite32(CRB_CTRL_REQ_GO_IDLE, &priv->cca->req);
@@ -129,7 +143,8 @@ static int __maybe_unused crb_cmd_ready(struct device *dev,
 {
 	ktime_t stop, start;
 
-	if (priv->flags & CRB_FL_ACPI_START)
+	if ((priv->flags & CRB_FL_ACPI_START) ||
+	    (priv->flags & CRB_FL_CRB_SMC_START))
 		return 0;
 
 	iowrite32(CRB_CTRL_REQ_CMD_READY, &priv->cca->req);
@@ -202,6 +217,33 @@ static int crb_do_acpi_start(struct tpm_chip *chip)
 	return rc;
 }
 
+#ifdef CONFIG_ARM64
+/*
+ * This is a TPM Command Response Buffer start method that invokes a
+ * Secure Monitor Call to requrest the firmware to execute or cancel
+ * a TPM 2.0 command.
+ */
+static inline int tpm_crb_smc_start(struct device *dev, unsigned long func_id)
+{
+	struct arm_smccc_res res;
+
+	arm_smccc_smc(func_id, 0, 0, 0, 0, 0, 0, 0, &res);
+	if (res.a0 != 0) {
+		dev_err(dev, FW_BUG "tpm_crb_smc_start() returns res.a0 = 0x%lx\n",
+			res.a0);
+		return -EIO;
+	}
+
+	return 0;
+}
+#else
+static inline int tpm_crb_smc_start(struct device *dev, unsigned long func_id)
+{
+	dev_err(dev, FW_BUG "tpm_crb: incorrect start method\n");
+	return -EINVAL;
+}
+#endif
+
 static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
 {
 	struct crb_priv *priv = dev_get_drvdata(&chip->dev);
@@ -229,6 +271,11 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
 	if (priv->flags & CRB_FL_ACPI_START)
 		rc = crb_do_acpi_start(chip);
 
+	if (priv->flags & CRB_FL_CRB_SMC_START) {
+		iowrite32(CRB_START_INVOKE, &priv->cca->start);
+		rc = tpm_crb_smc_start(&chip->dev, priv->smc_func_id);
+	}
+
 	return rc;
 }
 
@@ -409,6 +456,7 @@ static int crb_acpi_add(struct acpi_device *device)
 	struct crb_priv *priv;
 	struct tpm_chip *chip;
 	struct device *dev = &device->dev;
+	struct tpm2_crb_smc *crb_smc;
 	acpi_status status;
 	u32 sm;
 	int rc;
@@ -441,6 +489,18 @@ static int crb_acpi_add(struct acpi_device *device)
 	    sm == ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD)
 		priv->flags |= CRB_FL_ACPI_START;
 
+	if (sm == ACPI_TPM2_COMMAND_BUFFER_WITH_SMC) {
+		if (buf->header.length < (sizeof(*buf) + sizeof(*crb_smc))) {
+			dev_err(dev, FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n",
+				buf->header.length, ACPI_TPM2_COMMAND_BUFFER_WITH_SMC);
+			return -EINVAL;
+		}
+		crb_smc = (struct tpm2_crb_smc *) (((u8 *) buf) +
+			  ACPI_TPM2_START_METHOD_PARAMETER_OFFSET);
+		priv->smc_func_id = crb_smc->smc_func_id;
+		priv->flags |= CRB_FL_CRB_SMC_START;
+	}
+
 	rc = crb_map_io(device, priv, buf);
 	if (rc)
 		return rc;
Signature · 3 lines
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

author
#7 lore raw
In reply to a message not in the archive
Quoted 12 lines · Jarkko Sakkinen
Quoted 11 lines · Jiandi An

This enables TPM Command Response Buffer interface driver for ARM64 and implements an ARM specific TPM CRB start method that invokes a Secure Monitor Call (SMC) to request the TrustZone Firmware to execute or cancel a TPM 2.0 command.

In ARM, TrustZone security extensions enable a secure software environment with Secure Monitor mode. A Secure Monitor Call (SMC) is used to enter the Secure Monitor mode and perform a Secure Monitor service to communicate with TrustZone firmware which has control over the TPM hardware.

Quoted 5 lines
Quoted 1 line

Does not compile.

/Jarkko

I appologize for this. I see control area structure has recently changed. I'll ensure to rebase to your latest in v4.

- Jiandi

Quoted 155 lines
Quoted 155 lines
---
  drivers/char/tpm/Kconfig   |  2 +-
  drivers/char/tpm/tpm_crb.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
  2 files changed, 63 insertions(+), 3 deletions(-)
drivers/char/tpm/Kconfig +1 -1
index d520ac5..a3035220 100644
@@ -136,7 +136,7 @@ config TCG_XEN
 
  config TCG_CRB
  	tristate "TPM 2.0 CRB Interface"
-	depends on X86 && ACPI
+	depends on ACPI
  	---help---
  	  If you have a TPM security chip that is compliant with the
  	  TCG CRB 2.0 TPM specification say Yes and it will be accessible
drivers/char/tpm/tpm_crb.c +62 -3
index cb6fb13..f8a5470 100644
@@ -20,6 +20,9 @@
  #include <linux/rculist.h>
  #include <linux/module.h>
  #include <linux/pm_runtime.h>
+#ifdef CONFIG_ARM64
+#include <linux/arm-smccc.h>
+#endif
  #include "tpm.h"
 
  #define ACPI_SIG_TPM2 "TPM2"
@@ -73,6 +76,7 @@ enum crb_status {
  enum crb_flags {
  	CRB_FL_ACPI_START	= BIT(0),
  	CRB_FL_CRB_START	= BIT(1),
+	CRB_FL_CRB_SMC_START	= BIT(2),
  };
 
  struct crb_priv {
@@ -82,6 +86,15 @@ struct crb_priv {
  	u8 __iomem *cmd;
  	u8 __iomem *rsp;
  	u32 cmd_size;
+	u32 smc_func_id;
+};
+
+struct tpm2_crb_smc {
+	u32 interrupt;
+	u8 interrupt_flags;
+	u8 op_flags;
+	u16 reserved2;
+	u32 smc_func_id;
  };
 
  /**
@@ -101,7 +114,8 @@ struct crb_priv {
   */
  static int __maybe_unused crb_go_idle(struct device *dev, struct crb_priv *priv)
  {
-	if (priv->flags & CRB_FL_ACPI_START)
+	if ((priv->flags & CRB_FL_ACPI_START) ||
+	    (priv->flags & CRB_FL_CRB_SMC_START))
  		return 0;
 
  	iowrite32(CRB_CTRL_REQ_GO_IDLE, &priv->cca->req);
@@ -129,7 +143,8 @@ static int __maybe_unused crb_cmd_ready(struct device *dev,
  {
  	ktime_t stop, start;
 
-	if (priv->flags & CRB_FL_ACPI_START)
+	if ((priv->flags & CRB_FL_ACPI_START) ||
+	    (priv->flags & CRB_FL_CRB_SMC_START))
  		return 0;
 
  	iowrite32(CRB_CTRL_REQ_CMD_READY, &priv->cca->req);
@@ -202,6 +217,33 @@ static int crb_do_acpi_start(struct tpm_chip *chip)
  	return rc;
  }
 
+#ifdef CONFIG_ARM64
+/*
+ * This is a TPM Command Response Buffer start method that invokes a
+ * Secure Monitor Call to requrest the firmware to execute or cancel
+ * a TPM 2.0 command.
+ */
+static inline int tpm_crb_smc_start(struct device *dev, unsigned long func_id)
+{
+	struct arm_smccc_res res;
+
+	arm_smccc_smc(func_id, 0, 0, 0, 0, 0, 0, 0, &res);
+	if (res.a0 != 0) {
+		dev_err(dev, FW_BUG "tpm_crb_smc_start() returns res.a0 = 0x%lx\n",
+			res.a0);
+		return -EIO;
+	}
+
+	return 0;
+}
+#else
+static inline int tpm_crb_smc_start(struct device *dev, unsigned long func_id)
+{
+	dev_err(dev, FW_BUG "tpm_crb: incorrect start method\n");
+	return -EINVAL;
+}
+#endif
+
  static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
  {
  	struct crb_priv *priv = dev_get_drvdata(&chip->dev);
@@ -229,6 +271,11 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
  	if (priv->flags & CRB_FL_ACPI_START)
  		rc = crb_do_acpi_start(chip);
 
+	if (priv->flags & CRB_FL_CRB_SMC_START) {
+		iowrite32(CRB_START_INVOKE, &priv->cca->start);
+		rc = tpm_crb_smc_start(&chip->dev, priv->smc_func_id);
+	}
+
  	return rc;
  }
 
@@ -409,6 +456,7 @@ static int crb_acpi_add(struct acpi_device *device)
  	struct crb_priv *priv;
  	struct tpm_chip *chip;
  	struct device *dev = &device->dev;
+	struct tpm2_crb_smc *crb_smc;
  	acpi_status status;
  	u32 sm;
  	int rc;
@@ -441,6 +489,18 @@ static int crb_acpi_add(struct acpi_device *device)
  	    sm == ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD)
  		priv->flags |= CRB_FL_ACPI_START;
 
+	if (sm == ACPI_TPM2_COMMAND_BUFFER_WITH_SMC) {
+		if (buf->header.length < (sizeof(*buf) + sizeof(*crb_smc))) {
+			dev_err(dev, FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n",
+				buf->header.length, ACPI_TPM2_COMMAND_BUFFER_WITH_SMC);
+			return -EINVAL;
+		}
+		crb_smc = (struct tpm2_crb_smc *) (((u8 *) buf) +
+			  ACPI_TPM2_START_METHOD_PARAMETER_OFFSET);
+		priv->smc_func_id = crb_smc->smc_func_id;
+		priv->flags |= CRB_FL_CRB_SMC_START;
+	}
+
  	rc = crb_map_io(device, priv, buf);
  	if (rc)
  		return rc;
--

Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

Signature · 9 lines
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a
Linux Foundation Collaborative Project.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#9 lore raw
In reply to a message not in the archive
Quoted 15 lines · Jiandi An
Quoted 14 lines · Jarkko Sakkinen
Quoted 12 lines · Jiandi An

This enables TPM Command Response Buffer interface driver for ARM64 and implements an ARM specific TPM CRB start method that invokes a Secure Monitor Call (SMC) to request the TrustZone Firmware to execute or cancel a TPM 2.0 command.

In ARM, TrustZone security extensions enable a secure software environment with Secure Monitor mode. A Secure Monitor Call (SMC) is used to enter the Secure Monitor mode and perform a Secure Monitor service to communicate with TrustZone firmware which has control over the TPM hardware.

Quoted 8 lines
Quoted 3 lines

Does not compile.

/Jarkko

I appologize for this. I see control area structure has recently changed. I'll ensure to rebase to your latest in v4.

- Jiandi

No need for apologies, just remember to always rebase just before you git send-email.

/Jarkko

Quoted 148 lines
Quoted 148 lines
Quoted 148 lines

---
  drivers/char/tpm/Kconfig   |  2 +-
  drivers/char/tpm/tpm_crb.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
  2 files changed, 63 insertions(+), 3 deletions(-)
drivers/char/tpm/Kconfig +1 -1
index d520ac5..a3035220 100644
@@ -136,7 +136,7 @@ config TCG_XEN
 
  config TCG_CRB
  	tristate "TPM 2.0 CRB Interface"
-	depends on X86 && ACPI
+	depends on ACPI
  	---help---
  	  If you have a TPM security chip that is compliant with the
  	  TCG CRB 2.0 TPM specification say Yes and it will be accessible
drivers/char/tpm/tpm_crb.c +62 -2
index cb6fb13..f8a5470 100644
@@ -20,6 +20,9 @@
  #include <linux/rculist.h>
  #include <linux/module.h>
  #include <linux/pm_runtime.h>
+#ifdef CONFIG_ARM64
+#include <linux/arm-smccc.h>
+#endif
  #include "tpm.h"
 
  #define ACPI_SIG_TPM2 "TPM2"
@@ -73,6 +76,7 @@ enum crb_status {
  enum crb_flags {
  	CRB_FL_ACPI_START	= BIT(0),
  	CRB_FL_CRB_START	= BIT(1),
+	CRB_FL_CRB_SMC_START	= BIT(2),
  };
 
  struct crb_priv {
@@ -82,6 +86,15 @@ struct crb_priv {
  	u8 __iomem *cmd;
  	u8 __iomem *rsp;
  	u32 cmd_size;
+	u32 smc_func_id;
+};
+
+struct tpm2_crb_smc {
+	u32 interrupt;
+	u8 interrupt_flags;
+	u8 op_flags;
+	u16 reserved2;
+	u32 smc_func_id;
  };
 
  /**
@@ -101,7 +114,8 @@ struct crb_priv {
   */
  static int __maybe_unused crb_go_idle(struct device *dev, struct crb_priv *priv)
  {
-	if (priv->flags & CRB_FL_ACPI_START)
+	if ((priv->flags & CRB_FL_ACPI_START) ||
+	    (priv->flags & CRB_FL_CRB_SMC_START))
  		return 0;
 
  	iowrite32(CRB_CTRL_REQ_GO_IDLE, &priv->cca->req);
@@ -129,7 +143,8 @@ static int __maybe_unused crb_cmd_ready(struct device *dev,
  {
  	ktime_t stop, start;
 
-	if (priv->flags & CRB_FL_ACPI_START)
+	if ((priv->flags & CRB_FL_ACPI_START) ||
+	    (priv->flags & CRB_FL_CRB_SMC_START))
  		return 0;
 
  	iowrite32(CRB_CTRL_REQ_CMD_READY, &priv->cca->req);
@@ -202,6 +217,33 @@ static int crb_do_acpi_start(struct tpm_chip *chip)
  	return rc;
  }
 
+#ifdef CONFIG_ARM64
+/*
+ * This is a TPM Command Response Buffer start method that invokes a
+ * Secure Monitor Call to requrest the firmware to execute or cancel
+ * a TPM 2.0 command.
+ */
+static inline int tpm_crb_smc_start(struct device *dev, unsigned long func_id)
+{
+	struct arm_smccc_res res;
+
+	arm_smccc_smc(func_id, 0, 0, 0, 0, 0, 0, 0, &res);
+	if (res.a0 != 0) {
+		dev_err(dev, FW_BUG "tpm_crb_smc_start() returns res.a0 = 0x%lx\n",
+			res.a0);
+		return -EIO;
+	}
+
+	return 0;
+}
+#else
+static inline int tpm_crb_smc_start(struct device *dev, unsigned long func_id)
+{
+	dev_err(dev, FW_BUG "tpm_crb: incorrect start method\n");
+	return -EINVAL;
+}
+#endif
+
  static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
  {
  	struct crb_priv *priv = dev_get_drvdata(&chip->dev);
@@ -229,6 +271,11 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
  	if (priv->flags & CRB_FL_ACPI_START)
  		rc = crb_do_acpi_start(chip);
 
+	if (priv->flags & CRB_FL_CRB_SMC_START) {
+		iowrite32(CRB_START_INVOKE, &priv->cca->start);
+		rc = tpm_crb_smc_start(&chip->dev, priv->smc_func_id);
+	}
+
  	return rc;
  }
 
@@ -409,6 +456,7 @@ static int crb_acpi_add(struct acpi_device *device)
  	struct crb_priv *priv;
  	struct tpm_chip *chip;
  	struct device *dev = &device->dev;
+	struct tpm2_crb_smc *crb_smc;
  	acpi_status status;
  	u32 sm;
  	int rc;
@@ -441,6 +489,18 @@ static int crb_acpi_add(struct acpi_device *device)
  	    sm == ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD)
  		priv->flags |= CRB_FL_ACPI_START;
 
+	if (sm == ACPI_TPM2_COMMAND_BUFFER_WITH_SMC) {
+		if (buf->header.length < (sizeof(*buf) + sizeof(*crb_smc))) {
+			dev_err(dev, FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n",
+				buf->header.length, ACPI_TPM2_COMMAND_BUFFER_WITH_SMC);
+			return -EINVAL;
+		}
+		crb_smc = (struct tpm2_crb_smc *) (((u8 *) buf) +
+			  ACPI_TPM2_START_METHOD_PARAMETER_OFFSET);
+		priv->smc_func_id = crb_smc->smc_func_id;
+		priv->flags |= CRB_FL_CRB_SMC_START;
+	}
+
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
drivers/char/tpm/tpm_crb.c +0 -1
  	rc = crb_map_io(device, priv, buf);
  	if (rc)
  		return rc;
--

Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

Signature · 5 lines
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a
Linux Foundation Collaborative Project.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot