mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
Small fix and report OP-TEE revision information
* Adds one small fix correct max value of privileged device id allocation, this is only needed if there's more than TEE_NUM_DEVICES / 2 (16) tee drivers registered. One or two is a normal value. * Reports OP-TEE revision information (major, minro version and build id if available) -----BEGIN PGP SIGNATURE----- iQI3BAABCgAhBQJannVVGhxqZW5zLndpa2xhbmRlckBsaW5hcm8ub3JnAAoJELWw uEGXj+zTi7kP/A38yzO9H6Lgn+kdHg2VKkSVfSe8vAg4WapJSYKZvNsb1O5/+6RZ 7GEdxFu+bogvzOkXyRLwAdYoj1m9Edb0dBm966jBy20xIMcjuKSnUl0J2/e10NEC 6suB0E20iUOE6qL7UizTgSRUEmURITCXfyZt3NYxbqkaqCJE7CioF8XkcjqLo5Vf 2WmFNpoqaYIWtIix+EhGj1P+/dDt1YVwp/IsHFqaQvcBBVETCHsdFAyIUhnJNi14 4CHz4D5asz+5C9i4P1gCwggPzLg/xImBWh2x410liRlbg8DgW/O9TcagI2fDwVNJ YyOKeOMHIYcRiEqw7F47QsRWBhVyRALy3B/UmI06lWU1TkPR/ZHSZUhd2fhljo9Y veZM0kMh9m260IwluXn+DdQbc4WGX+VVSXOM1UFXdWzhebTLU4wK2c/YbEJNQ15F XthoMMwoXvhmxXKz6KGipNkpsYw3SFPpEdcjkDT1Nn24WMyUnqNlm1OM5X20bLaf uqkGMpqHhZHexYHvmCghEPAgU3EMRblbTKz53wACzL/VE4rp7pUjn4k2UrmSO57n 2H0GRuQ1/Mq/VZHJRufjLCAsBoS0A4ELebNhEmD/rglEselhnByUUAo+gU5DOite IUVvkwsjNY6BLvvRO2wyP1un1/dafWJJGwt0WJJSKZUbYodJQ5DAoVkD =a3dC -----END PGP SIGNATURE----- Merge tag 'tee-drv-misc-for-v4.17' of https://git.linaro.org:/people/jens.wiklander/linux-tee into next/drivers Pull "Small fix and report OP-TEE revision information" from Jens Wiklander: * Adds one small fix correct max value of privileged device id allocation, this is only needed if there's more than TEE_NUM_DEVICES / 2 (16) tee drivers registered. One or two is a normal value. * Reports OP-TEE revision information (major, minro version and build id if available) * tag 'tee-drv-misc-for-v4.17' of https://git.linaro.org:/people/jens.wiklander/linux-tee: tee: optee: report OP-TEE revision information tee: optee: GET_OS_REVISION: document a2 as a build identifier tee: correct max value for id allocation
This commit is contained in:
commit
a7e66ff96b
|
|
@ -356,6 +356,27 @@ static bool optee_msg_api_uid_is_optee_api(optee_invoke_fn *invoke_fn)
|
|||
return false;
|
||||
}
|
||||
|
||||
static void optee_msg_get_os_revision(optee_invoke_fn *invoke_fn)
|
||||
{
|
||||
union {
|
||||
struct arm_smccc_res smccc;
|
||||
struct optee_smc_call_get_os_revision_result result;
|
||||
} res = {
|
||||
.result = {
|
||||
.build_id = 0
|
||||
}
|
||||
};
|
||||
|
||||
invoke_fn(OPTEE_SMC_CALL_GET_OS_REVISION, 0, 0, 0, 0, 0, 0, 0,
|
||||
&res.smccc);
|
||||
|
||||
if (res.result.build_id)
|
||||
pr_info("revision %lu.%lu (%08lx)", res.result.major,
|
||||
res.result.minor, res.result.build_id);
|
||||
else
|
||||
pr_info("revision %lu.%lu", res.result.major, res.result.minor);
|
||||
}
|
||||
|
||||
static bool optee_msg_api_revision_is_compatible(optee_invoke_fn *invoke_fn)
|
||||
{
|
||||
union {
|
||||
|
|
@ -547,6 +568,8 @@ static struct optee *optee_probe(struct device_node *np)
|
|||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
optee_msg_get_os_revision(invoke_fn);
|
||||
|
||||
if (!optee_msg_api_revision_is_compatible(invoke_fn)) {
|
||||
pr_warn("api revision mismatch\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
|
|
|||
|
|
@ -112,12 +112,20 @@ struct optee_smc_calls_revision_result {
|
|||
* Trusted OS, not of the API.
|
||||
*
|
||||
* Returns revision in a0-1 in the same way as OPTEE_SMC_CALLS_REVISION
|
||||
* described above.
|
||||
* described above. May optionally return a 32-bit build identifier in a2,
|
||||
* with zero meaning unspecified.
|
||||
*/
|
||||
#define OPTEE_SMC_FUNCID_GET_OS_REVISION OPTEE_MSG_FUNCID_GET_OS_REVISION
|
||||
#define OPTEE_SMC_CALL_GET_OS_REVISION \
|
||||
OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_OS_REVISION)
|
||||
|
||||
struct optee_smc_call_get_os_revision_result {
|
||||
unsigned long major;
|
||||
unsigned long minor;
|
||||
unsigned long build_id;
|
||||
unsigned long reserved1;
|
||||
};
|
||||
|
||||
/*
|
||||
* Call with struct optee_msg_arg as argument
|
||||
*
|
||||
|
|
|
|||
|
|
@ -693,7 +693,7 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
|
|||
{
|
||||
struct tee_device *teedev;
|
||||
void *ret;
|
||||
int rc;
|
||||
int rc, max_id;
|
||||
int offs = 0;
|
||||
|
||||
if (!teedesc || !teedesc->name || !teedesc->ops ||
|
||||
|
|
@ -707,16 +707,20 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (teedesc->flags & TEE_DESC_PRIVILEGED)
|
||||
max_id = TEE_NUM_DEVICES / 2;
|
||||
|
||||
if (teedesc->flags & TEE_DESC_PRIVILEGED) {
|
||||
offs = TEE_NUM_DEVICES / 2;
|
||||
max_id = TEE_NUM_DEVICES;
|
||||
}
|
||||
|
||||
spin_lock(&driver_lock);
|
||||
teedev->id = find_next_zero_bit(dev_mask, TEE_NUM_DEVICES, offs);
|
||||
if (teedev->id < TEE_NUM_DEVICES)
|
||||
teedev->id = find_next_zero_bit(dev_mask, max_id, offs);
|
||||
if (teedev->id < max_id)
|
||||
set_bit(teedev->id, dev_mask);
|
||||
spin_unlock(&driver_lock);
|
||||
|
||||
if (teedev->id >= TEE_NUM_DEVICES) {
|
||||
if (teedev->id >= max_id) {
|
||||
ret = ERR_PTR(-ENOMEM);
|
||||
goto err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user