Add support for the TPM FF-A start method
Subsystems (5)
v2 cover Add support for the TPM FF-A start method
Firmware Framework for Arm A-profile (FF-A) is a messaging framework for Arm-based systems, and in the context of the TPM CRB driver is used to signal 'start' to a CRB-based TPM service which is hosted in an FF-A secure partition running in TrustZone.
These patches add support for the CRB FF-A start method defined in the TCG ACPI specification v1.4 and the FF-A ABI defined in the Arm TPM Service CRB over FF-A (DEN0138) specification:
https://developer.arm.com/documentation/den0138/latest/
The first patch adds an FF-A driver to handle the FF-A messaging when communicating with a CRB-based TPM secure partition built on FF-A. The driver is probed when the TPM secure partition is discovered by the Linux FF-A infrastructure.
The second patch consolidates the check for idle support in the CRB driver to one place.
The third patch defines the new ACPI start method enumeration for CRB over FF-A.
The fourth patch adds support for the FF-A ACPI start method to the TPM crb driver.
The fifth patch adds documentation explaining how the CRB driver and FF-A relate.
Version 2
-updates to cover letter to define FF-A
-added new patch with documentation
-created pull request in ACPIA and added link to the patch
updating actbl3.h
-added tpm_ prefix to the FF-A CRB driver
Stuart Yoder (5):
tpm_crb: implement driver compliant to CRB over FF-A
tpm_crb: refactor check for idle support into TPM into inline function
ACPICA: add start method for Arm FF-A
tpm_crb: add support for the Arm FF-A start method
Documentation: tpm: add documentation for the CRB FF-A interface
Documentation/security/tpm/tpm_ffa_crb.rst | 65 +++++ drivers/char/tpm/Kconfig | 9 + drivers/char/tpm/Makefile | 1 + drivers/char/tpm/tpm_crb.c | 81 +++++- drivers/char/tpm/tpm_ffa_crb.c | 310 +++++++++++++++++++++ drivers/char/tpm/tpm_ffa_crb.h | 30 ++ include/acpi/actbl3.h | 1 + 7 files changed, 491 insertions(+), 6 deletions(-) create mode 100644 Documentation/security/tpm/tpm_ffa_crb.rst create mode 100644 drivers/char/tpm/tpm_ffa_crb.c create mode 100644 drivers/char/tpm/tpm_ffa_crb.h
Signature · 1 line
2.34.1
PATCH v2 1/5 tpm_crb: implement driver compliant to CRB over FF-A
The Arm specification TPM Service CRB over FF-A specification defines the FF-A messages to interact with a CRB-based TPM implemented as an FF-A secure partition.
Spec URL:
https://developer.arm.com/documentation/den0138/latest/
This driver is probed when a TPM Secure Partition is discovered by the FF-A subsystem. It exposes APIs used by the TPM CRB driver to send notifications to the TPM.
--- drivers/char/tpm/Kconfig | 9 + drivers/char/tpm/Makefile | 1 + drivers/char/tpm/tpm_ffa_crb.c | 310 +++++++++++++++++++++++++++++++++ drivers/char/tpm/tpm_ffa_crb.h | 30 ++++ 4 files changed, 350 insertions(+) create mode 100644 drivers/char/tpm/tpm_ffa_crb.c create mode 100644 drivers/char/tpm/tpm_ffa_crb.h
drivers/char/tpm/Kconfig +9 -0
@@ -210,6 +210,15 @@ config TCG_CRB from within Linux. To compile this driver as a module, choose M here; the module will be called tpm_crb. +config TCG_ARM_FFA_CRB + tristate "TPM CRB over Arm FF-A Transport" + depends on ARM_FFA_TRANSPORT + default y if (TCG_CRB && ARM_FFA_TRANSPORT) + help + If the Arm FF-A transport is used to access the TPM say Yes. + To compile this driver as a module, choose M here; the module + will be called tpm_ffa_crb. + config TCG_VTPM_PROXY tristate "VTPM Proxy Interface" depends on TCG_TPM
drivers/char/tpm/Makefile +1 -0
@@ -42,5 +42,6 @@ obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o obj-$(CONFIG_TCG_TIS_ST33ZP24) += st33zp24/ obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o obj-$(CONFIG_TCG_CRB) += tpm_crb.o +obj-$(CONFIG_TCG_ARM_FFA_CRB) += tpm_ffa_crb.o obj-$(CONFIG_TCG_VTPM_PROXY) += tpm_vtpm_proxy.o obj-$(CONFIG_TCG_FTPM_TEE) += tpm_ftpm_tee.o
drivers/char/tpm/tpm_ffa_crb.c new file +310 -0
310 lines not on this page · raw message
drivers/char/tpm/tpm_ffa_crb.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2024 Arm Ltd. +* +* Authors: +* Stuart Yoder <[email protected]> +* +* Maintained by: <[email protected]> +* +* This device driver implements the TPM CRB start method +* as defined in the TPM Service Command Response Buffer +* Interface Over FF-A (DEN0138). +*/ +#ifndef _FFA_CRB_H +#define _FFA_CRB_H + +#if IS_ENABLED (CONFIG_TCG_ARM_FFA_CRB ) +int ffa_crb_init (void ); +int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor); +int ffa_crb_start (int request_type,int locality); +#else +static inline int ffa_crb_init (void ) {return 0 ; } +static inline int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor) {return 0 ; } +static inline int ffa_crb_start (int request_type,int locality) {return 0 ; } +#endif + +#define FFA_CRB_START_TYPE_COMMAND 0 +#define FFA_CRB_START_TYPE_LOCALITY_REQUEST 1 + +#endif
Signature · 1 line
2.34.1
Jarkko Sakkinen
maintainerRe: [PATCH v2 1/5] tpm_crb: implement driver compliant to CRB over FF-A
Quoted 409 lines · Stuart Yoder
The Arm specification TPM Service CRB over FF-A specification defines the FF-A messages to interact with a CRB-based TPM implemented as an FF-A secure partition.
Spec URL:
https://developer.arm.com/documentation/den0138/latest/This driver is probed when a TPM Secure Partition is discovered by the FF-A subsystem. It exposes APIs used by the TPM CRB driver to send notifications to the TPM.
Signed-off-by Stuart Yoder <[email protected]>--- drivers/char/tpm/Kconfig | 9 + drivers/char/tpm/Makefile | 1 + drivers/char/tpm/tpm_ffa_crb.c | 310 +++++++++++++++++++++++++++++++++ drivers/char/tpm/tpm_ffa_crb.h | 30 ++++ 4 files changed, 350 insertions(+) create mode 100644 drivers/char/tpm/tpm_ffa_crb.c create mode 100644 drivers/char/tpm/tpm_ffa_crb.hdrivers/char/tpm/Kconfig +9
-0@@ -210,6 +210,15 @@ config TCG_CRB from within Linux. To compile this driver as a module, choose M here; the module will be called tpm_crb. +config TCG_ARM_FFA_CRB + tristate "TPM CRB over Arm FF-A Transport" + depends on ARM_FFA_TRANSPORT + default y if (TCG_CRB && ARM_FFA_TRANSPORT) + help + If the Arm FF-A transport is used to access the TPM say Yes. + To compile this driver as a module, choose M here; the module + will be called tpm_ffa_crb. + config TCG_VTPM_PROXY tristate "VTPM Proxy Interface" depends on TCG_TPMdrivers/char/tpm/Makefile +1
-0@@ -42,5 +42,6 @@ obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o obj-$(CONFIG_TCG_TIS_ST33ZP24) += st33zp24/ obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o obj-$(CONFIG_TCG_CRB) += tpm_crb.o +obj-$(CONFIG_TCG_ARM_FFA_CRB) += tpm_ffa_crb.o obj-$(CONFIG_TCG_VTPM_PROXY) += tpm_vtpm_proxy.o obj-$(CONFIG_TCG_FTPM_TEE) += tpm_ftpm_tee.odrivers/char/tpm/tpm_ffa_crb.c new file +310
-0@@ -0,0 +1,310 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024 Arm Ltd. +* +* Maintained by: <[email protected]> +* +* This device driver implements the TPM CRB start method +* as defined in the TPM Service Command Response Buffer +* Interface Over FF-A (DEN0138). +*/ + +#define pr_fmt (fmt) "FFA_CRB: " fmt + +#include <linux/arm_ffa.h> +#include "tpm_ffa_crb.h" + +/* TPM service function status codes */ +#define FFA_CRB_OK 0x05000001 +#define FFA_CRB_OK_RESULTS_RETURNED 0x05000002 +#define FFA_CRB_NOFUNC 0x8e000001 +#define FFA_CRB_NOTSUP 0x8e000002 +#define FFA_CRB_INVARG 0x8e000005 +#define FFA_CRB_INV_CRB_CTRL_DATA 0x8e000006 +#define FFA_CRB_ALREADY 0x8e000009 +#define FFA_CRB_DENIED 0x8e00000a +#define FFA_CRB_NOMEM 0x8e00000b + +#define FFA_CRB_VERSION_MAJOR 1 +#define FFA_CRB_VERSION_MINOR 0 + +/* version encoding */ +#define FFA_CRB_MAJOR_VERSION_MASK GENMASK(30, 16) +#define FFA_CRB_MINOR_VERSION_MASK GENMASK(15, 0) +#define FFA_CRB_MAJOR_VERSION (x) ((u16)(FIELD_GET(FFA_CRB_MAJOR_VERSION_MASK, (x)))) +#define FFA_CRB_MINOR_VERSION (x) ((u16)(FIELD_GET(FFA_CRB_MINOR_VERSION_MASK, (x)))) + +/* +* Normal world sends requests with FFA_MSG_SEND_DIRECT_REQ and +* responses are returned with FFA_MSG_SEND_DIRECT_RESP for normal +* messages. +* +* All requests with FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP +* are using the AArch32 SMC calling convention with register usage as +* defined in FF-A specification: +* w0: Function ID (0x8400006F or 0x84000070) +* w1: Source/Destination IDs +* w2: Reserved (MBZ) +* w3-w7: Implementation defined, free to be used below +*/ + +/* +* Returns the version of the interface that is available +* Call register usage: +* w3: Not used (MBZ) +* w4: TPM service function ID, FFA_CRB_GET_INTERFACE_VERSION +* w5-w7: Reserved (MBZ) +* +* Return register usage: +* w3: Not used (MBZ) +* w4: TPM service function status +* w5: TPM service interface version +* Bits[31:16]: major version +* Bits[15:0]: minor version +* w6-w7: Reserved (MBZ) +* +* Possible function status codes in register w4: +* CRB_FFA_OK_RESULTS_RETURNED: The version of the interface has been +* returned. +*/ +#define FFA_CRB_GET_INTERFACE_VERSION 0x0f000001 + +/* +* Return information on a given feature of the TPM service +* Call register usage: +* w3: Not used (MBZ) +* w4: TPM service function ID, FFA_CRB_START +* w5: Start function qualifier +* Bits[31:8] (MBZ) +* Bits[7:0] +* 0: Notifies TPM that a command is ready to be processed +* 1: Notifies TPM that a locality request is ready to be processed +* w6: TPM locality, one of 0..4 +* -If the start function qualifier is 0, identifies the locality +* from where the command originated. +* -If the start function qualifier is 1, identifies the locality +* of the locality request +* w6-w7: Reserved (MBZ) +* +* Return register usage: +* w3: Not used (MBZ) +* w4: TPM service function status +* w5-w7: Reserved (MBZ) +* +* Possible function status codes in register w4: +* FFA_CRB_OK: the TPM service has been notified successfully +* FFA_CRB_INVARG: one or more arguments are not valid +* FFA_CRB_INV_CRB_CTRL_DATA: CRB control data or locality control +* data at the given TPM locality is not valid +* FFA_CRB_DENIED: the TPM has previously disabled locality requests and +* command processing at the given locality +*/ +#define FFA_CRB_START 0x0f000201 + +struct ffa_crb { +struct ffa_device *ffa_dev; +u16 major_version; +u16 minor_version; +struct mutex msg_data_lock; +struct ffa_send_direct_data direct_msg_data; +}; + +static struct ffa_crb *ffa_crb; + +static int ffa_crb_to_linux_errno (int errno) +{ +int rc; + +switch (errno) { +case FFA_CRB_OK : + rc =0 ; +break ; +case FFA_CRB_OK_RESULTS_RETURNED : + rc =0 ; +break ; +case FFA_CRB_NOFUNC : + rc = -ENOENT ; +break ; +case FFA_CRB_NOTSUP : + rc = -EPERM ; +break ; +case FFA_CRB_INVARG : + rc = -EINVAL ; +break ; +case FFA_CRB_INV_CRB_CTRL_DATA : + rc = -ENOEXEC ; +break ; +case FFA_CRB_ALREADY : + rc = -EEXIST ; +break ; +case FFA_CRB_DENIED : + rc = -EACCES ; +break ; +case FFA_CRB_NOMEM : + rc = -ENOMEM ; +break ; +default : + rc = -EINVAL ; + } + +return rc; +} + +int ffa_crb_init (void ) +{ +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (ffa_crb_init); + +static int __ffa_crb_send_recieve (unsigned long func_id, +unsigned long a0,unsigned long a1,unsigned long a2) +{ +int ret; +const struct ffa_msg_ops *msg_ops; + +if (ffa_crb ==NULL ) +return -ENOENT ; + + msg_ops = ffa_crb->ffa_dev->ops->msg_ops; + +memset (&ffa_crb->direct_msg_data,0x00 , +sizeof (struct ffa_send_direct_data )); + + ffa_crb->direct_msg_data.data1 = func_id; + ffa_crb->direct_msg_data.data2 = a0; + ffa_crb->direct_msg_data.data3 = a1; + ffa_crb->direct_msg_data.data4 = a2; + + ret = msg_ops->sync_send_receive (ffa_crb->ffa_dev, + &ffa_crb->direct_msg_data); +if (!ret) + ret =ffa_crb_to_linux_errno (ffa_crb->direct_msg_data.data1); + +return ret; +} + +int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor) +{ +int rc; + +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +if (major ==NULL || minor ==NULL ) +return -EINVAL ; + +guard (mutex)(&ffa_crb->msg_data_lock); + + rc =__ffa_crb_send_recieve (FFA_CRB_GET_INTERFACE_VERSION ,0x00 ,0x00 ,0x00 ); +if (!rc) { + *major =FFA_CRB_MAJOR_VERSION (ffa_crb->direct_msg_data.data2); + *minor =FFA_CRB_MINOR_VERSION (ffa_crb->direct_msg_data.data2); + } + +return rc; +} +EXPORT_SYMBOL_GPL (ffa_crb_get_interface_version); + +int ffa_crb_start (int request_type,int locality) +{ +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +guard (mutex)(&ffa_crb->msg_data_lock); + +return __ffa_crb_send_recieve (FFA_CRB_START , request_type, locality,0x00 ); +} +EXPORT_SYMBOL_GPL (ffa_crb_start); + +static int ffa_crb_probe (struct ffa_device *ffa_dev) +{ +int rc; +struct ffa_crb *p; + +/* only one instance of a TPM partition is supported */ +if (ffa_crb && !IS_ERR_VALUE (ffa_crb)) +return -EEXIST ; + + ffa_crb =ERR_PTR (-ENODEV );// set ffa_crb so we can detect probe failure + +if (!ffa_partition_supports_direct_recv (ffa_dev)) { +pr_err ("TPM partition doesn't support direct message receive.\n" ); +return -EINVAL ; + } + + p =kzalloc (sizeof (*ffa_crb),GFP_KERNEL ); +if (!p) +return -ENOMEM ; + ffa_crb = p; + +mutex_init (&ffa_crb->msg_data_lock); + ffa_crb->ffa_dev = ffa_dev; +ffa_dev_set_drvdata (ffa_dev, ffa_crb); + +/* if TPM is aarch32 use 32-bit SMCs */ +if (!ffa_partition_check_property (ffa_dev,FFA_PARTITION_AARCH64_EXEC )) + ffa_dev->ops->msg_ops->mode_32bit_set (ffa_dev); + +/* verify compatibility of TPM service version number */ + rc =ffa_crb_get_interface_version (&ffa_crb->major_version, + &ffa_crb->minor_version); +if (rc) { +pr_err ("failed to get crb interface version. rc:%d" , rc); + goto out; + } + +pr_info ("ABI version %u.%u" , ffa_crb->major_version, + ffa_crb->minor_version); + +if ((ffa_crb->major_version !=FFA_CRB_VERSION_MAJOR ) || + (ffa_crb->minor_version <FFA_CRB_VERSION_MINOR )) { +pr_err ("Incompatible ABI version" ); + goto out; + } + +return 0 ; + +out: +kfree (ffa_crb); + ffa_crb =ERR_PTR (-ENODEV ); +return -EINVAL ; +} + +static void ffa_crb_remove (struct ffa_device *ffa_dev) +{ +kfree (ffa_crb); + ffa_crb =NULL ; +} + +static const struct ffa_device_id ffa_crb_device_id[] = { +/* 17b862a4-1806-4faf-86b3-089a58353861 */ + {UUID_INIT (0x17b862a4 ,0x1806 ,0x4faf , +0x86 ,0xb3 ,0x08 ,0x9a ,0x58 ,0x35 ,0x38 ,0x61 ) }, + {} +}; + +static struct ffa_driver ffa_crb_driver = { + .name ="ffa-crb" , + .probe = ffa_crb_probe, + .remove = ffa_crb_remove, + .id_table = ffa_crb_device_id, +}; + +module_ffa_driver (ffa_crb_driver); + +MODULE_AUTHOR ("Arm" ); +MODULE_DESCRIPTION ("FFA CRB driver" ); +MODULE_VERSION ("1.0" ); +MODULE_LICENSE ("GPL" );drivers/char/tpm/tpm_ffa_crb.h new file +30
-0@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2024 Arm Ltd. +* +* Authors: +* Stuart Yoder <[email protected]> +* +* Maintained by: <[email protected]> +* +* This device driver implements the TPM CRB start method +* as defined in the TPM Service Command Response Buffer +* Interface Over FF-A (DEN0138). +*/ +#ifndef _FFA_CRB_H +#define _FFA_CRB_H + +#if IS_ENABLED (CONFIG_TCG_ARM_FFA_CRB ) +int ffa_crb_init (void ); +int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor); +int ffa_crb_start (int request_type,int locality); +#else +static inline int ffa_crb_init (void ) {return 0 ; } +static inline int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor) {return 0 ; } +static inline int ffa_crb_start (int request_type,int locality) {return 0 ; } +#endif + +#define FFA_CRB_START_TYPE_COMMAND 0 +#define FFA_CRB_START_TYPE_LOCALITY_REQUEST 1 + +#endif Signature · 1 line
2.34.1
tpm_crb_ffa_*
BR, Jarkko
Re: [PATCH v2 1/5] tpm_crb: implement driver compliant to CRB over FF-A
Quoted 404 lines · Jarkko Sakkinen
Quoted 403 lines · Stuart Yoder
The Arm specification TPM Service CRB over FF-A specification defines the FF-A messages to interact with a CRB-based TPM implemented as an FF-A secure partition.
Spec URL:
https://developer.arm.com/documentation/den0138/latest/This driver is probed when a TPM Secure Partition is discovered by the FF-A subsystem. It exposes APIs used by the TPM CRB driver to send notifications to the TPM.
Signed-off-by Stuart Yoder <[email protected]>--- drivers/char/tpm/Kconfig | 9 + drivers/char/tpm/Makefile | 1 + drivers/char/tpm/tpm_ffa_crb.c | 310 +++++++++++++++++++++++++++++++++ drivers/char/tpm/tpm_ffa_crb.h | 30 ++++ 4 files changed, 350 insertions(+)create mode 100644
drivers/char/tpm/tpm_ffa_crb.ccreate mode 100644drivers/char/tpm/tpm_ffa_crb.hdrivers/char/tpm/Kconfig +9
-0@@ -210,6 +210,15 @@ config TCG_CRB from within Linux. To compile this driver as a module, choose M here; the module will be called tpm_crb. +config TCG_ARM_FFA_CRB + tristate "TPM CRB over Arm FF-A Transport" + depends on ARM_FFA_TRANSPORT + default y if (TCG_CRB && ARM_FFA_TRANSPORT) + help + If the Arm FF-A transport is used to access the TPM say Yes. + To compile this driver as a module, choose M here; the module + will be called tpm_ffa_crb. + config TCG_VTPM_PROXY tristate "VTPM Proxy Interface" depends on TCG_TPMdrivers/char/tpm/Makefile +1
-0@@ -42,5 +42,6 @@ obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o obj-$(CONFIG_TCG_TIS_ST33ZP24) += st33zp24/ obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o obj-$(CONFIG_TCG_CRB) += tpm_crb.o +obj-$(CONFIG_TCG_ARM_FFA_CRB) += tpm_ffa_crb.o obj-$(CONFIG_TCG_VTPM_PROXY) += tpm_vtpm_proxy.o obj-$(CONFIG_TCG_FTPM_TEE) += tpm_ftpm_tee.odrivers/char/tpm/tpm_ffa_crb.c new file +310
-0@@ -0,0 +1,310 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024 Arm Ltd. +* +* Maintained by: <[email protected]> +* +* This device driver implements the TPM CRB start method +* as defined in the TPM Service Command Response Buffer +* Interface Over FF-A (DEN0138). +*/ + +#define pr_fmt (fmt) "FFA_CRB: " fmt + +#include <linux/arm_ffa.h> +#include "tpm_ffa_crb.h" + +/* TPM service function status codes */ +#define FFA_CRB_OK 0x05000001 +#define FFA_CRB_OK_RESULTS_RETURNED 0x05000002 +#define FFA_CRB_NOFUNC 0x8e000001 +#define FFA_CRB_NOTSUP 0x8e000002 +#define FFA_CRB_INVARG 0x8e000005 +#define FFA_CRB_INV_CRB_CTRL_DATA 0x8e000006 +#define FFA_CRB_ALREADY 0x8e000009 +#define FFA_CRB_DENIED 0x8e00000a +#define FFA_CRB_NOMEM 0x8e00000b + +#define FFA_CRB_VERSION_MAJOR 1 +#define FFA_CRB_VERSION_MINOR 0 + +/* version encoding */ +#define FFA_CRB_MAJOR_VERSION_MASK GENMASK(30, 16) +#define FFA_CRB_MINOR_VERSION_MASK GENMASK(15, 0) +#define FFA_CRB_MAJOR_VERSION (x) ((u16)(FIELD_GET(FFA_CRB_MAJOR_VERSION_MASK, (x)))) +#define FFA_CRB_MINOR_VERSION (x) ((u16)(FIELD_GET(FFA_CRB_MINOR_VERSION_MASK, (x)))) + +/* +* Normal world sends requests with FFA_MSG_SEND_DIRECT_REQ and +* responses are returned with FFA_MSG_SEND_DIRECT_RESP for normal +* messages. +* +* All requests with FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP +* are using the AArch32 SMC calling convention with register usage as +* defined in FF-A specification: +* w0: Function ID (0x8400006F or 0x84000070) +* w1: Source/Destination IDs +* w2: Reserved (MBZ) +* w3-w7: Implementation defined, free to be used below +*/ + +/* +* Returns the version of the interface that is available +* Call register usage: +* w3: Not used (MBZ) +* w4: TPM service function ID, FFA_CRB_GET_INTERFACE_VERSION +* w5-w7: Reserved (MBZ) +* +* Return register usage: +* w3: Not used (MBZ) +* w4: TPM service function status +* w5: TPM service interface version +* Bits[31:16]: major version +* Bits[15:0]: minor version +* w6-w7: Reserved (MBZ) +* +* Possible function status codes in register w4: +* CRB_FFA_OK_RESULTS_RETURNED: The version of the interface has been +* returned. +*/ +#define FFA_CRB_GET_INTERFACE_VERSION 0x0f000001 + +/* +* Return information on a given feature of the TPM service +* Call register usage: +* w3: Not used (MBZ) +* w4: TPM service function ID, FFA_CRB_START +* w5: Start function qualifier +* Bits[31:8] (MBZ) +* Bits[7:0] +* 0: Notifies TPM that a command is ready to be processed +* 1: Notifies TPM that a locality request is ready to be processed +* w6: TPM locality, one of 0..4 +* -If the start function qualifier is 0, identifies the locality +* from where the command originated. +* -If the start function qualifier is 1, identifies the locality +* of the locality request +* w6-w7: Reserved (MBZ) +* +* Return register usage: +* w3: Not used (MBZ) +* w4: TPM service function status +* w5-w7: Reserved (MBZ) +* +* Possible function status codes in register w4: +* FFA_CRB_OK: the TPM service has been notified successfully +* FFA_CRB_INVARG: one or more arguments are not valid +* FFA_CRB_INV_CRB_CTRL_DATA: CRB control data or locality control +* data at the given TPM locality is not valid +* FFA_CRB_DENIED: the TPM has previously disabled locality requests and +* command processing at the given locality +*/ +#define FFA_CRB_START 0x0f000201 + +struct ffa_crb { +struct ffa_device *ffa_dev; +u16 major_version; +u16 minor_version; +struct mutex msg_data_lock; +struct ffa_send_direct_data direct_msg_data; +}; + +static struct ffa_crb *ffa_crb; + +static int ffa_crb_to_linux_errno (int errno) +{ +int rc; + +switch (errno) { +case FFA_CRB_OK : + rc =0 ; +break ; +case FFA_CRB_OK_RESULTS_RETURNED : + rc =0 ; +break ; +case FFA_CRB_NOFUNC : + rc = -ENOENT ; +break ; +case FFA_CRB_NOTSUP : + rc = -EPERM ; +break ; +case FFA_CRB_INVARG : + rc = -EINVAL ; +break ; +case FFA_CRB_INV_CRB_CTRL_DATA : + rc = -ENOEXEC ; +break ; +case FFA_CRB_ALREADY : + rc = -EEXIST ; +break ; +case FFA_CRB_DENIED : + rc = -EACCES ; +break ; +case FFA_CRB_NOMEM : + rc = -ENOMEM ; +break ; +default : + rc = -EINVAL ; + } + +return rc; +} + +int ffa_crb_init (void ) +{ +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (ffa_crb_init); + +static int __ffa_crb_send_recieve (unsigned long func_id, +unsigned long a0,unsigned long a1,unsigned long a2) +{ +int ret; +const struct ffa_msg_ops *msg_ops; + +if (ffa_crb ==NULL ) +return -ENOENT ; + + msg_ops = ffa_crb->ffa_dev->ops->msg_ops; + +memset (&ffa_crb->direct_msg_data,0x00 , +sizeof (struct ffa_send_direct_data )); + + ffa_crb->direct_msg_data.data1 = func_id; + ffa_crb->direct_msg_data.data2 = a0; + ffa_crb->direct_msg_data.data3 = a1; + ffa_crb->direct_msg_data.data4 = a2; + + ret = msg_ops->sync_send_receive (ffa_crb->ffa_dev, + &ffa_crb->direct_msg_data); +if (!ret) + ret =ffa_crb_to_linux_errno (ffa_crb->direct_msg_data.data1); + +return ret; +} + +int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor) +{ +int rc; + +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +if (major ==NULL || minor ==NULL ) +return -EINVAL ; + +guard (mutex)(&ffa_crb->msg_data_lock); + + rc =__ffa_crb_send_recieve (FFA_CRB_GET_INTERFACE_VERSION ,0x00 ,0x00 ,0x00 ); +if (!rc) { + *major =FFA_CRB_MAJOR_VERSION (ffa_crb->direct_msg_data.data2); + *minor =FFA_CRB_MINOR_VERSION (ffa_crb->direct_msg_data.data2); + } + +return rc; +} +EXPORT_SYMBOL_GPL (ffa_crb_get_interface_version); + +int ffa_crb_start (int request_type,int locality) +{ +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +guard (mutex)(&ffa_crb->msg_data_lock); + +return __ffa_crb_send_recieve (FFA_CRB_START , request_type, locality,0x00 ); +} +EXPORT_SYMBOL_GPL (ffa_crb_start); + +static int ffa_crb_probe (struct ffa_device *ffa_dev) +{ +int rc; +struct ffa_crb *p; + +/* only one instance of a TPM partition is supported */ +if (ffa_crb && !IS_ERR_VALUE (ffa_crb)) +return -EEXIST ; + + ffa_crb =ERR_PTR (-ENODEV );// set ffa_crb so we can detect probe failure + +if (!ffa_partition_supports_direct_recv (ffa_dev)) { +pr_err ("TPM partition doesn't support direct message receive.\n" ); +return -EINVAL ; + } + + p =kzalloc (sizeof (*ffa_crb),GFP_KERNEL ); +if (!p) +return -ENOMEM ; + ffa_crb = p; + +mutex_init (&ffa_crb->msg_data_lock); + ffa_crb->ffa_dev = ffa_dev; +ffa_dev_set_drvdata (ffa_dev, ffa_crb); + +/* if TPM is aarch32 use 32-bit SMCs */ +if (!ffa_partition_check_property (ffa_dev,FFA_PARTITION_AARCH64_EXEC )) + ffa_dev->ops->msg_ops->mode_32bit_set (ffa_dev); + +/* verify compatibility of TPM service version number */ + rc =ffa_crb_get_interface_version (&ffa_crb->major_version, + &ffa_crb->minor_version); +if (rc) { +pr_err ("failed to get crb interface version. rc:%d" , rc); + goto out; + } + +pr_info ("ABI version %u.%u" , ffa_crb->major_version, + ffa_crb->minor_version); + +if ((ffa_crb->major_version !=FFA_CRB_VERSION_MAJOR ) || + (ffa_crb->minor_version <FFA_CRB_VERSION_MINOR )) { +pr_err ("Incompatible ABI version" ); + goto out; + } + +return 0 ; + +out: +kfree (ffa_crb); + ffa_crb =ERR_PTR (-ENODEV ); +return -EINVAL ; +} + +static void ffa_crb_remove (struct ffa_device *ffa_dev) +{ +kfree (ffa_crb); + ffa_crb =NULL ; +} + +static const struct ffa_device_id ffa_crb_device_id[] = { +/* 17b862a4-1806-4faf-86b3-089a58353861 */ + {UUID_INIT (0x17b862a4 ,0x1806 ,0x4faf , +0x86 ,0xb3 ,0x08 ,0x9a ,0x58 ,0x35 ,0x38 ,0x61 ) }, + {} +}; + +static struct ffa_driver ffa_crb_driver = { + .name ="ffa-crb" , + .probe = ffa_crb_probe, + .remove = ffa_crb_remove, + .id_table = ffa_crb_device_id, +}; + +module_ffa_driver (ffa_crb_driver); + +MODULE_AUTHOR ("Arm" ); +MODULE_DESCRIPTION ("FFA CRB driver" ); +MODULE_VERSION ("1.0" ); +MODULE_LICENSE ("GPL" );drivers/char/tpm/tpm_ffa_crb.h new file +28
-0@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2024 Arm Ltd. +* +* Authors: +* Stuart Yoder <[email protected]> +* +* Maintained by: <[email protected]> +* +* This device driver implements the TPM CRB start method +* as defined in the TPM Service Command Response Buffer +* Interface Over FF-A (DEN0138). +*/ +#ifndef _FFA_CRB_H +#define _FFA_CRB_H + +#if IS_ENABLED (CONFIG_TCG_ARM_FFA_CRB ) +int ffa_crb_init (void ); +int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor); +int ffa_crb_start (int request_type,int locality); +#else +static inline int ffa_crb_init (void ) {return 0 ; } +static inline int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor) {return 0 ; } +static inline int ffa_crb_start (int request_type,int locality) {return 0 ; } +#endif + +#define FFA_CRB_START_TYPE_COMMAND 0 +#define FFA_CRB_START_TYPE_LOCALITY_REQUEST 1
Quoted 8 lines
Quoted 6 lines
drivers/char/tpm/tpm_ffa_crb.h new file +2
-0+ +#endif Signature · 1 line
2.34.1tpm_crb_ffa_*
I had renamed the source file to be tpm_ffa_crb.c based on your previous feedback. It would be good to be consistent. Would you prefer:
tpm_crb_ffa_*
or
tpm_ffa_crb_*
Thanks,
Stuart
Jarkko Sakkinen
maintainerRe: [PATCH v2 1/5] tpm_crb: implement driver compliant to CRB over FF-A
Quoted 415 lines · Stuart Yoder
Quoted 403 lines · Jarkko Sakkinen
Quoted 402 lines · Stuart Yoder
The Arm specification TPM Service CRB over FF-A specification defines the FF-A messages to interact with a CRB-based TPM implemented as an FF-A secure partition.
Spec URL:
https://developer.arm.com/documentation/den0138/latest/This driver is probed when a TPM Secure Partition is discovered by the FF-A subsystem. It exposes APIs used by the TPM CRB driver to send notifications to the TPM.
Signed-off-by Stuart Yoder <[email protected]>--- drivers/char/tpm/Kconfig | 9 + drivers/char/tpm/Makefile | 1 + drivers/char/tpm/tpm_ffa_crb.c | 310 +++++++++++++++++++++++++++++++++ drivers/char/tpm/tpm_ffa_crb.h | 30 ++++ 4 files changed, 350 insertions(+)create mode 100644
drivers/char/tpm/tpm_ffa_crb.ccreate mode 100644drivers/char/tpm/tpm_ffa_crb.hdrivers/char/tpm/Kconfig +9
-0@@ -210,6 +210,15 @@ config TCG_CRB from within Linux. To compile this driver as a module, choose M here; the module will be called tpm_crb. +config TCG_ARM_FFA_CRB + tristate "TPM CRB over Arm FF-A Transport" + depends on ARM_FFA_TRANSPORT + default y if (TCG_CRB && ARM_FFA_TRANSPORT) + help + If the Arm FF-A transport is used to access the TPM say Yes. + To compile this driver as a module, choose M here; the module + will be called tpm_ffa_crb. + config TCG_VTPM_PROXY tristate "VTPM Proxy Interface" depends on TCG_TPMdrivers/char/tpm/Makefile +1
-0@@ -42,5 +42,6 @@ obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o obj-$(CONFIG_TCG_TIS_ST33ZP24) += st33zp24/ obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o obj-$(CONFIG_TCG_CRB) += tpm_crb.o +obj-$(CONFIG_TCG_ARM_FFA_CRB) += tpm_ffa_crb.o obj-$(CONFIG_TCG_VTPM_PROXY) += tpm_vtpm_proxy.o obj-$(CONFIG_TCG_FTPM_TEE) += tpm_ftpm_tee.odrivers/char/tpm/tpm_ffa_crb.c new file +310
-0@@ -0,0 +1,310 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024 Arm Ltd. +* +* Maintained by: <[email protected]> +* +* This device driver implements the TPM CRB start method +* as defined in the TPM Service Command Response Buffer +* Interface Over FF-A (DEN0138). +*/ + +#define pr_fmt (fmt) "FFA_CRB: " fmt + +#include <linux/arm_ffa.h> +#include "tpm_ffa_crb.h" + +/* TPM service function status codes */ +#define FFA_CRB_OK 0x05000001 +#define FFA_CRB_OK_RESULTS_RETURNED 0x05000002 +#define FFA_CRB_NOFUNC 0x8e000001 +#define FFA_CRB_NOTSUP 0x8e000002 +#define FFA_CRB_INVARG 0x8e000005 +#define FFA_CRB_INV_CRB_CTRL_DATA 0x8e000006 +#define FFA_CRB_ALREADY 0x8e000009 +#define FFA_CRB_DENIED 0x8e00000a +#define FFA_CRB_NOMEM 0x8e00000b + +#define FFA_CRB_VERSION_MAJOR 1 +#define FFA_CRB_VERSION_MINOR 0 + +/* version encoding */ +#define FFA_CRB_MAJOR_VERSION_MASK GENMASK(30, 16) +#define FFA_CRB_MINOR_VERSION_MASK GENMASK(15, 0) +#define FFA_CRB_MAJOR_VERSION (x) ((u16)(FIELD_GET(FFA_CRB_MAJOR_VERSION_MASK, (x)))) +#define FFA_CRB_MINOR_VERSION (x) ((u16)(FIELD_GET(FFA_CRB_MINOR_VERSION_MASK, (x)))) + +/* +* Normal world sends requests with FFA_MSG_SEND_DIRECT_REQ and +* responses are returned with FFA_MSG_SEND_DIRECT_RESP for normal +* messages. +* +* All requests with FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP +* are using the AArch32 SMC calling convention with register usage as +* defined in FF-A specification: +* w0: Function ID (0x8400006F or 0x84000070) +* w1: Source/Destination IDs +* w2: Reserved (MBZ) +* w3-w7: Implementation defined, free to be used below +*/ + +/* +* Returns the version of the interface that is available +* Call register usage: +* w3: Not used (MBZ) +* w4: TPM service function ID, FFA_CRB_GET_INTERFACE_VERSION +* w5-w7: Reserved (MBZ) +* +* Return register usage: +* w3: Not used (MBZ) +* w4: TPM service function status +* w5: TPM service interface version +* Bits[31:16]: major version +* Bits[15:0]: minor version +* w6-w7: Reserved (MBZ) +* +* Possible function status codes in register w4: +* CRB_FFA_OK_RESULTS_RETURNED: The version of the interface has been +* returned. +*/ +#define FFA_CRB_GET_INTERFACE_VERSION 0x0f000001 + +/* +* Return information on a given feature of the TPM service +* Call register usage: +* w3: Not used (MBZ) +* w4: TPM service function ID, FFA_CRB_START +* w5: Start function qualifier +* Bits[31:8] (MBZ) +* Bits[7:0] +* 0: Notifies TPM that a command is ready to be processed +* 1: Notifies TPM that a locality request is ready to be processed +* w6: TPM locality, one of 0..4 +* -If the start function qualifier is 0, identifies the locality +* from where the command originated. +* -If the start function qualifier is 1, identifies the locality +* of the locality request +* w6-w7: Reserved (MBZ) +* +* Return register usage: +* w3: Not used (MBZ) +* w4: TPM service function status +* w5-w7: Reserved (MBZ) +* +* Possible function status codes in register w4: +* FFA_CRB_OK: the TPM service has been notified successfully +* FFA_CRB_INVARG: one or more arguments are not valid +* FFA_CRB_INV_CRB_CTRL_DATA: CRB control data or locality control +* data at the given TPM locality is not valid +* FFA_CRB_DENIED: the TPM has previously disabled locality requests and +* command processing at the given locality +*/ +#define FFA_CRB_START 0x0f000201 + +struct ffa_crb { +struct ffa_device *ffa_dev; +u16 major_version; +u16 minor_version; +struct mutex msg_data_lock; +struct ffa_send_direct_data direct_msg_data; +}; + +static struct ffa_crb *ffa_crb; + +static int ffa_crb_to_linux_errno (int errno) +{ +int rc; + +switch (errno) { +case FFA_CRB_OK : + rc =0 ; +break ; +case FFA_CRB_OK_RESULTS_RETURNED : + rc =0 ; +break ; +case FFA_CRB_NOFUNC : + rc = -ENOENT ; +break ; +case FFA_CRB_NOTSUP : + rc = -EPERM ; +break ; +case FFA_CRB_INVARG : + rc = -EINVAL ; +break ; +case FFA_CRB_INV_CRB_CTRL_DATA : + rc = -ENOEXEC ; +break ; +case FFA_CRB_ALREADY : + rc = -EEXIST ; +break ; +case FFA_CRB_DENIED : + rc = -EACCES ; +break ; +case FFA_CRB_NOMEM : + rc = -ENOMEM ; +break ; +default : + rc = -EINVAL ; + } + +return rc; +} + +int ffa_crb_init (void ) +{ +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (ffa_crb_init); + +static int __ffa_crb_send_recieve (unsigned long func_id, +unsigned long a0,unsigned long a1,unsigned long a2) +{ +int ret; +const struct ffa_msg_ops *msg_ops; + +if (ffa_crb ==NULL ) +return -ENOENT ; + + msg_ops = ffa_crb->ffa_dev->ops->msg_ops; + +memset (&ffa_crb->direct_msg_data,0x00 , +sizeof (struct ffa_send_direct_data )); + + ffa_crb->direct_msg_data.data1 = func_id; + ffa_crb->direct_msg_data.data2 = a0; + ffa_crb->direct_msg_data.data3 = a1; + ffa_crb->direct_msg_data.data4 = a2; + + ret = msg_ops->sync_send_receive (ffa_crb->ffa_dev, + &ffa_crb->direct_msg_data); +if (!ret) + ret =ffa_crb_to_linux_errno (ffa_crb->direct_msg_data.data1); + +return ret; +} + +int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor) +{ +int rc; + +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +if (major ==NULL || minor ==NULL ) +return -EINVAL ; + +guard (mutex)(&ffa_crb->msg_data_lock); + + rc =__ffa_crb_send_recieve (FFA_CRB_GET_INTERFACE_VERSION ,0x00 ,0x00 ,0x00 ); +if (!rc) { + *major =FFA_CRB_MAJOR_VERSION (ffa_crb->direct_msg_data.data2); + *minor =FFA_CRB_MINOR_VERSION (ffa_crb->direct_msg_data.data2); + } + +return rc; +} +EXPORT_SYMBOL_GPL (ffa_crb_get_interface_version); + +int ffa_crb_start (int request_type,int locality) +{ +if (ffa_crb ==NULL ) +return -ENOENT ; + +if (IS_ERR_VALUE (ffa_crb)) +return -ENODEV ; + +guard (mutex)(&ffa_crb->msg_data_lock); + +return __ffa_crb_send_recieve (FFA_CRB_START , request_type, locality,0x00 ); +} +EXPORT_SYMBOL_GPL (ffa_crb_start); + +static int ffa_crb_probe (struct ffa_device *ffa_dev) +{ +int rc; +struct ffa_crb *p; + +/* only one instance of a TPM partition is supported */ +if (ffa_crb && !IS_ERR_VALUE (ffa_crb)) +return -EEXIST ; + + ffa_crb =ERR_PTR (-ENODEV );// set ffa_crb so we can detect probe failure + +if (!ffa_partition_supports_direct_recv (ffa_dev)) { +pr_err ("TPM partition doesn't support direct message receive.\n" ); +return -EINVAL ; + } + + p =kzalloc (sizeof (*ffa_crb),GFP_KERNEL ); +if (!p) +return -ENOMEM ; + ffa_crb = p; + +mutex_init (&ffa_crb->msg_data_lock); + ffa_crb->ffa_dev = ffa_dev; +ffa_dev_set_drvdata (ffa_dev, ffa_crb); + +/* if TPM is aarch32 use 32-bit SMCs */ +if (!ffa_partition_check_property (ffa_dev,FFA_PARTITION_AARCH64_EXEC )) + ffa_dev->ops->msg_ops->mode_32bit_set (ffa_dev); + +/* verify compatibility of TPM service version number */ + rc =ffa_crb_get_interface_version (&ffa_crb->major_version, + &ffa_crb->minor_version); +if (rc) { +pr_err ("failed to get crb interface version. rc:%d" , rc); + goto out; + } + +pr_info ("ABI version %u.%u" , ffa_crb->major_version, + ffa_crb->minor_version); + +if ((ffa_crb->major_version !=FFA_CRB_VERSION_MAJOR ) || + (ffa_crb->minor_version <FFA_CRB_VERSION_MINOR )) { +pr_err ("Incompatible ABI version" ); + goto out; + } + +return 0 ; + +out: +kfree (ffa_crb); + ffa_crb =ERR_PTR (-ENODEV ); +return -EINVAL ; +} + +static void ffa_crb_remove (struct ffa_device *ffa_dev) +{ +kfree (ffa_crb); + ffa_crb =NULL ; +} + +static const struct ffa_device_id ffa_crb_device_id[] = { +/* 17b862a4-1806-4faf-86b3-089a58353861 */ + {UUID_INIT (0x17b862a4 ,0x1806 ,0x4faf , +0x86 ,0xb3 ,0x08 ,0x9a ,0x58 ,0x35 ,0x38 ,0x61 ) }, + {} +}; + +static struct ffa_driver ffa_crb_driver = { + .name ="ffa-crb" , + .probe = ffa_crb_probe, + .remove = ffa_crb_remove, + .id_table = ffa_crb_device_id, +}; + +module_ffa_driver (ffa_crb_driver); + +MODULE_AUTHOR ("Arm" ); +MODULE_DESCRIPTION ("FFA CRB driver" ); +MODULE_VERSION ("1.0" ); +MODULE_LICENSE ("GPL" );drivers/char/tpm/tpm_ffa_crb.h new file +28
-0@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2024 Arm Ltd. +* +* Authors: +* Stuart Yoder <[email protected]> +* +* Maintained by: <[email protected]> +* +* This device driver implements the TPM CRB start method +* as defined in the TPM Service Command Response Buffer +* Interface Over FF-A (DEN0138). +*/ +#ifndef _FFA_CRB_H +#define _FFA_CRB_H + +#if IS_ENABLED (CONFIG_TCG_ARM_FFA_CRB ) +int ffa_crb_init (void ); +int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor); +int ffa_crb_start (int request_type,int locality); +#else +static inline int ffa_crb_init (void ) {return 0 ; } +static inline int ffa_crb_get_interface_version (uint16_t *major,uint16_t *minor) {return 0 ; } +static inline int ffa_crb_start (int request_type,int locality) {return 0 ; } +#endif + +#define FFA_CRB_START_TYPE_COMMAND 0 +#define FFA_CRB_START_TYPE_LOCALITY_REQUEST 1Quoted 8 lines
Quoted 6 lines
drivers/char/tpm/tpm_ffa_crb.h new file +2
-0+ +#endif Signature · 1 line
2.34.1tpm_crb_ffa_*
Quoted 7 lines
I had renamed the source file to be
tpm_ffa_crb.cbased on your previous feedback. It would be good to be consistent. Would you prefer:tpm_crb_ffa_*
or
tpm_ffa_crb_*
I made a mistake and apologize for that!
I thought about tpm_crb_ffa_* but wrote in misorder.
Sorry about this!
BR, Jarkko
kernel test robot
build botRe: [PATCH v2 1/5] tpm_crb: implement driver compliant to CRB over FF-A
In reply to Stuart Yoderkernel test robot noticed the following build warnings:
Hi Stuart,
kernel test robot noticed the following build warnings:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.14-rc2 next-20250214] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Stuart-Yoder/tpm_crb-implement-driver-compliant-to-CRB-over-FF-A/20250213-060938 base: char-misc/char-misc-testing patch link: https://lore.kernel.org/r/20250212220548.400447-2-stuart.yoder%40arm.com patch subject: [PATCH v2 1/5] tpm_crb: implement driver compliant to CRB over FF-A config: arm64-randconfig-r073-20250214 (https://download.01.org/0day-ci/archive/20250216/[email protected]/config) compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/char/tpm/tpm_ffa_crb.c:272 ffa_crb_probe() warn: unsigned 'ffa_crb->minor_version' is never less than zero.
vim +272 drivers/char/tpm/tpm_ffa_crb.c
230
231 static int ffa_crb_probe(struct ffa_device *ffa_dev)
232 {
233 int rc;
234 struct ffa_crb *p;
235
236 /* only one instance of a TPM partition is supported */
237 if (ffa_crb && !IS_ERR_VALUE(ffa_crb))
238 return -EEXIST;
239
240 ffa_crb = ERR_PTR(-ENODEV); // set ffa_crb so we can detect probe failure
241
242 if (!ffa_partition_supports_direct_recv(ffa_dev)) {
243 pr_err("TPM partition doesn't support direct message receive.\n");
244 return -EINVAL;
245 }
246
247 p = kzalloc(sizeof(*ffa_crb), GFP_KERNEL);
248 if (!p)
249 return -ENOMEM;
250 ffa_crb = p;
251
252 mutex_init(&ffa_crb->msg_data_lock);
253 ffa_crb->ffa_dev = ffa_dev;
254 ffa_dev_set_drvdata(ffa_dev, ffa_crb);
255
256 /* if TPM is aarch32 use 32-bit SMCs */
257 if (!ffa_partition_check_property(ffa_dev, FFA_PARTITION_AARCH64_EXEC))
258 ffa_dev->ops->msg_ops->mode_32bit_set(ffa_dev);
259
260 /* verify compatibility of TPM service version number */
261 rc = ffa_crb_get_interface_version(&ffa_crb->major_version,
262 &ffa_crb->minor_version);
263 if (rc) {
264 pr_err("failed to get crb interface version. rc:%d", rc);
265 goto out;
266 }
267
268 pr_info("ABI version %u.%u", ffa_crb->major_version,
269 ffa_crb->minor_version);
270
271 if ((ffa_crb->major_version != FFA_CRB_VERSION_MAJOR) ||
> 272 (ffa_crb->minor_version < FFA_CRB_VERSION_MINOR)) { 273 pr_err("Incompatible ABI version");
274 goto out;
275 }
276
277 return 0;
278
279 out:
280 kfree(ffa_crb);
281 ffa_crb = ERR_PTR(-ENODEV);
282 return -EINVAL;
283 }
284
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 2/5 tpm_crb: refactor check for idle support into TPM into inline function
In reply to Stuart YoderRefactor the two checks for whether the TPM supports idle into a single inline function.
--- drivers/char/tpm/tpm_crb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/char/tpm/tpm_crb.c +12 -6
@@ -115,6 +115,16 @@ struct tpm2_crb_pluton {u64 reply_addr; }; +static inline bool does_tpm_support_idle (u32 start_method) +{ +if ((start_method ==ACPI_TPM2_START_METHOD ) || + (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || + (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) +return false; +else +return true; +} +static bool crb_wait_for_reg_32 (u32 __iomem *reg,u32 mask,u32 value,unsigned long timeout) {
@@ -173,9 +183,7 @@ static int __crb_go_idle(struct device *dev, struct crb_priv *priv) {int rc; -if ((priv->sm ==ACPI_TPM2_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) +if (!does_tpm_support_idle (priv->sm))return 0 ;iowrite32 (CRB_CTRL_REQ_GO_IDLE , &priv->regs_t->ctrl_req);
@@ -222,9 +230,7 @@ static int __crb_cmd_ready(struct device *dev, struct crb_priv *priv) {int rc; -if ((priv->sm ==ACPI_TPM2_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) +if (!does_tpm_support_idle (priv->sm))return 0 ;iowrite32 (CRB_CTRL_REQ_CMD_READY , &priv->regs_t->ctrl_req);
Signature · 1 line
2.34.1
Jarkko Sakkinen
maintainerRe: [PATCH v2 2/5] tpm_crb: refactor check for idle support into TPM into inline function
Quoted 16 lines · Stuart Yoder
Refactor the two checks for whether the TPM supports idle into a single inline function.
Signed-off-by Stuart Yoder <[email protected]>--- drivers/char/tpm/tpm_crb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)drivers/char/tpm/tpm_crb.c +0
-0@@ -115,6 +115,16 @@ struct tpm2_crb_pluton {u64 reply_addr; };
drivers/char/tpm/tpm_crb.c struct tpm2_crb_pluton { · line 127
Quoted 10 lines
drivers/char/tpm/tpm_crb.c +10
-0+static inline bool does_tpm_support_idle (u32 start_method) +{ +if ((start_method ==ACPI_TPM2_START_METHOD ) || + (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || + (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) +return false; +else +return true; +} +
I think we could also prefix tpm_crb stuff with tpm_crb_* for the sake of easier grepping etc.
So I'd propose this to be called as: tpm_crb_has_idle()
Quoted 28 lines
drivers/char/tpm/tpm_crb.c +2
-6static bool crb_wait_for_reg_32 (u32 __iomem *reg,u32 mask,u32 value,unsigned long timeout) {@@ -173,9 +183,7 @@ static int __crb_go_idle(struct device *dev, struct crb_priv *priv) {int rc; -if ((priv->sm ==ACPI_TPM2_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) +if (!does_tpm_support_idle (priv->sm))return 0 ;iowrite32 (CRB_CTRL_REQ_GO_IDLE , &priv->regs_t->ctrl_req);@@ -222,9 +230,7 @@ static int __crb_cmd_ready(struct device *dev, struct crb_priv *priv) {int rc; -if ((priv->sm ==ACPI_TPM2_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || - (priv->sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) +if (!does_tpm_support_idle (priv->sm))return 0 ;iowrite32 (CRB_CTRL_REQ_CMD_READY , &priv->regs_t->ctrl_req);Signature · 1 line
2.34.1
BR, Jarkko
Re: [PATCH v2 2/5] tpm_crb: refactor check for idle support into TPM into inline function
Quoted 31 lines · Jarkko Sakkinen
Quoted 16 lines · Stuart Yoder
Refactor the two checks for whether the TPM supports idle into a single inline function.
Signed-off-by Stuart Yoder <[email protected]>--- drivers/char/tpm/tpm_crb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)drivers/char/tpm/tpm_crb.c +0
-0@@ -115,6 +115,16 @@ struct tpm2_crb_pluton {u64 reply_addr; };drivers/char/tpm/tpm_crb.c struct tpm2_crb_pluton { · line 127
Quoted 10 lines
drivers/char/tpm/tpm_crb.c +10
-0+static inline bool does_tpm_support_idle (u32 start_method) +{ +if ((start_method ==ACPI_TPM2_START_METHOD ) || + (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || + (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) +return false; +else +return true; +} +I think we could also prefix
tpm_crbstuff with tpm_crb_* for the sake of easier grepping etc.
Quoted 1 line
So I'd propose this to be called as:
tpm_crb_has_idle()
Ack.
Stuart
PATCH v2 3/5 ACPICA: add start method for Arm FF-A
In reply to Stuart YoderAdd TPM start method for Arm FF-A defined in the TCG ACPI specification v1.4.
--- include/acpi/actbl3.h | 1 + 1 file changed, 1 insertion(+)
include/acpi/actbl3.h +1 -0
@@ -466,6 +466,7 @@ struct acpi_tpm2_phy {#define ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC 11/* V1.2 Rev 8 */ #define ACPI_TPM2_RESERVED 12#define ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON 13 +#define ACPI_TPM2_CRB_WITH_ARM_FFA 15/* Optional trailer appears after any start_method subtables */
Signature · 1 line
2.34.1
PATCH v2 4/5 tpm_crb: add support for the Arm FF-A start method
In reply to Stuart YoderThe TCG ACPI spec v1.4 defines a start method for the TPMs implemented with the Arm CRB over FF-A ABI.
Add support for the FF-A start method, and use interfaces provided by the ffa_crb driver to interact with the FF-A based TPM.
--- drivers/char/tpm/tpm_crb.c | 65 +++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +64 -1
@@ -19,6 +19,7 @@#ifdef CONFIG_ARM64 #include <linux/arm-smccc.h> #endif +#include "tpm_ffa_crb.h" #include "tpm.h" #define ACPI_SIG_TPM2 "TPM2"
@@ -100,6 +101,8 @@ struct crb_priv {u32 smc_func_id;u32 __iomem *pluton_start_addr;u32 __iomem *pluton_reply_addr; +u8 ffa_flags; +u8 ffa_attributes; };struct tpm2_crb_smc {
@@ -110,6 +113,14 @@ struct tpm2_crb_smc {u32 smc_func_id; }; +/* CRB over FFA start method parameters in TCG2 ACPI table */ +struct tpm2_crb_ffa { +u8 flags; +u8 attributes; +u16 partition_id; +u8 reserved[8 ]; +}; +struct tpm2_crb_pluton {u64 start_addr;u64 reply_addr;
@@ -119,7 +130,8 @@ static inline bool does_tpm_support_idle(u32 start_method) {if ((start_method ==ACPI_TPM2_START_METHOD ) || (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ) || - (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC )) + (start_method ==ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC ) || + (start_method ==ACPI_TPM2_CRB_WITH_ARM_FFA ))return false;else return true;
@@ -261,6 +273,7 @@ static int crb_cmd_ready(struct tpm_chip *chip)static int __crb_request_locality (struct device *dev,struct crb_priv *priv,int loc) { +int rc;u32 value =CRB_LOC_STATE_LOC_ASSIGNED |CRB_LOC_STATE_TPM_REG_VALID_STS ;
@@ -268,6 +281,13 @@ static int __crb_request_locality(struct device *dev,return 0 ;iowrite32 (CRB_LOC_CTRL_REQUEST_ACCESS , &priv->regs_h->loc_ctrl); + +if (priv->sm ==ACPI_TPM2_CRB_WITH_ARM_FFA ) { + rc =ffa_crb_start (FFA_CRB_START_TYPE_LOCALITY_REQUEST , loc); +if (rc) +return rc; + } +if (!crb_wait_for_reg_32 (&priv->regs_h->loc_state, value, value,TPM2_TIMEOUT_C )) {dev_warn (dev,"TPM_LOC_STATE_x.requestAccess timed out\n" );
@@ -287,6 +307,7 @@ static int crb_request_locality(struct tpm_chip *chip, int loc)static int __crb_relinquish_locality (struct device *dev,struct crb_priv *priv,int loc) { +int rc;u32 mask =CRB_LOC_STATE_LOC_ASSIGNED |CRB_LOC_STATE_TPM_REG_VALID_STS ;u32 value =CRB_LOC_STATE_TPM_REG_VALID_STS ;
@@ -295,6 +316,13 @@ static int __crb_relinquish_locality(struct device *dev,return 0 ;iowrite32 (CRB_LOC_CTRL_RELINQUISH , &priv->regs_h->loc_ctrl); + +if (priv->sm ==ACPI_TPM2_CRB_WITH_ARM_FFA ) { + rc =ffa_crb_start (FFA_CRB_START_TYPE_LOCALITY_REQUEST , loc); +if (rc) +return rc; + } +if (!crb_wait_for_reg_32 (&priv->regs_h->loc_state, mask, value,TPM2_TIMEOUT_C )) {dev_warn (dev,"TPM_LOC_STATE_x.Relinquish timed out\n" );
@@ -443,6 +471,11 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len) rc =tpm_crb_smc_start (&chip->dev, priv->smc_func_id); } +if (priv->sm ==ACPI_TPM2_CRB_WITH_ARM_FFA ) { +iowrite32 (CRB_START_INVOKE , &priv->regs_t->ctrl_start); + rc =ffa_crb_start (FFA_CRB_START_TYPE_COMMAND , chip->locality); + } +if (rc)return rc;
@@ -451,6 +484,7 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)static void crb_cancel (struct tpm_chip *chip) { +int rc;struct crb_priv *priv =dev_get_drvdata (&chip->dev);iowrite32 (CRB_CANCEL_INVOKE , &priv->regs_t->ctrl_cancel);
@@ -459,6 +493,12 @@ static void crb_cancel(struct tpm_chip *chip) (priv->sm == ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD)) && crb_do_acpi_start(chip))dev_err (&chip->dev,"ACPI Start failed\n" ); + +if (priv->sm ==ACPI_TPM2_CRB_WITH_ARM_FFA ) { + rc =ffa_crb_start (FFA_CRB_START_TYPE_COMMAND , chip->locality); +if (rc) +dev_err (&chip->dev,"FF-A Start failed\n" ); + } }static bool crb_req_canceled (struct tpm_chip *chip,u8 status)
@@ -616,6 +656,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,* stuff that puts the control area outside the ACPI IO region. */ if ((priv->sm == ACPI_TPM2_COMMAND_BUFFER) || + (priv->sm == ACPI_TPM2_CRB_WITH_ARM_FFA) || (priv->sm == ACPI_TPM2_MEMORY_MAPPED)) { if (iores && buf->control_address == iores->start +
@@ -737,6 +778,7 @@ static int crb_acpi_add(struct acpi_device *device)struct tpm_chip *chip;struct device *dev = &device->dev;struct tpm2_crb_smc *crb_smc; +struct tpm2_crb_ffa *crb_ffa;struct tpm2_crb_pluton *crb_pluton;acpi_status status;u32 sm;
@@ -775,6 +817,27 @@ static int crb_acpi_add(struct acpi_device *device) priv->smc_func_id = crb_smc->smc_func_id; } +if (sm ==ACPI_TPM2_CRB_WITH_ARM_FFA ) { +if (buf->header.length < (sizeof (*buf) +sizeof (*crb_ffa))) { +dev_err (dev, +FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n" , + buf->header.length, +ACPI_TPM2_CRB_WITH_ARM_FFA ); + rc = -EINVAL ; + goto out; + } + crb_ffa = ACPI_ADD_PTR(struct tpm2_crb_ffa, buf, sizeof(*buf)); + priv->ffa_flags = crb_ffa->flags; + priv->ffa_attributes = crb_ffa->attributes; + rc =ffa_crb_init (); +if (rc) { +if (rc == -ENOENT ) {// FF-A driver is not available yet + rc = -EPROBE_DEFER ; + } + goto out; + } + } +if (sm ==ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON ) {if (buf->header.length < (sizeof (*buf) +sizeof (*crb_pluton))) { dev_err(dev,
Signature · 1 line
2.34.1
PATCH v2 5/5 Documentation: tpm: add documentation for the CRB FF-A interface
In reply to Stuart YoderAdd documentation providing details of how the CRB driver interacts with FF-A.
--- Documentation/security/tpm/tpm_ffa_crb.rst | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/security/tpm/tpm_ffa_crb.rst
Documentation/security/tpm/tpm_ffa_crb.rst new file +65 -0
@@ -0,0 +1,65 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======================== +TPM CRB over FF-A Driver +======================== + +The TPM Command Response Buffer (CRB) interface is a standard TPM interface +defined in the TCG PC Client Platform TPM Profile (PTP) Specification [1]_. +The CRB provides a structured set of control registers a client uses when +interacting with a TPM as well as a data buffer for storing TPM commands and +responses. A CRB interface can be implemented in: + +- hardware registers in a discrete TPM chip + +- in memory for a TPM running in isolated environment where shared memory + allows a client to interact with the TPM + +The Firmware Framework for Arm A-profile (FF-A) [2]_ is a specification +that defines interfaces and protocols for the following purposes: + +- Compartmentalize firmware into software partitions that run in the Arm + Secure world environment (also know as TrustZone) + +- Provide a standard interface for software components in the Non-secure + state, for example OS and Hypervisors, to communicate with this firmware. + +A TPM can be implemented as an FF-A secure service. This could be a firmware +TPM or could potentially be a TPM service that acts as a proxy to a discrete +TPM chip. An FF-A based TPM abstracts hardware details (e.g. bus controller +and chip selects) away from the OS and can protect locality 4 from access +by an OS. The TCG-defined CRB interface is used by clients to interact +with the TPM service. + +The Arm TPM Service Command Response Buffer Interface Over FF-A [3]_ +specification defines FF-A messages that can be used by a client to signal +when updates have been made to the CRB. + +How the Linux CRB driver interacts with FF-A is summarized below: + +- The tpm_ffa_crb driver registers with the FF-A subsystem in the kernel + with an architected TPM service UUID defined in the CRB over FF-A spec. + +- If a TPM service is discovered by FF-A, the probe() function in the + tpm_ffa_crb driver runs, and the driver initializes. + +- The probing and initialization of the Linux CRB driver is triggered + by the discovery of a TPM advertised via ACPI. The CRB driver can + detect the type of TPM through the ACPI 'start' method. The start + method for Arm FF-A was defined in TCG ACPI v1.4 [4]_. + +- When the CRB driver performs its normal functions such as signaling 'start' + and locality request/relinquish it invokes the ffa_crb_start() funnction + in the tpm_ffa_crb driver which handles the FF-A messaging to the TPM. + +References +========== + +.. [1] **TCG PC Client Platform TPM Profile (PTP) Specification** + https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ +.. [2] **Arm Firmware Framework for Arm A-profile (FF-A)** + https://developer.arm.com/documentation/den0077/latest/ +.. [3] **Arm TPM Service Command Response Buffer Interface Over FF-A** + https://developer.arm.com/documentation/den0138/latest/ +.. [4] **TCG ACPI Specification** + https://trustedcomputinggroup.org/resource/tcg-acpi-specification/
Signature · 1 line
2.34.1
Re: [PATCH v2 5/5] Documentation: tpm: add documentation for the CRB FF-A interface
Quoted 27 lines · Stuart Yoder
Add documentation providing details of how the CRB driver interacts with FF-A.
Signed-off-by Stuart Yoder <[email protected]>--- Documentation/security/tpm/tpm_ffa_crb.rst | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/security/tpm/tpm_ffa_crb.rstDocumentation/security/tpm/tpm_ffa_crb.rst new file +12
-0@@ -0,0 +1,65 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======================== +TPM CRB over FF-A Driver +======================== + +The TPM Command Response Buffer (CRB) interface is a standard TPM interface +defined in the TCG PC Client Platform TPM Profile (PTP) Specification [1]_. +The CRB provides a structured set of control registers a client uses when +interacting with a TPM as well as a data buffer for storing TPM commands and +responses. A CRB interface can be implemented in: +
Documentation/security/tpm/tpm_ffa_crb.rst line 22
Quoted 10 lines
Documentation/security/tpm/tpm_ffa_crb.rst new file +10
-0+- hardware registers in a discrete TPM chip + +- in memory for a TPM running in isolated environment where shared memory + allows a client to interact with the TPM + +The Firmware Framework for Arm A-profile (FF-A) [2]_ is a specification +that defines interfaces and protocols for the following purposes: + +- Compartmentalize firmware into software partitions that run in the Arm + Secure world environment (also know as TrustZone)
Does that also cover ARM CCA? Just a question (not a review question).
Quoted 45 lines
Documentation/security/tpm/tpm_ffa_crb.rst new file +43
-0+ +- Provide a standard interface for software components in the Non-secure + state, for example OS and Hypervisors, to communicate with this firmware. + +A TPM can be implemented as an FF-A secure service. This could be a firmware +TPM or could potentially be a TPM service that acts as a proxy to a discrete +TPM chip. An FF-A based TPM abstracts hardware details (e.g. bus controller +and chip selects) away from the OS and can protect locality 4 from access +by an OS. The TCG-defined CRB interface is used by clients to interact +with the TPM service. + +The Arm TPM Service Command Response Buffer Interface Over FF-A [3]_ +specification defines FF-A messages that can be used by a client to signal +when updates have been made to the CRB. + +How the Linux CRB driver interacts with FF-A is summarized below: + +- The tpm_ffa_crb driver registers with the FF-A subsystem in the kernel + with an architected TPM service UUID defined in the CRB over FF-A spec. + +- If a TPM service is discovered by FF-A, the probe() function in the + tpm_ffa_crb driver runs, and the driver initializes. + +- The probing and initialization of the Linux CRB driver is triggered + by the discovery of a TPM advertised via ACPI. The CRB driver can + detect the type of TPM through the ACPI 'start' method. The start + method for Arm FF-A was defined in TCG ACPI v1.4 [4]_. + +- When the CRB driver performs its normal functions such as signaling 'start' + and locality request/relinquish it invokes the ffa_crb_start() funnction + in the tpm_ffa_crb driver which handles the FF-A messaging to the TPM. + +References +========== + +.. [1] **TCG PC Client Platform TPM Profile (PTP) Specification** + https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ +.. [2] **Arm Firmware Framework for Arm A-profile (FF-A)** + https://developer.arm.com/documentation/den0077/latest/ +.. [3] **Arm TPM Service Command Response Buffer Interface Over FF-A** + https://developer.arm.com/documentation/den0138/latest/ +.. [4] **TCG ACPI Specification** + https://trustedcomputinggroup.org/resource/tcg-acpi-specification/Signature · 1 line
2.34.1
BR, Jarkko
Re: [PATCH v2 5/5] Documentation: tpm: add documentation for the CRB FF-A interface
Quoted 32 lines · Jarkko Sakkinen
Quoted 31 lines · Stuart Yoder
Add documentation providing details of how the CRB driver interacts with FF-A.
Signed-off-by Stuart Yoder <[email protected]>--- Documentation/security/tpm/tpm_ffa_crb.rst | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+)create mode 100644
Documentation/security/tpm/tpm_ffa_crb.rstDocumentation/security/tpm/tpm_ffa_crb.rst new file +16
-0@@ -0,0 +1,65 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======================== +TPM CRB over FF-A Driver +======================== + +The TPM Command Response Buffer (CRB) interface is a standard TPM interface +defined in the TCG PC Client Platform TPM Profile (PTP) Specification [1]_. +The CRB provides a structured set of control registers a client uses when +interacting with a TPM as well as a data buffer for storing TPM commands and +responses. A CRB interface can be implemented in: + +- hardware registers in a discrete TPM chip + +- in memory for a TPM running in isolated environment where shared memory + allows a client to interact with the TPM
Quoted 8 lines
Documentation/security/tpm/tpm_ffa_crb.rst line 22
Quoted 6 lines
Documentation/security/tpm/tpm_ffa_crb.rst new file +6
-0+ +The Firmware Framework for Arm A-profile (FF-A) [2]_ is a specification +that defines interfaces and protocols for the following purposes: + +- Compartmentalize firmware into software partitions that run in the Arm + Secure world environment (also know as TrustZone)Does that also cover ARM CCA? Just a question (not a review question).
No, CCA is for confidential VMs which is a separate trusted execution environment and FF-A is not used there.
Thanks,
Stuart
Jarkko Sakkinen
maintainerRe: [PATCH v2 5/5] Documentation: tpm: add documentation for the CRB FF-A interface
Quoted 44 lines · Stuart Yoder
Quoted 32 lines · Jarkko Sakkinen
Quoted 31 lines · Stuart Yoder
Add documentation providing details of how the CRB driver interacts with FF-A.
Signed-off-by Stuart Yoder <[email protected]>--- Documentation/security/tpm/tpm_ffa_crb.rst | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+)create mode 100644
Documentation/security/tpm/tpm_ffa_crb.rstDocumentation/security/tpm/tpm_ffa_crb.rst new file +16
-0@@ -0,0 +1,65 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======================== +TPM CRB over FF-A Driver +======================== + +The TPM Command Response Buffer (CRB) interface is a standard TPM interface +defined in the TCG PC Client Platform TPM Profile (PTP) Specification [1]_. +The CRB provides a structured set of control registers a client uses when +interacting with a TPM as well as a data buffer for storing TPM commands and +responses. A CRB interface can be implemented in: + +- hardware registers in a discrete TPM chip + +- in memory for a TPM running in isolated environment where shared memory + allows a client to interact with the TPMQuoted 8 lines
Documentation/security/tpm/tpm_ffa_crb.rst line 22
Quoted 6 lines
Documentation/security/tpm/tpm_ffa_crb.rst new file +6
-0+ +The Firmware Framework for Arm A-profile (FF-A) [2]_ is a specification +that defines interfaces and protocols for the following purposes: + +- Compartmentalize firmware into software partitions that run in the Arm + Secure world environment (also know as TrustZone)Does that also cover ARM CCA? Just a question (not a review question).
Quoted 2 lines
No, CCA is for confidential VMs which is a separate trusted execution environment and FF-A is not used there.
OK, cool, just plain interested :-)
Quoted 3 lines
Thanks,
Stuart
BR, Jarkko