firmware: qcom: Build the TrustZone memory allocator into qcom-scm
PATCH 1/1 firmware: qcom: Build the TrustZone memory allocator into qcom-scm
With QCOM_TZMEM_MODE_SHMBRIDGE=y, qcom_tzmem.ko calls qcom_scm_shm_bridge_enable(), qcom_scm_shm_bridge_create() and qcom_scm_shm_bridge_delete() in qcom-scm.ko, and qcom-scm.ko calls qcom_tzmem_alloc() and friends. With QCOM_SCM=m the two modules depend on each other, neither can be loaded first, and modules_install fails:
depmod: ERROR: Cycle detected: qcom_scm -> qcom_tzmem -> qcom_scm
depmod: ERROR: Found 2 modules in dependency cycles!
This has been possible since SHM Bridge mode was added. Since commit 35abc3cd8ab6 ("tee: remove TZMEM_MODE_GENERIC") it also happens for every QCOMTEE=m build with QCOM_SCM=m, because QCOMTEE's select of QCOM_TZMEM_MODE_SHMBRIDGE now takes effect.
QCOM_TZMEM is selected only by QCOM_SCM, so the two always have the same value. Build qcom_tzmem.o into qcom-scm.ko, and drop the MODULE_DESCRIPTION() and MODULE_LICENSE() that qcom-scm already has.
---
Tested on arm64 with allnoconfig plus: Nathan's fragment; ARCH_QCOM=y QCOM_SCM=m SHMBRIDGE=y; ARCH_QCOM=y QCOM_SCM=m QCOMTEE=m; QCOM_SCM=y QCOMTEE=m; QCOM_SCM=m SHMBRIDGE=n. All build without warnings and pass modules_install. Without the patch, Nathan's fragment and the QCOMTEE=m QCOM_SCM=m config fail depmod with the cycle above.
drivers/firmware/qcom/Makefile | 3 +-- drivers/firmware/qcom/qcom_tzmem.c | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/firmware/qcom/Makefile +1 -2
@@ -4,9 +4,8 @@ # obj-$(CONFIG_QCOM_SCM) += qcom-scm.o -qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o qcom_tzmem.o CFLAGS_qcom_scm-smc.o := -I$(src) -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_tzmem.c +0 -2
@@ -522,6 +522,4 @@ int qcom_tzmem_enable(struct device *dev) }EXPORT_SYMBOL_GPL (qcom_tzmem_enable); -MODULE_DESCRIPTION ("TrustZone memory allocator for Qualcomm firmware drivers" );MODULE_AUTHOR ("Bartosz Golaszewski <[email protected]>" ); -MODULE_LICENSE ("GPL" );
base-commit: 4843f6873f7c4835e62f2c73ba0fd538e57a2f22
Signature · 1 line
2.53.0
Quoted 18 lines · Sasha Levin
With QCOM_TZMEM_MODE_SHMBRIDGE=y, qcom_tzmem.ko calls
qcom_scm_shm_bridge_enable(),qcom_scm_shm_bridge_create()andqcom_scm_shm_bridge_delete()in qcom-scm.ko, and qcom-scm.ko callsqcom_tzmem_alloc()and friends. With QCOM_SCM=m the two modules depend on each other, neither can be loaded first, andmodules_installfails:depmod: ERROR: Cycle detected:
qcom_scm->qcom_tzmem->qcom_scm
depmod: ERROR: Found 2 modules in dependency cycles!This has been possible since SHM Bridge mode was added. Since commit
35abc3cd8ab6("tee: removeTZMEM_MODE_GENERIC") it also happens for every QCOMTEE=m build with QCOM_SCM=m, because QCOMTEE's select ofQCOM_TZMEM_MODE_SHMBRIDGEnow takes effect.
QCOM_TZMEMis selected only byQCOM_SCM, so the two always have the same value. Build qcom_tzmem.o into qcom-scm.ko, and drop theMODULE_DESCRIPTION()andMODULE_LICENSE()that qcom-scm already has.
Quoted 6 lines
Fixes f86c61498a57 ("firmware: qcom: tzmem: enable SHM Bridge support")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Quoted 39 lines · Sasha Levin
With QCOM_TZMEM_MODE_SHMBRIDGE=y, qcom_tzmem.ko calls
qcom_scm_shm_bridge_enable(),qcom_scm_shm_bridge_create()andqcom_scm_shm_bridge_delete()in qcom-scm.ko, and qcom-scm.ko callsqcom_tzmem_alloc()and friends. With QCOM_SCM=m the two modules depend on each other, neither can be loaded first, andmodules_installfails:depmod: ERROR: Cycle detected:
qcom_scm->qcom_tzmem->qcom_scm
depmod: ERROR: Found 2 modules in dependency cycles!This has been possible since SHM Bridge mode was added. Since commit
35abc3cd8ab6("tee: removeTZMEM_MODE_GENERIC") it also happens for every QCOMTEE=m build with QCOM_SCM=m, because QCOMTEE's select ofQCOM_TZMEM_MODE_SHMBRIDGEnow takes effect.
QCOM_TZMEMis selected only byQCOM_SCM, so the two always have the same value. Build qcom_tzmem.o into qcom-scm.ko, and drop theMODULE_DESCRIPTION()andMODULE_LICENSE()that qcom-scm already has.Fixes f86c61498a57 ("firmware: qcom: tzmem: enable SHM Bridge support")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Tested on arm64 with allnoconfig plus: Nathan's fragment; ARCH_QCOM=y QCOM_SCM=m SHMBRIDGE=y; ARCH_QCOM=y QCOM_SCM=m QCOMTEE=m; QCOM_SCM=y QCOMTEE=m; QCOM_SCM=m SHMBRIDGE=n. All build without warnings and pass
modules_install. Without the patch, Nathan's fragment and the QCOMTEE=m QCOM_SCM=m config fail depmod with the cycle above.drivers/firmware/qcom/Makefile | 3 +-- drivers/firmware/qcom/qcom_tzmem.c | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-)drivers/firmware/qcom/Makefile +0
-0
drivers/firmware/qcom/Makefile line 9
Quoted 7 lines
drivers/firmware/qcom/Makefile +1
-2@@ -4,9 +4,8 @@ # obj-$(CONFIG_QCOM_SCM) += qcom-scm.o -qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o qcom_tzmem.o CFLAGS_qcom_scm-smc.o := -I$(src) -obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o
This basically makes CONFIG_QCOM_TZMEM pointless, it should probably just be collapsed into CONFIG_QCOM_SCM formally.
drivers/firmware/qcom/Kconfig +2 -6
@@ -28,16 +28,12 @@ config QCOM_PAS_TEE config QCOM_SCM tristate "Qualcomm PAS SCM interface driver" if ARCH_QCOM || COMPILE_TEST select QCOM_PAS - select QCOM_TZMEM - default y if ARCH_QCOM - -config QCOM_TZMEM - tristate select GENERIC_ALLOCATOR + default y if ARCH_QCOM config QCOM_TZMEM_MODE_SHMBRIDGE bool "TrustZone interface memory allocator: SHM Bridge" - depends on QCOM_TZMEM + depends on QCOM_SCM help Use Qualcomm Shared Memory Bridge as memory allocator. The memory has the same alignment as in the 'Generic' allocator, which is used when this option
Signature · 2 lines
Cheers, Nathan