firmware: qcom: Add OP-TEE PAS service support
Subsystems (15)
v9 cover firmware: qcom: Add OP-TEE PAS service support
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
OP-TEE as an alternative trusted OS to Qualcomm TEE (QTEE) can't support these non-standard SCM calls. And even for newer architectures using S-EL2 with Hafnium support, QTEE won't be able to support SCM calls either with FF-A requirements coming in. And with both OP-TEE and QTEE drivers well integrated in the TEE subsystem, it makes further sense to reuse the TEE bus client drivers infrastructure.
The added benefit of TEE bus infrastructure is that there is support for discoverable/enumerable services. With that client drivers don't have to manually invoke a special SCM call to know the service status.
So enable the generic Peripheral Authentication Service (PAS) provided by the firmware. It acts as the common layer with different TZ backends plugged in whether it's an SCM implementation or a proper TEE bus based PAS service implementation.
The TEE PAS service ABI is designed to be extensible with additional API as PTA_QCOM_PAS_CAPABILITIES. This allows to accommodate any future extensions of the PAS service needed while still maintaining backwards compatibility.
Currently OP-TEE support is being added to provide the backend PAS service implementation which can be found as part of this PR [1]. This implementation has been tested on Kodiak/RB3Gen2 and lemans EVK boards. In addition to that WIN/IPQ targets tested OP-TEE with this service too. Surely the backwards compatibility is maintained and tested for SCM backend.
Note that kernel PAS service support while running in EL2 is at parity among OP-TEE vs QTEE. Especially the media (venus/iris) support depends on proper IOMMU support being worked out on the PAS client end.
Patch summary:
- Patch #1: adds generic PAS service.
- Patch #2: migrates SCM backend to generic PAS service.
- Patch #3: adds TEE/OP-TEE backend for generic PAS service.
- Patch #4-#12: migrates all client drivers to generic PAS service.
- Patch #13: drops legacy PAS SCM exported APIs.
The patch-set is based on v7.2-rc1 and can be found in git tree here [2].
Merge strategy:
It is expected due to APIs dependency, the entire patch-set to go via the Qcom tree. All other subsystem maintainers, it will be great if I can get acks for the corresponding subsystem patches.
[1] https://github.com/OP-TEE/optee_os/pull/7721 (already merged)
[2] https://git.kernel.org/pub/scm/linux/kernel/git/sumit.garg/linux.git/log/?h=qcom-pas-v9
---
Changes in v9:
- Rebased to 7.2-rc1.
- Enable SCM backend similar to TEE if ARCH_QCOM is set.
- Address misc. comments from Konrad.
- Add checks for corner cases (although not reachable as per OP-TEE ABI) reported by Shashiko on patch #3.
- Picked up review tags from Konrad.
Changes in v8:
- Rebased on mainline tip (no functional changes).
- Now Lemans EVK is also tested to support OP-TEE PAS here:
https://github.com/OP-TEE/optee_os/pull/7845
- Drop Kodiak DT patch as it is carried independently by Mukesh here:
https://lore.kernel.org/lkml/[email protected]/
- Regarding Sashiko comments, I have already replied in v6 the ones that don't apply but in v7 I got the same comments again. Specific context reasoning which Shashiko ignores:
- ABI contract between Linux and TZ
- No support for multiple concurrent backends
- The TZ backend doesn’t detach during the entire boot cycle
Changes in v7:
- Rebased to qcom tree (for-next branch) tip.
- Merged patch #5 and #7 due to build dependency.
- Disabled modem for kodiak EL2 as it isn't tested yet.
- Fix an issue found out by sashiko-bot for patch #4.
Changes in v6:
- Rebased to v7.1-rc4 tag.
- Patch #14: fixed ret error print.
- Add Kconfig descriptions for PAS symbols such that they are visible in menuconfig to update.
Changes in v5:
- Incorporated misc. comments from Mukesh.
- Split up patch #11 into 2 to add an independent commit for passing proper PAS ID to set_remote_state API.
- Picked up tags.
Changes in v4:
- Incorporate misc. comments on patch #4.
- Picked up an ack for patch #10.
- Clarify in cover letter about state of media support.
Changes in v3:
- Incorporated some style and misc. comments for patch #2, #3 and #4.
- Add QCOM_PAS Kconfig dependency for various subsystems.
- Switch from pseudo TA to proper TA invoke commands.
Changes in v2:
- Fixed kernel doc warnings.
- Polish commit message and comments for patch #2.
- Pass proper PAS ID in set_remote_state API for media firmware drivers.
- Added Maintainer entry and dropped MODULE_AUTHOR.
Sumit Garg (14):
firmware: qcom: Add a generic PAS service
firmware: qcom_scm: Migrate to generic PAS service
firmware: qcom: Add a PAS TEE service
remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs
remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs
remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs
remoteproc: qcom: Select QCOM_PAS generic service drm/msm: Switch to generic PAS TZ APIs
media: qcom: Switch to generic PAS TZ APIs
media: qcom: Pass proper PAS ID to set_remote_state API
net: ipa: Switch to generic PAS TZ APIs
wifi: ath12k: Switch to generic PAS TZ APIs
firmware: qcom_scm: Remove SCM PAS wrappers
MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service
MAINTAINERS | 9 + drivers/firmware/qcom/Kconfig | 22 +- drivers/firmware/qcom/Makefile | 2 + drivers/firmware/qcom/qcom_pas.c | 299 +++++++++++ drivers/firmware/qcom/qcom_pas.h | 50 ++ drivers/firmware/qcom/qcom_pas_tee.c | 479 ++++++++++++++++++ drivers/firmware/qcom/qcom_scm.c | 302 ++++------- drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 11 +- drivers/media/platform/qcom/iris/Kconfig | 27 +- .../media/platform/qcom/iris/iris_firmware.c | 9 +- drivers/media/platform/qcom/venus/Kconfig | 1 + drivers/media/platform/qcom/venus/firmware.c | 11 +- drivers/net/ipa/Kconfig | 2 +- drivers/net/ipa/ipa_main.c | 13 +- drivers/net/wireless/ath/ath12k/Kconfig | 2 +- drivers/net/wireless/ath/ath12k/ahb.c | 10 +- drivers/remoteproc/Kconfig | 4 +- drivers/remoteproc/qcom_q6v5_mss.c | 5 +- drivers/remoteproc/qcom_q6v5_pas.c | 51 +- drivers/remoteproc/qcom_wcnss.c | 12 +- drivers/soc/qcom/mdt_loader.c | 12 +- include/linux/firmware/qcom/qcom_pas.h | 43 ++ include/linux/firmware/qcom/qcom_scm.h | 29 -- include/linux/soc/qcom/mdt_loader.h | 6 +- 26 files changed, 1095 insertions(+), 321 deletions(-) create mode 100644 drivers/firmware/qcom/qcom_pas.c create mode 100644 drivers/firmware/qcom/qcom_pas.h create mode 100644 drivers/firmware/qcom/qcom_pas_tee.c create mode 100644 include/linux/firmware/qcom/qcom_pas.h
Signature · 1 line
2.53.0
PATCH v9 1/14 firmware: qcom: Add a generic PAS service
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
OP-TEE as an alternative trusted OS to Qualcomm TEE (QTEE) can't support these non-standard SCM calls. And even for newer architectures using S-EL2 with Hafnium support, QTEE won't be able to support SCM calls either with FF-A requirements coming in. And with both OP-TEE and QTEE drivers well integrated in the TEE subsystem, it makes further sense to reuse the TEE bus client drivers infrastructure.
The added benefit of TEE bus infrastructure is that there is support for discoverable/enumerable services. With that client drivers don't have to manually invoke a special SCM call to know the service status.
So enable the generic Peripheral Authentication Service (PAS) provided by the firmware. It acts as the common layer with different TZ backends plugged in whether it's an SCM implementation or a proper TEE bus based PAS service implementation.
--- drivers/firmware/qcom/Kconfig | 8 + drivers/firmware/qcom/Makefile | 1 + drivers/firmware/qcom/qcom_pas.c | 299 +++++++++++++++++++++++++ drivers/firmware/qcom/qcom_pas.h | 50 +++++ include/linux/firmware/qcom/qcom_pas.h | 43 ++++ 5 files changed, 401 insertions(+) create mode 100644 drivers/firmware/qcom/qcom_pas.c create mode 100644 drivers/firmware/qcom/qcom_pas.h create mode 100644 include/linux/firmware/qcom/qcom_pas.h
drivers/firmware/qcom/Kconfig +8 -0
@@ -6,6 +6,14 @@ menu "Qualcomm firmware drivers" +config QCOM_PAS + tristate "Qualcomm generic PAS interface driver" + help + Enable the generic Peripheral Authentication Service (PAS) provided + by the firmware. It acts as the common layer with different TZ + backends plugged in whether it's an SCM implementation or a proper + TEE bus based PAS service implementation. + config QCOM_SCM select QCOM_TZMEM tristate
drivers/firmware/qcom/Makefile +1 -0
@@ -8,3 +8,4 @@ qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o +obj-$(CONFIG_QCOM_PAS) += qcom_pas.o
drivers/firmware/qcom/qcom_pas.c new file +299 -0
299 lines not on this page · raw message
drivers/firmware/qcom/qcom_pas.h new file +50 -0
50 lines not on this page · raw message
include/linux/firmware/qcom/qcom_pas.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v9 2/14 firmware: qcom_scm: Migrate to generic PAS service
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
With the availability of generic PAS service, let's add SCM calls as a backend to keep supporting legacy QTEE interfaces. The exported qcom_scm* wrappers will get dropped once all the client drivers get migrated as part of future patches.
--- drivers/firmware/qcom/Kconfig | 4 +- drivers/firmware/qcom/qcom_scm.c | 335 ++++++++++++++----------------- 2 files changed, 157 insertions(+), 182 deletions(-)
drivers/firmware/qcom/Kconfig +3 -1
@@ -15,8 +15,10 @@ config QCOM_PAS TEE bus based PAS service implementation. config QCOM_SCM + tristate "Qualcomm PAS SCM interface driver" + select QCOM_PAS select QCOM_TZMEM - tristate + default y if ARCH_QCOM config QCOM_TZMEM tristate
drivers/firmware/qcom/qcom_scm.c +154 -181
547 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v9 3/14 firmware: qcom: Add a PAS TEE service
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Add support for Peripheral Authentication Service (PAS) driver based on TEE bus with OP-TEE providing the backend PAS service implementation.
The TEE PAS service ABI is designed to be extensible with additional API as PTA_QCOM_PAS_CAPABILITIES. This allows to accommodate any future extensions of the PAS service needed while still maintaining backwards compatibility.
--- drivers/firmware/qcom/Kconfig | 10 + drivers/firmware/qcom/Makefile | 1 + drivers/firmware/qcom/qcom_pas_tee.c | 479 +++++++++++++++++++++++++++ 3 files changed, 490 insertions(+) create mode 100644 drivers/firmware/qcom/qcom_pas_tee.c
drivers/firmware/qcom/Kconfig +10 -0
@@ -14,6 +14,16 @@ config QCOM_PAS backends plugged in whether it's an SCM implementation or a proper TEE bus based PAS service implementation. +config QCOM_PAS_TEE + tristate "Qualcomm PAS TEE interface driver" + select QCOM_PAS + depends on TEE + depends on !CPU_BIG_ENDIAN + default m if ARCH_QCOM + help + Enable the generic Peripheral Authentication Service (PAS) provided + by the firmware TEE implementation as the backend. + config QCOM_SCM tristate "Qualcomm PAS SCM interface driver" select QCOM_PAS
drivers/firmware/qcom/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o obj-$(CONFIG_QCOM_PAS) += qcom_pas.o +obj-$(CONFIG_QCOM_PAS_TEE) += qcom_pas_tee.o
drivers/firmware/qcom/qcom_pas_tee.c new file +479 -0
479 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v9 4/14 remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Switch qcom_q6v5_pas client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Since qcom_q6v5_pas depends on MDT loader for PAS firmware loading, it has to be switched over to generic PAS APIs in this commit to avoid any build issues.
--- drivers/remoteproc/qcom_q6v5_pas.c | 51 +++++++++++++++-------------- drivers/soc/qcom/mdt_loader.c | 12 +++---- include/linux/soc/qcom/mdt_loader.h | 6 ++-- 3 files changed, 35 insertions(+), 34 deletions(-)
drivers/remoteproc/qcom_q6v5_pas.c +26 -25
@@ -20,6 +20,7 @@#include <linux/platform_device.h> #include <linux/pm_domain.h> #include <linux/pm_runtime.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #include <linux/regulator/consumer.h> #include <linux/remoteproc.h>
@@ -115,8 +116,8 @@ struct qcom_pas {struct qcom_rproc_ssr ssr_subdev;struct qcom_sysmon *sysmon; -struct qcom_scm_pas_context *pas_ctx; -struct qcom_scm_pas_context *dtb_pas_ctx; +struct qcom_pas_context *pas_ctx; +struct qcom_pas_context *dtb_pas_ctx; }; static void qcom_pas_segment_dump(struct rproc *rproc,
@@ -193,7 +194,7 @@ static int qcom_pas_shutdown_poll_decrypt(struct qcom_pas *pas)do {msleep (QCOM_PAS_DECRYPT_SHUTDOWN_DELAY_MS ); - ret =qcom_scm_pas_shutdown (pas->pas_id); + ret =qcom_pas_shutdown (pas->pas_id); }while (ret == -EINVAL && --retry_num);return ret;
@@ -209,9 +210,9 @@ static int qcom_pas_unprepare(struct rproc *rproc)* auth_and_reset() was successful, but in other cases clean it up * here. */ -qcom_scm_pas_metadata_release (pas->pas_ctx); +qcom_pas_metadata_release (pas->pas_ctx);if (pas->dtb_pas_id) -qcom_scm_pas_metadata_release (pas->dtb_pas_ctx); +qcom_pas_metadata_release (pas->dtb_pas_ctx);return 0 ; }
@@ -225,9 +226,9 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw) pas->firmware = fw;if (pas->lite_pas_id) -qcom_scm_pas_shutdown (pas->lite_pas_id); +qcom_pas_shutdown (pas->lite_pas_id);if (pas->lite_dtb_pas_id) -qcom_scm_pas_shutdown (pas->lite_dtb_pas_id); +qcom_pas_shutdown (pas->lite_dtb_pas_id);if (pas->dtb_pas_id) { ret =request_firmware (&pas->dtb_firmware, pas->dtb_firmware_name, pas->dev);
@@ -247,7 +248,7 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)return 0 ; release_dtb_metadata: -qcom_scm_pas_metadata_release (pas->dtb_pas_ctx); +qcom_pas_metadata_release (pas->dtb_pas_ctx);release_firmware (pas->dtb_firmware);return ret;
@@ -307,7 +308,7 @@ static int qcom_pas_start(struct rproc *rproc)if (ret) goto disable_px_supply; - ret =qcom_scm_pas_prepare_and_auth_reset (pas->dtb_pas_ctx); + ret =qcom_pas_prepare_and_auth_reset (pas->dtb_pas_ctx);if (ret) {dev_err (pas->dev,"failed to authenticate dtb image and release reset\n" );
@@ -326,7 +327,7 @@ static int qcom_pas_start(struct rproc *rproc)if (ret) goto release_pas_metadata; - ret =qcom_scm_pas_prepare_and_auth_reset (pas->pas_ctx); + ret =qcom_pas_prepare_and_auth_reset (pas->pas_ctx);if (ret) {dev_err (pas->dev,"failed to authenticate image and release reset\n" );
@@ -336,13 +337,13 @@ static int qcom_pas_start(struct rproc *rproc) ret =qcom_q6v5_wait_for_start (&pas->q6v5,msecs_to_jiffies (5000 ));if (ret == -ETIMEDOUT ) {dev_err (pas->dev,"start timed out\n" ); -qcom_scm_pas_shutdown (pas->pas_id); +qcom_pas_shutdown (pas->pas_id); goto unmap_carveout; } -qcom_scm_pas_metadata_release (pas->pas_ctx); +qcom_pas_metadata_release (pas->pas_ctx);if (pas->dtb_pas_id) -qcom_scm_pas_metadata_release (pas->dtb_pas_ctx); +qcom_pas_metadata_release (pas->dtb_pas_ctx);/* firmware is used to pass reference from qcom_pas_start(), drop it now */ pas->firmware =NULL ;
@@ -352,9 +353,9 @@ static int qcom_pas_start(struct rproc *rproc) unmap_carveout:qcom_pas_unmap_carveout (rproc, pas->mem_phys, pas->mem_size); release_pas_metadata: -qcom_scm_pas_metadata_release (pas->pas_ctx); +qcom_pas_metadata_release (pas->pas_ctx);if (pas->dtb_pas_id) -qcom_scm_pas_metadata_release (pas->dtb_pas_ctx); +qcom_pas_metadata_release (pas->dtb_pas_ctx); unmap_dtb_carveout:if (pas->dtb_pas_id)
@@ -403,7 +404,7 @@ static int qcom_pas_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (pas->dev,"timed out on wait\n" ); - ret =qcom_scm_pas_shutdown (pas->pas_id); + ret =qcom_pas_shutdown (pas->pas_id);if (ret && pas->decrypt_shutdown) ret =qcom_pas_shutdown_poll_decrypt (pas);
@@ -411,7 +412,7 @@ static int qcom_pas_stop(struct rproc *rproc)dev_err (pas->dev,"failed to shutdown: %d\n" , ret);if (pas->dtb_pas_id) { - ret =qcom_scm_pas_shutdown (pas->dtb_pas_id); + ret =qcom_pas_shutdown (pas->dtb_pas_id);if (ret)dev_err (pas->dev,"failed to shutdown dtb: %d\n" , ret);
@@ -481,11 +482,11 @@ static int qcom_pas_parse_firmware(struct rproc *rproc, const struct firmware *f* * Here, we call rproc_elf_load_rsc_table() to check firmware binary has resources * or not and if it is not having then we pass NULL and zero as input resource -* table pointer and size respectively to the argument of qcom_scm_pas_get_rsc_table() +* table pointer and size respectively to the argument of qcom_pas_get_rsc_table() * and this is even true for Qualcomm remote processor who does follow remoteproc * framework. */ - output_rt =qcom_scm_pas_get_rsc_table (pas->pas_ctx, table, table_sz, &output_rt_size); + output_rt =qcom_pas_get_rsc_table (pas->pas_ctx, table, table_sz, &output_rt_size); ret =IS_ERR (output_rt) ?PTR_ERR (output_rt) :0 ;if (ret) {dev_err (pas->dev,"Error in getting resource table: %d\n" , ret);
@@ -743,7 +744,7 @@ static int qcom_pas_probe(struct platform_device *pdev)if (!desc)return -EINVAL ; -if (!qcom_scm_is_available ()) +if (!qcom_pas_is_available ())return -EPROBE_DEFER ; fw_name = desc->firmware_name;
@@ -835,16 +836,16 @@ static int qcom_pas_probe(struct platform_device *pdev)qcom_add_ssr_subdev (rproc, &pas->ssr_subdev, desc->ssr_name); - pas->pas_ctx =devm_qcom_scm_pas_context_alloc (pas->dev, pas->pas_id, - pas->mem_phys, pas->mem_size); + pas->pas_ctx =devm_qcom_pas_context_alloc (pas->dev, pas->pas_id, + pas->mem_phys, pas->mem_size);if (IS_ERR (pas->pas_ctx)) { ret =PTR_ERR (pas->pas_ctx); goto remove_ssr_sysmon; } - pas->dtb_pas_ctx =devm_qcom_scm_pas_context_alloc (pas->dev, pas->dtb_pas_id, - pas->dtb_mem_phys, - pas->dtb_mem_size); + pas->dtb_pas_ctx =devm_qcom_pas_context_alloc (pas->dev, pas->dtb_pas_id, + pas->dtb_mem_phys, + pas->dtb_mem_size);if (IS_ERR (pas->dtb_pas_ctx)) { ret =PTR_ERR (pas->dtb_pas_ctx); goto remove_ssr_sysmon;
drivers/soc/qcom/mdt_loader.c +6 -6
@@ -13,7 +13,7 @@#include <linux/firmware.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/sizes.h> #include <linux/slab.h> #include <linux/soc/qcom/mdt_loader.h>
@@ -229,7 +229,7 @@ EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata);static int __qcom_mdt_pas_init (struct device *dev,const struct firmware *fw,const char *fw_name,int pas_id,phys_addr_t mem_phys, -struct qcom_scm_pas_context *ctx) +struct qcom_pas_context *ctx) {const struct elf32_phdr *phdrs;const struct elf32_phdr *phdr;
@@ -271,7 +271,7 @@ static int __qcom_mdt_pas_init(struct device *dev, const struct firmware *fw, goto out; } - ret =qcom_scm_pas_init_image (pas_id, metadata, metadata_len, ctx); + ret =qcom_pas_init_image (pas_id, metadata, metadata_len, ctx);kfree (metadata);if (ret) {/* Invalid firmware metadata */
@@ -280,7 +280,7 @@ static int __qcom_mdt_pas_init(struct device *dev, const struct firmware *fw, }if (relocate) { - ret =qcom_scm_pas_mem_setup (pas_id, mem_phys, max_addr - min_addr); + ret =qcom_pas_mem_setup (pas_id, mem_phys, max_addr - min_addr);if (ret) {/* Unable to set up relocation */ dev_err (dev,"error %d setting up firmware %s\n" , ret, fw_name);
@@ -472,7 +472,7 @@ EXPORT_SYMBOL_GPL(qcom_mdt_load);* firmware segments (e.g., .bXX files). Authentication of the segments done * by a separate call. * -* The PAS context must be initialized using qcom_scm_pas_context_init() +* The PAS context must be initialized using devm_qcom_pas_context_alloc() * prior to invoking this function. * * @ctx: Pointer to the PAS (Peripheral Authentication Service) context
@@ -483,7 +483,7 @@ EXPORT_SYMBOL_GPL(qcom_mdt_load);* * Return: 0 on success or a negative error code on failure. */ -int qcom_mdt_pas_load (struct qcom_scm_pas_context *ctx,const struct firmware *fw, +int qcom_mdt_pas_load (struct qcom_pas_context *ctx,const struct firmware *fw,const char *firmware,void *mem_region,phys_addr_t *reloc_base) {int ret;
include/linux/soc/qcom/mdt_loader.h +3 -3
@@ -10,7 +10,7 @@struct device ;struct firmware ; -struct qcom_scm_pas_context ; +struct qcom_pas_context ;#if IS_ENABLED (CONFIG_QCOM_MDT_LOADER )
@@ -20,7 +20,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, phys_addr_t mem_phys, size_t mem_size, phys_addr_t *reloc_base); -int qcom_mdt_pas_load (struct qcom_scm_pas_context *ctx,const struct firmware *fw, +int qcom_mdt_pas_load (struct qcom_pas_context *ctx,const struct firmware *fw,const char *firmware,void *mem_region,phys_addr_t *reloc_base); int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
@@ -45,7 +45,7 @@ static inline int qcom_mdt_load(struct device *dev, const struct firmware *fw,return -ENODEV ; } -static inline int qcom_mdt_pas_load (struct qcom_scm_pas_context *ctx, +static inline int qcom_mdt_pas_load (struct qcom_pas_context *ctx,const struct firmware *fw,const char *firmware,void *mem_region,phys_addr_t *reloc_base) {
Signature · 1 line
2.53.0
PATCH v9 5/14 remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Switch qcom_q6v5_mss client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
--- drivers/remoteproc/qcom_q6v5_mss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +3 -2
@@ -34,6 +34,7 @@#include "qcom_pil_info.h" #include "qcom_q6v5.h" +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #define MPSS_CRASH_REASON_SMEM 421
@@ -1480,7 +1481,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc) }if (qproc->need_pas_mem_setup) { - ret =qcom_scm_pas_mem_setup (MPSS_PAS_ID , qproc->mpss_phys, qproc->mpss_size); + ret =qcom_pas_mem_setup (MPSS_PAS_ID , qproc->mpss_phys, qproc->mpss_size);if (ret) {dev_err (qproc->dev,"setting up mpss memory failed: %d\n" , ret);
@@ -2077,7 +2078,7 @@ static int q6v5_probe(struct platform_device *pdev)if (!desc)return -EINVAL ; -if (desc->need_mem_protection && !qcom_scm_is_available ()) +if (desc->need_mem_protection && !qcom_pas_is_available ())return -EPROBE_DEFER ; mba_image = desc->hexagon_mba_image;
Signature · 1 line
2.53.0
PATCH v9 6/14 remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Switch qcom_wcnss client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
--- drivers/remoteproc/qcom_wcnss.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/remoteproc/qcom_wcnss.c +6 -6
@@ -19,7 +19,7 @@#include <linux/platform_device.h> #include <linux/pm_domain.h> #include <linux/pm_runtime.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/regulator/consumer.h> #include <linux/remoteproc.h> #include <linux/soc/qcom/mdt_loader.h>
@@ -257,7 +257,7 @@ static int wcnss_start(struct rproc *rproc)wcnss_indicate_nv_download (wcnss);wcnss_configure_iris (wcnss); - ret =qcom_scm_pas_auth_and_reset (WCNSS_PAS_ID ); + ret =qcom_pas_auth_and_reset (WCNSS_PAS_ID );if (ret) {dev_err (wcnss->dev,"failed to authenticate image and release reset\n" );
@@ -269,7 +269,7 @@ static int wcnss_start(struct rproc *rproc)if (wcnss->ready_irq >0 && ret ==0 ) {/* We have a ready_irq, but it didn't fire in time. */ dev_err (wcnss->dev,"start timed out\n" ); -qcom_scm_pas_shutdown (WCNSS_PAS_ID ); +qcom_pas_shutdown (WCNSS_PAS_ID ); ret = -ETIMEDOUT ; goto disable_iris; }
@@ -311,7 +311,7 @@ static int wcnss_stop(struct rproc *rproc) 0); } - ret =qcom_scm_pas_shutdown (WCNSS_PAS_ID ); + ret =qcom_pas_shutdown (WCNSS_PAS_ID );if (ret)dev_err (wcnss->dev,"failed to shutdown: %d\n" , ret);
@@ -557,10 +557,10 @@ static int wcnss_probe(struct platform_device *pdev) data =of_device_get_match_data (&pdev->dev); -if (!qcom_scm_is_available ()) +if (!qcom_pas_is_available ())return -EPROBE_DEFER ; -if (!qcom_scm_pas_supported (WCNSS_PAS_ID )) { +if (!qcom_pas_supported (WCNSS_PAS_ID )) {dev_err (&pdev->dev,"PAS is not available for WCNSS\n" );return -ENXIO ; }
Signature · 1 line
2.53.0
PATCH v9 7/14 remoteproc: qcom: Select QCOM_PAS generic service
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Select PAS generic service driver to enable support for multiple PAS backends like OP-TEE in addition to SCM.
--- drivers/remoteproc/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/remoteproc/Kconfig +3 -1
@@ -210,6 +210,7 @@ config QCOM_Q6V5_MSS select QCOM_Q6V5_COMMON select QCOM_RPROC_COMMON select QCOM_SCM + select QCOM_PAS help Say y here to support the Qualcomm self-authenticating modem subsystem based on Hexagon V5. The TrustZone based system is
@@ -230,6 +231,7 @@ config QCOM_Q6V5_PAS select QCOM_Q6V5_COMMON select QCOM_RPROC_COMMON select QCOM_SCM + select QCOM_PAS help Say y here to support the TrustZone based Peripheral Image Loader for the Qualcomm remote processors. This is commonly used to control
@@ -282,7 +284,7 @@ config QCOM_WCNSS_PIL select QCOM_MDT_LOADER select QCOM_PIL_INFO select QCOM_RPROC_COMMON - select QCOM_SCM + select QCOM_PAS help Say y here to support the Peripheral Image Loader for loading WCNSS firmware and boot the core on e.g. MSM8974, MSM8916. The firmware is
Signature · 1 line
2.53.0
PATCH v9 8/14 drm/msm: Switch to generic PAS TZ APIs
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Switch drm/msm client drivers over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
--- drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 11 ++++++----- 3 files changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/Kconfig +1 -0
@@ -21,6 +21,7 @@ config DRM_MSM select SHMEM select TMPFS select QCOM_SCM + select QCOM_PAS select QCOM_UBWC_CONFIG select WANT_DEV_COREDUMP select SND_SOC_HDMI_CODEC if SND_SOC
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +2 -2
@@ -5,7 +5,7 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/cpumask.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/pm_opp.h> #include <linux/nvmem-consumer.h> #include <linux/slab.h>
@@ -653,7 +653,7 @@ static int a5xx_zap_shader_resume(struct msm_gpu *gpu)if (adreno_is_a506 (adreno_gpu))return 0 ; - ret =qcom_scm_set_remote_state (SCM_GPU_ZAP_SHADER_RESUME ,GPU_PAS_ID ); + ret =qcom_pas_set_remote_state (SCM_GPU_ZAP_SHADER_RESUME ,GPU_PAS_ID );if (ret)DRM_ERROR ("%s: zap-shader resume failed: %d\n" , gpu->name, ret);
drivers/gpu/drm/msm/adreno/adreno_gpu.c +6 -5
@@ -8,6 +8,7 @@#include <linux/ascii85.h> #include <linux/interconnect.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #include <linux/kernel.h> #include <linux/of_reserved_mem.h>
@@ -146,10 +147,10 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, goto out;/* Send the image to the secure world */ - ret =qcom_scm_pas_auth_and_reset (pasid); + ret =qcom_pas_auth_and_reset (pasid);/* -* If the scm call returns -EOPNOTSUPP we assume that this target +* If the pas call returns -EOPNOTSUPP we assume that this target * doesn't need/support the zap shader so quietly fail */ if (ret == -EOPNOTSUPP )
@@ -175,9 +176,9 @@ int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid)if (!zap_available)return -ENODEV ; -/* We need SCM to be able to load the firmware */ -if (!qcom_scm_is_available ()) { -DRM_DEV_ERROR (&pdev->dev,"SCM is not available\n" ); +/* We need PAS to be able to load the firmware */ +if (!qcom_pas_is_available ()) { +DRM_DEV_ERROR (&pdev->dev,"PAS is not available\n" );return -EPROBE_DEFER ; }
Signature · 1 line
2.53.0
PATCH v9 9/14 media: qcom: Switch to generic PAS TZ APIs
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Switch qcom media client drivers over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
--- drivers/media/platform/qcom/iris/Kconfig | 27 ++++++++++--------- .../media/platform/qcom/iris/iris_firmware.c | 9 ++++--- drivers/media/platform/qcom/venus/Kconfig | 1 + drivers/media/platform/qcom/venus/firmware.c | 11 ++++---- 4 files changed, 26 insertions(+), 22 deletions(-)
drivers/media/platform/qcom/iris/Kconfig +14 -13
@@ -1,14 +1,15 @@ config VIDEO_QCOM_IRIS - tristate "Qualcomm iris V4L2 decoder driver" - depends on VIDEO_DEV - depends on ARCH_QCOM || COMPILE_TEST - select V4L2_MEM2MEM_DEV - select QCOM_MDT_LOADER - select QCOM_SCM - select QCOM_UBWC_CONFIG - select VIDEOBUF2_DMA_CONTIG - help - This is a V4L2 driver for Qualcomm iris video accelerator - hardware. It accelerates decoding operations on various - Qualcomm SoCs. - To compile this driver as a module choose m here. + tristate "Qualcomm iris V4L2 decoder driver" + depends on VIDEO_DEV + depends on ARCH_QCOM || COMPILE_TEST + select V4L2_MEM2MEM_DEV + select QCOM_MDT_LOADER + select QCOM_SCM + select QCOM_PAS + select QCOM_UBWC_CONFIG + select VIDEOBUF2_DMA_CONTIG + help + This is a V4L2 driver for Qualcomm iris video accelerator + hardware. It accelerates decoding operations on various + Qualcomm SoCs. + To compile this driver as a module choose m here.
drivers/media/platform/qcom/iris/iris_firmware.c +5 -4
@@ -4,6 +4,7 @@*/ #include <linux/firmware.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #include <linux/of_address.h> #include <linux/of_reserved_mem.h>
@@ -80,7 +81,7 @@ int iris_fw_load(struct iris_core *core)return -ENOMEM ; } - ret =qcom_scm_pas_auth_and_reset (IRIS_PAS_ID ); + ret =qcom_pas_auth_and_reset (IRIS_PAS_ID );if (ret) {dev_err (core->dev,"auth and reset failed: %d\n" , ret);return ret;
@@ -94,7 +95,7 @@ int iris_fw_load(struct iris_core *core) cp_config->cp_nonpixel_size);if (ret) {dev_err (core->dev,"qcom_scm_mem_protect_video_var failed: %d\n" , ret); -qcom_scm_pas_shutdown (IRIS_PAS_ID ); +qcom_pas_shutdown (IRIS_PAS_ID );return ret; } }
@@ -104,10 +105,10 @@ int iris_fw_load(struct iris_core *core)int iris_fw_unload (struct iris_core *core) { -return qcom_scm_pas_shutdown (IRIS_PAS_ID ); +return qcom_pas_shutdown (IRIS_PAS_ID ); }int iris_set_hw_state (struct iris_core *core,bool resume) { -return qcom_scm_set_remote_state (resume,0 ); +return qcom_pas_set_remote_state (resume,0 ); }
drivers/media/platform/qcom/venus/Kconfig +1 -0
@@ -6,6 +6,7 @@ config VIDEO_QCOM_VENUS select OF_DYNAMIC if ARCH_QCOM select QCOM_MDT_LOADER select QCOM_SCM + select QCOM_PAS select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV help
drivers/media/platform/qcom/venus/firmware.c +6 -5
@@ -12,6 +12,7 @@#include <linux/of_reserved_mem.h> #include <linux/platform_device.h> #include <linux/of_device.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #include <linux/sizes.h> #include <linux/soc/qcom/mdt_loader.h>
@@ -58,7 +59,7 @@ int venus_set_hw_state(struct venus_core *core, bool resume)int ret;if (core->use_tz) { - ret =qcom_scm_set_remote_state (resume,0 ); + ret =qcom_pas_set_remote_state (resume,0 );if (resume && ret == -EINVAL ) ret =0 ;return ret;
@@ -218,7 +219,7 @@ int venus_boot(struct venus_core *core)int ret;if (!IS_ENABLED (CONFIG_QCOM_MDT_LOADER ) || - (core->use_tz && !qcom_scm_is_available ())) + (core->use_tz && !qcom_pas_is_available ()))return -EPROBE_DEFER ; ret = of_property_read_string_index(dev->of_node, "firmware-name", 0,
@@ -236,7 +237,7 @@ int venus_boot(struct venus_core *core) core->fw.mem_phys = mem_phys;if (core->use_tz) - ret =qcom_scm_pas_auth_and_reset (VENUS_PAS_ID ); + ret =qcom_pas_auth_and_reset (VENUS_PAS_ID );else ret =venus_boot_no_tz (core, mem_phys, mem_size);
@@ -259,7 +260,7 @@ int venus_boot(struct venus_core *core) res->cp_nonpixel_start, res->cp_nonpixel_size);if (ret) { -qcom_scm_pas_shutdown (VENUS_PAS_ID ); +qcom_pas_shutdown (VENUS_PAS_ID );dev_err (dev,"set virtual address ranges fail (%d)\n" , ret);return ret;
@@ -274,7 +275,7 @@ int venus_shutdown(struct venus_core *core)int ret;if (core->use_tz) - ret =qcom_scm_pas_shutdown (VENUS_PAS_ID ); + ret =qcom_pas_shutdown (VENUS_PAS_ID );else ret =venus_shutdown_no_tz (core);
Signature · 1 line
2.53.0
PATCH v9 10/14 media: qcom: Pass proper PAS ID to set_remote_state API
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
As per testing the SCM backend just ignores it while OP-TEE makes use of it to for proper book keeping purpose.
--- drivers/media/platform/qcom/iris/iris_firmware.c | 2 +- drivers/media/platform/qcom/venus/firmware.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_firmware.c +1 -1
@@ -110,5 +110,5 @@ int iris_fw_unload(struct iris_core *core)int iris_set_hw_state (struct iris_core *core,bool resume) { -return qcom_pas_set_remote_state (resume,0 ); +return qcom_pas_set_remote_state (resume,IRIS_PAS_ID ); }
drivers/media/platform/qcom/venus/firmware.c +1 -1
@@ -59,7 +59,7 @@ int venus_set_hw_state(struct venus_core *core, bool resume)int ret;if (core->use_tz) { - ret =qcom_pas_set_remote_state (resume,0 ); + ret =qcom_pas_set_remote_state (resume,VENUS_PAS_ID );if (resume && ret == -EINVAL ) ret =0 ;return ret;
Signature · 1 line
2.53.0
PATCH v9 11/14 net: ipa: Switch to generic PAS TZ APIs
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Switch ipa client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
--- drivers/net/ipa/Kconfig | 2 +- drivers/net/ipa/ipa_main.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/ipa/Kconfig +1 -1
@@ -6,7 +6,7 @@ config QCOM_IPA depends on QCOM_RPROC_COMMON || (QCOM_RPROC_COMMON=n && COMPILE_TEST) depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n select QCOM_MDT_LOADER - select QCOM_SCM + select QCOM_PAS select QCOM_QMI_HELPERS help Choose Y or M here to include support for the Qualcomm
drivers/net/ipa/ipa_main.c +8 -5
@@ -14,7 +14,7 @@#include <linux/pm_runtime.h> #include <linux/types.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/soc/qcom/mdt_loader.h> #include "ipa.h"
@@ -624,10 +624,13 @@ static int ipa_firmware_load(struct device *dev) } ret =qcom_mdt_load (dev, fw, path,IPA_PAS_ID , virt, phys, size,NULL ); -if (ret) +if (ret) {dev_err (dev,"error %d loading \"%s\"\n" , ret, path); -else if ((ret =qcom_scm_pas_auth_and_reset (IPA_PAS_ID ))) -dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }else { + ret =qcom_pas_auth_and_reset (IPA_PAS_ID ); +if (ret) +dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }memunmap (virt); out_release_firmware:
@@ -758,7 +761,7 @@ static enum ipa_firmware_loader ipa_firmware_loader(struct device *dev)return IPA_LOADER_INVALID ; out_self:/* We need Trust Zone to load firmware; make sure it's available */ -if (qcom_scm_is_available ()) +if (qcom_pas_is_available ())return IPA_LOADER_SELF ;return IPA_LOADER_DEFER ;
Signature · 1 line
2.53.0
PATCH v9 12/14 wifi: ath12k: Switch to generic PAS TZ APIs
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Switch ath12k client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
--- drivers/net/wireless/ath/ath12k/Kconfig | 2 +- drivers/net/wireless/ath/ath12k/ahb.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath12k/Kconfig +1 -1
@@ -18,7 +18,7 @@ config ATH12K_AHB bool "Qualcomm ath12k AHB support" depends on ATH12K && REMOTEPROC select QCOM_MDT_LOADER - select QCOM_SCM + select QCOM_PAS help Enable support for Ath12k AHB bus chipsets, example IPQ5332.
drivers/net/wireless/ath/ath12k/ahb.c +5 -5
@@ -5,7 +5,7 @@*/ #include <linux/dma-mapping.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/platform_device.h>
@@ -420,7 +420,7 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)if (ab_ahb->scm_auth_enabled) {/* Authenticate FW image using peripheral ID */ - ret =qcom_scm_pas_auth_and_reset (pasid); + ret =qcom_pas_auth_and_reset (pasid);if (ret) {ath12k_err (ab,"failed to boot the remote processor %d\n" , ret); goto err_fw2;
@@ -485,10 +485,10 @@ static void ath12k_ahb_power_down(struct ath12k_base *ab, bool is_suspend) pasid = (u32_encode_bits (ab_ahb->userpd_id,ATH12K_USERPD_ID_MASK )) |ATH12K_AHB_UPD_SWID ;/* Release the firmware */ - ret =qcom_scm_pas_shutdown (pasid); + ret =qcom_pas_shutdown (pasid);if (ret) -ath12k_err (ab,"scm pas shutdown failed for userPD%d\n" , - ab_ahb->userpd_id); +ath12k_err (ab,"PAS shutdown failed for userPD%d: %d\n" , + ab_ahb->userpd_id, ret); } }
Signature · 1 line
2.53.0
PATCH v9 13/14 firmware: qcom_scm: Remove SCM PAS wrappers
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Now since all the Qcom SCM client drivers have been migrated over to generic PAS TZ service, let's drop the exported SCM PAS wrappers.
--- drivers/firmware/qcom/qcom_scm.c | 143 +++++-------------------- include/linux/firmware/qcom/qcom_scm.h | 29 ----- 2 files changed, 29 insertions(+), 143 deletions(-)
drivers/firmware/qcom/qcom_scm.c +29 -114
@@ -553,26 +553,6 @@ static void qcom_scm_set_download_mode(u32 dload_mode)dev_err (__scm->dev,"failed to set download mode: %d\n" , ret); } -struct qcom_scm_pas_context *devm_qcom_scm_pas_context_alloc (struct device *dev, -u32 pas_id, -phys_addr_t mem_phys, -size_t mem_size) -{ -struct qcom_pas_context *ctx; - - ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL ); -if (!ctx) -return ERR_PTR (-ENOMEM ); - - ctx->dev = dev; - ctx->pas_id = pas_id; - ctx->mem_phys = mem_phys; - ctx->mem_size = mem_size; - -return (struct qcom_scm_pas_context *)ctx; -} -EXPORT_SYMBOL_GPL (devm_qcom_scm_pas_context_alloc); -static int __qcom_scm_pas_init_image (struct device *dev,u32 pas_id,dma_addr_t mdata_phys,struct qcom_scm_res *res)
@@ -630,9 +610,9 @@ static int qcom_scm_pas_prep_and_init_image(struct device *dev,return ret ? : res.result[0 ]; } -static int __qcom_scm_pas_init_image2 (struct device *dev,u32 pas_id, -const void *metadata,size_t size, -struct qcom_pas_context *ctx) +static int qcom_scm_pas_init_image (struct device *dev,u32 pas_id, +const void *metadata,size_t size, +struct qcom_pas_context *ctx) {struct qcom_scm_res res;dma_addr_t mdata_phys;
@@ -672,16 +652,8 @@ static int __qcom_scm_pas_init_image2(struct device *dev, u32 pas_id,return ret ? : res.result[0 ]; } -int qcom_scm_pas_init_image (u32 pas_id,const void *metadata,size_t size, -struct qcom_scm_pas_context *ctx) -{ -return __qcom_scm_pas_init_image2 (__scm->dev, pas_id, metadata, size, - (struct qcom_pas_context *)ctx); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_init_image); - -static void __qcom_scm_pas_metadata_release (struct device *dev, -struct qcom_pas_context *ctx) +static void qcom_scm_pas_metadata_release (struct device *dev, +struct qcom_pas_context *ctx) {if (ctx->use_tzmem)qcom_tzmem_free (ctx->ptr);
@@ -691,15 +663,8 @@ static void __qcom_scm_pas_metadata_release(struct device *dev, ctx->ptr =NULL ; } -void qcom_scm_pas_metadata_release (struct qcom_scm_pas_context *ctx) -{ -__qcom_scm_pas_metadata_release (__scm->dev, - (struct qcom_pas_context *)ctx); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_metadata_release); - -static int __qcom_scm_pas_mem_setup (struct device *dev,u32 pas_id, -phys_addr_t addr,phys_addr_t size) +static int qcom_scm_pas_mem_setup (struct device *dev,u32 pas_id, +phys_addr_t addr,phys_addr_t size) {int ret;struct qcom_scm_desc desc = {
@@ -730,12 +695,6 @@ static int __qcom_scm_pas_mem_setup(struct device *dev, u32 pas_id,return ret ? : res.result[0 ]; } -int qcom_scm_pas_mem_setup (u32 pas_id,phys_addr_t addr,phys_addr_t size) -{ -return __qcom_scm_pas_mem_setup (__scm->dev, pas_id, addr, size); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_mem_setup); - static void *__qcom_scm_pas_get_rsc_table(struct device *dev, u32 pas_id, void *input_rt_tzm, size_t input_rt_size,
@@ -789,11 +748,10 @@ static void *__qcom_scm_pas_get_rsc_table(struct device *dev, u32 pas_id,return ret ?ERR_PTR (ret) : output_rt_tzm; } -static void *__qcom_scm_pas_get_rsc_table2 (struct device *dev, -struct qcom_pas_context *ctx, -void *input_rt, -size_t input_rt_size, -size_t *output_rt_size) +static void *qcom_scm_pas_get_rsc_table (struct device *dev, +struct qcom_pas_context *ctx, +void *input_rt,size_t input_rt_size, +size_t *output_rt_size) {struct resource_table empty_rsc = {};size_t size =SZ_16K ;
@@ -864,19 +822,7 @@ static void *__qcom_scm_pas_get_rsc_table2(struct device *dev,return ret ?ERR_PTR (ret) : tbl_ptr; } -struct resource_table *qcom_scm_pas_get_rsc_table (struct qcom_scm_pas_context *ctx, -void *input_rt, -size_t input_rt_size, -size_t *output_rt_size) -{ -return __qcom_scm_pas_get_rsc_table2 (__scm->dev, - (struct qcom_pas_context *)ctx, - input_rt, input_rt_size, - output_rt_size); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_get_rsc_table); - -static int __qcom_scm_pas_auth_and_reset (struct device *dev,u32 pas_id) +static int qcom_scm_pas_auth_and_reset (struct device *dev,u32 pas_id) {int ret;struct qcom_scm_desc desc = {
@@ -905,14 +851,8 @@ static int __qcom_scm_pas_auth_and_reset(struct device *dev, u32 pas_id)return ret ? : res.result[0 ]; } -int qcom_scm_pas_auth_and_reset (u32 pas_id) -{ -return __qcom_scm_pas_auth_and_reset (__scm->dev, pas_id); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_auth_and_reset); - -static int __qcom_scm_pas_prepare_and_auth_reset (struct device *dev, -struct qcom_pas_context *ctx) +static int qcom_scm_pas_prepare_and_auth_reset (struct device *dev, +struct qcom_pas_context *ctx) {u64 handle;int ret;
@@ -923,7 +863,7 @@ static int __qcom_scm_pas_prepare_and_auth_reset(struct device *dev,* memory region and then invokes a call to TrustZone to authenticate. */ if (!ctx->use_tzmem) -return __qcom_scm_pas_auth_and_reset (dev, ctx->pas_id); +return qcom_scm_pas_auth_and_reset (dev, ctx->pas_id);/* * When Linux runs @ EL2 Linux must create the shmbridge itself and then
@@ -933,21 +873,14 @@ static int __qcom_scm_pas_prepare_and_auth_reset(struct device *dev,if (ret)return ret; - ret =__qcom_scm_pas_auth_and_reset (dev, ctx->pas_id); + ret =qcom_scm_pas_auth_and_reset (dev, ctx->pas_id);qcom_tzmem_shm_bridge_delete (handle);return ret; } -int qcom_scm_pas_prepare_and_auth_reset (struct qcom_scm_pas_context *ctx) -{ -return __qcom_scm_pas_prepare_and_auth_reset (__scm->dev, - (struct qcom_pas_context *)ctx); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_prepare_and_auth_reset); - -static int __qcom_scm_pas_set_remote_state (struct device *dev,u32 state, -u32 pas_id) +static int qcom_scm_pas_set_remote_state (struct device *dev,u32 state, +u32 pas_id) {struct qcom_scm_desc desc = { .svc =QCOM_SCM_SVC_BOOT ,
@@ -965,13 +898,7 @@ static int __qcom_scm_pas_set_remote_state(struct device *dev, u32 state,return ret ? : res.result[0 ]; } -int qcom_scm_set_remote_state (u32 state,u32 id) -{ -return __qcom_scm_pas_set_remote_state (__scm->dev, state, id); -} -EXPORT_SYMBOL_GPL (qcom_scm_set_remote_state); - -static int __qcom_scm_pas_shutdown (struct device *dev,u32 pas_id) +static int qcom_scm_pas_shutdown (struct device *dev,u32 pas_id) {int ret;struct qcom_scm_desc desc = {
@@ -1000,13 +927,7 @@ static int __qcom_scm_pas_shutdown(struct device *dev, u32 pas_id)return ret ? : res.result[0 ]; } -int qcom_scm_pas_shutdown (u32 pas_id) -{ -return __qcom_scm_pas_shutdown (__scm->dev, pas_id); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_shutdown); - -static bool __qcom_scm_pas_supported (struct device *dev,u32 pas_id) +static bool qcom_scm_pas_supported (struct device *dev,u32 pas_id) {int ret;struct qcom_scm_desc desc = {
@@ -1027,23 +948,17 @@ static bool __qcom_scm_pas_supported(struct device *dev, u32 pas_id)return ret ? false : !!res.result[0 ]; } -bool qcom_scm_pas_supported (u32 pas_id) -{ -return __qcom_scm_pas_supported (__scm->dev, pas_id); -} -EXPORT_SYMBOL_GPL (qcom_scm_pas_supported); -static struct qcom_pas_ops qcom_pas_ops_scm = { .drv_name ="qcom_scm" , - .supported = __qcom_scm_pas_supported, - .init_image = __qcom_scm_pas_init_image2, - .mem_setup = __qcom_scm_pas_mem_setup, - .get_rsc_table = __qcom_scm_pas_get_rsc_table2, - .auth_and_reset = __qcom_scm_pas_auth_and_reset, - .prepare_and_auth_reset = __qcom_scm_pas_prepare_and_auth_reset, - .set_remote_state = __qcom_scm_pas_set_remote_state, - .shutdown = __qcom_scm_pas_shutdown, - .metadata_release = __qcom_scm_pas_metadata_release, + .supported = qcom_scm_pas_supported, + .init_image = qcom_scm_pas_init_image, + .mem_setup = qcom_scm_pas_mem_setup, + .get_rsc_table = qcom_scm_pas_get_rsc_table, + .auth_and_reset = qcom_scm_pas_auth_and_reset, + .prepare_and_auth_reset = qcom_scm_pas_prepare_and_auth_reset, + .set_remote_state = qcom_scm_pas_set_remote_state, + .shutdown = qcom_scm_pas_shutdown, + .metadata_release = qcom_scm_pas_metadata_release, };/**
include/linux/firmware/qcom/qcom_scm.h +0 -29
@@ -64,35 +64,6 @@ bool qcom_scm_is_available(void);int qcom_scm_set_cold_boot_addr (void *entry);int qcom_scm_set_warm_boot_addr (void *entry);void qcom_scm_cpu_power_down (u32 flags); -int qcom_scm_set_remote_state (u32 state,u32 id); - -struct qcom_scm_pas_context { -struct device *dev; -u32 pas_id; -phys_addr_t mem_phys; -size_t mem_size; -void *ptr; -dma_addr_t phys; -ssize_t size; -bool use_tzmem; -}; - -struct qcom_scm_pas_context *devm_qcom_scm_pas_context_alloc (struct device *dev, -u32 pas_id, -phys_addr_t mem_phys, -size_t mem_size); -int qcom_scm_pas_init_image (u32 pas_id,const void *metadata,size_t size, -struct qcom_scm_pas_context *ctx); -void qcom_scm_pas_metadata_release (struct qcom_scm_pas_context *ctx); -int qcom_scm_pas_mem_setup (u32 pas_id,phys_addr_t addr,phys_addr_t size); -int qcom_scm_pas_auth_and_reset (u32 pas_id); -int qcom_scm_pas_shutdown (u32 pas_id); -bool qcom_scm_pas_supported (u32 pas_id); -struct resource_table *qcom_scm_pas_get_rsc_table (struct qcom_scm_pas_context *ctx, -void *input_rt,size_t input_rt_size, -size_t *output_rt_size); - -int qcom_scm_pas_prepare_and_auth_reset (struct qcom_scm_pas_context *ctx);int qcom_scm_io_readl (phys_addr_t addr,unsigned int *val);int qcom_scm_io_writel (phys_addr_t addr,unsigned int val);
Signature · 1 line
2.53.0
PATCH v9 14/14 MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Add Sumit Garg as the maintainer for the Qualcomm generic Peripheral Authentication Service (PAS) as well as the PAS TEE backend driver.
--- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
@@ -22315,6 +22315,15 @@ F: Documentation/devicetree/bindings/media/*qcom* F: drivers/media/platform/qcom F: include/dt-bindings/media/*qcom* +QUALCOMM PAS TZ SERVICE +M: Sumit Garg <[email protected]> +L: [email protected] +S: Maintained +F: drivers/firmware/qcom/qcom_pas.c +F: drivers/firmware/qcom/qcom_pas.h +F: drivers/firmware/qcom/qcom_pas_tee.c +F: include/linux/firmware/qcom/qcom_pas.h + QUALCOMM SMB CHARGER DRIVER M: Casey Connolly <[email protected]> L: [email protected]
Signature · 1 line
2.53.0
Re: [PATCH v9 10/14] media: qcom: Pass proper PAS ID to set_remote_state API
In reply to Sumit GargQuoted 4 lines · Sumit Garg
From: Sumit Garg <[email protected]>
As per testing the SCM backend just ignores it while OP-TEE makes use of it to for proper book keeping purpose.
It's apparently not ignored, but 0 is assumed to mean video for historical reasons
Konrad
Re: [PATCH v9 12/14] wifi: ath12k: Switch to generic PAS TZ APIs
In reply to Sumit GargQuoted 10 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Switch ath12k client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Acked-by Jeff Johnson <[email protected]>Signed-off-by Sumit Garg <[email protected]>---
Konrad
Mathieu Poirier
maintainerHey Sumit - nice hearing from you...
Is there some kind of overarching design harminisation between what you are proposing here and what Arnaud posted back in April [1] ?
Quoted 166 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
OP-TEE as an alternative trusted OS to Qualcomm TEE (QTEE) can't support these non-standard SCM calls. And even for newer architectures using S-EL2 with Hafnium support, QTEE won't be able to support SCM calls either with FF-A requirements coming in. And with both OP-TEE and QTEE drivers well integrated in the TEE subsystem, it makes further sense to reuse the TEE bus client drivers infrastructure.
The added benefit of TEE bus infrastructure is that there is support for discoverable/enumerable services. With that client drivers don't have to manually invoke a special SCM call to know the service status.
So enable the generic Peripheral Authentication Service (PAS) provided by the firmware. It acts as the common layer with different TZ backends plugged in whether it's an SCM implementation or a proper TEE bus based PAS service implementation.
The TEE PAS service ABI is designed to be extensible with additional API as
PTA_QCOM_PAS_CAPABILITIES. This allows to accommodate any future extensions of the PAS service needed while still maintaining backwards compatibility.Currently OP-TEE support is being added to provide the backend PAS service implementation which can be found as part of this PR [1]. This implementation has been tested on Kodiak/RB3Gen2 and lemans EVK boards. In addition to that WIN/IPQ targets tested OP-TEE with this service too. Surely the backwards compatibility is maintained and tested for SCM backend.
Note that kernel PAS service support while running in EL2 is at parity among OP-TEE vs QTEE. Especially the media (venus/iris) support depends on proper IOMMU support being worked out on the PAS client end.
Patch summary:
- Patch #1: adds generic PAS service.
- Patch #2: migrates SCM backend to generic PAS service.
- Patch #3: adds TEE/OP-TEE backend for generic PAS service.
- Patch #4-#12: migrates all client drivers to generic PAS service.
- Patch #13: drops legacy PAS SCM exported APIs.The patch-set is based on v7.2-rc1 and can be found in git tree here [2].
Merge strategy:
It is expected due to APIs dependency, the entire patch-set to go via the Qcom tree. All other subsystem maintainers, it will be great if I can get acks for the corresponding subsystem patches.
[1] https://github.com/OP-TEE/optee_os/pull/7721 (already merged)
[2] https://git.kernel.org/pub/scm/linux/kernel/git/sumit.garg/linux.git/log/?h=qcom-pas-v9---
Changes in v9:
- Rebased to 7.2-rc1.
- Enable SCM backend similar to TEE ifARCH_QCOMis set.
- Address misc. comments from Konrad.
- Add checks for corner cases (although not reachable as per OP-TEE ABI) reported by Shashiko on patch #3.
- Picked up review tags from Konrad.Changes in v8:
- Rebased on mainline tip (no functional changes).
- Now Lemans EVK is also tested to support OP-TEE PAS here:
https://github.com/OP-TEE/optee_os/pull/7845
- Drop Kodiak DT patch as it is carried independently by Mukesh here:
https://lore.kernel.org/lkml/[email protected]/
- Regarding Sashiko comments, I have already replied in v6 the ones that don't apply but in v7 I got the same comments again. Specific context reasoning which Shashiko ignores:
- ABI contract between Linux and TZ
- No support for multiple concurrent backends
- The TZ backend doesn’t detach during the entire boot cycleChanges in v7:
- Rebased to qcom tree (for-next branch) tip.
- Merged patch #5 and #7 due to build dependency.
- Disabled modem for kodiak EL2 as it isn't tested yet.
- Fix an issue found out by sashiko-bot for patch #4.Changes in v6:
- Rebased to v7.1-rc4 tag.
- Patch #14: fixed ret error print.
- AddKconfigdescriptions for PAS symbols such that they are visible in menuconfig to update.Changes in v5:
- Incorporated misc. comments from Mukesh.
- Split up patch #11 into 2 to add an independent commit for passing proper PAS ID toset_remote_stateAPI.
- Picked up tags.Changes in v4:
- Incorporate misc. comments on patch #4.
- Picked up an ack for patch #10.
- Clarify in cover letter about state of media support.Changes in v3:
- Incorporated some style and misc. comments for patch #2, #3 and #4.
- AddQCOM_PASKconfigdependency for various subsystems.
- Switch from pseudo TA to proper TA invoke commands.Changes in v2:
- Fixed kernel doc warnings.
- Polish commit message and comments for patch #2.
- Pass proper PAS ID inset_remote_stateAPI for media firmware drivers.
- Added Maintainer entry and droppedMODULE_AUTHOR.Sumit Garg (14):
firmware: qcom: Add a generic PAS service
firmware:qcom_scm: Migrate to generic PAS service
firmware: qcom: Add a PAS TEE service
remoteproc:qcom_q6v5_pas: Switch over to generic PAS TZ APIs
remoteproc:qcom_q6v5_mss: Switch to generic PAS TZ APIs
remoteproc:qcom_wcnss: Switch to generic PAS TZ APIs
remoteproc: qcom: SelectQCOM_PASgeneric service drm/msm: Switch to generic PAS TZ APIs
media: qcom: Switch to generic PAS TZ APIs
media: qcom: Pass proper PAS ID toset_remote_stateAPI
net: ipa: Switch to generic PAS TZ APIs
wifi: ath12k: Switch to generic PAS TZ APIs
firmware:qcom_scm: Remove SCM PAS wrappers
MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ serviceMAINTAINERS | 9 + drivers/firmware/qcom/Kconfig | 22 +- drivers/firmware/qcom/Makefile | 2 + drivers/firmware/qcom/qcom_pas.c | 299 +++++++++++ drivers/firmware/qcom/qcom_pas.h | 50 ++ drivers/firmware/qcom/qcom_pas_tee.c | 479 ++++++++++++++++++ drivers/firmware/qcom/qcom_scm.c | 302 ++++------- drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 11 +- drivers/media/platform/qcom/iris/Kconfig | 27 +- .../media/platform/qcom/iris/iris_firmware.c | 9 +- drivers/media/platform/qcom/venus/Kconfig | 1 + drivers/media/platform/qcom/venus/firmware.c | 11 +- drivers/net/ipa/Kconfig | 2 +- drivers/net/ipa/ipa_main.c | 13 +- drivers/net/wireless/ath/ath12k/Kconfig | 2 +- drivers/net/wireless/ath/ath12k/ahb.c | 10 +- drivers/remoteproc/Kconfig | 4 +- drivers/remoteproc/qcom_q6v5_mss.c | 5 +- drivers/remoteproc/qcom_q6v5_pas.c | 51 +- drivers/remoteproc/qcom_wcnss.c | 12 +- drivers/soc/qcom/mdt_loader.c | 12 +- include/linux/firmware/qcom/qcom_pas.h | 43 ++ include/linux/firmware/qcom/qcom_scm.h | 29 -- include/linux/soc/qcom/mdt_loader.h | 6 +- 26 files changed, 1095 insertions(+), 321 deletions(-) create mode 100644 drivers/firmware/qcom/qcom_pas.c create mode 100644 drivers/firmware/qcom/qcom_pas.h create mode 100644 drivers/firmware/qcom/qcom_pas_tee.c create mode 100644 include/linux/firmware/qcom/qcom_pas.h--
2.53.0
Hey Mathieu,
Quoted 2 lines · Mathieu Poirier
Hey Sumit - nice hearing from you...
Good to hear from you too.
Quoted 2 lines
Is there some kind of overarching design harminisation between what you are proposing here and what Arnaud posted back in April [1] ?
The design here for remoteproc bringup on Qcom platforms for OP-TEE is carried forward from whatever existed earlier with QTEE. This patch-set just adds OP-TEE backend and replicate the same co-processor bringup design as QTEE.
Co-processor bringup using a TEE is very different on Qcom platforms as compared to what ST did. The image formats for Qcom are custom ones using MBN format over ELF for which the MDT loader exists in the kernel only. Similarly the firmware image authentication is very tightly coupled with Qcom secure boot chain.
The ST framework rather uses an ELF loader in OP-TEE for image loading and have an authentication mechanism similar to TAs. Also, the OP-TEE ABI is altogether different from the PAS ABI that Qcom has for the TEE.
-Sumit
Quoted 171 lines
Quoted 166 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
OP-TEE as an alternative trusted OS to Qualcomm TEE (QTEE) can't support these non-standard SCM calls. And even for newer architectures using S-EL2 with Hafnium support, QTEE won't be able to support SCM calls either with FF-A requirements coming in. And with both OP-TEE and QTEE drivers well integrated in the TEE subsystem, it makes further sense to reuse the TEE bus client drivers infrastructure.
The added benefit of TEE bus infrastructure is that there is support for discoverable/enumerable services. With that client drivers don't have to manually invoke a special SCM call to know the service status.
So enable the generic Peripheral Authentication Service (PAS) provided by the firmware. It acts as the common layer with different TZ backends plugged in whether it's an SCM implementation or a proper TEE bus based PAS service implementation.
The TEE PAS service ABI is designed to be extensible with additional API as
PTA_QCOM_PAS_CAPABILITIES. This allows to accommodate any future extensions of the PAS service needed while still maintaining backwards compatibility.Currently OP-TEE support is being added to provide the backend PAS service implementation which can be found as part of this PR [1]. This implementation has been tested on Kodiak/RB3Gen2 and lemans EVK boards. In addition to that WIN/IPQ targets tested OP-TEE with this service too. Surely the backwards compatibility is maintained and tested for SCM backend.
Note that kernel PAS service support while running in EL2 is at parity among OP-TEE vs QTEE. Especially the media (venus/iris) support depends on proper IOMMU support being worked out on the PAS client end.
Patch summary:
- Patch #1: adds generic PAS service.
- Patch #2: migrates SCM backend to generic PAS service.
- Patch #3: adds TEE/OP-TEE backend for generic PAS service.
- Patch #4-#12: migrates all client drivers to generic PAS service.
- Patch #13: drops legacy PAS SCM exported APIs.The patch-set is based on v7.2-rc1 and can be found in git tree here [2].
Merge strategy:
It is expected due to APIs dependency, the entire patch-set to go via the Qcom tree. All other subsystem maintainers, it will be great if I can get acks for the corresponding subsystem patches.
[1] https://github.com/OP-TEE/optee_os/pull/7721 (already merged)
[2] https://git.kernel.org/pub/scm/linux/kernel/git/sumit.garg/linux.git/log/?h=qcom-pas-v9---
Changes in v9:
- Rebased to 7.2-rc1.
- Enable SCM backend similar to TEE ifARCH_QCOMis set.
- Address misc. comments from Konrad.
- Add checks for corner cases (although not reachable as per OP-TEE ABI) reported by Shashiko on patch #3.
- Picked up review tags from Konrad.Changes in v8:
- Rebased on mainline tip (no functional changes).
- Now Lemans EVK is also tested to support OP-TEE PAS here:
https://github.com/OP-TEE/optee_os/pull/7845
- Drop Kodiak DT patch as it is carried independently by Mukesh here:
https://lore.kernel.org/lkml/[email protected]/
- Regarding Sashiko comments, I have already replied in v6 the ones that don't apply but in v7 I got the same comments again. Specific context reasoning which Shashiko ignores:
- ABI contract between Linux and TZ
- No support for multiple concurrent backends
- The TZ backend doesn’t detach during the entire boot cycleChanges in v7:
- Rebased to qcom tree (for-next branch) tip.
- Merged patch #5 and #7 due to build dependency.
- Disabled modem for kodiak EL2 as it isn't tested yet.
- Fix an issue found out by sashiko-bot for patch #4.Changes in v6:
- Rebased to v7.1-rc4 tag.
- Patch #14: fixed ret error print.
- AddKconfigdescriptions for PAS symbols such that they are visible in menuconfig to update.Changes in v5:
- Incorporated misc. comments from Mukesh.
- Split up patch #11 into 2 to add an independent commit for passing proper PAS ID toset_remote_stateAPI.
- Picked up tags.Changes in v4:
- Incorporate misc. comments on patch #4.
- Picked up an ack for patch #10.
- Clarify in cover letter about state of media support.Changes in v3:
- Incorporated some style and misc. comments for patch #2, #3 and #4.
- AddQCOM_PASKconfigdependency for various subsystems.
- Switch from pseudo TA to proper TA invoke commands.Changes in v2:
- Fixed kernel doc warnings.
- Polish commit message and comments for patch #2.
- Pass proper PAS ID inset_remote_stateAPI for media firmware drivers.
- Added Maintainer entry and droppedMODULE_AUTHOR.Sumit Garg (14):
firmware: qcom: Add a generic PAS service
firmware:qcom_scm: Migrate to generic PAS service
firmware: qcom: Add a PAS TEE service
remoteproc:qcom_q6v5_pas: Switch over to generic PAS TZ APIs
remoteproc:qcom_q6v5_mss: Switch to generic PAS TZ APIs
remoteproc:qcom_wcnss: Switch to generic PAS TZ APIs
remoteproc: qcom: SelectQCOM_PASgeneric service drm/msm: Switch to generic PAS TZ APIs
media: qcom: Switch to generic PAS TZ APIs
media: qcom: Pass proper PAS ID toset_remote_stateAPI
net: ipa: Switch to generic PAS TZ APIs
wifi: ath12k: Switch to generic PAS TZ APIs
firmware:qcom_scm: Remove SCM PAS wrappers
MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ serviceMAINTAINERS | 9 + drivers/firmware/qcom/Kconfig | 22 +- drivers/firmware/qcom/Makefile | 2 + drivers/firmware/qcom/qcom_pas.c | 299 +++++++++++ drivers/firmware/qcom/qcom_pas.h | 50 ++ drivers/firmware/qcom/qcom_pas_tee.c | 479 ++++++++++++++++++ drivers/firmware/qcom/qcom_scm.c | 302 ++++------- drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 11 +- drivers/media/platform/qcom/iris/Kconfig | 27 +- .../media/platform/qcom/iris/iris_firmware.c | 9 +- drivers/media/platform/qcom/venus/Kconfig | 1 + drivers/media/platform/qcom/venus/firmware.c | 11 +- drivers/net/ipa/Kconfig | 2 +- drivers/net/ipa/ipa_main.c | 13 +- drivers/net/wireless/ath/ath12k/Kconfig | 2 +- drivers/net/wireless/ath/ath12k/ahb.c | 10 +- drivers/remoteproc/Kconfig | 4 +- drivers/remoteproc/qcom_q6v5_mss.c | 5 +- drivers/remoteproc/qcom_q6v5_pas.c | 51 +- drivers/remoteproc/qcom_wcnss.c | 12 +- drivers/soc/qcom/mdt_loader.c | 12 +- include/linux/firmware/qcom/qcom_pas.h | 43 ++ include/linux/firmware/qcom/qcom_scm.h | 29 -- include/linux/soc/qcom/mdt_loader.h | 6 +- 26 files changed, 1095 insertions(+), 321 deletions(-) create mode 100644 drivers/firmware/qcom/qcom_pas.c create mode 100644 drivers/firmware/qcom/qcom_pas.h create mode 100644 drivers/firmware/qcom/qcom_pas_tee.c create mode 100644 include/linux/firmware/qcom/qcom_pas.h--
2.53.0
[email protected]
AI reviewRe: [PATCH v9 08/14] drm/msm: Switch to generic PAS TZ APIs
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Generic PAS TEE backend maps TA-level errors to -EINVAL, breaking the DRM MSM fallback logic.
- [High] TOCTOU race condition in generic PAS API wrappers leading to NULL pointer dereference.
- [High] Unconditional PAS availability check causes infinite probe deferral on platforms without PAS support.
Pre-existing issues:
- [High] The MSM DRM driver propagates -EOPNOTSUPP instead of -ENODEV, fatally failing GPU initialization. --
commit fd17ff54a9520d92288105f263b3bc29eb9cbd4b
Author: Sumit Garg <[email protected]>
drm/msm: Switch to generic PAS TZ APIs
Switch drm/msm client drivers over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Quoted 4 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.c +0
-0
[ ... ]
drivers/gpu/drm/msm/adreno/adreno_gpu.c static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, · line 150
Quoted 6 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1
-1@@ -146,10 +147,10 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, goto out;/* Send the image to the secure world */ - ret =qcom_scm_pas_auth_and_reset (pasid); + ret =qcom_pas_auth_and_reset (pasid);
[Severity: High]
Does this new PAS API wrapper have a TOCTOU race condition?
If the PAS backend unregisters concurrently, could ops_ptr become NULL between the check and the dereference in qcom_pas_auth_and_reset()?
drivers/firmware/qcom/qcom_pas.c:qcom_pas_auth_and_reset() {
if (!ops_ptr)
return -ENODEV;
return ops_ptr->auth_and_reset(ops_ptr->dev, pas_id);
}drivers/gpu/drm/msm/adreno/adreno_gpu.c static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, · line 156
Quoted 7 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1
-1/* -* If the scm call returns -EOPNOTSUPP we assume that this target +* If the pas call returns -EOPNOTSUPP we assume that this target * doesn't need/support the zap shader so quietly fail */ if (ret == -EOPNOTSUPP )
[Severity: High]
Is the DRM MSM fallback logic preserved with this generic backend?
The driver expects -EOPNOTSUPP to gracefully handle unsupported zap shaders.
If the generic PAS TEE backend's __qcom_pas_tee_auth_and_reset() unconditionally maps all TA errors to -EINVAL, will this cause GPU probe to fail fatally on TEE platforms where the zap shader is not supported?
drivers/firmware/qcom/qcom_pas_tee.c:__qcom_pas_tee_auth_and_reset() {
ret = tee_client_invoke_func(data->ctx, &inv_arg, param);
if (ret < 0 || inv_arg.ret != 0) {
...
return ret ?: -EINVAL;
}
}[Severity: High]
This isn't a bug introduced by this patch, but does this function propagate -EOPNOTSUPP instead of -ENODEV?
If qcom_pas_auth_and_reset() returns -EOPNOTSUPP, the code sets zap_available = false but leaves ret = -EOPNOTSUPP.
Since callers explicitly check for -ENODEV to fall back to SECVID_TRUST_CNTL, could this unmapped -EOPNOTSUPP abort hardware initialization?
Quoted 3 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.c +0
-0zap_available = false;drivers/gpu/drm/msm/adreno/adreno_gpu.c +0
-0else if (ret)DRM_DEV_ERROR (dev,"Unable to authorize the image\n" );
[ ... ]
drivers/gpu/drm/msm/adreno/adreno_gpu.c int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid) · line 183
Quoted 12 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3
-3@@ -175,9 +176,9 @@ int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid)if (!zap_available)return -ENODEV ; -/* We need SCM to be able to load the firmware */ -if (!qcom_scm_is_available ()) { -DRM_DEV_ERROR (&pdev->dev,"SCM is not available\n" ); +/* We need PAS to be able to load the firmware */ +if (!qcom_pas_is_available ()) { +DRM_DEV_ERROR (&pdev->dev,"PAS is not available\n" );return -EPROBE_DEFER ; }
[Severity: High]
Could this unconditional PAS availability check cause infinite probe deferral on platforms without PAS support?
By checking qcom_pas_is_available() before checking if the zap-shader DT node exists (which happens inside zap_shader_load_mdt()), do platforms that lack PAS capabilities fail to reach the DT node check and defer indefinitely?
Previously, qcom_scm_is_available() returned true on these platforms, allowing the driver to gracefully return -ENODEV when the DT node was missing.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
[email protected]
AI reviewRe: [PATCH v9 06/14] remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] The generic qcom_pas API lacks synchronization against concurrent registration and backend unregistration, leading to TOCTOU races and Use-After-Free.
- [High] Blindly trusting param[1].u.memref.size from the second TEE invocation in qcom_pas_tee_get_rsc_table() leads to an out-of-bounds read and kernel memory leak.
Pre-existing issues:
- [High] The wcnss_probe() function fails to clean up sysmon and smd subdevices on error paths, leading to memory/socket leaks and dangling pointers in a global notifier chain. --
commit f9552b7475ea1af7226f210e3b4d0e315d46e17d
Author: Sumit Garg <[email protected]>
remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs
Switch qcom_wcnss client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Quoted 4 lines
Switch
qcom_wcnssclient driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
[Severity: High]
Is there an out-of-bounds read and kernel memory leak in the OP-TEE PAS service?
In drivers/firmware/qcom/qcom_pas_tee.c:qcom_pas_tee_get_rsc_table(), a shared memory buffer is allocated based on the size from the first TEE invocation. In the second TEE invocation, the TEE can modify param[1].u.memref.size.
The function then blindly trusts this size:
*output_rt_size = param[1].u.memref.size;
rt_buf = kmemdup(rt_shm_va, *output_rt_size, GFP_KERNEL);Can a compromised TrustZone environment return an increased size, causing an out-of-bounds read from the originally allocated buffer?
Quoted 4 lines
drivers/remoteproc/qcom_wcnss.c +0
-0
[ ... ]
drivers/remoteproc/qcom_wcnss.c static int wcnss_start(struct rproc *rproc) · line 260
Quoted 6 lines
drivers/remoteproc/qcom_wcnss.c +1
-1@@ -257,7 +257,7 @@ static int wcnss_start(struct rproc *rproc)wcnss_indicate_nv_download (wcnss);wcnss_configure_iris (wcnss); - ret =qcom_scm_pas_auth_and_reset (WCNSS_PAS_ID ); + ret =qcom_pas_auth_and_reset (WCNSS_PAS_ID );
[Severity: High]
Can this introduce a TOCTOU race window?
If multiple PAS backends probe concurrently, qcom_pas_ops_register() in drivers/firmware/qcom/qcom_pas.c performs a lockless read-modify-write of ops_ptr:
if (!qcom_pas_is_available())
smp_store_release(&ops_ptr, ops);This allows one backend to silently overwrite another.
Additionally, when this driver calls qcom_pas_auth_and_reset(), it lacks RCU or try_module_get() protection:
if (!ops_ptr)
return -ENODEV;
return ops_ptr->auth_and_reset(ops_ptr->dev, pas_id);If the backend module is unloaded concurrently, ops_ptr is unregistered and the module memory is freed, leaving this driver to dereference a dangling function pointer. Is there a way to serialize these registrations and protect the backend access?
[ ... ]
drivers/remoteproc/qcom_wcnss.c static int wcnss_probe(struct platform_device *pdev) · line 561
Quoted 7 lines
drivers/remoteproc/qcom_wcnss.c +1
-1@@ -557,10 +557,10 @@ static int wcnss_probe(struct platform_device *pdev) data =of_device_get_match_data (&pdev->dev); -if (!qcom_scm_is_available ()) +if (!qcom_pas_is_available ())return -EPROBE_DEFER ;
[Severity: High]
This is a pre-existing issue, but does wcnss_probe() fail to clean up subdevices on error paths?
Earlier in wcnss_probe(), qcom_add_sysmon_subdev() and qcom_add_smd_subdev() are called. If qcom_iris_probe() subsequently fails (e.g., returning -EPROBE_DEFER because regulators are not ready), the error path jumps to detach_pds:
if (IS_ERR(wcnss->iris)) {
ret = PTR_ERR(wcnss->iris);
goto detach_pds;
}And the cleanup path skips subdevice removal entirely:
remove_iris:
qcom_iris_remove(wcnss->iris);
detach_pds:
wcnss_release_pds(wcnss);Since qcom_add_sysmon_subdev() allocates memory, creates a QMI socket, and registers a notifier on the global sysmon_notifiers chain, does this leak these resources on every probe deferral?
Furthermore, sysmon->dev caches the platform device pointer, which becomes a dangling pointer if the device is ultimately removed. Could this lead to a use-after-free when sysmon_notify iterates over the leaked notifiers?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
AI reviewRe: [PATCH v9 07/14] remoteproc: qcom: Select QCOM_PAS generic service
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] QCOM_WCNSS_PIL still implicitly depends on QCOM_SCM via QCOM_MDT_LOADER, defeating the attempted…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] QCOM_WCNSS_PIL still implicitly depends on QCOM_SCM via QCOM_MDT_LOADER, defeating the attempted decoupling. --
commit daedd535ea1eca89bbb7b28d89c346e3968988b4
Author: Sumit Garg <[email protected]>
remoteproc: qcom: Select QCOM_PAS generic service
This commit selects the PAS generic service driver to enable support for multiple PAS backends like OP-TEE in addition to SCM.
Quoted 4 lines
drivers/remoteproc/Kconfig +0
-0
[ ... ]
drivers/remoteproc/Kconfig config QCOM_WCNSS_PIL · line 287
Quoted 6 lines
drivers/remoteproc/Kconfig +1
-1@@ -282,7 +284,7 @@ config QCOM_WCNSS_PIL select QCOM_MDT_LOADER select QCOM_PIL_INFO select QCOM_RPROC_COMMON - select QCOM_SCM + select QCOM_PAS
[Severity: Medium]
Does this change fully decouple the driver from QCOM_SCM as intended?
Looking at drivers/soc/qcom/Kconfig, QCOM_MDT_LOADER still contains a select QCOM_SCM directive. Since QCOM_WCNSS_PIL continues to select QCOM_MDT_LOADER, it seems Kconfig will still unconditionally enable QCOM_SCM through transitive dependency propagation.
Will this prevent users from building the driver solely with the OP-TEE PAS backend, as the kernel image would still pull in the SCM backend?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
[email protected]
AI reviewRe: [PATCH v9 09/14] media: qcom: Switch to generic PAS TZ APIs
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Calling qcom_scm_mem_protect_video_var() after changing the availability check to qcom_pas_is_available() causes a NULL pointer dereference on non-SCM platforms.
Pre-existing issues:
- [High] The iris driver misses the mandatory qcom_pas_is_available() check, failing to defer probe and missing an smp_load_acquire() memory barrier when accessing the generic PAS API. --
commit d77a18836b2d6ae833e5833c165d79299ffd8a66
Author: Sumit Garg <[email protected]>
media: qcom: Switch to generic PAS TZ APIs
Switch qcom media client drivers over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0
[ ... ]
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 84
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_firmware.c +1
-1@@ -80,7 +81,7 @@ int iris_fw_load(struct iris_core *core)return -ENOMEM ; } - ret =qcom_scm_pas_auth_and_reset (IRIS_PAS_ID ); + ret =qcom_pas_auth_and_reset (IRIS_PAS_ID );
[Severity: High]
This is a pre-existing issue, but it seems the iris driver is missing a check for qcom_pas_is_available() during probe to defer if the backend isn't ready.
Because it misses the qcom_pas_is_available() check, it misses the mandatory smp_load_acquire() memory barrier.
When userspace opens the device, iris_fw_load() invokes qcom_pas_auth_and_reset(). This function performs a plain lockless load of ops_ptr.
Is it possible for a weakly ordered architecture to observe a non-NULL ops_ptr but uninitialized function pointers within the ops structure here, causing a kernel panic?
drivers/media/platform/qcom/iris/iris_firmware.c int iris_fw_load(struct iris_core *core) · line 98
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_firmware.c +1
-1if (ret) {dev_err (core->dev,"auth and reset failed: %d\n" , ret);return ret;@@ -94,7 +95,7 @@ int iris_fw_load(struct iris_core *core) cp_config->cp_nonpixel_size);if (ret) {dev_err (core->dev,"qcom_scm_mem_protect_video_var failed: %d\n" , ret); -qcom_scm_pas_shutdown (IRIS_PAS_ID ); +qcom_pas_shutdown (IRIS_PAS_ID );
[Severity: High]
If the PAS backend is non-SCM (like OP-TEE), the SCM driver will not be probed.
Since qcom_scm_mem_protect_video_var() is still called unconditionally just before this error handling block, will it dereference a NULL __scm pointer (__scm->dev) and crash the kernel?
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_firmware.c +0
-0return ret; } }drivers/media/platform/qcom/venus/firmware.c +0
-0
[ ... ]
Quoted 9 lines
drivers/media/platform/qcom/venus/firmware.c +1
-1@@ -218,7 +219,7 @@ int venus_boot(struct venus_core *core)int ret;if (!IS_ENABLED (CONFIG_QCOM_MDT_LOADER ) || - (core->use_tz && !qcom_scm_is_available ())) + (core->use_tz && !qcom_pas_is_available ()))return -EPROBE_DEFER ; ret = of_property_read_string_index(dev->of_node, "firmware-name", 0,
[ ... ]
drivers/media/platform/qcom/venus/firmware.c int venus_boot(struct venus_core *core) · line 263
Quoted 6 lines
drivers/media/platform/qcom/venus/firmware.c +1
-1@@ -259,7 +260,7 @@ int venus_boot(struct venus_core *core) res->cp_nonpixel_start, res->cp_nonpixel_size);if (ret) { -qcom_scm_pas_shutdown (VENUS_PAS_ID ); +qcom_pas_shutdown (VENUS_PAS_ID );
[Severity: High]
Similar to the iris driver, the availability check was changed to qcom_pas_is_available(), but qcom_scm_mem_protect_video_var() is still called unconditionally when cp_size > 0.
Will this also result in a NULL pointer dereference on non-SCM platforms?
Quoted 3 lines
drivers/media/platform/qcom/venus/firmware.c +0
-0dev_err (dev,"set virtual address ranges fail (%d)\n" , ret);return ret;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
[email protected]
AI reviewRe: [PATCH v9 05/14] remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Replacing the SCM availability check with a generic PAS check during probe breaks the strict SCM…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Replacing the SCM availability check with a generic PAS check during probe breaks the strict SCM dependency for memory protection, leading to a NULL pointer dereference in qcom_scm_assign_mem().
- [High] Missing module reference counting in the generic PAS API exposes client drivers to a TOCTOU race and use-after-free if the backend module is unloaded.
--
commit f9f49708d56de20022405acdb58867dd0cffe7bb
Author: Sumit Garg <[email protected]>
remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs
Switch qcom_q6v5_mss client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_mss.c +0
-0
[ ... ]
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_mpss_load(struct q6v5 *qproc) · line 1484
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_mss.c +1
-1@@ -1480,7 +1481,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc) }if (qproc->need_pas_mem_setup) { - ret =qcom_scm_pas_mem_setup (MPSS_PAS_ID , qproc->mpss_phys, qproc->mpss_size); + ret =qcom_pas_mem_setup (MPSS_PAS_ID , qproc->mpss_phys, qproc->mpss_size);
[Severity: High]
Is there a time-of-check to time-of-use race in the generic PAS API that could lead to a use-after-free or NULL pointer dereference?
The client driver switches to using the newly introduced generic PAS API without any mechanism to prevent backend unloads.
Looking at qcom_pas_mem_setup() in drivers/firmware/qcom/qcom_pas.c, the API locklessly dereferences ops_ptr after checking it, without holding a module reference or synchronization:
drivers/firmware/qcom/qcom_pas.c:qcom_pas_mem_setup() {
if (!ops_ptr)
return -ENODEV;
return ops_ptr->mem_setup(ops_ptr->dev, pas_id, addr, size);
}If a privileged user unloads the backend module (like qcom_pas_tee) concurrently with the client driver starting the remoteproc, ops_ptr could be set to NULL between the check and the dereference.
Does the generic PAS API need module reference counting (like try_module_get()) or device links to prevent the backend module from being unloaded while in use?
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_mss.c +0
-0if (ret) {dev_err (qproc->dev,"setting up mpss memory failed: %d\n" , ret);
[ ... ]
drivers/remoteproc/qcom_q6v5_mss.c static int q6v5_probe(struct platform_device *pdev) · line 2081
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_mss.c +1
-1@@ -2077,7 +2078,7 @@ static int q6v5_probe(struct platform_device *pdev)if (!desc)return -EINVAL ; -if (desc->need_mem_protection && !qcom_scm_is_available ()) +if (desc->need_mem_protection && !qcom_pas_is_available ())
[Severity: High]
Does this change break the memory protection dependency on the SCM driver?
If desc->need_mem_protection is true, but the SCM driver is not available (for example, if the OP-TEE PAS backend probes first, or if SCM fails to probe), q6v5_probe() will now observe qcom_pas_is_available() as true and incorrectly succeed without deferring probe for SCM.
When the remoteproc is later started, q6v5_xfer_mem_ownership() unconditionally calls qcom_scm_assign_mem(), which directly dereferences the uninitialized __scm pointer:
drivers/firmware/qcom/qcom_scm.c:qcom_scm_assign_mem() {
...
void *ptr __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool,
ptr_sz, GFP_KERNEL);...
}
Could this lead to a NULL pointer dereference in qcom_scm_assign_mem() on configurations that use OP-TEE PAS or have SCM probe delayed?
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_mss.c +0
-0return -EPROBE_DEFER ; mba_image = desc->hexagon_mba_image;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH v9 04/14] remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unconditional call to SCM-specific qcom_scm_assign_mem() causes NULL pointer dereference with non-SCM backends.
- [High] Missing module reference counting in the generic PAS API introduces a Use-After-Free and race condition.
Pre-existing issues:
- [High] Asynchronous pm_runtime_put() is canceled during device removal, leaving hardware powered on.
- [High] The DTB firmware buffer is leaked on the successful boot path.
- [High] The DTB PAS backend authentication session is not shut down if starting the main image fails. --
commit 5fe417b2557886cf59a2b2dcdc429ef1c4165522
Author: Sumit Garg <[email protected]>
remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs
Switch qcom_q6v5_pas client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Since qcom_q6v5_pas depends on MDT loader for PAS firmware loading, it has to be switched over to generic PAS APIs in this commit to avoid any build issues.
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pas.c +0
-0
[ ... ]
drivers/remoteproc/qcom_q6v5_pas.c static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw) · line 249
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pas.c +0
-0@@ -247,7 +248,7 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)return 0 ;
[Severity: High]
This is a pre-existing issue, but does this leak the dtb_firmware buffer on the successful boot path?
If the loading process succeeds, the function returns 0 without releasing the buffer allocated earlier by request_firmware(). Since the remoteproc core only automatically frees the main firmware buffer, wouldn't the auxiliary dtb_firmware buffer be left allocated every time the remote processor boots?
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pas.c +1
-1release_dtb_metadata: -qcom_scm_pas_metadata_release (pas->dtb_pas_ctx); +qcom_pas_metadata_release (pas->dtb_pas_ctx);release_firmware (pas->dtb_firmware);return ret;
[ ... ]
drivers/remoteproc/qcom_q6v5_pas.c static int qcom_pas_start(struct rproc *rproc) · line 361
Quoted 12 lines
drivers/remoteproc/qcom_q6v5_pas.c +2
-2@@ -352,9 +353,9 @@ static int qcom_pas_start(struct rproc *rproc) unmap_carveout:qcom_pas_unmap_carveout (rproc, pas->mem_phys, pas->mem_size); release_pas_metadata: -qcom_scm_pas_metadata_release (pas->pas_ctx); +qcom_pas_metadata_release (pas->pas_ctx);if (pas->dtb_pas_id) -qcom_scm_pas_metadata_release (pas->dtb_pas_ctx); +qcom_pas_metadata_release (pas->dtb_pas_ctx); unmap_dtb_carveout:if (pas->dtb_pas_id)
[Severity: High]
This is a pre-existing issue, but does the error rollback path miss shutting down the DTB PAS backend?
If a subsequent step in qcom_pas_start() fails after the DTB image is mapped and authenticated, the error path jumps to release_pas_metadata and unmap_dtb_carveout.
However, it doesn't appear to invoke qcom_pas_shutdown() for the dtb_pas_id. Could this leave the DTB backend authentication session active and prevent the subsystem from loading again until the device reboots?
[ ... ]
drivers/remoteproc/qcom_q6v5_pas.c static int qcom_pas_stop(struct rproc *rproc) · line 407
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pas.c +1
-1@@ -403,7 +404,7 @@ static int qcom_pas_stop(struct rproc *rproc)if (ret == -ETIMEDOUT )dev_err (pas->dev,"timed out on wait\n" ); - ret =qcom_scm_pas_shutdown (pas->pas_id); + ret =qcom_pas_shutdown (pas->pas_id);
[Severity: High]
Could this lead to memory corruption if the backend module is unloaded?
With the switch to the generic PAS API, struct qcom_pas_ops lacks an owner field, and the wrapper functions don't take a reference to the backend module using try_module_get().
If the backend is unloaded concurrently, the global ops_ptr would be cleared, causing qcom_pas_shutdown() to return -ENODEV instead of shutting down the hardware.
Wouldn't the remote processor continue executing while its carveout memory is unmapped and freed by Linux?
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pas.c +0
-0if (ret && pas->decrypt_shutdown) ret =qcom_pas_shutdown_poll_decrypt (pas);if (ret)
[ ... ]
drivers/remoteproc/qcom_q6v5_pas.c static int qcom_pas_probe(struct platform_device *pdev) · line 749
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pas.c +1
-1@@ -743,7 +744,7 @@ static int qcom_pas_probe(struct platform_device *pdev)if (!desc)return -EINVAL ; -if (!qcom_scm_is_available ()) +if (!qcom_pas_is_available ())return -EPROBE_DEFER ;
[Severity: High]
Can this cause a NULL pointer dereference with non-SCM backends?
By broadening the check to qcom_pas_is_available(), probe can proceed when backed by non-SCM services like OP-TEE. However, further down in the probe sequence, qcom_pas_assign_memory_region() unconditionally calls the SCM-specific qcom_scm_assign_mem() (if region_assign_idx is present).
If qcom_scm did not probe, the internal pointer inside qcom_scm_assign_mem() would be NULL, leading to a kernel panic when dereferenced.
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_pas.c +0
-0fw_name = desc->firmware_name;ret = of_property_read_string(pdev->dev.of_node, "firmware-name",
[ ... ]
drivers/remoteproc/qcom_q6v5_pas.c static int qcom_pas_probe(struct platform_device *pdev) · line 845
Quoted 13 lines
drivers/remoteproc/qcom_q6v5_pas.c +2
-2@@ -835,16 +836,16 @@ static int qcom_pas_probe(struct platform_device *pdev)qcom_add_ssr_subdev (rproc, &pas->ssr_subdev, desc->ssr_name); - pas->pas_ctx =devm_qcom_scm_pas_context_alloc (pas->dev, pas->pas_id, - pas->mem_phys, pas->mem_size); + pas->pas_ctx =devm_qcom_pas_context_alloc (pas->dev, pas->pas_id, + pas->mem_phys, pas->mem_size);if (IS_ERR (pas->pas_ctx)) { ret =PTR_ERR (pas->pas_ctx); goto remove_ssr_sysmon; }
[Severity: High]
This isn't a bug introduced by this patch, but does the device teardown path cancel pending asynchronous suspends?
If probe fails and jumps to the teardown labels, qcom_pas_pds_disable() is called, which drops the usage counter for power domains using the asynchronous pm_runtime_put(). This is followed shortly by pm_runtime_disable() in qcom_pas_pds_detach().
Since pm_runtime_disable() cancels pending asynchronous suspend work, wouldn't this leave the hardware in an incorrect active power state? Should the synchronous pm_runtime_put_sync() be used instead?
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_pas.c +3
-3- pas->dtb_pas_ctx =devm_qcom_scm_pas_context_alloc (pas->dev, pas->dtb_pas_id, - pas->dtb_mem_phys, - pas->dtb_mem_size); + pas->dtb_pas_ctx =devm_qcom_pas_context_alloc (pas->dev, pas->dtb_pas_id, + pas->dtb_mem_phys, + pas->dtb_mem_size);if (IS_ERR (pas->dtb_pas_ctx)) { ret =PTR_ERR (pas->dtb_pas_ctx); goto remove_ssr_sysmon;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH v9 01/14] firmware: qcom: Add a generic PAS service
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] TOCTOU data race and missing memory barriers in PAS wrapper functions. - [High] Check-then-set…
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] TOCTOU data race and missing memory barriers in PAS wrapper functions.
- [High] Check-then-set race condition in qcom_pas_ops_register() allows concurrent overwrites and unsafe reads.
- [High] Missing module lifecycle management and reference counting for the PAS backend provider.
- [Medium] Resource leak when calling qcom_pas_metadata_release after provider unregistration.
- [Medium] Missing NULL pointer validation for mandatory ops callbacks before execution.
--
Note: This review is provided in a free-form summary format without direct patch quotes due to system recitation restrictions.
[Severity: High]
In wrapper functions like qcom_pas_init_image() and qcom_pas_get_rsc_table(), the code checks if ops_ptr is NULL using a plain load, and then subsequently dereferences ops_ptr to call the provider.
Since these loads are not protected by a mechanism to fetch into a local variable, could the compiler fetch the pointer multiple times from memory? If the provider module is unloaded concurrently, might ops_ptr become NULL between the check and the dereference, leading to a crash?
[Severity: High]
Looking at qcom_pas_ops_register(), there appears to be a check-then-set race condition. If two threads call this simultaneously, both might check the availability, see NULL, and both perform the store release, allowing concurrent registrations to overwrite each other.
Additionally, in the error path for this function, it directly reads the driver name from ops_ptr. If qcom_pas_ops_unregister() is called concurrently, could this pointer become NULL and cause a crash when printing the error?
[Severity: High]
The qcom_pas_ops structure lacks a module owner field for lifecycle management.
When wrapper functions like qcom_pas_auth_and_reset() invoke these callbacks, they do not appear to pin the provider module in memory using a reference count. If the backend provider module is unloaded while its callbacks are actively executing, will the kernel jump to unmapped memory?
[Severity: Medium]
In qcom_pas_metadata_release(), there is an early return if the operations pointer is NULL.
If the backend provider is unregistered before the client releases its context, this bypasses the metadata release callback entirely. Does this early return permanently leak resources, such as DMA mappings or shared memory, that were allocated by the client during initialization?
[Severity: Medium]
Wrapper functions like qcom_pas_shutdown() directly execute callbacks from the operations pointer without verifying if the specific function pointer is populated.
If a registered backend provider fails to populate all mandatory callback function pointers during registration, could this lead to a NULL pointer dereference when the wrapper attempts to execute them?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH v9 03/14] firmware: qcom: Add a PAS TEE service
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider: - [High] qcom_pas_tee_remove() unconditionally unregisters the global PAS ops, which can corrupt system…
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] qcom_pas_tee_remove() unconditionally unregisters the global PAS ops, which can corrupt system state by deregistering another active backend.
- [High] qcom_pas_tee_get_rsc_table() fails with -EINVAL and aborts initialization when handling a zero-sized resource table.
- [High] Broken TEE size-query logic in qcom_pas_tee_get_rsc_table() aborts on TEEC_ERROR_SHORT_BUFFER and passes a NULL buffer with a non-zero size.
- [High] qcom_pas_tee_get_rsc_table() silently discards the resource table if the TA requests a size smaller than input_rt_size.
- [High] Lack of synchronization and module refcounting on the global ops_ptr leads to TOCTOU and Use-After-Free bugs.
- [High] Unvalidated TA-provided size leads to an out-of-bounds read of kernel memory in qcom_pas_tee_get_rsc_table().
--
Note: The format of this report is altered due to system recitation restrictions. Instead of inline diff quotes, a free-form summary of the findings is provided below.
commit c175d6ee38b74c2a77d95052360287597c771c21
Author: Sumit Garg <[email protected]>
Subject: firmware: qcom: Add a PAS TEE service
This commit adds support for the Peripheral Authentication Service (PAS) driver based on the TEE bus with OP-TEE. It provides the backend PAS service implementation.
[Severity: High]
In drivers/firmware/qcom/qcom_pas_tee.c during driver removal, does qcom_pas_tee_remove() forcefully unregister the global PAS ops even if this driver wasn't the one that successfully registered them?
Looking at qcom_pas_tee_probe(), it calls qcom_pas_ops_register() which returns void and only logs an error if another provider (like qcom_scm) is already registered. This allows the probe to succeed without aborting. However, upon module removal, qcom_pas_tee_remove() unconditionally calls qcom_pas_ops_unregister() which wipes the global pointer, potentially breaking subsequent operations for the actual active backend.
[Severity: High]
Does qcom_pas_tee_get_rsc_table() fail the initialization sequence for peripherals without dynamic resource requirements?
If input_rt_size is 0 and the TA also returns a required size of 0, the driver allocates a 0-sized shared memory object and calls tee_shm_get_va(rt_shm, 0). This triggers a size check failure internally in the TEE subsystem because the offset (0) is not less than the size (0), returning -EINVAL and aborting the setup sequence.
[Severity: High]
Could the TEE size-query logic in qcom_pas_tee_get_rsc_table() pass a NULL buffer with a non-zero size to the TA?
During the initial invocation, the driver sets the parameter size to input_rt_size but does not allocate a shared memory buffer, passing NULL. Additionally, if the TA correctly responds with TEEC_ERROR_SHORT_BUFFER to request a larger buffer, the driver treats any non-zero return code as a fatal error and aborts instead of proceeding to allocate the buffer.
[Severity: High]
Will qcom_pas_tee_get_rsc_table() silently discard the resource table if the TA requires a smaller size than the original input_rt_size?
If the TA optimizes or removes entries and returns a required size strictly less than input_rt_size, the driver falls into the else block, sets the output size to 0, and returns NULL. This causes the original static resource table to be lost.
[Severity: High]
Are there missing concurrency protections for the global ops_ptr in the new core driver design?
In wrappers like qcom_pas_shutdown(), the global ops_ptr is read twice (first to check for NULL, then to dereference) without any locking or RCU. If qcom_pas_tee_remove() is called concurrently, it sets ops_ptr to NULL, which could cause a NULL pointer dereference. Furthermore, since the operations structure lacks an owner field to pin the module in memory, the backend module could be unloaded while its functions are actively executing on another CPU.
[Severity: High]
Can qcom_pas_tee_get_rsc_table() read out of bounds from kernel memory if the TA provides an unexpectedly large size?
During the second TA invocation, the driver unconditionally trusts the size returned by the TA and uses it in kmemdup(). If the returned size exceeds the originally allocated size of the rt_shm buffer, kmemdup() will read past the bounds of the buffer on the kernel heap, leaking sensitive memory.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH v9 11/14] net: ipa: Switch to generic PAS TZ APIs
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Switching to the generic PAS API breaks the hard module dependency on the PAS backend driver…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Switching to the generic PAS API breaks the hard module dependency on the PAS backend driver, exposing a TOCTOU and Use-After-Free race condition against backend module unloading. --
commit 6d60b150886ed8cbb76a8f5f11bec8a93730899c
Author: Sumit Garg <[email protected]>
Subject: net: ipa: Switch to generic PAS TZ APIs
This commit switches the IPA client driver to use the generic PAS TZ APIs. The change allows the driver to support multiple TrustZone implementation backends rather than being tied specifically to the QTEE based SCM PAS service.
Quoted 4 lines
drivers/net/ipa/ipa_main.c static int ipa_firmware_load(struct device *dev) · line 630
Quoted 10 lines
drivers/net/ipa/ipa_main.c +3
-3@@ -624,10 +624,13 @@ static int ipa_firmware_load(struct device *dev) } ret =qcom_mdt_load (dev, fw, path,IPA_PAS_ID , virt, phys, size,NULL ); -if (ret) +if (ret) {dev_err (dev,"error %d loading \"%s\"\n" , ret, path); -else if ((ret =qcom_scm_pas_auth_and_reset (IPA_PAS_ID ))) -dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }else { + ret =qcom_pas_auth_and_reset (IPA_PAS_ID );
[Severity: High]
Does switching to the generic PAS API here break the hard module dependency on the PAS backend driver?
By removing the direct symbol dependency on qcom_scm, it appears the backend PAS module can now be concurrently unloaded. If the backend is unloaded during this call, could it cause a use-after-free or NULL pointer dereference?
For example:
1. ipa_firmware_load() calls qcom_pas_auth_and_reset().
2. qcom_pas_auth_and_reset() checks if (!ops_ptr).
3. The backend PAS module is concurrently unloaded, and qcom_pas_ops_unregister() clears ops_ptr and frees the module memory.
4. qcom_pas_auth_and_reset() dereferences the now-freed ops_ptr memory.
Before this patch, the direct symbol call to qcom_scm_pas_auth_and_reset() forced a strict module dependency that prevented backend removal.
Quoted 5 lines
drivers/net/ipa/ipa_main.c +3
-0+if (ret) +dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }memunmap (virt);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
[email protected]
AI reviewRe: [PATCH v9 12/14] wifi: ath12k: Switch to generic PAS TZ APIs
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Lockless double-read of global ops_ptr causes TOCTOU NULL pointer dereference.
Pre-existing issues:
- [High] Repeated calls to devm_memremap() cause memory/vmap leaks during firmware recovery.
- [High] Missing qcom_pas_shutdown() on error paths leaves remote processor running. --
commit e338489a518c55193a64126b6633cfb19d87e0ba
Author: Sumit Garg <[email protected]>
wifi: ath12k: Switch to generic PAS TZ APIs
This commit switches the ath12k client driver over to generic PAS TZ APIs to support multiple TZ implementation backends.
Quoted 4 lines
drivers/net/wireless/ath/ath12k/ahb.c +0
-0
[ ... ]
drivers/net/wireless/ath/ath12k/ahb.c static int ath12k_ahb_power_up(struct ath12k_base *ab) · line 423
Quoted 6 lines
drivers/net/wireless/ath/ath12k/ahb.c +1
-1@@ -420,7 +420,7 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)if (ab_ahb->scm_auth_enabled) {/* Authenticate FW image using peripheral ID */ - ret =qcom_scm_pas_auth_and_reset (pasid); + ret =qcom_pas_auth_and_reset (pasid);
[Severity: High]
This is a pre-existing issue, but does ath12k_ahb_power_up() leak memory during firmware recovery?
Earlier in this function, devm_memremap() is used:
mem_region = devm_memremap(dev, mem_phys, mem_size, MEMREMAP_WC);
When the ath12k device undergoes a firmware crash recovery or reset, ath12k_core_reset() calls ath12k_hif_power_up(), which calls ath12k_ahb_power_up(). Because devm_memremap() allocates device-managed memory, and the device itself is not destroyed or unbound during a reset, the memory mapping is permanently leaked into the device's resource list.
[Severity: High]
Does calling this new API introduce a TOCTOU NULL pointer dereference?
Looking at qcom_pas_auth_and_reset() in drivers/firmware/qcom/qcom_pas.c:
int qcom_pas_auth_and_reset(u32 pas_id)
{
if (!ops_ptr)
return -ENODEV;
return ops_ptr->auth_and_reset(ops_ptr->dev, pas_id);
}If a concurrent module unload of the PAS backend occurs, ops_ptr could be set to NULL between the check and the dereference. Even with READ_ONCE(), the lack of module reference counting allows the backend to be unloaded while its functions are executing. The same issue exists in qcom_pas_shutdown().
drivers/net/wireless/ath/ath12k/ahb.c static int ath12k_ahb_power_up(struct ath12k_base *ab) · line 426
Quoted 3 lines
drivers/net/wireless/ath/ath12k/ahb.c +0
-0if (ret) {ath12k_err (ab,"failed to boot the remote processor %d\n" , ret); goto err_fw2;
[Severity: High]
This is a pre-existing issue, but does this error path leave the remote processor running?
If qcom_pas_auth_and_reset() succeeds, but a subsequent step like updating the SMEM state or waiting for completion fails, the code jumps to err_fw2 and returns an error without shutting down the PAS. This can lead to memory corruption if the driver unloads and the remote processor continues to DMA into freed kernel memory.
[ ... ]
drivers/net/wireless/ath/ath12k/ahb.c static void ath12k_ahb_power_down(struct ath12k_base *ab, bool is_suspend) · line 488
Quoted 6 lines
drivers/net/wireless/ath/ath12k/ahb.c +1
-1@@ -485,10 +485,10 @@ static void ath12k_ahb_power_down(struct ath12k_base *ab, bool is_suspend) pasid = (u32_encode_bits (ab_ahb->userpd_id,ATH12K_USERPD_ID_MASK )) |ATH12K_AHB_UPD_SWID ;/* Release the firmware */ - ret =qcom_scm_pas_shutdown (pasid); + ret =qcom_pas_shutdown (pasid);
[Severity: High]
This is also a pre-existing issue, but does ath12k_ahb_power_down() skip shutting down the PAS on timeout?
If the wait for userpd_stopped times out earlier in this function:
if (!time_left) {
ath12k_err(ab, "UserPD stop wait timed out\n");
return;
}The function returns early without invoking qcom_pas_shutdown(), which can also leave the remote processor running.
Quoted 7 lines
drivers/net/wireless/ath/ath12k/ahb.c +2
-2if (ret) -ath12k_err (ab,"scm pas shutdown failed for userPD%d\n" , - ab_ahb->userpd_id); +ath12k_err (ab,"PAS shutdown failed for userPD%d: %d\n" , + ab_ahb->userpd_id, ret); } }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
[email protected]
AI reviewRe: [PATCH v9 13/14] firmware: qcom_scm: Remove SCM PAS wrappers
In reply to Sumit GargThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Time-of-check to time-of-use (TOCTOU) race condition in PAS API wrappers leading to potential NULL pointer dereference. --
commit 979ccc647befac000888b4c5f41818fc1037d4ff
Author: Sumit Garg <[email protected]>
firmware: qcom_scm: Remove SCM PAS wrappers
Now since all the Qcom SCM client drivers have been migrated over to generic PAS TZ service, let's drop the exported SCM PAS wrappers.
drivers/firmware/qcom/qcom_scm.c
Quoted 4 lines
drivers/firmware/qcom/qcom_scm.c +0
-0
[ ... ]
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the new generic PAS TZ service usage, I noticed a potential race condition in the API wrappers in drivers/firmware/qcom/qcom_pas.c:
drivers/firmware/qcom/qcom_pas.c:qcom_pas_init_image() {
...
if (!ops_ptr)
return -ENODEV;
return ops_ptr->init_image(ops_ptr->dev, pas_id, metadata, size, ctx);
}Since ops_ptr is a global pointer and isn't accessed with READ_ONCE() or protected by a lock, could the compiler generate multiple loads?
If a PAS backend is unbound and qcom_pas_ops_unregister() sets ops_ptr to NULL concurrently, can this lead to a NULL pointer dereference when accessing ops_ptr->init_image or ops_ptr->dev?
The same pattern appears in other wrappers as well:
drivers/firmware/qcom/qcom_pas.c:qcom_pas_metadata_release() {
...
if (!ops_ptr || !ctx || !ctx->ptr)
return;
ops_ptr->metadata_release(ops_ptr->dev, ctx);
}Should these wrappers use READ_ONCE() or some form of synchronization to ensure safe dereferencing of ops_ptr?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
Re: [PATCH v9 01/14] firmware: qcom: Add a generic PAS service
In reply to Sumit GargQuoted 23 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
OP-TEE as an alternative trusted OS to Qualcomm TEE (QTEE) can't support these non-standard SCM calls. And even for newer architectures using S-EL2 with Hafnium support, QTEE won't be able to support SCM calls either with FF-A requirements coming in. And with both OP-TEE and QTEE drivers well integrated in the TEE subsystem, it makes further sense to reuse the TEE bus client drivers infrastructure.
The added benefit of TEE bus infrastructure is that there is support for discoverable/enumerable services. With that client drivers don't have to manually invoke a special SCM call to know the service status.
So enable the generic Peripheral Authentication Service (PAS) provided by the firmware. It acts as the common layer with different TZ backends plugged in whether it's an SCM implementation or a proper TEE bus based PAS service implementation.
Quoted 6 lines
Reviewed-by Mukesh Ojha <[email protected]>Tested-by Mukesh Ojha <[email protected]> # LemansReviewed-by Harshal Dev <[email protected]>Signed-off-by Sumit Garg <[email protected]>---
Konrad
Re: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Sumit GargQuoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[01/14] firmware: qcom: Add a generic PAS service
commit: 08314e7c2c38b9ae6a5e01c58ed10a950859404d
[02/14] firmware: qcom_scm: Migrate to generic PAS service
commit: 5c1a2975d23c51c01aca51945d0f10a4ee4c9020
[03/14] firmware: qcom: Add a PAS TEE service
commit: b6f7978da0c4d26fe465aa6634f5a0b48f900de0
[14/14] MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service
commit: 6701259025d49139131a0eb2257659a066dcca22This is available as an immutable branch, for other subsystems to pull at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]
[04/14] remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs
commit: 254030af0d81b12b7624d9ce85c6bdd3171629c6
[05/14] remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs
commit: f3b1357673ddb37ae8b9a8fe44df73cbd2a519c5
[06/14] remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs
commit: ea3b5245f5deba916320b32a8e6510a74c034c17
[07/14] remoteproc: qcom: Select QCOM_PAS generic service
commit: c4383254ac7a529736577e304176a10371c2ee0bBest regards,
Signature · 1 line
Bjorn Andersson <[email protected]>
Re: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
Hi Bjorn,
Quoted 26 lines · Bjorn Andersson
Quoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[01/14] firmware: qcom: Add a generic PAS service
commit: 08314e7c2c38b9ae6a5e01c58ed10a950859404d [02/14] firmware: qcom_scm: Migrate to generic PAS service commit: 5c1a2975d23c51c01aca51945d0f10a4ee4c9020 [03/14] firmware: qcom: Add a PAS TEE service commit: b6f7978da0c4d26fe465aa6634f5a0b48f900de0 [14/14] MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service commit: 6701259025d49139131a0eb2257659a066dcca22This is available as an immutable branch, for other subsystems to pull at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]
Quoted 9 lines
[04/14] remoteproc:
qcom_q6v5_pas: Switch over to generic PAS TZ APIscommit: 254030af0d81b12b7624d9ce85c6bdd3171629c6 [05/14] remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs commit: f3b1357673ddb37ae8b9a8fe44df73cbd2a519c5 [06/14] remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs commit: ea3b5245f5deba916320b32a8e6510a74c034c17 [07/14] remoteproc: qcom: Select QCOM_PAS generic service commit: c4383254ac7a529736577e304176a10371c2ee0b
Thanks for picking the partial set although I expected for you to pick the entire set given acks from all the other subsystem maintainers. Let me know how we should proceed further.
-Sumit
Re: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Bjorn AnderssonQuoted 22 lines · Bjorn Andersson
Quoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[01/14] firmware: qcom: Add a generic PAS service
commit: 08314e7c2c38b9ae6a5e01c58ed10a950859404d [02/14] firmware: qcom_scm: Migrate to generic PAS service commit: 5c1a2975d23c51c01aca51945d0f10a4ee4c9020 [03/14] firmware: qcom: Add a PAS TEE service commit: b6f7978da0c4d26fe465aa6634f5a0b48f900de0 [14/14] MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service commit: 6701259025d49139131a0eb2257659a066dcca22
Quoted 2 lines
This is available as an immutable branch, for other subsystems to pull at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]
I've merged this branch into ath/ath-next so it is available for ongoing ath12k support.
/jeff
Bjorn Andersson
maintainerRe: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Sumit GargQuoted 39 lines · Sumit Garg
Hi Bjorn,
Quoted 26 lines · Bjorn Andersson
Quoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[01/14] firmware: qcom: Add a generic PAS service
commit: 08314e7c2c38b9ae6a5e01c58ed10a950859404d [02/14] firmware: qcom_scm: Migrate to generic PAS service commit: 5c1a2975d23c51c01aca51945d0f10a4ee4c9020 [03/14] firmware: qcom: Add a PAS TEE service commit: b6f7978da0c4d26fe465aa6634f5a0b48f900de0 [14/14] MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service commit: 6701259025d49139131a0eb2257659a066dcca22This is available as an immutable branch, for other subsystems to pull at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]Quoted 9 lines
[04/14] remoteproc:
qcom_q6v5_pas: Switch over to generic PAS TZ APIscommit: 254030af0d81b12b7624d9ce85c6bdd3171629c6 [05/14] remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs commit: f3b1357673ddb37ae8b9a8fe44df73cbd2a519c5 [06/14] remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs commit: ea3b5245f5deba916320b32a8e6510a74c034c17 [07/14] remoteproc: qcom: Select QCOM_PAS generic service commit: c4383254ac7a529736577e304176a10371c2ee0b
Quoted 4 lines
Thanks for picking the partial set although I expected for you to pick the entire set given acks from all the other subsystem maintainers. Let me know how we should proceed further.
That would be desirable, so that I can also merge the cleanup patch at the tail end there.
I did miss Dmitry's ack on the drm patch - that one I could have merged, but I don't see acks from media and net maintainers. I'm fine either way (them providing acks, or merging the immutable branch and respective change).
As you can see Jeff did the latter already. Thanks Jeff!
This leaves us with the cleanup patch (13), which I think we can pick for v7.3-rc2.
Regards,
Bjorn
Bjorn Andersson
maintainerRe: [PATCH v9 09/14] media: qcom: Switch to generic PAS TZ APIs
In reply to Sumit GargQuoted 7 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Switch qcom media client drivers over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Please find an immutable branch with the dependencies for this patch at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]
Alternatively, if you think there will be no conflicting patches in the time leading up to next merge window provide an Ack and I can pick this through the qcom tree.
Thanks,
Bjorn
Quoted 159 lines
Reviewed-by Mukesh Ojha <[email protected]>Tested-by Mukesh Ojha <[email protected]> # LemansReviewed-by Konrad Dybcio <[email protected]>Signed-off-by Sumit Garg <[email protected]>--- drivers/media/platform/qcom/iris/Kconfig | 27 ++++++++++--------- .../media/platform/qcom/iris/iris_firmware.c | 9 ++++--- drivers/media/platform/qcom/venus/Kconfig | 1 + drivers/media/platform/qcom/venus/firmware.c | 11 ++++---- 4 files changed, 26 insertions(+), 22 deletions(-)drivers/media/platform/qcom/iris/Kconfig +14
-13@@ -1,14 +1,15 @@ config VIDEO_QCOM_IRIS - tristate "Qualcomm iris V4L2 decoder driver" - depends on VIDEO_DEV - depends on ARCH_QCOM || COMPILE_TEST - select V4L2_MEM2MEM_DEV - select QCOM_MDT_LOADER - select QCOM_SCM - select QCOM_UBWC_CONFIG - select VIDEOBUF2_DMA_CONTIG - help - This is a V4L2 driver for Qualcomm iris video accelerator - hardware. It accelerates decoding operations on various - Qualcomm SoCs. - To compile this driver as a module choose m here. + tristate "Qualcomm iris V4L2 decoder driver" + depends on VIDEO_DEV + depends on ARCH_QCOM || COMPILE_TEST + select V4L2_MEM2MEM_DEV + select QCOM_MDT_LOADER + select QCOM_SCM + select QCOM_PAS + select QCOM_UBWC_CONFIG + select VIDEOBUF2_DMA_CONTIG + help + This is a V4L2 driver for Qualcomm iris video accelerator + hardware. It accelerates decoding operations on various + Qualcomm SoCs. + To compile this driver as a module choose m here.drivers/media/platform/qcom/iris/iris_firmware.c +5
-4@@ -4,6 +4,7 @@*/ #include <linux/firmware.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #include <linux/of_address.h> #include <linux/of_reserved_mem.h> @@ -80,7 +81,7 @@ int iris_fw_load(struct iris_core *core)return -ENOMEM ; } - ret =qcom_scm_pas_auth_and_reset (IRIS_PAS_ID ); + ret =qcom_pas_auth_and_reset (IRIS_PAS_ID );if (ret) {dev_err (core->dev,"auth and reset failed: %d\n" , ret);return ret;@@ -94,7 +95,7 @@ int iris_fw_load(struct iris_core *core) cp_config->cp_nonpixel_size);if (ret) {dev_err (core->dev,"qcom_scm_mem_protect_video_var failed: %d\n" , ret); -qcom_scm_pas_shutdown (IRIS_PAS_ID ); +qcom_pas_shutdown (IRIS_PAS_ID );return ret; } }@@ -104,10 +105,10 @@ int iris_fw_load(struct iris_core *core)int iris_fw_unload (struct iris_core *core) { -return qcom_scm_pas_shutdown (IRIS_PAS_ID ); +return qcom_pas_shutdown (IRIS_PAS_ID ); }int iris_set_hw_state (struct iris_core *core,bool resume) { -return qcom_scm_set_remote_state (resume,0 ); +return qcom_pas_set_remote_state (resume,0 ); }drivers/media/platform/qcom/venus/Kconfig +1
-0@@ -6,6 +6,7 @@ config VIDEO_QCOM_VENUS select OF_DYNAMIC if ARCH_QCOM select QCOM_MDT_LOADER select QCOM_SCM + select QCOM_PAS select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV helpdrivers/media/platform/qcom/venus/firmware.c +6
-5@@ -12,6 +12,7 @@#include <linux/of_reserved_mem.h> #include <linux/platform_device.h> #include <linux/of_device.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/firmware/qcom/qcom_scm.h> #include <linux/sizes.h> #include <linux/soc/qcom/mdt_loader.h> @@ -58,7 +59,7 @@ int venus_set_hw_state(struct venus_core *core, bool resume)int ret;if (core->use_tz) { - ret =qcom_scm_set_remote_state (resume,0 ); + ret =qcom_pas_set_remote_state (resume,0 );if (resume && ret == -EINVAL ) ret =0 ;return ret;@@ -218,7 +219,7 @@ int venus_boot(struct venus_core *core)int ret;if (!IS_ENABLED (CONFIG_QCOM_MDT_LOADER ) || - (core->use_tz && !qcom_scm_is_available ())) + (core->use_tz && !qcom_pas_is_available ()))return -EPROBE_DEFER ; ret = of_property_read_string_index(dev->of_node, "firmware-name", 0,@@ -236,7 +237,7 @@ int venus_boot(struct venus_core *core) core->fw.mem_phys = mem_phys;if (core->use_tz) - ret =qcom_scm_pas_auth_and_reset (VENUS_PAS_ID ); + ret =qcom_pas_auth_and_reset (VENUS_PAS_ID );else ret =venus_boot_no_tz (core, mem_phys, mem_size);@@ -259,7 +260,7 @@ int venus_boot(struct venus_core *core) res->cp_nonpixel_start, res->cp_nonpixel_size);if (ret) { -qcom_scm_pas_shutdown (VENUS_PAS_ID ); +qcom_pas_shutdown (VENUS_PAS_ID );dev_err (dev,"set virtual address ranges fail (%d)\n" , ret);return ret;@@ -274,7 +275,7 @@ int venus_shutdown(struct venus_core *core)int ret;if (core->use_tz) - ret =qcom_scm_pas_shutdown (VENUS_PAS_ID ); + ret =qcom_pas_shutdown (VENUS_PAS_ID );else ret =venus_shutdown_no_tz (core);Signature · 1 line
2.53.0
Bjorn Andersson
maintainerRe: [PATCH v9 11/14] net: ipa: Switch to generic PAS TZ APIs
In reply to Sumit GargQuoted 7 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Switch ipa client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Please find an immutable branch with the dependencies for this patch at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]
Alternatively, if you think there will be no conflicting patches in the time leading up to next merge window provide an Ack and I can pick this through the qcom tree.
Thanks,
Bjorn
Quoted 63 lines
Reviewed-by Alex Elder <[email protected]>Reviewed-by Konrad Dybcio <[email protected]>Signed-off-by Sumit Garg <[email protected]>--- drivers/net/ipa/Kconfig | 2 +- drivers/net/ipa/ipa_main.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-)drivers/net/ipa/Kconfig +1
-1@@ -6,7 +6,7 @@ config QCOM_IPA depends on QCOM_RPROC_COMMON || (QCOM_RPROC_COMMON=n && COMPILE_TEST) depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n select QCOM_MDT_LOADER - select QCOM_SCM + select QCOM_PAS select QCOM_QMI_HELPERS help Choose Y or M here to include support for the Qualcommdrivers/net/ipa/ipa_main.c +8
-5@@ -14,7 +14,7 @@#include <linux/pm_runtime.h> #include <linux/types.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/soc/qcom/mdt_loader.h> #include "ipa.h" @@ -624,10 +624,13 @@ static int ipa_firmware_load(struct device *dev) } ret =qcom_mdt_load (dev, fw, path,IPA_PAS_ID , virt, phys, size,NULL ); -if (ret) +if (ret) {dev_err (dev,"error %d loading \"%s\"\n" , ret, path); -else if ((ret =qcom_scm_pas_auth_and_reset (IPA_PAS_ID ))) -dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }else { + ret =qcom_pas_auth_and_reset (IPA_PAS_ID ); +if (ret) +dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }memunmap (virt); out_release_firmware:@@ -758,7 +761,7 @@ static enum ipa_firmware_loader ipa_firmware_loader(struct device *dev)return IPA_LOADER_INVALID ; out_self:/* We need Trust Zone to load firmware; make sure it's available */ -if (qcom_scm_is_available ()) +if (qcom_pas_is_available ())return IPA_LOADER_SELF ;return IPA_LOADER_DEFER ;Signature · 1 line
2.53.0
Re: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Sumit GargQuoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[08/14] drm/msm: Switch to generic PAS TZ APIs
commit: 0be72be03ca7de55f22dd4c0622d81ac98aee38a
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>
Re: [PATCH v9 12/14] wifi: ath12k: Switch to generic PAS TZ APIs
In reply to Sumit GargQuoted 53 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Switch ath12k client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Acked-by Jeff Johnson <[email protected]>Signed-off-by Sumit Garg <[email protected]>--- drivers/net/wireless/ath/ath12k/Kconfig | 2 +- drivers/net/wireless/ath/ath12k/ahb.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)drivers/net/wireless/ath/ath12k/Kconfig +1
-1@@ -18,7 +18,7 @@ config ATH12K_AHB bool "Qualcomm ath12k AHB support" depends on ATH12K && REMOTEPROC select QCOM_MDT_LOADER - select QCOM_SCM + select QCOM_PAS help Enable support for Ath12k AHB bus chipsets, example IPQ5332.drivers/net/wireless/ath/ath12k/ahb.c +2
-2@@ -5,7 +5,7 @@*/ #include <linux/dma-mapping.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/platform_device.h> @@ -420,7 +420,7 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)if (ab_ahb->scm_auth_enabled) {/* Authenticate FW image using peripheral ID */ - ret =qcom_scm_pas_auth_and_reset (pasid); + ret =qcom_pas_auth_and_reset (pasid);if (ret) {ath12k_err (ab,"failed to boot the remote processor %d\n" , ret); goto err_fw2;@@ -485,10 +485,10 @@ static void ath12k_ahb_power_down(struct ath12k_base *ab, bool is_suspend) pasid = (u32_encode_bits (ab_ahb->userpd_id,ATH12K_USERPD_ID_MASK )) |ATH12K_AHB_UPD_SWID ;/* Release the firmware */
drivers/net/wireless/ath/ath12k/ahb.c static void ath12k_ahb_power_down(struct ath12k_base *ab, bool is_suspend) · line 494
Quoted 10 lines
drivers/net/wireless/ath/ath12k/ahb.c +3
-3- ret =qcom_scm_pas_shutdown (pasid); + ret =qcom_pas_shutdown (pasid);if (ret) -ath12k_err (ab,"scm pas shutdown failed for userPD%d\n" , - ab_ahb->userpd_id); +ath12k_err (ab,"PAS shutdown failed for userPD%d: %d\n" , + ab_ahb->userpd_id, ret); } }
My code review agent is flagging:
**Missing probe-defer guard** (ahb.c:422) — qcom_pas_is_available() is explicitly documented as mandatory before any PAS call. The OP-TEE backend registers its ops asynchronously; without an if (!qcom_pas_is_available()) return -EPROBE_DEFER in the probe path, firmware auth silently returns -ENODEV with no retry.
Is it an existing deficiency in ath12k that there is no probe deferral? Or did the qcom_scm_*() calls somehow guarantee something that is no longer true with the qcom_pas_*() calls?
And also for future cleanup:
**Misleading field name** (ahb.c:384) — scm_auth_enabled should be pas_auth_enabled to match the backend-agnostic API it now guards.
I plan on taking this patch as-is through the ath tree since it is currently just simple API changes. Any additional changes can come separately.
/jeff
Jeff Johnson
AppliedRe: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Sumit GargQuoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[12/14] wifi: ath12k: Switch to generic PAS TZ APIs
commit: d418509383b0c884b70814ae85d3ef105a63b940
Best regards,
Signature · 1 line
Jeff Johnson <[email protected]>
Alex Elder
Acked-byRe: [PATCH v9 11/14] net: ipa: Switch to generic PAS TZ APIs
In reply to Bjorn AnderssonQuoted 9 lines · Bjorn Andersson
Quoted 7 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Switch ipa client driver over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Quoted 6 lines
Please find an immutable branch with the dependencies for this patch at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]Alternatively, if you think there will be no conflicting patches in the time leading up to next merge window provide an Ack and I can pick this through the qcom tree.
I don't see any reason there would be any conflicts (certainly no difficult conflicts) with this commit, so I think you can safely take it with the others through the Qualcomm tree.
So if my ack is what you're looking for:
Thank you Sumit and Bjorn.
Quoted 67 lines
Thanks,
BjornQuoted 63 lines
Reviewed-by Alex Elder <[email protected]>Reviewed-by Konrad Dybcio <[email protected]>Signed-off-by Sumit Garg <[email protected]>--- drivers/net/ipa/Kconfig | 2 +- drivers/net/ipa/ipa_main.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-)drivers/net/ipa/Kconfig +1
-1@@ -6,7 +6,7 @@ config QCOM_IPA depends on QCOM_RPROC_COMMON || (QCOM_RPROC_COMMON=n && COMPILE_TEST) depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n select QCOM_MDT_LOADER - select QCOM_SCM + select QCOM_PAS select QCOM_QMI_HELPERS help Choose Y or M here to include support for the Qualcommdrivers/net/ipa/ipa_main.c +8
-5@@ -14,7 +14,7 @@#include <linux/pm_runtime.h> #include <linux/types.h> -#include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_pas.h> #include <linux/soc/qcom/mdt_loader.h> #include "ipa.h" @@ -624,10 +624,13 @@ static int ipa_firmware_load(struct device *dev) } ret =qcom_mdt_load (dev, fw, path,IPA_PAS_ID , virt, phys, size,NULL ); -if (ret) +if (ret) {dev_err (dev,"error %d loading \"%s\"\n" , ret, path); -else if ((ret =qcom_scm_pas_auth_and_reset (IPA_PAS_ID ))) -dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }else { + ret =qcom_pas_auth_and_reset (IPA_PAS_ID ); +if (ret) +dev_err (dev,"error %d authenticating \"%s\"\n" , ret, path); + }memunmap (virt); out_release_firmware:@@ -758,7 +761,7 @@ static enum ipa_firmware_loader ipa_firmware_loader(struct device *dev)return IPA_LOADER_INVALID ; out_self:/* We need Trust Zone to load firmware; make sure it's available */ -if (qcom_scm_is_available ()) +if (qcom_pas_is_available ())return IPA_LOADER_SELF ;return IPA_LOADER_DEFER ;Signature · 1 line
2.53.0
Re: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Sumit GargQuoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[11/14] net: ipa: Switch to generic PAS TZ APIs
commit: 85b88ceeeeb7bb93cd0af7ccaf2a4b010d5bc5c6
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>
Sumit Garg
maintainerRe: [PATCH v9 09/14] media: qcom: Switch to generic PAS TZ APIs
In reply to Bjorn AnderssonHi Bryan, Mauro,
Quoted 10 lines · Bjorn Andersson
Quoted 7 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Switch qcom media client drivers over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Quoted 6 lines
Please find an immutable branch with the dependencies for this patch at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]Alternatively, if you think there will be no conflicting patches in the time leading up to next merge window provide an Ack and I can pick this through the qcom tree.
Just a gentle reminder for this patch to be picked up as only the Qcom media client is left in the next branch for migration to the generic PAS layer.
If there aren't any conflicts then please allow Bjorn to pick this patch since the cleanup patch dropping the old SCM APIs is blocked on this.
-Sumit
Quoted 9 lines
Thanks,
BjornQuoted 5 lines
Reviewed-by Mukesh Ojha <[email protected]>Tested-by Mukesh Ojha <[email protected]> # LemansReviewed-by Konrad Dybcio <[email protected]>Signed-off-by Sumit Garg <[email protected]>---
Sumit Garg
maintainerRe: [PATCH v9 09/14] media: qcom: Switch to generic PAS TZ APIs
Quoted 21 lines · Sumit Garg
Hi Bryan, Mauro,
Quoted 10 lines · Bjorn Andersson
Quoted 7 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Switch qcom media client drivers over to generic PAS TZ APIs. Generic PAS TZ service allows to support multiple TZ implementation backends like QTEE based SCM PAS service, OP-TEE based PAS service and any further future TZ backend service.
Quoted 6 lines
Please find an immutable branch with the dependencies for this patch at:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git [email protected]Alternatively, if you think there will be no conflicting patches in the time leading up to next merge window provide an Ack and I can pick this through the qcom tree.
Quoted 8 lines
Just a gentle reminder for this patch to be picked up as only the Qcom media client is left in the next branch for migration to the generic PAS layer.
If there aren't any conflicts then please allow Bjorn to pick this patch since the cleanup patch dropping the old SCM APIs is blocked on this.
Gentle reminder again for ack on this patch. We don't want to keep the legacy SCM APIs just for the media subsystem in v7.3 release.
Can we consider it as a silent ack for Bjorn to pick this patch? This patch doesn't make any functional changes but it's just about renaming APIs.
-Sumit
Quoted 10 lines
Quoted 10 lines
Thanks,
BjornQuoted 5 lines
Reviewed-by Mukesh Ojha <[email protected]>Tested-by Mukesh Ojha <[email protected]> # LemansReviewed-by Konrad Dybcio <[email protected]>Signed-off-by Sumit Garg <[email protected]>---
Re: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Sumit GargQuoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[09/14] media: qcom: Switch to generic PAS TZ APIs
commit: 94d3305d990b055e1561e3b78275344b1f40c86e
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>
Re: (subset) [PATCH v9 00/14] firmware: qcom: Add OP-TEE PAS service support
In reply to Sumit GargQuoted 8 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Qcom platforms has the legacy of using non-standard SCM calls splintered over the various kernel drivers. These SCM calls aren't compliant with the standard SMC calling conventions which is a prerequisite to enable migration to the FF-A specifications from Arm.
[...]
Applied, thanks!
[13/14] firmware: qcom_scm: Remove SCM PAS wrappers
commit: 3eda4fa73e30207eb7afedde6987f7f321f74fbc
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>