From: Amirreza Zarrabi <quic_azarrabi@quicinc.com>
To: Jens Wiklander <jens.wiklander@linaro.org>
Cc: Sumit Garg <sumit.garg@linaro.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
<linux-arm-msm@vger.kernel.org>,
<op-tee@lists.trustedfirmware.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-doc@vger.kernel.org>
Subject: Re: [PATCH 02/10] tee: add TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF
Date: Tue, 10 Dec 2024 10:00:42 +1100 [thread overview]
Message-ID: <72e113e7-c1be-48c0-9018-2580f654667a@quicinc.com> (raw)
In-Reply-To: <CAHUa44GxY=nZP9O6XpO-nRKJ_wUnK66h-QEnFPJ9myFGydBZYw@mail.gmail.com>
Hi Jens.
On 12/10/2024 2:46 AM, Jens Wiklander wrote:
> Hi Amirreza,
>
> On Tue, Dec 3, 2024 at 5:20 AM Amirreza Zarrabi
> <quic_azarrabi@quicinc.com> wrote:
>>
>> For drivers that can transfer data to the TEE without needing shared
>> memory from client, it is necessary to receive the user address
>> directly, bypassing any processing by the TEE subsystem. Introduce
>> TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INPUT/OUTPUT/INOUT to represent
>> userspace buffers.
>
> Internally you allocate a bounce buffer from the pool of shared memory
> and copy the content of the user space buffer into that.
> Wouldn't it be fair to replace "without needing shared memory" with
> "without using shared memory"?
>
You are right. I'll update it.
>>
>> Signed-off-by: Amirreza Zarrabi <quic_azarrabi@quicinc.com>
>> ---
>> drivers/tee/tee_core.c | 26 ++++++++++++++++++++++++++
>> include/linux/tee_drv.h | 6 ++++++
>> include/uapi/linux/tee.h | 22 ++++++++++++++++------
>> 3 files changed, 48 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
>> index 24edce4cdbaa..942ff5b359b2 100644
>> --- a/drivers/tee/tee_core.c
>> +++ b/drivers/tee/tee_core.c
>> @@ -381,6 +381,16 @@ static int params_from_user(struct tee_context *ctx, struct tee_param *params,
>> params[n].u.value.b = ip.b;
>> params[n].u.value.c = ip.c;
>> break;
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INPUT:
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_OUTPUT:
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INOUT:
>> + params[n].u.membuf.uaddr = u64_to_user_ptr(ip.a);
>> + params[n].u.membuf.size = ip.b;
>> +
>> + if (!access_ok(params[n].u.membuf.uaddr, params[n].u.membuf.size))
>> + return -EFAULT;
>> +
>> + break;
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT:
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
>> @@ -449,6 +459,11 @@ static int params_to_user(struct tee_ioctl_param __user *uparams,
>> put_user(p->u.value.c, &up->c))
>> return -EFAULT;
>> break;
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_OUTPUT:
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INOUT:
>> + if (put_user((u64)p->u.membuf.size, &up->b))
>> + return -EFAULT;
>> + break;
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
>> if (put_user((u64)p->u.memref.size, &up->b))
>> @@ -649,6 +664,12 @@ static int params_to_supp(struct tee_context *ctx,
>> ip.b = p->u.value.b;
>> ip.c = p->u.value.c;
>> break;
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INPUT:
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INOUT:
>> + ip.a = (u64)p->u.membuf.uaddr;
>> + ip.b = p->u.membuf.size;
>> + ip.c = 0;
>> + break;
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT:
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
>> @@ -751,6 +772,11 @@ static int params_from_supp(struct tee_param *params, size_t num_params,
>> p->u.value.b = ip.b;
>> p->u.value.c = ip.c;
>> break;
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_OUTPUT:
>> + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INOUT:
>> + p->u.membuf.uaddr = u64_to_user_ptr(ip.a);
>> + p->u.membuf.size = ip.b;
>> + break;
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
>> case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
>> /*
>> diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
>> index a54c203000ed..b66e611fece4 100644
>> --- a/include/linux/tee_drv.h
>> +++ b/include/linux/tee_drv.h
>> @@ -82,6 +82,11 @@ struct tee_param_memref {
>> struct tee_shm *shm;
>> };
>>
>> +struct tee_param_membuf {
>
> I would prefer tee_param_ubuf to better describe what it is.
>
Ack.
>> + void * __user uaddr;
>> + size_t size;
>> +};
>> +
>> struct tee_param_value {
>> u64 a;
>> u64 b;
>> @@ -92,6 +97,7 @@ struct tee_param {
>> u64 attr;
>> union {
>> struct tee_param_memref memref;
>> + struct tee_param_membuf membuf;
>> struct tee_param_value value;
>> } u;
>> };
>> diff --git a/include/uapi/linux/tee.h b/include/uapi/linux/tee.h
>> index d0430bee8292..fae68386968a 100644
>> --- a/include/uapi/linux/tee.h
>> +++ b/include/uapi/linux/tee.h
>> @@ -151,6 +151,13 @@ struct tee_ioctl_buf_data {
>> #define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT 6
>> #define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT 7 /* input and output */
>>
>> +/*
>> + * These defines memory buffer parameters.
>
> user space buffer
>
>> + */
>> +#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INPUT 8
>> +#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_OUTPUT 9
>> +#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF_INOUT 10 /* input and output */
>
> TEE_IOCTL_PARAM_ATTR_TYPE_UBUF_*
>
Ack.
>> +
>> /*
>> * Mask for the type part of the attribute, leaves room for more types
>> */
>> @@ -186,14 +193,17 @@ struct tee_ioctl_buf_data {
>> /**
>> * struct tee_ioctl_param - parameter
>> * @attr: attributes
>> - * @a: if a memref, offset into the shared memory object, else a value parameter
>> - * @b: if a memref, size of the buffer, else a value parameter
>> + * @a: if a memref, offset into the shared memory object,
>> + * else if a membuf, address into the user buffer,
>> + * else a value parameter
>> + * @b: if a memref or membuf, size of the buffer, else a value parameter
>> * @c: if a memref, shared memory identifier, else a value parameter
>> *
>> - * @attr & TEE_PARAM_ATTR_TYPE_MASK indicates if memref or value is used in
>> - * the union. TEE_PARAM_ATTR_TYPE_VALUE_* indicates value and
>> - * TEE_PARAM_ATTR_TYPE_MEMREF_* indicates memref. TEE_PARAM_ATTR_TYPE_NONE
>> - * indicates that none of the members are used.
>> + * @attr & TEE_PARAM_ATTR_TYPE_MASK indicates if memref, membuf, or value is
>> + * used in the union. TEE_PARAM_ATTR_TYPE_VALUE_* indicates value,
>> + * TEE_PARAM_ATTR_TYPE_MEMREF_* indicates memref, and TEE_PARAM_ATTR_TYPE_MEMBUF_*
>> + * indicates membuf. TEE_PARAM_ATTR_TYPE_NONE indicates that none of the members
>> + * are used.
>> *
>> * Shared memory is allocated with TEE_IOC_SHM_ALLOC which returns an
>> * identifier representing the shared memory object. A memref can reference
>
> Please update the comment above with UBUF and ubuf as needed.
>
Ack.
> Cheers,
> Jens
>
Best Regadrs,
Amir
>>
>> --
>> 2.34.1
>>
next prev parent reply other threads:[~2024-12-09 23:00 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 4:19 [PATCH 00/10] Trusted Execution Environment (TEE) driver for Qualcomm TEE (QTEE) Amirreza Zarrabi
2024-12-03 4:19 ` [PATCH 01/10] tee: allow a driver to allocate a tee_device without a pool Amirreza Zarrabi
2024-12-03 4:19 ` [PATCH 02/10] tee: add TEE_IOCTL_PARAM_ATTR_TYPE_MEMBUF Amirreza Zarrabi
2024-12-03 8:01 ` kernel test robot
2024-12-09 15:46 ` Jens Wiklander
2024-12-09 23:00 ` Amirreza Zarrabi [this message]
2024-12-03 4:19 ` [PATCH 03/10] tee: add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF Amirreza Zarrabi
2024-12-03 4:19 ` [PATCH 04/10] firmware: qcom: scm: add support for object invocation Amirreza Zarrabi
2024-12-03 4:19 ` [PATCH 05/10] qcomtee: implement object invoke support Amirreza Zarrabi
2024-12-09 18:43 ` Jens Wiklander
2024-12-10 21:42 ` Amirreza Zarrabi
2024-12-10 10:24 ` Jens Wiklander
2024-12-10 21:44 ` Amirreza Zarrabi
2024-12-03 4:19 ` [PATCH 06/10] qcomtee: add primordial object Amirreza Zarrabi
2024-12-03 4:19 ` [PATCH 07/10] dt-bindings: arm: qcomtee: add QTEE driver devicetree binding for TEE subsystem Amirreza Zarrabi
2024-12-03 7:55 ` Krzysztof Kozlowski
2024-12-03 4:19 ` [PATCH 08/10] tee: add Qualcomm TEE driver Amirreza Zarrabi
2024-12-03 7:57 ` Krzysztof Kozlowski
2024-12-10 11:58 ` Jens Wiklander
2024-12-11 2:30 ` Amirreza Zarrabi
2024-12-11 14:04 ` Jens Wiklander
2024-12-12 0:19 ` Amirreza Zarrabi
2024-12-12 7:07 ` Jens Wiklander
2024-12-03 4:19 ` [PATCH 09/10] arm64: dts: qcom: sm8650: add support for QTEE Amirreza Zarrabi
2024-12-03 7:59 ` Krzysztof Kozlowski
2024-12-04 1:00 ` Amirreza Zarrabi
2024-12-03 4:19 ` [PATCH 10/10] Documentation: tee: Add Qualcomm TEE driver Amirreza Zarrabi
2024-12-03 7:58 ` Krzysztof Kozlowski
2024-12-03 6:06 ` [PATCH 00/10] Trusted Execution Environment (TEE) driver for Qualcomm TEE (QTEE) Trilok Soni
2024-12-03 22:13 ` Amirreza Zarrabi
2024-12-03 23:43 ` Dmitry Baryshkov
2024-12-04 0:45 ` Amirreza Zarrabi
2024-12-18 14:25 ` Sumit Garg
2024-12-18 19:20 ` Amirreza Zarrabi
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=72e113e7-c1be-48c0-9018-2580f654667a@quicinc.com \
--to=quic_azarrabi@quicinc.com \
--cc=andersson@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jens.wiklander@linaro.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=op-tee@lists.trustedfirmware.org \
--cc=robh@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=sumit.garg@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®