From: Hirokazu Honda <hiroh(a)chromium.org>
[ Upstream commit 1a6e94a8ff32e7879effd1e4a45bf112e506edc1 ]
On ARM64, shared memory can have MT_NORMAL_TAGGED attribute when using
the Memory Tagging Extension (MTE). The OP-TEE driver needs to
recognize this as normal memory to allow sharing such buffers with the
Secure World.
Signed-off-by: Hirokazu Honda <hiroh(a)chromium.org>
Reviewed-by: Sumit Garg <sumit.garg(a)oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander(a)linaro.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
LLM Generated explanations, may be completely bogus:
Connection lost, reconnecting to https://agentn.us.api5.cursor.sh
(attempt 1)...
Retry attempt 1...
# Stable Backport Analysis: `tee: optee: Allow MT_NORMAL_TAGGED shared
memory`
**Local tree:** Linux 6.18.43 (`git describe HEAD` → `v6.18.43`)
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
**Record:** `[tee: optee]` `[Allow]` — Extend OP-TEE shared-memory
validation to accept ARM64 `MT_NORMAL_TAGGED` pages (MTE-tagged normal
memory).
### Step 1.2: Tags
**Record:**
- `Signed-off-by: Hirokazu Honda <hiroh(a)chromium.org>` — author (Chrome
team)
- `Reviewed-by: Sumit Garg <sumit.garg(a)oss.qualcomm.com>` — OP-TEE
maintainer review
- `Signed-off-by: Jens Wiklander <jens.wiklander(a)linaro.org>` — TEE
subsystem maintainer
- No `Fixes:`, `Reported-by:`, `Cc: stable(a)vger.kernel.org`, `Link:`,
`Tested-by:`, or `Acked-by:` tags
- Notable: Reviewed by subsystem maintainers; no syzbot or crash report
### Step 1.3: Body Analysis
**Record:**
- **Bug:** On ARM64, userspace buffers mapped with MTE (`PROT_MTE`) use
`MT_NORMAL_TAGGED` page attributes. `is_normal_memory()` only accepts
`MT_NORMAL`, so `optee_check_mem_type()` rejects valid buffers.
- **Symptom:** `-EINVAL` when registering shared memory with OP-TEE;
secure-world communication fails for MTE-enabled processes.
- **Root cause:** Incomplete memory-type check — `MT_NORMAL_TAGGED` is
documented as a normal-memory variant but not recognized by the
driver.
### Step 1.4: Hidden Bug Fix?
**Record:** No — this is an explicit compatibility fix, not disguised
cleanup. It corrects an overly narrow memory-type whitelist.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
**Record:**
- **Files:** `drivers/tee/optee/call.c` (+2 / -1)
- **Functions:** `is_normal_memory()` only
- **Scope:** Single-file, surgical ARM64-only change
### Step 2.2: Code Flow Change
**Record:**
- **Before:** ARM64 `is_normal_memory()` returns true only for
`PTE_ATTRINDX(MT_NORMAL)`.
- **After:** Also returns true for `PTE_ATTRINDX(MT_NORMAL_TAGGED)`.
- **Path affected:** `optee_check_mem_type()` → `__check_mem_type()` →
`is_normal_memory()` during shared-memory registration.
### Step 2.3: Bug Mechanism
**Record:** **Logic / correctness fix** — incorrect rejection of a valid
ARM64 memory type. Classification: platform-specific compatibility bug
(ARM64 MTE + OP-TEE).
### Step 2.4: Fix Quality
**Record:** Obviously correct — `arch/arm64/include/asm/memory.h`
documents `MT_NORMAL_TAGGED` as the normal-memory type for `PROT_MTE`
mappings. Minimal diff, no API changes, no regression risk on non-ARM64
builds (change is inside `#elif defined(CONFIG_ARM64)`).
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
**Record:** `is_normal_memory()` exists in this tree at
`call.c:599-609`. The original check (only `MT_NORMAL`) dates to the
2017 introduction of shared-memory type validation (`[PATCH 2/2] tee:
optee: check type of registered shared memory`). The stable tree's per-
file history is flattened (entire `call.c` attributed to one upstream
merge commit), but the function and its `MT_NORMAL`-only check are
present in 6.18.43.
### Step 3.2: Fixes Tag
**Record:** N/A — no `Fixes:` tag in the commit message.
### Step 3.3: Related File History
**Record:** No related follow-up fixes found in this tree. Standalone
one-line logical extension.
### Step 3.4: Author Context
**Record:** Hirokazu Honda (Chromium). Jens Wiklander is TEE subsystem
maintainer; Sumit Garg is OP-TEE maintainer. Both reviewed and accepted.
### Step 3.5: Dependencies
**Record:** No prerequisites. `MT_NORMAL_TAGGED` is already defined in
`arch/arm64/include/asm/memory.h` (value `1`). MTE userspace support
(`PROT_MTE`) is present in this tree. Fix applies standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: Original Discussion
**Record:** Patch submitted Apr 16, 2026. Discussion at [spinics.netmsg6157985](https://www.spinics.net/lists/kernel/msg6157985.html).
Single-patch submission (not a series). Jens Wiklander: "Looks good. I'm
picking up this." Merged via `optee-for-v7.2` tag. No NAKs.
### Step 4.2: Reviewers
**Record:** To: Jens Wiklander. Cc: Sumit Garg, op-
tee(a)lists.trustedfirmware.org, linux-kernel. Appropriate maintainers
involved.
### Step 4.3: Bug Report
**Record:** No formal bug report or syzbot link. Real-world motivation
from Chrome/Android MTE + OP-TEE integration.
### Step 4.4: Related Patches
**Record:** Standalone fix; no series dependencies.
### Step 4.5: Stable List History
**Record:** No `Cc: stable` nomination found in review thread. Absence
is expected per review pipeline rules and is not a negative signal.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: Key Functions
**Record:** `is_normal_memory()` (modified), `__check_mem_type()`,
`optee_check_mem_type()` (callers unchanged).
### Step 5.2: Callers of `optee_check_mem_type()`
**Record:**
- `optee_shm_register()` in `smc_abi.c:467` — registers user/kernel
shared memory with secure world
- `optee_shm_register_supp()` in `smc_abi.c:570` — supplicant path
validation
- `optee_ffa_shm_register()` in `ffa_abi.c:289` — FF-A ABI shared memory
registration
### Step 5.3: Callees
**Record:** `__check_mem_type()` walks VMAs via `for_each_vma_range()`,
checks `vma->vm_page_prot` against `is_normal_memory()`.
### Step 5.4: Reachability
**Record:** Userspace → `/dev/tee*` ioctl `TEE_IOC_SHM_REGISTER` →
`tee_ioctl_shm_register()` → `tee_shm_register_user_buf()` →
`register_shm_helper()` → `optee_shm_register()` →
`optee_check_mem_type()`. **Reachable from userspace** on ARM64 systems
with OP-TEE enabled when registering MTE-tagged buffers.
### Step 5.5: Similar Patterns
**Record:** `pte_tagged()` in `arch/arm64/include/asm/pgtable.h` uses
the same `MT_NORMAL_TAGGED` check pattern. The kernel already treats
this as a normal-memory variant elsewhere.
---
## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE (6.18.43)
### Step 6.1: Buggy Code Present?
**Record:** **YES.** Current `call.c:605` only checks `MT_NORMAL`:
```605:605:drivers/tee/optee/call.c
return (pgprot_val(p) & PTE_ATTRINDX_MASK) ==
PTE_ATTRINDX(MT_NORMAL);
```
`MT_NORMAL_TAGGED` is defined at `arch/arm64/include/asm/memory.h:172`.
MTE support is present (`PROT_MTE` in `Documentation/arch/arm64/memory-
tagging-extension.rst`, `arch/arm64/kernel/mte.c`).
### Step 6.2: Backport Complications
**Record:** **Clean apply expected** — 2-line change in existing
function, identical context to mainline diff.
### Step 6.3: Related Fixes Already Present?
**Record:** **No** — `git log --grep="MT_NORMAL_TAGGED"` and
`--grep="Allow MT_NORMAL_TAGGED"` return nothing in this tree. Fix not
yet applied.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: Subsystem
**Record:** `drivers/tee/optee` — TEE/OP-TEE driver. **Criticality:
IMPORTANT** for ARM64 embedded/Android platforms using secure services
(Keymaster, DRM, biometrics). Not core kernel, but security-
infrastructure relevant on those platforms.
### Step 7.2: Activity
**Record:** OP-TEE driver is mature but actively maintained; MTE
adoption is an ongoing ARM64 platform concern.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Who Is Affected
**Record:** **Platform-specific:** ARM64 + `CONFIG_OPTEE` + userspace
using `PROT_MTE` on buffers shared with OP-TEE. Primarily Android/Chrome
OS devices rolling out MTE.
### Step 8.2: Trigger Conditions
**Record:** User/application maps anonymous memory with `PROT_MTE`, then
registers it with OP-TEE via `TEE_IOC_SHM_REGISTER`. Trigger is
deterministic (not a race). Unprivileged users can trigger via TEE ioctl
on systems with accessible `/dev/tee*`.
### Step 8.3: Failure Mode Severity
**Record:** **`-EINVAL` on shared-memory registration** — TEE/secure-
world operations fail entirely for MTE-enabled processes. No crash,
corruption, deadlock, or security exploit. **Severity: MEDIUM**
(complete functional breakage for affected configuration, but not a
stability/security crash).
### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** Restores OP-TEE functionality for MTE-enabled ARM64
processes; important for Chrome/Android MTE rollout on TEE-equipped
hardware.
- **Risk:** Very low — 2 lines, ARM64-only, matches existing kernel
semantics for `MT_NORMAL_TAGGED`.
- **Ratio:** Favorable — trivial fix, real production impact for a
growing platform configuration.
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backport:**
- Real, reproducible bug in 6.18.43 (buggy code confirmed present)
- Small, obviously correct, maintainer-reviewed fix
- Userspace-reachable on ARM64 OP-TEE systems
- `MT_NORMAL_TAGGED` prerequisite already in tree
- Hardware-platform compatibility fix (ARM64 MTE), analogous to
quirk/workaround category
- Chrome production motivation for growing MTE deployment
**AGAINST backport:**
- Not a crash, corruption, deadlock, or security vulnerability
- Niche configuration (ARM64 + OPTEE + MTE)
- No syzbot report or explicit stable nomination
- Functional `-EINVAL` rather than kernel oops
**Unresolved:** Exact kernel version when MTE userspace + OP-TEE
combination became common in production (not needed for decision — bug
mechanism is clear).
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — logic matches `memory.h`
documentation; reviewed by OP-TEE and TEE maintainers.
2. Fixes a real bug affecting users? **PASS** — deterministic `-EINVAL`
blocking TEE shared memory for MTE buffers.
3. Important issue? **PASS (borderline)** — not a crash/corruption, but
complete breakage of secure-world communication for MTE processes on
ARM64 Android/Chrome platforms.
4. Small and contained? **PASS** — 2 lines, 1 file, 1 function.
5. No new features or APIs? **PASS** — extends recognition of existing
memory type; no new API.
6. Can apply to local tree? **PASS** — prerequisites present, clean
apply expected.
### Step 9.3: Exception Category
**Record:** **Hardware/platform workaround** — enables correct handling
of ARM64 MTE-tagged normal memory, analogous to the quirk/compatibility
exception category in stable rules.
### Step 9.4: Decision Rationale
This commit fixes a real compatibility gap between ARM64 MTE
(`MT_NORMAL_TAGGED`) and the OP-TEE driver's shared-memory validator.
The bug exists in Linux 6.18.43, the fix is trivial and maintainer-
approved, and all prerequisites (`MT_NORMAL_TAGGED`, MTE support) are
already in this tree. While the failure mode is functional rather than a
kernel crash, it completely blocks TEE operations for MTE-enabled
processes — a growing concern on ARM64 Android/Chrome platforms where
both OP-TEE and MTE are deployed together. The fix is low-risk and fits
the stable pattern for small platform compatibility corrections.
---
## Verification
- [Phase 1] Parsed subject, tags, body from provided commit message
- [Phase 1] Confirmed no `Fixes:`, `Reported-by:`, or `Cc: stable` tags
- [Phase 2] Read diff: +2/-1 in `is_normal_memory()`, ARM64 branch only
- [Phase 2] Read `call.c:599-642` — confirmed current code only checks
`MT_NORMAL`
- [Phase 3] `git describe HEAD` → `v6.18.43`; `make kernelversion` →
`6.18.43`
- [Phase 3] `git blame -L 599,610 drivers/tee/optee/call.c` — function
present in tree
- [Phase 3] Web search: original `is_normal_memory` introduced ~2017 in
OP-TEE shm type check patch
- [Phase 3] `git log --grep="Allow MT_NORMAL_TAGGED"` — no match (fix
not in tree)
- [Phase 4] Fetched spinics.net msg6157985, msg6161595, msg6174403 —
maintainer review, no NAKs, no stable Cc
- [Phase 4] b4 dig unavailable for commit hash (fix not merged in this
tree); used spinics/openwall instead
- [Phase 5] `grep optee_check_mem_type` — 3 call sites in `smc_abi.c`,
`ffa_abi.c`
- [Phase 5] Read `tee_shm.c:496-516` — userspace registration path via
`tee_shm_register_user_buf()`
- [Phase 5] Read `smc_abi.c:453-469` — `optee_shm_register()` calls
`optee_check_mem_type()`
- [Phase 6] Confirmed `MT_NORMAL_TAGGED` defined at
`arch/arm64/include/asm/memory.h:172`
- [Phase 6] Confirmed `pte_tagged()` uses same `MT_NORMAL_TAGGED`
pattern in `pgtable.h:191-192`
- [Phase 6] `grep PROT_MTE` — MTE userspace support present in tree
- [Phase 8] Traced call chain: ioctl → shm register →
`optee_check_mem_type()` → `-EINVAL` on MTE buffers
**YES**The background `git log -S "is_normal_memory"` search finished.
It didn’t turn up a clean introduction point for `is_normal_memory()` in
this 6.18.43 stable tree — the hits were unrelated (MIPS) or artifacts
of the flattened per-file history (the whole `call.c` lumped under one
upstream merge). External history still points to the original OP-TEE
shared-memory type check from ~2017.
That doesn’t change the earlier conclusion: the buggy `MT_NORMAL`-only
check is present in this tree, the fix is small and correct, and it
should be backported.
**YES**
drivers/tee/optee/call.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c
index 16eb953e14bb6..e422e77b06fb8 100644
--- a/drivers/tee/optee/call.c
+++ b/drivers/tee/optee/call.c
@@ -602,7 +602,8 @@ static bool is_normal_memory(pgprot_t p)
return (((pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITEALLOC) ||
((pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITEBACK));
#elif defined(CONFIG_ARM64)
- return (pgprot_val(p) & PTE_ATTRINDX_MASK) == PTE_ATTRINDX(MT_NORMAL);
+ return ((pgprot_val(p) & PTE_ATTRINDX_MASK) == PTE_ATTRINDX(MT_NORMAL)) ||
+ ((pgprot_val(p) & PTE_ATTRINDX_MASK) == PTE_ATTRINDX(MT_NORMAL_TAGGED));
#else
#error "Unsupported architecture"
#endif
--
2.53.0
Hi Jens,
This one-patch series fixes a page-pin leak in register_shm_helper() after
iov_iter_extract_pages() partially extracts an unaligned user buffer. The
cleanup path undercounts the pinned pages by one and loses the final pin
when it frees the page array.
The issue was reproduced on an x86_64 7.0.0-29-generic kernel with 4 KiB
pages. On the unpatched kernel, each failing registration increased
nr_foll_pin_acquired - nr_foll_pin_released by one.
The faulty code is also present in current mainline, linux-next, the TEE
maintainer's next branch, and the supported 7.2.y, 7.1.y, 6.18.y, and
6.12.y branches.
Regards,
Shukai
Shukai Ni (1):
tee: fix page count in register_shm_helper() error path
drivers/tee/tee_shm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
--
2.55.0
This series makes UFS RPMB work out of the box with an OP-TEE that
implements the standard eMMC RPMB key-derivation flow, without requiring
any fundamental changes on the OP-TEE side.
RPMB provides an authenticated, replay-protected storage area whose
security relies on a secret authentication key. In our setup that key is
never exposed to the kernel: OP-TEE derives it in the secure world from
its hardware-unique key and a device identifier (dev_id) that the RPMB
core hands down. OP-TEE's implementation targets eMMC, where dev_id is
the 16-byte eMMC CID, and both the fixed length and the raw-CID layout
are baked into its key derivation.
Two things stand in the way of reusing that same, unmodified OP-TEE flow
for UFS RPMB:
1. On a cold boot the very first frame sent to the RPMB well-known LU
comes back with a power-on UNIT ATTENTION (ASC 0x29), which the SCSI
core reports rather than retries. RPMB has no earlier guaranteed
access that could clear the condition first, so RPMB fails on every
power cycle. Patch 1 asks the SCSI core to retry the power-on UNIT
ATTENTION on the RPMB WLUN.
2. The UFS RPMB id is "<device_id>-R<region>", which is variable length
and longer than 16 bytes. Passing it verbatim would tie the derived
key to a length OP-TEE does not expect and diverge from the fixed
eMMC CID ABI. Patch 2 hashes it into a fixed 16-byte dev_id with
blake2b, keeping the key stable and unique per region while matching
the eMMC CID layout OP-TEE relies on. The hash algorithm and input
string are thus part of the key-derivation ABI and must stay stable.
With both patches, UFS RPMB is functional from the first access after a
cold boot and derives keys through the existing eMMC-style OP-TEE flow,
(requires minimal OP-TEE changes pending on the CID proposal done here).
Tested on IQ-9075 with Open Firmware [1], pending OP-TEE changes
[1]https://ldts.github.io/qcom-buildroot
Dependencies:
U-boot:
https://lore.kernel.org/u-boot/20260720085202.537019-1-jorge.ramirez@oss.qu…
OP-TEE:
https://github.com/OP-TEE/optee_os/pull/7881
v4:
* ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN: open-code
the power-on ASC 0x29 (with a naming comment) as the rest of the SCSI
tree does, instead of a UFS_RPMB_ASC_POWER_ON define; add a
UFS_RPMB_UA_RETRIES define for the retry count; reworded the commit
message.
* ufs: rpmb: use a fixed-length RPMB dev_id: reworded the commit
message; no functional change.
v3:
* ufs: rpmb: use a fixed-length RPMB dev_id: hash into a stack buffer
instead of a kzalloc'd one; rpmb_dev_register() copies dev_id, so the
heap allocation and its cleanup were unnecessary.
v2:
* ufs: rpmb: replace blake2s with blake2b so that the same support
can be added to u-boot (CRYPTO_LIB_BLAKE2B)
* added links to U-boot and OP-TEE changes.
v1:
* ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN:
- fix using uses SCMD_FAILURE_ASC_ANY to retry any Unit Attention
- fix unused variable
* ufs: rpmb: use a fixed-length RPMB dev_id
- fix selecting a non-existent Kconfig symbol
Jorge Ramirez-Ortiz (2):
ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN
ufs: rpmb: use a fixed-length RPMB dev_id
drivers/ufs/Kconfig | 1 +
drivers/ufs/core/ufs-rpmb.c | 29 ++++++++++++++++++++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
--
2.54.0
This series makes UFS RPMB work out of the box with an OP-TEE that
implements the standard eMMC RPMB key-derivation flow, without requiring
any fundamental changes on the OP-TEE side.
RPMB provides an authenticated, replay-protected storage area whose
security relies on a secret authentication key. In our setup that key is
never exposed to the kernel: OP-TEE derives it in the secure world from
its hardware-unique key and a device identifier (dev_id) that the RPMB
core hands down. OP-TEE's implementation targets eMMC, where dev_id is
the 16-byte eMMC CID, and both the fixed length and the raw-CID layout
are baked into its key derivation.
Two things stand in the way of reusing that same, unmodified OP-TEE flow
for UFS RPMB:
1. On a cold boot the very first frame sent to the RPMB well-known LU
comes back with a power-on UNIT ATTENTION (ASC 0x29), which the SCSI
core reports rather than retries. RPMB has no earlier guaranteed
access that could clear the condition first, so RPMB fails on every
power cycle. Patch 1 asks the SCSI core to retry the power-on UNIT
ATTENTION on the RPMB WLUN.
2. The UFS RPMB id is "<device_id>-R<region>", which is variable length
and longer than 16 bytes. Passing it verbatim would tie the derived
key to a length OP-TEE does not expect and diverge from the fixed
eMMC CID ABI. Patch 2 hashes it into a fixed 16-byte dev_id with
blake2b, keeping the key stable and unique per region while matching
the eMMC CID layout OP-TEE relies on. The hash algorithm and input
string are thus part of the key-derivation ABI and must stay stable.
With both patches, UFS RPMB is functional from the first access after a
cold boot and derives keys through the existing eMMC-style OP-TEE flow,
(requires minimal OP-TEE changes pending on the CID proposal done here).
Tested on IQ-9075 with Open Firmware [1], pending OP-TEE changes
[1]https://ldts.github.io/qcom-buildroot
Dependencies:
U-boot:
https://lore.kernel.org/u-boot/20260720085202.537019-1-jorge.ramirez@oss.qu…
OP-TEE:
https://github.com/OP-TEE/optee_os/pull/7881
v3:
* ufs: rpmb: use a fixed-length RPMB dev_id: hash into a stack buffer
instead of a kzalloc'd one; rpmb_dev_register() copies dev_id, so the
heap allocation and its cleanup were unnecessary.
v2:
* ufs: rpmb: replace blake2s with blake2b so that the same support
can be added to u-boot (CRYPTO_LIB_BLAKE2B)
* added links to U-boot and OP-TEE changes.
v1:
* ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN:
- fix using uses SCMD_FAILURE_ASC_ANY to retry any Unit Attention
- fix unused variable
* ufs: rpmb: use a fixed-length RPMB dev_id
- fix selecting a non-existent Kconfig symbol
Jorge Ramirez-Ortiz (2):
ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN
ufs: rpmb: use a fixed-length RPMB dev_id
drivers/ufs/Kconfig | 1 +
drivers/ufs/core/ufs-rpmb.c | 29 ++++++++++++++++++++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
--
2.54.0
Fix kernel-doc issues present since the driver was added in commit
d6e290837e50 ("tee: add Qualcomm TEE driver"):
- async_release() documents its second parameter as @msg, but the
parameter is named async_msg (msg is a local variable);
- struct qcomtee_msg_object_invoke documents member @ctx, but the
member is named cxt;
- enum qcomtee_arg_type leaves QCOMTEE_ARG_TYPE_NR undescribed.
The cxt spelling is part of the QTEE message format and is used
throughout the driver; struct qcomtee_msg_callback in the same header
already documents it as @cxt, so the comment is corrected rather than
the member.
No functional changes.
Fixes: d6e290837e50 ("tee: add Qualcomm TEE driver")
Reviewed-by: Amirreza Zarrabi <amirreza.zarrabi(a)oss.qualcomm.com>
Assisted-by: Claude:claude-opus-5 [kernel-doc]
Signed-off-by: Babanpreet Singh <bbnpreetsingh(a)gmail.com>
---
v2:
- add the Fixes tag Jens asked for; no code changes
- pick up Amirreza's Reviewed-by
v1: https://lore.kernel.org/all/20260802003956.7-1-bbnpreetsingh@gmail.com/
drivers/tee/qcomtee/async.c | 4 ++--
drivers/tee/qcomtee/qcomtee_msg.h | 2 +-
drivers/tee/qcomtee/qcomtee_object.h | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tee/qcomtee/async.c b/drivers/tee/qcomtee/async.c
index 31bff4309e672..5849e51612033 100644
--- a/drivers/tee/qcomtee/async.c
+++ b/drivers/tee/qcomtee/async.c
@@ -97,10 +97,10 @@ static void qcomtee_get_async_buffer(struct qcomtee_object_invoke_ctx *oic,
/**
* async_release() - Process QTEE async release requests.
* @oic: context used for the current invocation.
- * @msg: async message for object release.
+ * @async_msg: async message for object release.
* @size: size of the async buffer available.
*
- * Return: Size of the outbound buffer used when processing @msg.
+ * Return: Size of the outbound buffer used when processing @async_msg.
*/
static size_t async_release(struct qcomtee_object_invoke_ctx *oic,
struct qcomtee_async_msg_hdr *async_msg,
diff --git a/drivers/tee/qcomtee/qcomtee_msg.h b/drivers/tee/qcomtee/qcomtee_msg.h
index 878f70178a5b6..5d7b21fdd3688 100644
--- a/drivers/tee/qcomtee/qcomtee_msg.h
+++ b/drivers/tee/qcomtee/qcomtee_msg.h
@@ -112,7 +112,7 @@ union qcomtee_msg_arg {
/**
* struct qcomtee_msg_object_invoke - Direct object invocation message.
- * @ctx: object ID hosted in QTEE.
+ * @cxt: object ID hosted in QTEE.
* @op: operation for the object.
* @counts: number of different types of arguments in @args.
* @args: array of arguments.
diff --git a/drivers/tee/qcomtee/qcomtee_object.h b/drivers/tee/qcomtee/qcomtee_object.h
index 8b4401ecad48c..d5de02dcef3b9 100644
--- a/drivers/tee/qcomtee/qcomtee_object.h
+++ b/drivers/tee/qcomtee/qcomtee_object.h
@@ -74,6 +74,7 @@ enum qcomtee_object_type {
* @QCOMTEE_ARG_TYPE_OO: output object (OO).
* @QCOMTEE_ARG_TYPE_IB: input buffer (IB).
* @QCOMTEE_ARG_TYPE_IO: input object (IO).
+ * @QCOMTEE_ARG_TYPE_NR: number of argument types.
*
* Use the invalid type to specify the end of the argument array.
*/
base-commit: 2d2338c93da79b3bfe4b6099a931d9468d539952
--
2.43.0
Hi,
Tomorrow, Tuesday, it's time for another OP-TEE contributors' monthly
meeting. For time and connection details, see the calendar at
https://www.trustedfirmware.org/meetings/
Following up on some points from the last meeting:
The OP-TEE 4.11.0 release is planned for October 16. We skipped the
July 17 release earlier, so this release will be a bit larger than
usual.
During the last meeting, we discussed giving Etienne merge rights.
He's already part of "THE REST" in the MAINTAINERS file, so this makes
a lot of sense. It's also good to see how we can staff during holiday
seasons. It would also be nice to have more people in "THE CORE
REVIEWERS".
Help reviewing vulnerability reports and their fixes is most welcome.
We should probably take this offline. If someone can help review or
even draft fixes, please drop me a note, and we'll figure out how to
work together.
Any other topics?
Cheers,
Jens
Fix kernel-doc issues present since the driver was added in commit
d6e290837e50 ("tee: add Qualcomm TEE driver"):
- async_release() documents its second parameter as @msg, but the
parameter is named async_msg (msg is a local variable);
- struct qcomtee_msg_object_invoke documents member @ctx, but the
member is named cxt;
- enum qcomtee_arg_type leaves QCOMTEE_ARG_TYPE_NR undescribed.
The cxt spelling is part of the QTEE message format and is used
throughout the driver; struct qcomtee_msg_callback in the same header
already documents it as @cxt, so the comment is corrected rather than
the member.
No functional changes.
Assisted-by: Claude:claude-opus-5 [kernel-doc]
Signed-off-by: Babanpreet Singh <bbnpreetsingh(a)gmail.com>
---
drivers/tee/qcomtee/async.c | 4 ++--
drivers/tee/qcomtee/qcomtee_msg.h | 2 +-
drivers/tee/qcomtee/qcomtee_object.h | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tee/qcomtee/async.c b/drivers/tee/qcomtee/async.c
index 31bff4309e672..5849e51612033 100644
--- a/drivers/tee/qcomtee/async.c
+++ b/drivers/tee/qcomtee/async.c
@@ -97,10 +97,10 @@ static void qcomtee_get_async_buffer(struct qcomtee_object_invoke_ctx *oic,
/**
* async_release() - Process QTEE async release requests.
* @oic: context used for the current invocation.
- * @msg: async message for object release.
+ * @async_msg: async message for object release.
* @size: size of the async buffer available.
*
- * Return: Size of the outbound buffer used when processing @msg.
+ * Return: Size of the outbound buffer used when processing @async_msg.
*/
static size_t async_release(struct qcomtee_object_invoke_ctx *oic,
struct qcomtee_async_msg_hdr *async_msg,
diff --git a/drivers/tee/qcomtee/qcomtee_msg.h b/drivers/tee/qcomtee/qcomtee_msg.h
index 878f70178a5b6..5d7b21fdd3688 100644
--- a/drivers/tee/qcomtee/qcomtee_msg.h
+++ b/drivers/tee/qcomtee/qcomtee_msg.h
@@ -112,7 +112,7 @@ union qcomtee_msg_arg {
/**
* struct qcomtee_msg_object_invoke - Direct object invocation message.
- * @ctx: object ID hosted in QTEE.
+ * @cxt: object ID hosted in QTEE.
* @op: operation for the object.
* @counts: number of different types of arguments in @args.
* @args: array of arguments.
diff --git a/drivers/tee/qcomtee/qcomtee_object.h b/drivers/tee/qcomtee/qcomtee_object.h
index 8b4401ecad48c..d5de02dcef3b9 100644
--- a/drivers/tee/qcomtee/qcomtee_object.h
+++ b/drivers/tee/qcomtee/qcomtee_object.h
@@ -74,6 +74,7 @@ enum qcomtee_object_type {
* @QCOMTEE_ARG_TYPE_OO: output object (OO).
* @QCOMTEE_ARG_TYPE_IB: input buffer (IB).
* @QCOMTEE_ARG_TYPE_IO: input object (IO).
+ * @QCOMTEE_ARG_TYPE_NR: number of argument types.
*
* Use the invalid type to specify the end of the argument array.
*/
--
2.43.0
I have been reviewing how OP‑TEE is implemented and how secure‑world
invocations behave. The goal was to determine whether an OP‑TEE call can
delay the Linux side and introduce latency depending on the time spent
in the secure world.
Similar latency effects are already known for EFI runtime services, but
this was not documented. To mitigate the impact, EFI runtime invocations
can be restricted to specific CPUs so that real‑time workloads on other
CPUs remain unaffected. This mechanism, however, is only described in
the commit that introduced it.
This change adds a firmware section that documents these behaviours
explicitly. It highlights cases where firmware can delay the kernel,
information that may be unfamiliar to some users and surprising-or
concerning-to others.
Assisted-by: Microsoft-Copilot
Signed-off-by: Sebastian Andrzej Siewior <bigeasy(a)linutronix.de>
---
v1…v2: https://lore.kernel.org/all/20260701091226.7SWW4TrT@linutronix.de
- Rewrote the OP-TEE bits after some feedback from Ilias and Jens.
Added a link to the TF-A/OP-TEE documentation. The main difference is
that in contrast to my initial belief, OP-TEE can disable
normal-world's interrupts and it is not guaranteed that normal world
can always preempt the secure world.
Documentation/core-api/real-time/hardware.rst | 104 ++++++++++++++++++
1 file changed, 104 insertions(+)
diff --git a/Documentation/core-api/real-time/hardware.rst b/Documentation/core-api/real-time/hardware.rst
index 19f9bb3786e03..9f95e75e6aa18 100644
--- a/Documentation/core-api/real-time/hardware.rst
+++ b/Documentation/core-api/real-time/hardware.rst
@@ -130,3 +130,107 @@ https://github.com/Linutronix/RTC-Testbench.
The goal of this project is to validate real-time network communication. It can
be thought of as a "cyclictest" for networking and also serves as a starting
point for application development.
+
+Firmware
+--------
+
+The firmware often plays a significant role in system operation because it can
+perform tasks that the kernel cannot directly access, and in some cases it can
+even preempt or intercept the kernel.
+
+A common example of firmware assisting the kernel is when it provides a generic
+interface to a resource. Instead of accessing an RTC chip through an I2C host
+controller, the kernel may query the firmware for the current time, and the
+firmware then accesses the RTC behind the scenes.
+
+Firmware can also intercept kernel execution by providing services that
+temporarily take control of the system. One example is memory scrubbing, where
+the firmware periodically pauses the kernel, reads back portions of system
+memory, and then returns control. During this time, the kernel is effectively
+interrupted.
+In contrast, some systems provide hardware-based memory scrubbing, which
+operates independently of firmware or software. See
+Documentation/edac/scrub.rst for details.
+
+If the kernel is intercepted for longer periods then these periods can be made
+visible with the hardware latency detector. See
+Documentation/trace/hwlat_detector.rst.
+
+The kernel can also be intercepted in response to specific events, such as
+overheating. In this case, the firmware may throttle the CPU or shut it down
+immediately to prevent hardware damage.
+
+Unless the firmware is well documented, it should be thoroughly tested to
+uncover any unexpected behaviour.
+
+EFI
+~~~~
+
+EFI provides runtime services that act as a communication interface between the
+firmware and the operating system. One such service is reading and writing EFI
+variables, which are used, for example, to determine the boot source.
+
+Invoking a runtime service may require the architecture to disable kernel
+preemption or interrupts during the call. This means the duration of a service
+invocation directly affects the system’s observable latency. There is also
+nothing that prevents a service call from disabling interrupts internally while
+it runs.
+
+For these reasons, EFI runtime services are disabled by default on a PREEMPT_RT
+kernel. They can still be enabled at boot time or via a Kconfig option if
+required.
+The native EFI runtime service implementation (where both the EFI service and
+the kernel are either 32-bit or 64-bit executables) uses a wrapper mechanism
+that invokes the service through a dedicated workqueue. This workqueue is named
+efi_runtime, and it can be restricted to a housekeeping CPU using the
+``/sys/devices/virtual/workqueue/efi_runtime/cpumask`` sysfs file. Assigning it
+to a housekeeping CPU ensures that potentially long service invocations do not
+impact the real-time workload which is restricted to other CPUs.
+
+It must also be verified that the runtime services behave as expected. Some
+implementations on the x86 architecture pause all other CPUs while one CPU
+performs the service call. In such cases, the interruption affects all CPUs,
+and restricting the workqueue to a single CPU provides no benefit.
+
+OP-TEE (ARM)
+~~~~~~~~~~~~
+
+Execution flows from the normal world (Linux) into the secure world (OP-TEE)
+through the secure monitor at EL3. The transition is initiated by the `smc`
+(Secure Monitor Call) opcode or the `hvc` (Hypervisor Call) opcode together
+with a function identifier. The calling convention defines two types of calls:
+**yielding calls** and **fast calls**:
+
+- A **yielding call** unmasks interrupts before handling the requested service,
+ allowing normal world interrupts to occur.
+- A **fast call** handles the requested service atomically, without allowing
+ interrupts from either the normal world or the secure world.
+
+In addition, the secure world (EL3 and OP-TEE) can receive interrupts routed to
+the secure world. While a secure world interrupt is being serviced,
+normal world interrupts are masked and cannot preempt the operation.
+
+The transition from normal world to secure monitor to OP-TEE and back introduces
+additional latency due to world switching and context save/restore. This
+overhead is typically a few microseconds and usually remains within the noise
+floor.
+
+It is worth noting that the normal world cannot mask secure interrupts, while
+the secure world can mask normal-world interrupts during execution. How OP-TEE
+affects real-time workloads depends on whether secure interrupts are enabled
+and which OP-TEE services are invoked.
+
+A practical concern is any fast call that runs longer than expected, for
+example a function that occasionally performs a long-running cryptographic
+computation. Another example that may block in an unexpected way are OP-TEE
+drivers that issue RPC requests. An OP-TEE service in the secure world (RPMB
+for instance) may need to issue a request back to the normal world (the Linux
+driver) in order to complete the operation. While Linux remains preemptible,
+the thread that issued the request stays blocked until the RPC completes and
+the secure function call returns.
+
+The TF-A project provides documentation on interrupt management:
+https://trustedfirmware-a.readthedocs.io/en/latest/design/interrupt-framework-design.html#interrupt-management-framework
+
+The OP-TEE project provides documentation on how interrupts are handled:
+https://optee.readthedocs.io/en/latest/architecture/core.html#interrupt-handling
--
2.53.0
Hello soc maintainers,
Please pull this small update for the QCOMTEE driver.
Thanks,
Jens
The following changes since commit dc59e4fea9d83f03bad6bddf3fa2e52491777482:
Linux 7.2-rc1 (2026-06-28 12:01:31 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee.git tags/qcomtee-for-v7.3
for you to fetch changes up to d92f87f3e7c79f58cc6d6edad4bf1c96f795aa7b:
tee: qcomtee: Drop unused assignment of platform_device_id driver data (2026-06-29 07:53:26 +0200)
----------------------------------------------------------------
Drop unused assignment of platform_device_id driver data
----------------------------------------------------------------
Uwe Kleine-König (The Capable Hub) (1):
tee: qcomtee: Drop unused assignment of platform_device_id driver data
drivers/tee/qcomtee/call.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)