Skip to contentSkip to conversation

tee: optee: report OP-TEE revision information

PATCH New Jerome Forissier 2 participants 5 messages Nov 24, 2017 – Jan 12, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tee: optee: report OP-TEE revision information

Hi,

This patchset updates the OP-TEE driver to report the version of the secure OS upon initialization. To further facilitate troubleshooting, an optional build ID is introduced in the response to the OPTEE_SMC_CALL_GET_OS_REVISION request. Upstream OP-TEE uses this field to report its Git SHA1 since commit 29cff5cf09aa ("core: GET_OS_REVISION:
return SHA1 of current Git commit").

Typical boot log (>> is introduced by this patchset):

optee: probing for conduit method from DT.

Quoted 1 line
Quoted 1 line

optee: revision 2.6 (947cfeec)

optee: initialized driver

...or, if the build ID is not set by the TEE or set to zero:

optee: probing for conduit method from DT.

Quoted 1 line
Quoted 1 line

optee: revision 2.6

optee: initialized driver

Jerome Forissier (2):
tee: optee: GET_OS_REVISION: document a2 as a build identifier
tee: optee: report OP-TEE revision information

 drivers/tee/optee/core.c      | 23 +++++++++++++++++++++++
 drivers/tee/optee/optee_smc.h | 10 +++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 tee: optee: GET_OS_REVISION: document a2 as a build identifier

In the OPTEE_SMC_CALL_GET_OS_REVISION request, the previously reserved parameter a2 is now documented as being an optional build identifier (such as an SCM revision or commit ID, for instance).

A new structure optee_smc_call_get_os_revision_result is introduced to be used when querying the secure OS version, instead of re-using the struct defined for OPTEE_SMC_CALLS_REVISION.

---
 drivers/tee/optee/optee_smc.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/tee/optee/optee_smc.h +9 -1
index 069c8e1429de..d0b67c65ea8f 100644
@@ -112,12 +112,20 @@ struct optee_smc_calls_revision_result {
  * Trusted OS, not of the API.
  *
  * Returns revision in a0-1 in the same way as OPTEE_SMC_CALLS_REVISION
- * described above.
+ * described above. May optionally return a 32-bit build identifier in a2,
+ * with zero meaning unspecified.
  */
 #define OPTEE_SMC_FUNCID_GET_OS_REVISION OPTEE_MSG_FUNCID_GET_OS_REVISION
 #define OPTEE_SMC_CALL_GET_OS_REVISION \
 	OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_OS_REVISION)
 
+struct optee_smc_call_get_os_revision_result {
+	unsigned long major;
+	unsigned long minor;
+	unsigned long build_id;
+	unsigned long reserved1;
+};
+
 /*
  * Call with struct optee_msg_arg as argument
  *
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 tee: optee: report OP-TEE revision information

In reply to Jerome Forissier

When the driver initializes, report the following information about the OP-TEE OS:
- major and minor version,
- build identifier (if available).

---
 drivers/tee/optee/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/tee/optee/core.c +23 -0
index 7952357df9c8..d04f4617aed2 100644
@@ -302,6 +302,27 @@ static bool optee_msg_api_uid_is_optee_api(optee_invoke_fn *invoke_fn)
 	return false;
 }
 
+static void optee_msg_get_os_revision(optee_invoke_fn *invoke_fn)
+{
+	union {
+		struct arm_smccc_res smccc;
+		struct optee_smc_call_get_os_revision_result result;
+	} res = {
+		.result = {
+			.build_id = 0
+		}
+	};
+
+	invoke_fn(OPTEE_SMC_CALL_GET_OS_REVISION, 0, 0, 0, 0, 0, 0, 0,
+		  &res.smccc);
+
+	if (res.result.build_id)
+		pr_info("revision %lu.%lu (%08lx)", res.result.major,
+			res.result.minor, res.result.build_id);
+	else
+		pr_info("revision %lu.%lu", res.result.major, res.result.minor);
+}
+
 static bool optee_msg_api_revision_is_compatible(optee_invoke_fn *invoke_fn)
 {
 	union {
@@ -465,6 +486,8 @@ static struct optee *optee_probe(struct device_node *np)
 		return ERR_PTR(-EINVAL);
 	}
 
+	optee_msg_get_os_revision(invoke_fn);
+
 	if (!optee_msg_api_revision_is_compatible(invoke_fn)) {
 		pr_warn("api revision mismatch\n");
 		return ERR_PTR(-EINVAL);
Signature · 1 line
2.7.4
#3 lore raw

cover tee: optee: report OP-TEE revision information

In reply to Jerome Forissier
Quoted 21 lines · Jerome Forissier

Hi,

This patchset updates the OP-TEE driver to report the version of the secure OS upon initialization. To further facilitate troubleshooting, an optional build ID is introduced in the response to the OPTEE_SMC_CALL_GET_OS_REVISION request. Upstream OP-TEE uses this field to report its Git SHA1 since commit 29cff5cf09aa ("core: GET_OS_REVISION:
return SHA1 of current Git commit").

Typical boot log (>> is introduced by this patchset):

optee: probing for conduit method from DT.

Quoted 1 line
Quoted 1 line

optee: revision 2.6 (947cfeec)

optee: initialized driver

...or, if the build ID is not set by the TEE or set to zero:

optee: probing for conduit method from DT.

Quoted 1 line
Quoted 1 line

optee: revision 2.6

optee: initialized driver

Quoted 8 lines

Jerome Forissier (2):
tee: optee: GET_OS_REVISION: document a2 as a build identifier
tee: optee: report OP-TEE revision information

 drivers/tee/optee/core.c      | 23 +++++++++++++++++++++++
 drivers/tee/optee/optee_smc.h | 10 +++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

Ping?

#4 lore raw

cover tee: optee: report OP-TEE revision information

In reply to Jerome Forissier
Quoted 21 lines · Jerome Forissier

Hi,

This patchset updates the OP-TEE driver to report the version of the secure OS upon initialization. To further facilitate troubleshooting, an optional build ID is introduced in the response to the OPTEE_SMC_CALL_GET_OS_REVISION request. Upstream OP-TEE uses this field to report its Git SHA1 since commit 29cff5cf09aa ("core: GET_OS_REVISION:
return SHA1 of current Git commit").

Typical boot log (>> is introduced by this patchset):

optee: probing for conduit method from DT.

Quoted 1 line
Quoted 1 line

optee: revision 2.6 (947cfeec)

optee: initialized driver

...or, if the build ID is not set by the TEE or set to zero:

optee: probing for conduit method from DT.

Quoted 1 line
Quoted 1 line

optee: revision 2.6

optee: initialized driver

Quoted 8 lines

Jerome Forissier (2):
tee: optee: GET_OS_REVISION: document a2 as a build identifier
tee: optee: report OP-TEE revision information

 drivers/tee/optee/core.c      | 23 +++++++++++++++++++++++
 drivers/tee/optee/optee_smc.h | 10 +++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)