Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+41 -6
+23
drivers/tee/optee/core.c
··· 356 356 return false; 357 357 } 358 358 359 + static void optee_msg_get_os_revision(optee_invoke_fn *invoke_fn) 360 + { 361 + union { 362 + struct arm_smccc_res smccc; 363 + struct optee_smc_call_get_os_revision_result result; 364 + } res = { 365 + .result = { 366 + .build_id = 0 367 + } 368 + }; 369 + 370 + invoke_fn(OPTEE_SMC_CALL_GET_OS_REVISION, 0, 0, 0, 0, 0, 0, 0, 371 + &res.smccc); 372 + 373 + if (res.result.build_id) 374 + pr_info("revision %lu.%lu (%08lx)", res.result.major, 375 + res.result.minor, res.result.build_id); 376 + else 377 + pr_info("revision %lu.%lu", res.result.major, res.result.minor); 378 + } 379 + 359 380 static bool optee_msg_api_revision_is_compatible(optee_invoke_fn *invoke_fn) 360 381 { 361 382 union { ··· 567 546 pr_warn("api uid mismatch\n"); 568 547 return ERR_PTR(-EINVAL); 569 548 } 549 + 550 + optee_msg_get_os_revision(invoke_fn); 570 551 571 552 if (!optee_msg_api_revision_is_compatible(invoke_fn)) { 572 553 pr_warn("api revision mismatch\n");
+9 -1
drivers/tee/optee/optee_smc.h
··· 112 112 * Trusted OS, not of the API. 113 113 * 114 114 * Returns revision in a0-1 in the same way as OPTEE_SMC_CALLS_REVISION 115 - * described above. 115 + * described above. May optionally return a 32-bit build identifier in a2, 116 + * with zero meaning unspecified. 116 117 */ 117 118 #define OPTEE_SMC_FUNCID_GET_OS_REVISION OPTEE_MSG_FUNCID_GET_OS_REVISION 118 119 #define OPTEE_SMC_CALL_GET_OS_REVISION \ 119 120 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_OS_REVISION) 121 + 122 + struct optee_smc_call_get_os_revision_result { 123 + unsigned long major; 124 + unsigned long minor; 125 + unsigned long build_id; 126 + unsigned long reserved1; 127 + }; 120 128 121 129 /* 122 130 * Call with struct optee_msg_arg as argument
+9 -5
drivers/tee/tee_core.c
··· 693 693 { 694 694 struct tee_device *teedev; 695 695 void *ret; 696 - int rc; 696 + int rc, max_id; 697 697 int offs = 0; 698 698 699 699 if (!teedesc || !teedesc->name || !teedesc->ops || ··· 707 707 goto err; 708 708 } 709 709 710 - if (teedesc->flags & TEE_DESC_PRIVILEGED) 710 + max_id = TEE_NUM_DEVICES / 2; 711 + 712 + if (teedesc->flags & TEE_DESC_PRIVILEGED) { 711 713 offs = TEE_NUM_DEVICES / 2; 714 + max_id = TEE_NUM_DEVICES; 715 + } 712 716 713 717 spin_lock(&driver_lock); 714 - teedev->id = find_next_zero_bit(dev_mask, TEE_NUM_DEVICES, offs); 715 - if (teedev->id < TEE_NUM_DEVICES) 718 + teedev->id = find_next_zero_bit(dev_mask, max_id, offs); 719 + if (teedev->id < max_id) 716 720 set_bit(teedev->id, dev_mask); 717 721 spin_unlock(&driver_lock); 718 722 719 - if (teedev->id >= TEE_NUM_DEVICES) { 723 + if (teedev->id >= max_id) { 720 724 ret = ERR_PTR(-ENOMEM); 721 725 goto err; 722 726 }