tee: add cancellation support to client interface
authorIgor Opaniuk <igor.opaniuk@linaro.org>
Thu, 24 Jan 2019 17:32:31 +0000 (19:32 +0200)
committerJens Wiklander <jens.wiklander@linaro.org>
Thu, 28 Feb 2019 12:49:29 +0000 (13:49 +0100)
Add support of cancellation request to the TEE kernel internal
client interface. Can be used by software TPM drivers, that leverage
TEE under the hood (for instance TPM2.0 mobile profile), for requesting
cancellation of time-consuming operations (RSA key-pair generation etc.).

Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
drivers/tee/tee_core.c
include/linux/tee_drv.h

index 25f3b9cc8908f44ecb179e540a74ab87fa6721c7..ecffdd8a29b71e474a5ea35702a88062e565aa35 100644 (file)
@@ -1039,6 +1039,15 @@ int tee_client_invoke_func(struct tee_context *ctx,
 }
 EXPORT_SYMBOL_GPL(tee_client_invoke_func);
 
+int tee_client_cancel_req(struct tee_context *ctx,
+                         struct tee_ioctl_cancel_arg *arg)
+{
+       if (!ctx->teedev->desc->ops->cancel_req)
+               return -EINVAL;
+       return ctx->teedev->desc->ops->cancel_req(ctx, arg->cancel_id,
+                                                 arg->session);
+}
+
 static int tee_client_device_match(struct device *dev,
                                   struct device_driver *drv)
 {
index 56d7f1b4516d448a37077169196a66089887efc8..4a49f80e7f711091db1c442a4afb27ce49c1e7f8 100644 (file)
@@ -535,6 +535,18 @@ int tee_client_invoke_func(struct tee_context *ctx,
                           struct tee_ioctl_invoke_arg *arg,
                           struct tee_param *param);
 
+/**
+ * tee_client_cancel_req() - Request cancellation of the previous open-session
+ * or invoke-command operations in a Trusted Application
+ * @ctx:       TEE Context
+ * @arg:       Cancellation arguments, see description of
+ *             struct tee_ioctl_cancel_arg
+ *
+ * Returns < 0 on error else 0 if the cancellation was successfully requested.
+ */
+int tee_client_cancel_req(struct tee_context *ctx,
+                         struct tee_ioctl_cancel_arg *arg);
+
 static inline bool tee_param_is_memref(struct tee_param *param)
 {
        switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {