securemsm-kernel: Add support for qseecom proxy module

A new module named qseecom_proxy has been defined in kernel
which acts as a forwarder for calls received from kernel clients
of qseecom and smcinvoke. This change adds the support for calling
that module from the vendor dlkm modules smcinvoke and qseecom.

Change-Id: I0d1aa93b9cea9e6a6e1fee17c33c78e14deb8ecf
Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com>
This commit is contained in:
Anmolpreet Kaur
2022-09-22 17:53:28 +05:30
parent 32a90722f5
commit 8456ddc256
5 changed files with 139 additions and 15 deletions

View File

@@ -23,7 +23,11 @@
#include <linux/errno.h>
#include <linux/kthread.h>
#include <linux/hdcp_qseecom.h>
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
#include <linux/qseecom_kernel.h>
#else
#include "misc/qseecom_kernel.h"
#endif
#define HDCP2P2_APP_NAME "hdcp2p2"
#define HDCP1_APP_NAME "hdcp1"

25
linux/misc/qseecom_priv.h Normal file
View File

@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __QSEECOM_PRIV_H_
#define __QSEECOM_PRIV_H_
#include <linux/types.h>
#if IS_ENABLED(CONFIG_QSEECOM) || IS_ENABLED(CONFIG_ARCH_SA8155)
int qseecom_process_listener_from_smcinvoke(uint32_t *result,
u64 *response_type, unsigned int *data);
#else
static inline int qseecom_process_listener_from_smcinvoke(uint32_t *result,
u64 *response_type, unsigned int *data)
{
return -EOPNOTSUPP;
}
#endif
int get_qseecom_kernel_fun_ops(void);
#endif

View File

@@ -35,7 +35,6 @@
#include <soc/qcom/qseecom_scm.h>
#include <soc/qcom/qseecomi.h>
#include <asm/cacheflush.h>
#include <misc/qseecom_kernel.h>
#include <linux/delay.h>
#include <linux/signal.h>
#include <linux/compat.h>
@@ -48,6 +47,12 @@
#include <linux/qtee_shmbridge.h>
#include <linux/mem-buf.h>
#include "ice.h"
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
#include <linux/qseecom_kernel.h>
#include "misc/qseecom_priv.h"
#else
#include "misc/qseecom_kernel.h"
#endif
#define QSEECOM_DEV "qseecom"
#define QSEOS_VERSION_14 0x14
@@ -4994,7 +4999,7 @@ static int qseecom_unload_commonlib_image(void)
return ret;
}
int qseecom_start_app(struct qseecom_handle **handle,
static int __qseecom_start_app(struct qseecom_handle **handle,
char *app_name, uint32_t size)
{
int32_t ret = 0;
@@ -5162,9 +5167,8 @@ err:
__wakeup_unload_app_kthread();
return ret;
}
EXPORT_SYMBOL(qseecom_start_app);
int qseecom_shutdown_app(struct qseecom_handle **handle)
static int __qseecom_shutdown_app(struct qseecom_handle **handle)
{
int ret = -EINVAL;
struct qseecom_dev_handle *data;
@@ -5218,9 +5222,8 @@ int qseecom_shutdown_app(struct qseecom_handle **handle)
__wakeup_unload_app_kthread();
return ret;
}
EXPORT_SYMBOL(qseecom_shutdown_app);
int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
static int __qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len)
{
int ret = 0;
@@ -5302,7 +5305,42 @@ int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
req.resp_len, req.resp_buf);
return ret;
}
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
const static struct qseecom_drv_ops qseecom_driver_ops = {
.qseecom_send_command = __qseecom_send_command,
.qseecom_start_app = __qseecom_start_app,
.qseecom_shutdown_app = __qseecom_shutdown_app,
};
int get_qseecom_kernel_fun_ops(void)
{
return provide_qseecom_kernel_fun_ops(&qseecom_driver_ops);
}
#else
int qseecom_start_app(struct qseecom_handle **handle,
char *app_name, uint32_t size)
{
return __qseecom_start_app(handle, app_name, size);
}
EXPORT_SYMBOL(qseecom_start_app);
int qseecom_shutdown_app(struct qseecom_handle **handle)
{
return __qseecom_shutdown_app(handle);
}
EXPORT_SYMBOL(qseecom_shutdown_app);
int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len)
{
return __qseecom_send_command(handle, send_buf, sbuf_len,
resp_buf, rbuf_len);
}
EXPORT_SYMBOL(qseecom_send_command);
#endif
int qseecom_set_bandwidth(struct qseecom_handle *handle, bool high)
{
@@ -9577,6 +9615,14 @@ static int qseecom_probe(struct platform_device *pdev)
rc = qseecom_create_kthreads();
if (rc)
goto exit_deinit_bus;
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
/*If the api fails to get the func ops, print the error and continue
* Do not treat it as fatal*/
rc = get_qseecom_kernel_fun_ops();
if (rc)
pr_err("failed to provide qseecom ops %d", rc);
#endif
atomic_set(&qseecom.qseecom_state, QSEECOM_STATE_READY);
return 0;

View File

@@ -30,10 +30,15 @@
#include <soc/qcom/qseecomi.h>
#include <linux/qtee_shmbridge.h>
#include <linux/kthread.h>
#include "misc/qseecom_kernel.h"
#include "smcinvoke.h"
#include "smcinvoke_object.h"
#include "IClientEnv.h"
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
#include <linux/qseecom_kernel.h>
#include "misc/qseecom_priv.h"
#else
#include "misc/qseecom_kernel.h"
#endif
#define CREATE_TRACE_POINTS
#include "trace_smcinvoke.h"
@@ -2795,6 +2800,14 @@ static int smcinvoke_probe(struct platform_device *pdev)
}
smcinvoke_pdev = pdev;
#if !IS_ENABLED(CONFIG_QSEECOM) && IS_ENABLED(CONFIG_QSEECOM_PROXY)
/*If the api fails to get the func ops, print the error and continue
* Do not treat it as fatal*/
rc = get_qseecom_kernel_fun_ops();
if (rc) {
pr_err("failed to get qseecom kernel func ops %d", rc);
}
#endif
return 0;
exit_destroy_device:

