From: Harshal Dev <harshal.dev@oss.qualcomm.com>
To: Jens Wiklander <jens.wiklander@linaro.org>,
Jens Wiklander <jens.wiklander@oss.qualcomm.com>,
Sumit Garg <sumit.garg@kernel.org>,
Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: Basant Kumar <basantk@qti.qualcomm.com>,
Apurupa Pattapu <apurupa@qti.qualcomm.com>,
Arun Kumar Neelakantam <aneelaka@qti.qualcomm.com>,
op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
Harshal Dev <harshal.dev@oss.qualcomm.com>
Subject: [PATCH v2 1/6] tee: qcomtee: Track the object invocation context
Date: Wed, 22 Jul 2026 12:29:12 +0530 [thread overview]
Message-ID: <20260722-qcom_uefisecapp_migrate_qcomtee-v2-1-b8a8fcbe4211@oss.qualcomm.com> (raw)
In-Reply-To: <20260722-qcom_uefisecapp_migrate_qcomtee-v2-0-b8a8fcbe4211@oss.qualcomm.com>
QCOMTEE needs to distinguish between object invocations arriving from
kernel clients and user-space clients in order to correctly marshal
UBUF parameters and decide whether certain operations should be permitted.
Introduce an enum tee_object_invoke_origin to allow clients to indicate
the context of the TEE object invocation, and add a kernel_ctx flag to the
QCOMTEE context so the TEE back-end can track it.
Signed-off-by: Harshal Dev <harshal.dev@oss.qualcomm.com>
---
drivers/tee/qcomtee/call.c | 11 ++++++++---
drivers/tee/qcomtee/qcomtee_object.h | 8 ++++++--
drivers/tee/tee_core.c | 3 ++-
include/linux/tee_core.h | 8 +++++++-
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/drivers/tee/qcomtee/call.c b/drivers/tee/qcomtee/call.c
index 0efc5646242a..03d33b118f6d 100644
--- a/drivers/tee/qcomtee/call.c
+++ b/drivers/tee/qcomtee/call.c
@@ -393,15 +393,20 @@ static int qcomtee_root_object_check(u32 op, struct tee_param *params,
*/
static int qcomtee_object_invoke(struct tee_context *ctx,
struct tee_ioctl_object_invoke_arg *arg,
- struct tee_param *params)
+ struct tee_param *params,
+ enum tee_object_invoke_origin origin)
{
struct qcomtee_context_data *ctxdata = ctx->data;
struct qcomtee_object *object;
+ bool kernel_ctx = false;
int i, ret, result;
if (qcomtee_params_check(params, arg->num_params))
return -EINVAL;
+ if (origin == TEE_OBJECT_INVOKE_KERNEL)
+ kernel_ctx = true;
+
/* First, handle reserved operations: */
if (arg->op == QCOMTEE_MSG_OBJECT_OP_RELEASE) {
del_qtee_object(arg->id, ctxdata);
@@ -411,7 +416,7 @@ static int qcomtee_object_invoke(struct tee_context *ctx,
/* Otherwise, invoke a QTEE object: */
struct qcomtee_object_invoke_ctx *oic __free(kfree) =
- qcomtee_object_invoke_ctx_alloc(ctx);
+ qcomtee_object_invoke_ctx_alloc(ctx, kernel_ctx);
if (!oic)
return -ENOMEM;
@@ -648,7 +653,7 @@ static void qcomtee_get_qtee_feature_list(struct tee_context *ctx, u32 id,
int result;
struct qcomtee_object_invoke_ctx *oic __free(kfree) =
- qcomtee_object_invoke_ctx_alloc(ctx);
+ qcomtee_object_invoke_ctx_alloc(ctx, true);
if (!oic)
return;
diff --git a/drivers/tee/qcomtee/qcomtee_object.h b/drivers/tee/qcomtee/qcomtee_object.h
index 8b4401ecad48..2528d07e4576 100644
--- a/drivers/tee/qcomtee/qcomtee_object.h
+++ b/drivers/tee/qcomtee/qcomtee_object.h
@@ -146,6 +146,7 @@ static inline int qcomtee_args_len(struct qcomtee_arg *args)
* struct qcomtee_object_invoke_ctx - QTEE context for object invocation.
* @ctx: TEE context for this invocation.
* @flags: flags for the invocation context.
+ * @kernel_ctx: flag that indicates this context is owned by a kernel client.
* @errno: error code for the invocation.
* @object: current object invoked in this callback context.
* @u: array of arguments for the current invocation (+1 for ending arg).
@@ -158,6 +159,7 @@ static inline int qcomtee_args_len(struct qcomtee_arg *args)
struct qcomtee_object_invoke_ctx {
struct tee_context *ctx;
unsigned long flags;
+ bool kernel_ctx;
int errno;
struct qcomtee_object *object;
@@ -172,13 +174,15 @@ struct qcomtee_object_invoke_ctx {
};
static inline struct qcomtee_object_invoke_ctx *
-qcomtee_object_invoke_ctx_alloc(struct tee_context *ctx)
+qcomtee_object_invoke_ctx_alloc(struct tee_context *ctx, bool kernel_ctx)
{
struct qcomtee_object_invoke_ctx *oic;
oic = kzalloc_obj(*oic);
- if (oic)
+ if (oic) {
oic->ctx = ctx;
+ oic->kernel_ctx = kernel_ctx;
+ }
return oic;
}
diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index ef9642d72672..dba5d4d2d47e 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -706,7 +706,8 @@ static int tee_ioctl_object_invoke(struct tee_context *ctx,
goto out;
}
- rc = ctx->teedev->desc->ops->object_invoke_func(ctx, &arg, params);
+ rc = ctx->teedev->desc->ops->object_invoke_func(ctx, &arg, params,
+ TEE_OBJECT_INVOKE_USERSPACE);
if (rc)
goto out;
diff --git a/include/linux/tee_core.h b/include/linux/tee_core.h
index f993d5118edd..bcb5418d6fdc 100644
--- a/include/linux/tee_core.h
+++ b/include/linux/tee_core.h
@@ -73,6 +73,11 @@ struct tee_device {
struct tee_shm_pool *pool;
};
+enum tee_object_invoke_origin {
+ TEE_OBJECT_INVOKE_USERSPACE,
+ TEE_OBJECT_INVOKE_KERNEL,
+};
+
/**
* struct tee_driver_ops - driver operations vtable
* @get_version: returns version of driver
@@ -117,7 +122,8 @@ struct tee_driver_ops {
struct tee_param *param);
int (*object_invoke_func)(struct tee_context *ctx,
struct tee_ioctl_object_invoke_arg *arg,
- struct tee_param *param);
+ struct tee_param *param,
+ enum tee_object_invoke_origin origin);
int (*cancel_req)(struct tee_context *ctx, u32 cancel_id, u32 session);
int (*supp_recv)(struct tee_context *ctx, u32 *func, u32 *num_params,
struct tee_param *param);
--
2.34.1
WARNING: multiple messages have this Message-ID (diff)
From: Harshal Dev via OP-TEE <op-tee@lists.trustedfirmware.org>
To: Jens Wiklander <jens.wiklander@linaro.org>,
Jens Wiklander <jens.wiklander@oss.qualcomm.com>,
Sumit Garg <sumit.garg@kernel.org>,
Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: Basant Kumar <basantk@qti.qualcomm.com>,
Apurupa Pattapu <apurupa@qti.qualcomm.com>,
Arun Kumar Neelakantam <aneelaka@qti.qualcomm.com>,
op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
Harshal Dev <harshal.dev@oss.qualcomm.com>
Subject: [PATCH v2 1/6] tee: qcomtee: Track the object invocation context
Date: Wed, 22 Jul 2026 12:29:12 +0530 [thread overview]
Message-ID: <20260722-qcom_uefisecapp_migrate_qcomtee-v2-1-b8a8fcbe4211@oss.qualcomm.com> (raw)
In-Reply-To: <20260722-qcom_uefisecapp_migrate_qcomtee-v2-0-b8a8fcbe4211@oss.qualcomm.com>
QCOMTEE needs to distinguish between object invocations arriving from
kernel clients and user-space clients in order to correctly marshal
UBUF parameters and decide whether certain operations should be permitted.
Introduce an enum tee_object_invoke_origin to allow clients to indicate
the context of the TEE object invocation, and add a kernel_ctx flag to the
QCOMTEE context so the TEE back-end can track it.
Signed-off-by: Harshal Dev <harshal.dev@oss.qualcomm.com>
---
drivers/tee/qcomtee/call.c | 11 ++++++++---
drivers/tee/qcomtee/qcomtee_object.h | 8 ++++++--
drivers/tee/tee_core.c | 3 ++-
include/linux/tee_core.h | 8 +++++++-
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/drivers/tee/qcomtee/call.c b/drivers/tee/qcomtee/call.c
index 0efc5646242a..03d33b118f6d 100644
--- a/drivers/tee/qcomtee/call.c
+++ b/drivers/tee/qcomtee/call.c
@@ -393,15 +393,20 @@ static int qcomtee_root_object_check(u32 op, struct tee_param *params,
*/
static int qcomtee_object_invoke(struct tee_context *ctx,
struct tee_ioctl_object_invoke_arg *arg,
- struct tee_param *params)
+ struct tee_param *params,
+ enum tee_object_invoke_origin origin)
{
struct qcomtee_context_data *ctxdata = ctx->data;
struct qcomtee_object *object;
+ bool kernel_ctx = false;
int i, ret, result;
if (qcomtee_params_check(params, arg->num_params))
return -EINVAL;
+ if (origin == TEE_OBJECT_INVOKE_KERNEL)
+ kernel_ctx = true;
+
/* First, handle reserved operations: */
if (arg->op == QCOMTEE_MSG_OBJECT_OP_RELEASE) {
del_qtee_object(arg->id, ctxdata);
@@ -411,7 +416,7 @@ static int qcomtee_object_invoke(struct tee_context *ctx,
/* Otherwise, invoke a QTEE object: */
struct qcomtee_object_invoke_ctx *oic __free(kfree) =
- qcomtee_object_invoke_ctx_alloc(ctx);
+ qcomtee_object_invoke_ctx_alloc(ctx, kernel_ctx);
if (!oic)
return -ENOMEM;
@@ -648,7 +653,7 @@ static void qcomtee_get_qtee_feature_list(struct tee_context *ctx, u32 id,
int result;
struct qcomtee_object_invoke_ctx *oic __free(kfree) =
- qcomtee_object_invoke_ctx_alloc(ctx);
+ qcomtee_object_invoke_ctx_alloc(ctx, true);
if (!oic)
return;
diff --git a/drivers/tee/qcomtee/qcomtee_object.h b/drivers/tee/qcomtee/qcomtee_object.h
index 8b4401ecad48..2528d07e4576 100644
--- a/drivers/tee/qcomtee/qcomtee_object.h
+++ b/drivers/tee/qcomtee/qcomtee_object.h
@@ -146,6 +146,7 @@ static inline int qcomtee_args_len(struct qcomtee_arg *args)
* struct qcomtee_object_invoke_ctx - QTEE context for object invocation.
* @ctx: TEE context for this invocation.
* @flags: flags for the invocation context.
+ * @kernel_ctx: flag that indicates this context is owned by a kernel client.
* @errno: error code for the invocation.
* @object: current object invoked in this callback context.
* @u: array of arguments for the current invocation (+1 for ending arg).
@@ -158,6 +159,7 @@ static inline int qcomtee_args_len(struct qcomtee_arg *args)
struct qcomtee_object_invoke_ctx {
struct tee_context *ctx;
unsigned long flags;
+ bool kernel_ctx;
int errno;
struct qcomtee_object *object;
@@ -172,13 +174,15 @@ struct qcomtee_object_invoke_ctx {
};
static inline struct qcomtee_object_invoke_ctx *
-qcomtee_object_invoke_ctx_alloc(struct tee_context *ctx)
+qcomtee_object_invoke_ctx_alloc(struct tee_context *ctx, bool kernel_ctx)
{
struct qcomtee_object_invoke_ctx *oic;
oic = kzalloc_obj(*oic);
- if (oic)
+ if (oic) {
oic->ctx = ctx;
+ oic->kernel_ctx = kernel_ctx;
+ }
return oic;
}
diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index ef9642d72672..dba5d4d2d47e 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -706,7 +706,8 @@ static int tee_ioctl_object_invoke(struct tee_context *ctx,
goto out;
}
- rc = ctx->teedev->desc->ops->object_invoke_func(ctx, &arg, params);
+ rc = ctx->teedev->desc->ops->object_invoke_func(ctx, &arg, params,
+ TEE_OBJECT_INVOKE_USERSPACE);
if (rc)
goto out;
diff --git a/include/linux/tee_core.h b/include/linux/tee_core.h
index f993d5118edd..bcb5418d6fdc 100644
--- a/include/linux/tee_core.h
+++ b/include/linux/tee_core.h
@@ -73,6 +73,11 @@ struct tee_device {
struct tee_shm_pool *pool;
};
+enum tee_object_invoke_origin {
+ TEE_OBJECT_INVOKE_USERSPACE,
+ TEE_OBJECT_INVOKE_KERNEL,
+};
+
/**
* struct tee_driver_ops - driver operations vtable
* @get_version: returns version of driver
@@ -117,7 +122,8 @@ struct tee_driver_ops {
struct tee_param *param);
int (*object_invoke_func)(struct tee_context *ctx,
struct tee_ioctl_object_invoke_arg *arg,
- struct tee_param *param);
+ struct tee_param *param,
+ enum tee_object_invoke_origin origin);
int (*cancel_req)(struct tee_context *ctx, u32 cancel_id, u32 session);
int (*supp_recv)(struct tee_context *ctx, u32 *func, u32 *num_params,
struct tee_param *param);
--
2.34.1
next prev parent reply other threads:[~2026-07-22 6:59 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 6:59 [PATCH v2 0/6] Add TEE based client driver for UEFI Secure Application Harshal Dev via OP-TEE
2026-07-22 6:59 ` Harshal Dev
2026-07-22 6:59 ` Harshal Dev [this message]
2026-07-22 6:59 ` [PATCH v2 1/6] tee: qcomtee: Track the object invocation context Harshal Dev via OP-TEE
2026-07-22 6:59 ` [PATCH v2 2/6] tee: Add kernel client object invoke helper Harshal Dev
2026-07-22 6:59 ` Harshal Dev via OP-TEE
2026-07-22 6:59 ` [PATCH v2 3/6] tee: qcomtee: Allow object invokes from kernel clients Harshal Dev
2026-07-22 6:59 ` Harshal Dev via OP-TEE
2026-07-29 7:06 ` Amirreza Zarrabi via OP-TEE
2026-07-29 7:06 ` Amirreza Zarrabi
2026-07-31 7:38 ` Harshal Dev via OP-TEE
2026-07-31 7:38 ` Harshal Dev
2026-07-22 6:59 ` [PATCH v2 4/6] tee: Export uuidv5 generation for TEE backends Harshal Dev
2026-07-22 6:59 ` Harshal Dev via OP-TEE
2026-07-22 6:59 ` [PATCH v2 5/6] tee: qcomtee: Add support for registering QTEE services on TEE bus Harshal Dev
2026-07-22 6:59 ` Harshal Dev via OP-TEE
2026-07-22 8:29 ` Dmitry Baryshkov
2026-07-22 8:29 ` Dmitry Baryshkov via OP-TEE
2026-07-24 9:13 ` Harshal Dev via OP-TEE
2026-07-24 9:13 ` Harshal Dev
2026-07-29 7:05 ` Amirreza Zarrabi via OP-TEE
2026-07-29 7:05 ` Amirreza Zarrabi
2026-07-31 8:35 ` Harshal Dev via OP-TEE
2026-07-31 8:35 ` Harshal Dev
2026-07-22 6:59 ` [PATCH v2 6/6] firmware: qcom: Add support for TEE based EFI-var client driver Harshal Dev
2026-07-22 6:59 ` Harshal Dev via OP-TEE
2026-07-22 8:37 ` Dmitry Baryshkov
2026-07-22 8:37 ` Dmitry Baryshkov via OP-TEE
2026-07-24 9:14 ` Harshal Dev via OP-TEE
2026-07-24 9:14 ` Harshal Dev
2026-07-24 10:09 ` Harshal Dev
2026-07-24 10:09 ` Harshal Dev via OP-TEE
2026-07-22 8:26 ` [PATCH v2 0/6] Add TEE based client driver for UEFI Secure Application Dmitry Baryshkov
2026-07-22 8:26 ` Dmitry Baryshkov via OP-TEE
2026-07-24 9:13 ` Harshal Dev via OP-TEE
2026-07-24 9:13 ` Harshal Dev
2026-08-03 14:52 ` Harshal Dev via OP-TEE
2026-08-03 14:52 ` Harshal Dev
2026-08-10 5:41 ` Harshal Dev via OP-TEE
2026-08-10 5:41 ` Harshal Dev
2026-08-10 7:07 ` Dmitry Baryshkov via OP-TEE
2026-08-10 7:07 ` Dmitry Baryshkov
2026-08-12 11:30 ` Harshal Dev via OP-TEE
2026-08-12 11:30 ` Harshal Dev
2026-08-17 6:24 ` Harshal Dev via OP-TEE
2026-08-17 6:24 ` Harshal Dev
2026-08-21 8:34 ` Harshal Dev
2026-08-21 8:34 ` Harshal Dev via OP-TEE
2026-08-26 6:43 ` Harshal Dev via OP-TEE
2026-08-26 6:43 ` Harshal Dev
2026-08-29 14:49 ` Dmitry Baryshkov via OP-TEE
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260722-qcom_uefisecapp_migrate_qcomtee-v2-1-b8a8fcbe4211@oss.qualcomm.com \
--to=harshal.dev@oss.qualcomm.com \
--cc=amirreza.zarrabi@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=aneelaka@qti.qualcomm.com \
--cc=apurupa@qti.qualcomm.com \
--cc=basantk@qti.qualcomm.com \
--cc=jens.wiklander@linaro.org \
--cc=jens.wiklander@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=op-tee@lists.trustedfirmware.org \
--cc=sumit.garg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.