Both the OP-TEE core and some OP-TEE drivers use an if/else expression
to check a boolean which can instead be returned directly. Implement
this change.
---
Rouven Czerwinski (3):
optee: simplify OP-TEE context match
hwrng: optee - simplify OP-TEE context match
rtc: optee: simplify OP-TEE context match
drivers/char/hw_random/optee-rng.c | 5 +----
drivers/rtc/rtc-optee.c | 5 +----
drivers/tee/optee/device.c | 5 +----
3 files changed, 3 insertions(+), 12 deletions(-)
---
base-commit: 63804fed149a6750ffd28610c5c1c98cce6bd377
change-id: 20260126-optee-simplify-context-match-d5b3467bfacc
Best regards,
--
Rouven Czerwinski <rouven.czerwinski(a)linaro.org>
When we do SCMI on OP-TEE, the in buffer and out buffer are the same buffer.
I added some debug code to confirm this:
diff --git a/module/msg_smt/src/mod_msg_smt.c b/module/msg_smt/src/mod_msg_smt.c
index 853fe66b8d27..1e92dcd49c29 100644
--- a/module/msg_smt/src/mod_msg_smt.c
+++ b/module/msg_smt/src/mod_msg_smt.c
@@ -175,6 +175,11 @@ static int smt_write_payload(fwk_id_t channel_id,
if (!channel_ctx->locked)
return FWK_E_ACCESS;
+ FWK_LOG_ERR("OUT=%p IN=%p %s",
+ channel_ctx->out->payload,
+ channel_ctx->in->payload,
+ (channel_ctx->out->payload == channel_ctx->in->payload) ? "equal" : "different");
+
memcpy(((uint8_t*)channel_ctx->out->payload) + offset, payload, size);
return FWK_SUCCESS;
And it's true:
[ 0.000000] OUT=0x9c401004 IN=0x9c401004 equal
This normally isn't a problem because we read a few inputs at the
start of the function and then write out the result to the output at the
end.
But in the scmi_pin_control_list_associations_handler() it does a loop
where each iteration reads from parameters->index which is input and
writes to the output with scmi_pin_control_ctx.scmi_api->write_payload()
and that corrupts the input data.
Copying the input buffer to a the stack the issue for me, but I feel
like it is a hack. It would be better to use separate buffers for
input and output.
I think this comes from:
https://github.com/OP-TEE/optee_os/blob/master/core/kernel/pseudo_ta.c#L93
I added a print statement to there as well:
diff --git a/core/kernel/pseudo_ta.c b/core/kernel/pseudo_ta.c
index 587faa41a770..426870fb934c 100644
--- a/core/kernel/pseudo_ta.c
+++ b/core/kernel/pseudo_ta.c
@@ -90,6 +90,7 @@ static TEE_Result copy_in_param(struct ts_session *s __maybe_unused,
va = NULL;
}
+ EMSG("n=%lu va=%p", n, va);
tee_param[n].memref.buffer = va;
tee_param[n].memref.size = mem->size;
break;
E/TC:? 0 copy_in_param:93 n=1 va=0x9c401000
E/TC:? 0 copy_in_param:93 n=2 va=0x9c401000
Here is the patch to save "parameters" to a different buffer.
---
.../scmi_pin_control/src/mod_scmi_pin_control.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/module/scmi_pin_control/src/mod_scmi_pin_control.c b/module/scmi_pin_control/src/mod_scmi_pin_control.c
index a0b90dd2b73f..54e613b70f69 100644
--- a/module/scmi_pin_control/src/mod_scmi_pin_control.c
+++ b/module/scmi_pin_control/src/mod_scmi_pin_control.c
@@ -344,7 +344,7 @@ static int scmi_pin_control_list_associations_handler(
fwk_id_t service_id,
const uint32_t *payload)
{
- const struct scmi_pin_control_list_associations_a2p *parameters;
+ const struct scmi_pin_control_list_associations_a2p parameters;
uint32_t payload_size;
uint16_t identifiers_count;
uint16_t total_number_of_associations;
@@ -362,8 +362,9 @@ static int scmi_pin_control_list_associations_handler(
payload_size = (uint32_t)sizeof(return_values);
parameters = (const struct scmi_pin_control_list_associations_a2p *)payload;
+ memcpy(¶meters, payload, sizeof(parameters));
- status = map_identifier(parameters->identifier, &mapped_identifier);
+ status = map_identifier(parameters.identifier, &mapped_identifier);
if (status != FWK_SUCCESS) {
return_values.status = SCMI_NOT_FOUND;
@@ -371,7 +372,7 @@ static int scmi_pin_control_list_associations_handler(
}
status = scmi_pin_control_ctx.pinctrl_api->get_total_number_of_associations(
- mapped_identifier, parameters->flags, &total_number_of_associations);
+ mapped_identifier, parameters.flags, &total_number_of_associations);
if (status != FWK_SUCCESS) {
return_values.status = SCMI_NOT_FOUND;
goto exit;
@@ -388,11 +389,11 @@ static int scmi_pin_control_list_associations_handler(
identifiers_count = (uint16_t)FWK_MIN(
buffer_allowed_identifiers,
- (uint16_t)(total_number_of_associations - parameters->index));
+ (uint16_t)(total_number_of_associations - parameters.index));
return_values.flags = identifiers_count;
return_values.flags |= SHIFT_LEFT_BY_POS(
- (total_number_of_associations - parameters->index - identifiers_count),
+ (total_number_of_associations - parameters.index - identifiers_count),
NUM_OF_REMAINING_ELEMENTS_POS);
for (identifier_index = 0; identifier_index < identifiers_count;
@@ -401,8 +402,8 @@ static int scmi_pin_control_list_associations_handler(
status = scmi_pin_control_ctx.pinctrl_api->get_list_associations(
mapped_identifier,
- parameters->flags,
- (parameters->index + identifier_index),
+ parameters.flags,
+ (parameters.index + identifier_index),
&object_id);
if (status != FWK_SUCCESS) {
return_values.status = SCMI_NOT_FOUND;
--
2.51.0
All Qualcomm SoCs starting from SM8650 provide access to the Qualcomm
Trusted Execution Environment (QTEE) through the SMCInvoke interface,
implemented by the QCOMTEE driver. QTEE runs in the Secure World domain
on ARM64 CPUs and exposes secure services to Linux running in the Normal
World domain.
This change enables the QCOMTEE driver as a module to support
communication with QTEE.
QCOMTEE has been tested on a Qualcomm RB3Gen2 board by loading and
executing a Trusted Application via tests hosted at
github.com/qualcomm/minkipc.
Signed-off-by: Harshal Dev <harshal.dev(a)oss.qualcomm.com>
---
Changes in v4:
- Updated the commit message as per discussion to clarify the following:
- Why we are enabling QCOMTEE for all arm64 boards.
- From which Qualcomm SoC onwards the driver is applicable.
- What functionality the driver provides.
- How the functionality has been tested and on which board.
- Link to v3: https://lore.kernel.org/r/20251208-qcom_qcomtee_defconfig-v3-1-b50dcf8ab45e…
Changes in v3:
- Updated the commit message to reflect the supported Qualcomm platforms.
- Link to v2: https://lore.kernel.org/r/20251205-qcom_qcomtee_defconfig-v2-1-c92560b0346e…
Changes in v2:
- Updated CONFIG_QCOMTEE flag to 'm' since QCOMTEE can be built as a module.
- Link to v1: https://lore.kernel.org/r/20251202-qcom_qcomtee_defconfig-v1-1-11bfe40a8ea4…
---
arch/arm64/configs/defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index cdb7d69e3b24..e952d24bef77 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1789,6 +1789,7 @@ CONFIG_FPGA_MGR_ZYNQMP_FPGA=m
CONFIG_FPGA_MGR_VERSAL_FPGA=m
CONFIG_TEE=y
CONFIG_OPTEE=y
+CONFIG_QCOMTEE=m
CONFIG_MUX_GPIO=m
CONFIG_MUX_MMIO=y
CONFIG_SLIMBUS=m
---
base-commit: 47b7b5e32bb7264b51b89186043e1ada4090b558
change-id: 20251202-qcom_qcomtee_defconfig-8dc0fed1411b
Best regards,
--
Harshal Dev <harshal.dev(a)oss.qualcomm.com>
Hi,
I've just rebased the linaro-swg/kernel optee branch on v6.18 from
v6.14. By rebasing, we eliminated a few workarounds on the optee
branch and gained FF-A version 1.2 support in the kernel.
Cheers,
Jens
Hello arm-soc maintainers,
Please pull these two patches adding a generic TEE revision sysfs
attribute and implement support for OP-TEE.
Thanks,
Jens
The following changes since commit 8f0b4cce4481fb22653697cced8d0d04027cb1e8:
Linux 6.19-rc1 (2025-12-14 16:05:07 +1200)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee.git tags/tee-sysfs-for-6.20
for you to fetch changes up to c19faf5a62315d5e0e65dde49b7b59e30330b9c2:
tee: optee: store OS revision for TEE core (2026-01-15 10:35:14 +0100)
----------------------------------------------------------------
TEE sysfs for 6.20
- Add an optional generic sysfs attribute for TEE revision
- Implement revision reporting for OP-TEE using both SMC and FF-A ABIs
----------------------------------------------------------------
Aristo Chen (2):
tee: add revision sysfs attribute
tee: optee: store OS revision for TEE core
Documentation/ABI/testing/sysfs-class-tee | 10 ++++++
drivers/tee/optee/core.c | 23 +++++++++++++
drivers/tee/optee/ffa_abi.c | 54 +++++++++++++++++++++++--------
drivers/tee/optee/optee_private.h | 19 +++++++++++
drivers/tee/optee/smc_abi.c | 15 +++++++--
drivers/tee/tee_core.c | 51 ++++++++++++++++++++++++++++-
include/linux/tee_core.h | 9 ++++++
7 files changed, 163 insertions(+), 18 deletions(-)
Hello arm-soc maintainers,
Please pull this small patch removing unused return variables in a
couple of functions in the AMDTEE driver in the TEE subsystem.
Thanks,
Jens
The following changes since commit 8f0b4cce4481fb22653697cced8d0d04027cb1e8:
Linux 6.19-rc1 (2025-12-14 16:05:07 +1200)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee.git tags/amdtee-update-for-6.20
for you to fetch changes up to a0db08f47c836251fbaccf711e12fe8428235465:
tee: amdtee: Remove unused return variables (2026-01-14 10:20:51 +0100)
----------------------------------------------------------------
AMDTEE update for 6.20
Remove unused return variables
----------------------------------------------------------------
Thorsten Blum (1):
tee: amdtee: Remove unused return variables
drivers/tee/amdtee/call.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Hello arm-soc maintainers,
Please pull these updates adding TEE bus callbacks to let the users of
the bus get rid of the struct device_driver callbacks .probe(),
.remove() and .shutdown().
The maintainers for the updated drivers using the TEE bus have agreed to
take these changes via my tree, with the exception of the maintainer for
drivers/firmware/broadcom/tee_bnxt_fw.c, who has remained silent during
the review. However, the changes in the drivers are straight forward so
it's better to take these patches too rather than excluding them.
Further details are in the last patch set:
https://lore.kernel.org/op-tee/cover.1765791463.git.u.kleine-koenig@baylibr…
Thanks,
Jens
The following changes since commit 8f0b4cce4481fb22653697cced8d0d04027cb1e8:
Linux 6.19-rc1 (2025-12-14 16:05:07 +1200)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee.git tags/tee-bus-callback-for-6.20
for you to fetch changes up to e82d0477fd80707221c3d110f56d05506de2698c:
tpm/tpm_ftpm_tee: Fix kdoc after function renames (2026-01-15 10:28:33 +0100)
----------------------------------------------------------------
TEE bus callback for 6.20
- Move from generic device_driver to TEE bus-specific callbacks
- Add module_tee_client_driver() and registration helpers to reduce
boilerplate
- Convert several client drivers (TPM, KEYS, firmware, EFI, hwrng,
and RTC)
- Update documentation and fix kernel-doc warnings
----------------------------------------------------------------
Uwe Kleine-König (18):
tee: Add some helpers to reduce boilerplate for tee client drivers
tee: Add probe, remove and shutdown bus callbacks to tee_client_driver
tee: Adapt documentation to cover recent additions
rtc: optee: Migrate to use tee specific driver registration function
rtc: optee: Make use of tee bus methods
hwrng: optee - Make use of module_tee_client_driver()
hwrng: optee - Make use of tee bus methods
efi: stmm: Make use of module_tee_client_driver()
efi: stmm: Make use of tee bus methods
firmware: arm_scmi: optee: Make use of module_tee_client_driver()
firmware: arm_scmi: Make use of tee bus methods
firmware: tee_bnxt: Make use of module_tee_client_driver()
firmware: tee_bnxt: Make use of tee bus methods
KEYS: trusted: Migrate to use tee specific driver registration function
KEYS: trusted: Make use of tee bus methods
tpm/tpm_ftpm_tee: Make use of tee specific driver registration
tpm/tpm_ftpm_tee: Make use of tee bus methods
tpm/tpm_ftpm_tee: Fix kdoc after function renames
Documentation/driver-api/tee.rst | 18 +-----
drivers/char/hw_random/optee-rng.c | 26 ++-------
drivers/char/tpm/tpm_ftpm_tee.c | 35 ++++++++----
drivers/firmware/arm_scmi/transports/optee.c | 32 ++++-------
drivers/firmware/broadcom/tee_bnxt_fw.c | 30 +++-------
drivers/firmware/efi/stmm/tee_stmm_efi.c | 25 ++-------
drivers/rtc/rtc-optee.c | 27 +++------
drivers/tee/tee_core.c | 84 ++++++++++++++++++++++++++++
include/linux/tee_drv.h | 12 ++++
security/keys/trusted-keys/trusted_tee.c | 17 +++---
10 files changed, 166 insertions(+), 140 deletions(-)