From: Haozhen Li <dezige131@foxmail.com>
To: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: "Abel Vesa" <abelvesa@kernel.org>,
"Dawid Wróbel" <me@dawidwrobel.com>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
"Haozhen Li" <dezige131@foxmail.com>
Subject: [RFC PATCH 0/2] firmware: qcom: scm: QSEECOM app loading and listener support
Date: Sun, 1 Nov 2026 16:01:07 +0000 [thread overview]
Message-ID: <tencent_123976BCEABEFB4C0F5CE28BCAA346A72405@qq.com> (raw)
The QSEECOM interface in qcom_scm.c currently only supports interacting
with pre-loaded trusted applications via qcom_scm_qseecom_app_get_id() and
qcom_scm_qseecom_app_send(). It lacks support for loading applications at
runtime, unloading them, and servicing normal-world listener requests.
When an application requires normal-world interaction, the SMC returns
QSEECOM_RESULT_INCOMPLETE. Currently, qcom_scm_qseecom_call() issues a
WARN_ON() and returns 0 on incomplete calls, leaving the application
blocked in TrustZone and rendering subsequent QSEECOM calls unresponsive
(-EBUSY). This behavior is the primary reason the driver currently relies
on a machine allowlist (qcom_scm_qseecom_allowlist).
Design rationale:
Currently, QSEECOM expects apps to be pre-loaded by early bootloaders.
However, runtime loading via APP_START is required for modular devices
and trusted applications (e.g. fingerprint) whose lifecycles are tied to
user-space daemons or loadable drivers. Furthermore, dynamic loading and
unloading frees secure-world memory when the app is idle. We believe
providing qcom_scm_qseecom_app_load() and shutdown() within qcom_scm is
the least intrusive way to expose this firmware capability, but feedback
on whether this belongs here or should eventually hook into a higher-level
tee subsystem is very welcome.
This series implements the missing app-manager and listener commands:
Patch 1 adds qcom_scm_qseecom_app_load() and
qcom_scm_qseecom_app_shutdown() using the APP_START and APP_SHUTDOWN SMC
commands. It supports both split (.mdt) and single signed ELF images, and
enforces a <4 GiB physical address check required by the 32-bit SMC32
arguments.
Patch 2 introduces listener registration and request handling. During an
incomplete call, qcom_scm_qseecom_call() dispatches the request to the
registered listener callback and returns the result via LISTENER_RESPONSE.
An iteration limit prevents indefinite blocking in case of misbehaving
applications. The listener shared buffer is conservatively required to lie
entirely below 4 GiB, mirroring the image constraint of patch 1.
Removing the machine allowlist is deferred to follow-up work once existing
callers have been verified for re-entrancy.
This work builds upon the QSEECOM transport logic developed by Dawid Wrobel
and samcday [1], adapted to modern mainline interfaces (qcom_tzmem,
lockdep, and proper kerneldoc constraints).
In accordance with Documentation/process/generated-content.rst: an AI
assistant was used to port the transport logic onto current mainline APIs
and to draft the kerneldoc and commit messages. The architecture and code
were reviewed and validated on hardware by the author, who assumes full
DCO responsibility.
Build-tested on arm64 with defconfig and CONFIG_QCOM_QSEECOM=y (W=1 clean,
checkpatch --strict clean).
The transport logic this series ports has been exercised on hardware
before: on SDM670 through the work it derives from [1], and on sc8280xp
(huawei,gaokun3) through the equivalent out-of-tree patch. This exact
series has been boot-tested on sc8280xp (huawei,gaokun3) with an
out-of-tree client of the fingerprint trusted application: trustlet
loading and shutdown verified across multiple start/shutdown cycles
with consecutive loads succeeding (confirming that APP_SHUTDOWN releases
the secure-world memory and name), sensor initialization and image
capture stable across repeated enroll and verify transactions, and no
dmesg regressions compared to the out-of-tree baseline.
[1] https://github.com/samcday/linux
branch codex/sargo-fingerprint-kernel11-baseline
Signed-off-by: Haozhen Li <dezige131@foxmail.com>
Haozhen Li (2):
firmware: qcom: scm: Add QSEECOM app loading and shutdown
firmware: qcom: scm: Handle QSEECOM listener callbacks
drivers/firmware/qcom/qcom_scm.c | 394 ++++++++++++++++++++++++-
include/linux/firmware/qcom/qcom_scm.h | 62 ++++
2 files changed, 444 insertions(+), 12 deletions(-)
base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a
--
2.43.0
next reply other threads:[~2026-11-01 16:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 16:01 Haozhen Li [this message]
2026-11-02 13:54 ` Dawid Wrobel
2026-11-02 16:27 ` Haozhen Li
2026-11-02 18:21 ` Dawid Wrobel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_123976BCEABEFB4C0F5CE28BCAA346A72405@qq.com \
--to=dezige131@foxmail.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@dawidwrobel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®