diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2017-03-15 11:23:10 +0100 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2017-03-15 14:13:20 +0100 |
commit | d35e3b092dc6084130570c899df0c48268481579 (patch) | |
tree | fbb4a874f3ae19fe78f32097ab5678c261d7a097 | |
parent | 0d1d664eb8b381f6b1fd9315870c34859f1abde5 (diff) |
tee: apply v16 deltav3.18/topic/optee
Applies the v16 of the generic TEE subsystem patch set.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r-- | drivers/tee/optee/core.c | 31 | ||||
-rw-r--r-- | drivers/tee/optee/optee_smc.h | 2 | ||||
-rw-r--r-- | drivers/tee/tee_core.c | 2 | ||||
-rw-r--r-- | drivers/tee/tee_shm.c | 3 | ||||
-rw-r--r-- | include/linux/tee_drv.h | 3 |
5 files changed, 32 insertions, 9 deletions
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index c98a81213151..8890a185d320 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -14,6 +14,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include <linux/arm-smccc.h> #include <linux/errno.h> #include <linux/io.h> #include <linux/module.h> @@ -329,9 +330,8 @@ static bool optee_msg_exchange_capabilities(optee_invoke_fn *invoke_fn, * point of view) or not, is_smp() returns the the information * needed, but can't be called directly from here. */ -#ifndef CONFIG_SMP - a1 |= OPTEE_SMC_NSEC_CAP_UNIPROCESSOR; -#endif + if (!IS_ENABLED(CONFIG_SMP) || nr_cpu_ids == 1) + a1 |= OPTEE_SMC_NSEC_CAP_UNIPROCESSOR; invoke_fn(OPTEE_SMC_EXCHANGE_CAPABILITIES, a1, 0, 0, 0, 0, 0, 0, &res.smccc); @@ -406,6 +406,25 @@ out: return pool; } +/* Simple wrapper functions to be able to use a function pointer */ +static void optee_smccc_smc(unsigned long a0, unsigned long a1, + unsigned long a2, unsigned long a3, + unsigned long a4, unsigned long a5, + unsigned long a6, unsigned long a7, + struct arm_smccc_res *res) +{ + arm_smccc_smc(a0, a1, a2, a3, a4, a5, a6, a7, res); +} + +static void optee_smccc_hvc(unsigned long a0, unsigned long a1, + unsigned long a2, unsigned long a3, + unsigned long a4, unsigned long a5, + unsigned long a6, unsigned long a7, + struct arm_smccc_res *res) +{ + arm_smccc_hvc(a0, a1, a2, a3, a4, a5, a6, a7, res); +} + static optee_invoke_fn *get_invoke_func(struct device_node *np) { const char *method; @@ -418,9 +437,9 @@ static optee_invoke_fn *get_invoke_func(struct device_node *np) } if (!strcmp("hvc", method)) - return arm_smccc_hvc; + return optee_smccc_hvc; else if (!strcmp("smc", method)) - return arm_smccc_smc; + return optee_smccc_smc; pr_warn("invalid \"method\" property: %s\n", method); return ERR_PTR(-EINVAL); @@ -459,7 +478,7 @@ static struct optee *optee_probe(struct device_node *np) * We have no other option for shared memory, if secure world * doesn't have any reserved memory we can use we can't continue. */ - if (!(sec_caps & OPTEE_SMC_SEC_CAP_HAVE_RESERVERED_SHM)) + if (!(sec_caps & OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM)) return ERR_PTR(-EINVAL); pool = optee_config_shm_memremap(invoke_fn, &memremaped_shm); diff --git a/drivers/tee/optee/optee_smc.h b/drivers/tee/optee/optee_smc.h index d470d450b182..13b7c98cdf25 100644 --- a/drivers/tee/optee/optee_smc.h +++ b/drivers/tee/optee/optee_smc.h @@ -219,7 +219,7 @@ struct optee_smc_get_shm_config_result { /* Normal world works as a uniprocessor system */ #define OPTEE_SMC_NSEC_CAP_UNIPROCESSOR BIT(0) /* Secure world has reserved shared memory for normal world to use */ -#define OPTEE_SMC_SEC_CAP_HAVE_RESERVERED_SHM BIT(0) +#define OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM BIT(0) /* Secure world can communicate via previously unregistered shared memory */ #define OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM BIT(1) #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9 diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index 3cae9591fb59..ac34acd7bb93 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -618,6 +618,7 @@ static void tee_release_device(struct device *dev) clear_bit(teedev->id, dev_mask); spin_unlock(&driver_lock); mutex_destroy(&teedev->mutex); + idr_destroy(&teedev->idr); kfree(teedev); } @@ -695,6 +696,7 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc, teedev->num_users = 1; init_completion(&teedev->c_no_users); mutex_init(&teedev->mutex); + idr_init(&teedev->idr); teedev->desc = teedesc; teedev->pool = pool; diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index c2c90a8249be..549e5b9fee0c 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -303,7 +303,8 @@ int tee_shm_get_pa(struct tee_shm *shm, size_t offs, phys_addr_t *pa) EXPORT_SYMBOL_GPL(tee_shm_get_pa); /** - * tee_shm_get_from_id() - Find shared memory object and increase referece count + * tee_shm_get_from_id() - Find shared memory object and increase reference + * count * @ctx: Context owning the shared memory * @id: Id of shared memory object * @returns a pointer to 'struct tee_shm' on success or an ERR_PTR on failure diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index 9c6106efcbca..0f175b8f6456 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -266,7 +266,8 @@ int tee_shm_get_pa(struct tee_shm *shm, size_t offs, phys_addr_t *pa); int tee_shm_get_id(struct tee_shm *shm); /** - * tee_shm_get_from_id() - Find shared memory object and increase referece count + * tee_shm_get_from_id() - Find shared memory object and increase reference + * count * @ctx: Context owning the shared memory * @id: Id of shared memory object * @returns a pointer to 'struct tee_shm' on success or an ERR_PTR on failure |