From: sashiko-bot@kernel.org
To: "Harshal Dev" <harshal.dev@oss.qualcomm.com>,
"Eric Biggers" <ebiggers@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
"Abel Vesa" <abelvesa@kernel.org>,
"Kuldeep Singh" <kuldeep.singh@oss.qualcomm.com>,
"Neeraj Soni" <neeraj.soni@oss.qualcomm.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@oss.qualcomm.com>,
"Sumit Garg" <sumit.garg@oss.qualcomm.com>,
"Selvam Sathappan Periakaruppan"
<selvam.periakaruppan@oss.qualcomm.com>
Cc: "Basant Kumar" <basantk@qti.qualcomm.com>, linux-crypto@vger.kernel.org
Subject: Re: [PATCH v2 1/6] soc: qcom: ice: Add TZ agnostic re-direction functions
Date: Wed, 11 Nov 2026 14:37:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-209172@kernel.org> (raw)
In-Reply-To: <20261111-ice-migrate-tee-svc-v2-1-29d19f6c92ab@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] soc: qcom: ice: broken CONFIG_QCOM_INLINE_CRYPTO_ENGINE=m guard
in ice.h
- [High] soc: qcom: ice: broken TZ availability check in
qcom_ice_tz_is_available()
- [Medium] soc: qcom: ice: qcom_ice_tz_has_wrapped_key_support() returns
-ENODEV as bool
- [Low] soc: qcom: ice: non-atomic check-then-store in
qcom_ice_tz_ops_register()
--
commit aaede1b942c524f288e35421c3d46bb0baa718ed
Author: Harshal Dev <harshal.dev@oss.qualcomm.com>
soc: qcom: ice: Add TZ agnostic re-direction functions
This commit adds TrustZone-agnostic redirection functions and a backend
operations registration interface so the Qualcomm ICE driver can route calls
to either QTEE SCM or an OP-TEE backend.
> diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
> index e256595b9826f..452896b1858f1 100644
> --- a/drivers/soc/qcom/ice.c
> +++ b/drivers/soc/qcom/ice.c
> @@ -118,6 +118,130 @@ struct qcom_ice {
> static DEFINE_XARRAY(ice_handles);
> static DEFINE_MUTEX(ice_mutex);
>
> +static struct qcom_ice_tz_ops *ice_tz_ops;
> +
> +static bool qcom_ice_tz_ops_registered(void)
> +{
> + /*
> + * The barrier is intended to synchronize the data stores for the
> + * ice_tz_ops data structure when client drivers (UFS/SDHC) are in
> + * parallel checking for ICE service availability.
> + */
> + return !!smp_load_acquire(&ice_tz_ops);
> +}
> +
> +static bool qcom_ice_tz_is_available(void)
> +{
> + return qcom_scm_is_available();
> +}
[Severity: High]
As reported by Eric Biggers on v1 [1], does qcom_ice_tz_is_available() cause
qcom_ice_create() to return -EPROBE_DEFER indefinitely on QTEE-only
platforms?
Later in this series, commit "tee: optee: Register TEE devices on the
platform bus" updates qcom_ice_tz_is_available() to return
(qcom_scm_is_available() & qcom_ice_tee_is_available()), and commit
"soc: qcom: ice: Migrate to the TZ agnostic ICE APIs" makes
qcom_ice_create() return -EPROBE_DEFER when qcom_ice_tz_is_available() is
false before checking qcom_ice_tz_ops_registered(). Because
qcom_ice_tee_is_available() only becomes true after an OP-TEE platform
device probes, it stays false on QTEE-only platforms (or when CONFIG_OPTEE
is disabled). Since ufs_qcom_ice_init() and sdhci_msm_ice_init() only fall
back to running without inline encryption on -EOPNOTSUPP and propagate
-EPROBE_DEFER, UFS and eMMC/SDHC controllers never finish probing on those
platforms.
[ ... ]
> +static bool qcom_ice_tz_has_wrapped_key_support(void)
> +{
> + struct qcom_ice_tz_ops *ops;
> +
> + ops = ice_tz_ops;
> + if (!ops)
> + return -ENODEV;
> +
> + return ops->ice_has_wrapped_key_support(ops->dev);
> +}
[Severity: Medium]
Does returning -ENODEV from a bool function evaluate to true when
ice_tz_ops is NULL? Besides triggering a -Wint-in-bool-context compiler
warning, this reports that wrapped keys are supported when no TZ backend is
registered.
[ ... ]
> +int qcom_ice_tz_ops_register(struct qcom_ice_tz_ops *ops)
> +{
> + if (!qcom_ice_tz_ops_registered())
> + /* Paired with smp_load_acquire() in qcom_ice_tz_ops_registered() */
> + smp_store_release(&ice_tz_ops, ops);
> + else
> + return -EBUSY;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(qcom_ice_tz_ops_register);
> +
> +void qcom_ice_tz_ops_unregister(struct qcom_ice_tz_ops *ops)
> +{
> + if (READ_ONCE(ice_tz_ops) == ops)
> + /* Paired with smp_load_acquire() in qcom_ice_tz_ops_registered() */
> + smp_store_release(&ice_tz_ops, NULL);
> +}
> +EXPORT_SYMBOL_GPL(qcom_ice_tz_ops_unregister);
[Severity: Low]
Can two backends probing in parallel on the platform and TEE buses both pass
!qcom_ice_tz_ops_registered() and overwrite ice_tz_ops instead of returning
-EBUSY? Using cmpxchg() or a mutex across register and unregister would make
the check and update atomic.
> diff --git a/include/soc/qcom/ice.h b/include/soc/qcom/ice.h
> index 4bee553f0a59d..89e62e151b85b 100644
> --- a/include/soc/qcom/ice.h
> +++ b/include/soc/qcom/ice.h
[ ... ]
> @@ -31,4 +72,19 @@ int qcom_ice_import_key(struct qcom_ice *ice,
> u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE]);
> struct qcom_ice *devm_of_qcom_ice_get(struct device *dev);
>
> +#ifdef CONFIG_QCOM_INLINE_CRYPTO_ENGINE
> +int qcom_ice_tz_ops_register(struct qcom_ice_tz_ops *ops);
> +void qcom_ice_tz_ops_unregister(struct qcom_ice_tz_ops *ops);
> +#else
> +static inline int qcom_ice_tz_ops_register(struct qcom_ice_tz_ops *__unused)
> +{
> + return 0;
> +}
> +
> +static inline
> +void qcom_ice_tz_ops_unregister(struct qcom_ice_tz_ops *__unused)
> +{
> +}
> +#endif /* CONFIG_QCOM_INLINE_CRYPTO_ENGINE */
> +
> #endif /* __QCOM_ICE_H__ */
[Severity: High]
Does #ifdef CONFIG_QCOM_INLINE_CRYPTO_ENGINE break the build when
CONFIG_QCOM_INLINE_CRYPTO_ENGINE=m?
QCOM_INLINE_CRYPTO_ENGINE is a tristate symbol (and defaults to =m in arm64
defconfig), so when built as a module only
CONFIG_QCOM_INLINE_CRYPTO_ENGINE_MODULE is defined. The header then exposes
the static inline stubs, which conflict with the non-static definitions in
drivers/soc/qcom/ice.c and cause TZ backends to call no-op stubs. Also, if
CONFIG_QCOM_SCM=y while CONFIG_QCOM_INLINE_CRYPTO_ENGINE=m, built-in
qcom_scm cannot link against symbols exported by qcom_ice.ko.
[1] https://lore.kernel.org/r/20261024185602.GF2553@quark
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111-ice-migrate-tee-svc-v2-0-29d19f6c92ab@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-11-11 14:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 14:17 [PATCH v2 0/6] Add support for a TEE agnostic Inline Crypto Engine service Harshal Dev
2026-11-11 14:17 ` [PATCH v2 1/6] soc: qcom: ice: Add TZ agnostic re-direction functions Harshal Dev
2026-11-11 14:37 ` sashiko-bot [this message]
2026-11-11 14:17 ` [PATCH v2 2/6] firmware: qcom_scm: Transition to ICE TZ agnostic operations Harshal Dev
2026-11-11 14:55 ` sashiko-bot
2026-11-11 14:17 ` [PATCH v2 3/6] firmware: qcom: Add a TEE bus based ICE back-end Harshal Dev
2026-11-11 15:07 ` sashiko-bot
2026-11-11 14:17 ` [PATCH v2 4/6] tee: optee: Register TEE devices on the platform bus Harshal Dev
2026-11-11 14:57 ` Harshal Dev
2026-11-11 15:30 ` sashiko-bot
2026-11-11 14:17 ` [PATCH v2 5/6] soc: qcom: ice: Migrate to the TZ agnostic ICE APIs Harshal Dev
2026-11-11 15:47 ` sashiko-bot
2026-11-11 14:17 ` [PATCH v2 6/6] firmware: qcom: scm: Drop exported ICE wrapper functions Harshal Dev
2026-11-11 15:54 ` sashiko-bot
2026-11-11 14:21 ` [PATCH v2 0/6] Add support for a TEE agnostic Inline Crypto Engine service Harshal Dev
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=sashiko-outbox-209172@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=basantk@qti.qualcomm.com \
--cc=ebiggers@kernel.org \
--cc=harshal.dev@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=kuldeep.singh@oss.qualcomm.com \
--cc=linux-crypto@vger.kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
--cc=neeraj.soni@oss.qualcomm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=selvam.periakaruppan@oss.qualcomm.com \
--cc=sumit.garg@oss.qualcomm.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