View File

@@ -15,12 +15,15 @@
#include "smcinvoke.h"
#include "smcinvoke_object.h"
#include "IClientEnv.h"
#if !IS_ENABLED(CONFIG_QSEECOM)
#include "linux/qseecom.h"
#include "misc/qseecom_kernel.h"
#include "IQSEEComCompat.h"
#include "IQSEEComCompatAppLoader.h"
#include "linux/qseecom.h"
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
#include <linux/qseecom_kernel.h>
#else
#include "misc/qseecom_kernel.h"
#endif
#endif
const uint32_t CQSEEComCompatAppLoader_UID = 122;
@@ -361,7 +364,7 @@ exit_release_shm:
return ret;
}
int qseecom_start_app(struct qseecom_handle **handle,
static int __qseecom_start_app(struct qseecom_handle **handle,
char *app_name, uint32_t size)
{
int ret = 0;
@@ -430,9 +433,8 @@ exit_free_cxt:
return ret;
}
EXPORT_SYMBOL(qseecom_start_app);
int qseecom_shutdown_app(struct qseecom_handle **handle)
static int __qseecom_shutdown_app(struct qseecom_handle **handle)
{
struct qseecom_compat_context *cxt =
(struct qseecom_compat_context *)(*handle);
@@ -450,9 +452,8 @@ int qseecom_shutdown_app(struct qseecom_handle **handle)
*handle = NULL;
return 0;
}
EXPORT_SYMBOL(qseecom_shutdown_app);
int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
static int __qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len)
{
struct qseecom_compat_context *cxt =
@@ -477,5 +478,40 @@ int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
Object_NULL, Object_NULL,
Object_NULL, Object_NULL);
}
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
const static struct qseecom_drv_ops qseecom_driver_ops = {
.qseecom_send_command = __qseecom_send_command,
.qseecom_start_app = __qseecom_start_app,
.qseecom_shutdown_app = __qseecom_shutdown_app,
};
int get_qseecom_kernel_fun_ops(void)
{
return provide_qseecom_kernel_fun_ops(&qseecom_driver_ops);
}
#else
int qseecom_start_app(struct qseecom_handle **handle,
char *app_name, uint32_t size)
{
return __qseecom_start_app(handle, app_name, size);
}
EXPORT_SYMBOL(qseecom_start_app);
int qseecom_shutdown_app(struct qseecom_handle **handle)
{
return __qseecom_shutdown_app(handle);
}
EXPORT_SYMBOL(qseecom_shutdown_app);
int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len)
{
return __qseecom_send_command(handle, send_buf, sbuf_len,
resp_buf, rbuf_len);
}
EXPORT_SYMBOL(qseecom_send_command);
#endif
#endif