UPSTREAM: tee: apply v16 delta
Applies the v16 of the generic TEE subsystem patch set. Change-Id: I86f6f9e7801f999f77240828d9becbb7a6cc8d9b Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Zhang Zhijie <zhangzj@rock-chips.com> (cherry picked from https://git.linaro.org/kernel/linux-linaro-stable.git v3.18/topic/optee commit d35e3b092dc6084130570c899df0c48268481579)
This commit is contained in:
committed by
Zhang Zhijie
parent
ccce29f360
commit
08e634640b
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user