* [PATCH RFC 1/2] firmware: qcom: Introduce qcom_secure_log interface to display QTEE logs
2026-12-01 22:33 [PATCH RFC 0/2] Add support to display QTEE/OPTEE secure logs on Qualcomm platforms Kuldeep Singh
@ 2026-12-01 22:33 ` Kuldeep Singh
2026-12-01 22:33 ` [PATCH RFC 2/2] firmware: qcom: Add legacy QSEE secure log support Kuldeep Singh
1 sibling, 0 replies; 3+ messages in thread
From: Kuldeep Singh @ 2026-12-01 22:33 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Abel Vesa, Dmitry Baryshkov
Cc: linux-kernel, linux-arm-msm, Kuldeep Singh
Define an interface to basically map TZ diag ocimem physical address as
per soc family and ioremap further to map region for userspace access.
The ocimem address is roughly same over targets(few possible values
only) and hence, maintaining machine compatible list and size for target
family.
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/firmware/qcom/Kconfig | 8 ++
drivers/firmware/qcom/Makefile | 1 +
drivers/firmware/qcom/qcom_secure_log.c | 228 ++++++++++++++++++++++++++++++++
3 files changed, 237 insertions(+)
diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig
index 3ad22f8fc3e5..8ca173677c64 100644
--- a/drivers/firmware/qcom/Kconfig
+++ b/drivers/firmware/qcom/Kconfig
@@ -46,6 +46,14 @@ config QCOM_TZMEM_MODE_SHMBRIDGE
With this selected, all buffers passed to the TrustZone must be allocated
using the TZMem allocator or else the TrustZone will refuse to use them.
+config QCOM_SECURE_LOG
+ tristate "Qualcomm secure-world log userspace interface"
+ depends on ARCH_QCOM || COMPILE_TEST
+ help
+ Provide a provisional userspace ABI for Qualcomm secure-world log
+ buffers. Userspace is expected to mmap supported log regions and
+ parse the firmware log format.
+
config QCOM_QSEECOM
bool "Qualcomm QSEECOM interface driver"
depends on QCOM_SCM=y
diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile
index 88ce74d74c3e..bec90e13d0cb 100644
--- a/drivers/firmware/qcom/Makefile
+++ b/drivers/firmware/qcom/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_QCOM_SCM) += qcom-scm.o
qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o
CFLAGS_qcom_scm-smc.o := -I$(src)
obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o
+obj-$(CONFIG_QCOM_SECURE_LOG) += qcom_secure_log.o
obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o
obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o
obj-$(CONFIG_QCOM_PAS) += qcom_pas.o
diff --git a/drivers/firmware/qcom/qcom_secure_log.c b/drivers/firmware/qcom/qcom_secure_log.c
new file mode 100644
index 000000000000..7760ad46bd29
--- /dev/null
+++ b/drivers/firmware/qcom/qcom_secure_log.c
@@ -0,0 +1,228 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Qualcomm secure-world log userspace interface
+ *
+ * Copyright (c) 2026 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#include <linux/fs.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of.h>
+
+#define QCOM_SECURE_LOG_SIZE 0x3000
+
+/**
+ * struct qcom_secure_log_config - target-specific secure log configuration
+ * @compatibles: NULL-terminated root machine compatible string list
+ * @imem_phys: physical IMEM address that stores the TZ diagnostic buffer base
+ * @size: TZ diagnostic buffer size
+ */
+struct qcom_secure_log_config {
+ const char * const *compatibles;
+ phys_addr_t imem_phys;
+ size_t size;
+};
+
+/**
+ * struct qcom_secure_log - secure-log device state
+ * @miscdev: userspace miscdevice
+ * @config: selected target-specific secure log configuration
+ * @imem_base: mapping of the IMEM pointer area
+ * @tz_diag_base: kernel mapping of the TZ diagnostic buffer
+ * @tz_diag_phys: physical start of the TZ diagnostic buffer
+ */
+struct qcom_secure_log {
+ struct miscdevice miscdev;
+ const struct qcom_secure_log_config *config;
+ void __iomem *imem_base;
+ void __iomem *tz_diag_base;
+ phys_addr_t tz_diag_phys;
+};
+
+static const char * const qcom_secure_log_c125720[] = {
+ "qcom,qcs8300",
+ NULL,
+};
+
+static const char * const qcom_secure_log_146bf720[] = {
+ "qcom,sm8150",
+ NULL,
+};
+
+static const char * const qcom_secure_log_14680720[] = {
+ "qcom,lanai",
+ "qcom,sm8750",
+ "qcom,kaanapali",
+ "qcom,hawi",
+ NULL,
+};
+
+static const char * const qcom_secure_log_146aa720[] = {
+ "qcom,qcm6490",
+ "qcom,hamoa",
+ NULL,
+};
+
+static const char * const qcom_secure_log_c11e720[] = {
+ "qcom,shikra",
+ NULL,
+};
+
+static const struct qcom_secure_log_config qcom_secure_log_configs[] = {
+ {
+ .compatibles = qcom_secure_log_c125720,
+ .imem_phys = 0x0c125720,
+ .size = QCOM_SECURE_LOG_SIZE,
+ },
+ {
+ .compatibles = qcom_secure_log_146bf720,
+ .imem_phys = 0x146bf720,
+ .size = QCOM_SECURE_LOG_SIZE,
+ },
+ {
+ .compatibles = qcom_secure_log_14680720,
+ .imem_phys = 0x14680720,
+ .size = QCOM_SECURE_LOG_SIZE,
+ },
+ {
+ .compatibles = qcom_secure_log_146aa720,
+ .imem_phys = 0x146aa720,
+ .size = QCOM_SECURE_LOG_SIZE,
+ },
+ {
+ .compatibles = qcom_secure_log_c11e720,
+ .imem_phys = 0x0c11e720,
+ .size = QCOM_SECURE_LOG_SIZE,
+ },
+};
+
+static struct qcom_secure_log qcom_secure_log;
+
+static int qcom_secure_log_mmap(struct file *file, struct vm_area_struct *vma)
+{
+ struct qcom_secure_log *log = container_of(file->private_data,
+ struct qcom_secure_log,
+ miscdev);
+ unsigned long size = vma->vm_end - vma->vm_start;
+
+ if (vma->vm_flags & VM_WRITE)
+ return -EPERM;
+
+ if (vma->vm_pgoff)
+ return -EINVAL;
+
+ if (size != log->config->size)
+ return -EINVAL;
+
+ vm_flags_clear(vma, VM_MAYWRITE);
+ vm_flags_set(vma, VM_IO | VM_DONTDUMP | VM_DONTEXPAND);
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+ return remap_pfn_range(vma, vma->vm_start, PHYS_PFN(log->tz_diag_phys),
+ size, vma->vm_page_prot);
+}
+
+static const struct file_operations qcom_secure_log_fops = {
+ .owner = THIS_MODULE,
+ .mmap = qcom_secure_log_mmap,
+ .llseek = noop_llseek,
+};
+
+static const struct qcom_secure_log_config *qcom_secure_log_find_config(void)
+{
+ const struct qcom_secure_log_config *config;
+ const char * const *compatible;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(qcom_secure_log_configs); i++) {
+ config = &qcom_secure_log_configs[i];
+
+ for (compatible = config->compatibles; *compatible; compatible++) {
+ if (of_machine_is_compatible(*compatible))
+ return config;
+ }
+ }
+
+ return NULL;
+}
+
+static int qcom_secure_log_init_tz_diag(struct qcom_secure_log *log)
+{
+ phys_addr_t tz_diag_phys;
+
+ log->config = qcom_secure_log_find_config();
+ if (!log->config)
+ return -ENODEV;
+
+ log->imem_base = ioremap(log->config->imem_phys, log->config->size);
+ if (!log->imem_base)
+ return -ENOMEM;
+
+ tz_diag_phys = readl_relaxed(log->imem_base);
+ if (!tz_diag_phys || !PAGE_ALIGNED(tz_diag_phys))
+ goto err_unmap_imem;
+
+ log->tz_diag_base = ioremap(tz_diag_phys, log->config->size);
+ if (!log->tz_diag_base)
+ goto err_unmap_imem;
+
+ log->tz_diag_phys = tz_diag_phys;
+
+ return 0;
+
+err_unmap_imem:
+ iounmap(log->imem_base);
+ log->imem_base = NULL;
+ return -ENODEV;
+}
+
+static void qcom_secure_log_release_tz_diag(struct qcom_secure_log *log)
+{
+ if (log->tz_diag_base)
+ iounmap(log->tz_diag_base);
+
+ if (log->imem_base)
+ iounmap(log->imem_base);
+}
+
+static int __init qcom_secure_log_init(void)
+{
+ struct qcom_secure_log *log = &qcom_secure_log;
+ int ret;
+
+ ret = qcom_secure_log_init_tz_diag(log);
+ if (ret)
+ goto err_release_tz_diag;
+
+ log->miscdev.minor = MISC_DYNAMIC_MINOR;
+ log->miscdev.name = "secure_log";
+ log->miscdev.fops = &qcom_secure_log_fops;
+
+ ret = misc_register(&log->miscdev);
+ if (ret)
+ goto err_release_tz_diag;
+
+ return 0;
+
+err_release_tz_diag:
+ qcom_secure_log_release_tz_diag(log);
+ return ret;
+}
+
+static void __exit qcom_secure_log_exit(void)
+{
+ struct qcom_secure_log *log = &qcom_secure_log;
+
+ misc_deregister(&log->miscdev);
+ qcom_secure_log_release_tz_diag(log);
+}
+
+module_init(qcom_secure_log_init);
+module_exit(qcom_secure_log_exit);
+
+MODULE_DESCRIPTION("Qualcomm TZ diagnostic log");
+MODULE_LICENSE("GPL");
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH RFC 2/2] firmware: qcom: Add legacy QSEE secure log support
2026-12-01 22:33 [PATCH RFC 0/2] Add support to display QTEE/OPTEE secure logs on Qualcomm platforms Kuldeep Singh
2026-12-01 22:33 ` [PATCH RFC 1/2] firmware: qcom: Introduce qcom_secure_log interface to display QTEE logs Kuldeep Singh
@ 2026-12-01 22:33 ` Kuldeep Singh
1 sibling, 0 replies; 3+ messages in thread
From: Kuldeep Singh @ 2026-12-01 22:33 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Abel Vesa, Dmitry Baryshkov
Cc: linux-kernel, linux-arm-msm, Kuldeep Singh
QSee log(or TA log buffer) is owned by kernel and QTEE doesn't own of
it's own. Implement new scm call to register this buffer with QTEE where
QTEE maps buffer as RW and RO for kernel by imposing access restriction.
The qsee log read mechanism is somewhat similar to reading TZ diag logs
and be done in userspace.
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/firmware/qcom/Kconfig | 1 +
drivers/firmware/qcom/qcom_scm.c | 34 +++++
drivers/firmware/qcom/qcom_scm.h | 3 +
drivers/firmware/qcom/qcom_secure_log.c | 237 +++++++++++++++++++++++++++-----
include/linux/firmware/qcom/qcom_scm.h | 2 +
5 files changed, 241 insertions(+), 36 deletions(-)
diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig
index 8ca173677c64..5698cac9bb2a 100644
--- a/drivers/firmware/qcom/Kconfig
+++ b/drivers/firmware/qcom/Kconfig
@@ -49,6 +49,7 @@ config QCOM_TZMEM_MODE_SHMBRIDGE
config QCOM_SECURE_LOG
tristate "Qualcomm secure-world log userspace interface"
depends on ARCH_QCOM || COMPILE_TEST
+ depends on QCOM_SCM || !QCOM_SCM
help
Provide a provisional userspace ABI for Qualcomm secure-world log
buffers. Userspace is expected to mmap supported log regions and
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index fa94eaa020c3..3ae452b4e93e 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -1099,6 +1099,40 @@ bool qcom_scm_restore_sec_cfg_available(void)
}
EXPORT_SYMBOL_GPL(qcom_scm_restore_sec_cfg_available);
+/**
+ * qcom_scm_register_qsee_log_buf() - register a legacy QSEE log buffer
+ * @buf: physical address of the HLOS-owned log buffer
+ * @len: size of the log buffer
+ *
+ * Register a DMA/coherent buffer that secure firmware may use for legacy
+ * QSEE log output. The caller owns the buffer and must keep it alive while
+ * secure firmware may write to it.
+ *
+ * Return: 0 on success, negative errno on failure, or a positive firmware
+ * status value if firmware rejects the buffer.
+ */
+int qcom_scm_register_qsee_log_buf(phys_addr_t buf, size_t len)
+{
+ struct qcom_scm_desc desc = {
+ .svc = QCOM_SCM_SVC_QSEELOG,
+ .cmd = QCOM_SCM_QSEELOG_REGISTER,
+ .owner = ARM_SMCCC_OWNER_TRUSTED_OS,
+ .args[0] = buf,
+ .args[1] = len,
+ .arginfo = QCOM_SCM_ARGS(2, QCOM_SCM_RW, QCOM_SCM_VAL),
+ };
+ struct qcom_scm_res res;
+ int ret;
+
+ if (!len)
+ return -EINVAL;
+
+ ret = qcom_scm_call(__scm->dev, &desc, &res);
+
+ return ret ? : res.result[0];
+}
+EXPORT_SYMBOL_GPL(qcom_scm_register_qsee_log_buf);
+
int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare)
{
struct qcom_scm_desc desc = {
diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h
index cf90a565fdfb..d3d18041881a 100644
--- a/drivers/firmware/qcom/qcom_scm.h
+++ b/drivers/firmware/qcom/qcom_scm.h
@@ -111,6 +111,9 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev);
#define QCOM_SCM_IO_READ 0x01
#define QCOM_SCM_IO_WRITE 0x02
+#define QCOM_SCM_SVC_QSEELOG 0x01
+#define QCOM_SCM_QSEELOG_REGISTER 0x06
+
#define QCOM_SCM_SVC_INFO 0x06
#define QCOM_SCM_INFO_IS_CALL_AVAIL 0x01
diff --git a/drivers/firmware/qcom/qcom_secure_log.c b/drivers/firmware/qcom/qcom_secure_log.c
index 7760ad46bd29..1e0c8de753b3 100644
--- a/drivers/firmware/qcom/qcom_secure_log.c
+++ b/drivers/firmware/qcom/qcom_secure_log.c
@@ -6,14 +6,21 @@
*/
#include <linux/fs.h>
+#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/sizes.h>
+#include <linux/slab.h>
+
+#include <linux/firmware/qcom/qcom_scm.h>
#define QCOM_SECURE_LOG_SIZE 0x3000
+#define QCOM_QSEE_LOG_SIZE SZ_128K
/**
* struct qcom_secure_log_config - target-specific secure log configuration
@@ -34,6 +41,14 @@ struct qcom_secure_log_config {
* @imem_base: mapping of the IMEM pointer area
* @tz_diag_base: kernel mapping of the TZ diagnostic buffer
* @tz_diag_phys: physical start of the TZ diagnostic buffer
+ * @qsee_miscdev: userspace miscdevice for the legacy QSEE log buffer
+ * @qsee_pdev: device owning the QSEE DMA allocation
+ * @qsee_dev: device used for QSEE DMA allocation
+ * @qsee_buf: CPU mapping of the coherent QSEE log buffer
+ * @qsee_dma: DMA/physical address registered with secure firmware
+ * @qsee_size: QSEE log buffer size
+ * @tz_registered: true after the TZ diagnostic miscdevice is registered
+ * @qsee_registered: true after the QSEE miscdevice is registered
*/
struct qcom_secure_log {
struct miscdevice miscdev;
@@ -41,6 +56,14 @@ struct qcom_secure_log {
void __iomem *imem_base;
void __iomem *tz_diag_base;
phys_addr_t tz_diag_phys;
+ struct miscdevice qsee_miscdev;
+ struct platform_device *qsee_pdev;
+ struct device *qsee_dev;
+ void *qsee_buf;
+ dma_addr_t qsee_dma;
+ size_t qsee_size;
+ bool tz_registered;
+ bool qsee_registered;
};
static const char * const qcom_secure_log_c125720[] = {
@@ -102,36 +125,6 @@ static const struct qcom_secure_log_config qcom_secure_log_configs[] = {
static struct qcom_secure_log qcom_secure_log;
-static int qcom_secure_log_mmap(struct file *file, struct vm_area_struct *vma)
-{
- struct qcom_secure_log *log = container_of(file->private_data,
- struct qcom_secure_log,
- miscdev);
- unsigned long size = vma->vm_end - vma->vm_start;
-
- if (vma->vm_flags & VM_WRITE)
- return -EPERM;
-
- if (vma->vm_pgoff)
- return -EINVAL;
-
- if (size != log->config->size)
- return -EINVAL;
-
- vm_flags_clear(vma, VM_MAYWRITE);
- vm_flags_set(vma, VM_IO | VM_DONTDUMP | VM_DONTEXPAND);
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
- return remap_pfn_range(vma, vma->vm_start, PHYS_PFN(log->tz_diag_phys),
- size, vma->vm_page_prot);
-}
-
-static const struct file_operations qcom_secure_log_fops = {
- .owner = THIS_MODULE,
- .mmap = qcom_secure_log_mmap,
- .llseek = noop_llseek,
-};
-
static const struct qcom_secure_log_config *qcom_secure_log_find_config(void)
{
const struct qcom_secure_log_config *config;
@@ -150,6 +143,26 @@ static const struct qcom_secure_log_config *qcom_secure_log_find_config(void)
return NULL;
}
+static int qcom_secure_log_map_readonly(struct vm_area_struct *vma,
+ size_t expected_size)
+{
+ unsigned long size = vma->vm_end - vma->vm_start;
+
+ if (vma->vm_flags & VM_WRITE)
+ return -EPERM;
+
+ if (vma->vm_pgoff)
+ return -EINVAL;
+
+ if (size != expected_size)
+ return -EINVAL;
+
+ vm_flags_clear(vma, VM_MAYWRITE);
+ vm_flags_set(vma, VM_DONTDUMP | VM_DONTEXPAND);
+
+ return 0;
+}
+
static int qcom_secure_log_init_tz_diag(struct qcom_secure_log *log)
{
phys_addr_t tz_diag_phys;
@@ -180,6 +193,53 @@ static int qcom_secure_log_init_tz_diag(struct qcom_secure_log *log)
return -ENODEV;
}
+static int qcom_secure_log_tz_mmap(struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct qcom_secure_log *log = container_of(file->private_data,
+ struct qcom_secure_log,
+ miscdev);
+ int ret;
+
+ ret = qcom_secure_log_map_readonly(vma, log->config->size);
+ if (ret)
+ return ret;
+
+ vm_flags_set(vma, VM_IO);
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+ return remap_pfn_range(vma, vma->vm_start, PHYS_PFN(log->tz_diag_phys),
+ log->config->size, vma->vm_page_prot);
+}
+
+static int qcom_secure_log_qsee_mmap(struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct qcom_secure_log *log = container_of(file->private_data,
+ struct qcom_secure_log,
+ qsee_miscdev);
+ int ret;
+
+ ret = qcom_secure_log_map_readonly(vma, log->qsee_size);
+ if (ret)
+ return ret;
+
+ return dma_mmap_coherent(log->qsee_dev, vma, log->qsee_buf, log->qsee_dma,
+ log->qsee_size);
+}
+
+static const struct file_operations qcom_secure_log_tz_fops = {
+ .owner = THIS_MODULE,
+ .mmap = qcom_secure_log_tz_mmap,
+ .llseek = noop_llseek,
+};
+
+static const struct file_operations qcom_secure_log_qsee_fops = {
+ .owner = THIS_MODULE,
+ .mmap = qcom_secure_log_qsee_mmap,
+ .llseek = noop_llseek,
+};
+
static void qcom_secure_log_release_tz_diag(struct qcom_secure_log *log)
{
if (log->tz_diag_base)
@@ -189,23 +249,24 @@ static void qcom_secure_log_release_tz_diag(struct qcom_secure_log *log)
iounmap(log->imem_base);
}
-static int __init qcom_secure_log_init(void)
+static int qcom_secure_log_register_tz(struct qcom_secure_log *log)
{
- struct qcom_secure_log *log = &qcom_secure_log;
int ret;
ret = qcom_secure_log_init_tz_diag(log);
if (ret)
- goto err_release_tz_diag;
+ return ret;
log->miscdev.minor = MISC_DYNAMIC_MINOR;
log->miscdev.name = "secure_log";
- log->miscdev.fops = &qcom_secure_log_fops;
+ log->miscdev.fops = &qcom_secure_log_tz_fops;
ret = misc_register(&log->miscdev);
if (ret)
goto err_release_tz_diag;
+ log->tz_registered = true;
+
return 0;
err_release_tz_diag:
@@ -213,16 +274,120 @@ static int __init qcom_secure_log_init(void)
return ret;
}
+static void qcom_secure_log_release_qsee(struct qcom_secure_log *log)
+{
+ if (log->qsee_registered) {
+ misc_deregister(&log->qsee_miscdev);
+ log->qsee_registered = false;
+ }
+
+ if (log->qsee_buf) {
+ dma_free_coherent(log->qsee_dev, log->qsee_size, log->qsee_buf,
+ log->qsee_dma);
+ log->qsee_buf = NULL;
+ log->qsee_dma = 0;
+ log->qsee_dev = NULL;
+ }
+
+ if (log->qsee_pdev) {
+ platform_device_unregister(log->qsee_pdev);
+ log->qsee_pdev = NULL;
+ }
+}
+
+static int qcom_secure_log_register_qsee(struct qcom_secure_log *log)
+{
+ struct platform_device *pdev;
+ int ret;
+
+ if (!qcom_scm_is_available())
+ return -ENODEV;
+
+ pdev = platform_device_register_simple("qcom-secure-log-qsee", -1,
+ NULL, 0);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
+ log->qsee_pdev = pdev;
+ log->qsee_dev = &pdev->dev;
+
+ ret = dma_set_mask_and_coherent(log->qsee_dev, DMA_BIT_MASK(64));
+ if (ret)
+ ret = dma_set_mask_and_coherent(log->qsee_dev, DMA_BIT_MASK(32));
+ if (ret)
+ goto err_release_qsee;
+
+ log->qsee_size = QCOM_QSEE_LOG_SIZE;
+ log->qsee_buf = dma_alloc_coherent(log->qsee_dev, log->qsee_size,
+ &log->qsee_dma, GFP_KERNEL);
+ if (!log->qsee_buf) {
+ ret = -ENOMEM;
+ goto err_release_qsee;
+ }
+
+ memset(log->qsee_buf, 0, log->qsee_size);
+
+ ret = qcom_scm_register_qsee_log_buf(log->qsee_dma, log->qsee_size);
+ if (ret)
+ goto err_release_qsee;
+
+ log->qsee_miscdev.minor = MISC_DYNAMIC_MINOR;
+ log->qsee_miscdev.name = "qsee_log";
+ log->qsee_miscdev.fops = &qcom_secure_log_qsee_fops;
+
+ ret = misc_register(&log->qsee_miscdev);
+ if (ret)
+ goto err_release_qsee;
+
+ log->qsee_registered = true;
+
+ return 0;
+
+err_release_qsee:
+ qcom_secure_log_release_qsee(log);
+ return ret;
+}
+
+static int __init qcom_secure_log_init(void)
+{
+ struct qcom_secure_log *log = &qcom_secure_log;
+ int ret;
+
+ ret = qcom_secure_log_register_tz(log);
+ if (ret && ret != -ENODEV)
+ return ret;
+
+ ret = qcom_secure_log_register_qsee(log);
+ if (ret && ret != -ENODEV)
+ goto err_release_tz;
+
+ return 0;
+
+err_release_tz:
+ if (log->tz_registered) {
+ misc_deregister(&log->miscdev);
+ log->tz_registered = false;
+ }
+ qcom_secure_log_release_tz_diag(log);
+ return ret;
+}
+
static void __exit qcom_secure_log_exit(void)
{
struct qcom_secure_log *log = &qcom_secure_log;
- misc_deregister(&log->miscdev);
+ qcom_secure_log_release_qsee(log);
+
+ if (log->tz_registered) {
+ misc_deregister(&log->miscdev);
+ log->tz_registered = false;
+ }
+
qcom_secure_log_release_tz_diag(log);
}
module_init(qcom_secure_log_init);
module_exit(qcom_secure_log_exit);
-MODULE_DESCRIPTION("Qualcomm TZ diagnostic log");
+MODULE_DESCRIPTION("Qualcomm secure-world log interface");
MODULE_LICENSE("GPL");
diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
index a0a6bc0229c4..f73664132e05 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -61,6 +61,8 @@ enum qcom_scm_ice_cipher {
bool qcom_scm_is_available(void);
+int qcom_scm_register_qsee_log_buf(phys_addr_t buf, size_t len);
+
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);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread