#include <linux/tee_core.h>
#include <linux/tee_ioc.h>
+#include <asm/smp_plat.h>
#include <tee_shm.h>
#include <tee_supp_com.h>
#include <tee_mutex_wait.h>
#include "tee_tz_priv.h"
#include "handle.h"
+#define SWITCH_CPU0_DEBUG
+
#define _TEE_TZ_NAME "armtz"
#define DEV (ptee->tee->dev)
/*******************************************************************
* Calling TEE
*******************************************************************/
+#ifdef CONFIG_SMP
+static void switch_cpumask_to_cpu0(cpumask_t *saved_cpu_mask)
+{
+ long ret;
+ cpumask_t local_cpu_mask = CPU_MASK_NONE;
+ pr_info("switch_cpumask_to_cpu cpu0\n");
+ cpu_set(0, local_cpu_mask);
+ cpumask_copy(saved_cpu_mask, tsk_cpus_allowed(current));
+ ret = sched_setaffinity(0, &local_cpu_mask);
+ if (ret)
+ pr_err("sched_setaffinity #1 -> 0x%lX", ret);
+}
+
+static void restore_cpumask(cpumask_t *saved_cpu_mask)
+{
+ long ret;
+ pr_info("restore_cpumask cpu0\n");
+ ret = sched_setaffinity(0, saved_cpu_mask);
+ if (ret)
+ pr_err("sched_setaffinity #2 -> 0x%lX", ret);
+}
+#else
+static inline void switch_cpumask_to_cpu0(void) {};
+static inline void restore_cpumask(void) {};
+#endif
+static int tee_smc_call_switchcpu0(struct smc_param *param)
+{
+ cpumask_t saved_cpu_mask;
+
+ switch_cpumask_to_cpu0(&saved_cpu_mask);
+ tee_smc_call(param);
+ restore_cpumask(&saved_cpu_mask);
+ return 0;
+}
static void e_lock_teez(struct tee_tz *ptee)
{
while (true) {
param.a0 = funcid;
+#ifdef SWITCH_CPU0_DEBUG
+ tee_smc_call_switchcpu0(¶m);
+#else
tee_smc_call(¶m);
+#endif
ret = param.a0;
if (ret == TEESMC_RETURN_EBUSY) {
memset(¶m, 0, sizeof(param));
param.a0 = TEESMC32_ST_FASTCALL_L2CC_MUTEX;
param.a1 = TEESMC_ST_L2CC_MUTEX_GET_ADDR;
+#ifdef SWITCH_CPU0_DEBUG
+ tee_smc_call_switchcpu0(¶m);
+#else
tee_smc_call(¶m);
+#endif
if (param.a0 != TEESMC_RETURN_OK) {
dev_warn(DEV, "no TZ l2cc mutex service supported\n");
memset(¶m, 0, sizeof(param));
param.a0 = TEESMC32_ST_FASTCALL_L2CC_MUTEX;
param.a1 = TEESMC_ST_L2CC_MUTEX_ENABLE;
+#ifdef SWITCH_CPU0_DEBUG
+ tee_smc_call_switchcpu0(¶m);
+#else
tee_smc_call(¶m);
+#endif
if (param.a0 != TEESMC_RETURN_OK) {
memset(¶m, 0, sizeof(param));
param.a0 = TEESMC32_ST_FASTCALL_L2CC_MUTEX;
param.a1 = TEESMC_ST_L2CC_MUTEX_DISABLE;
+#ifdef SWITCH_CPU0_DEBUG
+ tee_smc_call_switchcpu0(¶m);
+#else
tee_smc_call(¶m);
+#endif
outer_tz_mutex(NULL);
if (vaddr)
iounmap(vaddr);
mutex_lock(&ptee->mutex);
param.a0 = TEESMC32_ST_FASTCALL_GET_SHM_CONFIG;
+#ifdef SWITCH_CPU0_DEBUG
+ tee_smc_call_switchcpu0(¶m);
+#else
tee_smc_call(¶m);
+#endif
mutex_unlock(&ptee->mutex);
if (param.a0 != TEESMC_RETURN_OK) {
/******************************************************************************/
-const struct tee_ops tee_fops = {
+static const struct tee_ops tee_fops = {
.type = "tz",
.owner = THIS_MODULE,
.start = tz_start,
#define _TEE_CORE_FW_VER "1:0.1"
-static char *_tee_supp_app_name = "tee-supplicant";
+static char *_tee_supp_app_name = "tee_supplicant";
/* Store the class misc reference */
static struct class *misc_class;
return ret;
}
-const struct file_operations tee_fops = {
+static const struct file_operations tee_file_fops = {
.owner = THIS_MODULE,
.read = tee_supp_read,
.write = tee_supp_write,
.open = tee_ctx_open,
.release = tee_ctx_release,
- .unlocked_ioctl = tee_ioctl
+ .unlocked_ioctl = tee_ioctl,
+ .compat_ioctl = tee_ioctl
};
static void tee_plt_device_release(struct device *dev)
tee->miscdev.parent = dev;
tee->miscdev.minor = MISC_DYNAMIC_MINOR;
tee->miscdev.name = tee->name;
- tee->miscdev.fops = &tee_fops;
+ tee->miscdev.fops = &tee_file_fops;
mutex_init(&tee->lock);
atomic_set(&tee->refcount, 0);