All of lore.kernel.org
 help / color / mirror / Atom feed
From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Julien Grall <julien.grall@arm.com>
Cc: "tee-dev@lists.linaro.org" <tee-dev@lists.linaro.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Volodymyr Babchuk <vlad.babchuk@gmail.com>
Subject: Re: [PATCH v4 05/10] xen/arm: optee: add std call handling
Date: Wed, 20 Mar 2019 17:42:50 +0000	[thread overview]
Message-ID: <87imwd8msm.fsf@epam.com> (raw)
In-Reply-To: <26dfc6e8-ed0d-8764-0ed4-e973a1389b38@arm.com>


Julien Grall writes:

> On 20/03/2019 16:14, Volodymyr Babchuk wrote:
>>
>> Hi Julien,
>
> Hi Volodymyr,
>
>> Julien Grall writes:
>>
>> [...]
>>>>        struct dt_device_node *node;
>>>> @@ -48,12 +82,25 @@ static bool optee_probe(void)
>>>>             (uint32_t)resp.a3 != OPTEE_MSG_UID_3 )
>>>>            return false;
>>>>    +    /* Read number of threads */
>>>> +    arm_smccc_smc(OPTEE_SMC_GET_CONFIG, OPTEE_SMC_CONFIG_NUM_THREADS, &resp);
>>>> +    if ( resp.a0 == OPTEE_SMC_RETURN_OK )
>>>
>>> Out of interest, when was this call added?
>>
>> It is on review right now. We have achieved agreement on that this call
>> is needed. I believe this will be merged into OP-TEE before I'll send v5
>> of this series.
>
> Please mention it after --- so we don't forget to check the state of
> the new call before merging to Xen.
Okay, sure

>
>>
>>>> +    {
>>>> +        max_optee_threads = resp.a1;
>>>> +        printk(XENLOG_DEBUG "OP-TEE supports %u threads.\n", max_optee_threads);
>>>
>>> extra NIT: I would use XENLOG_INFO rather than XENLOG_DEBUG. This is a
>>> useful information to have in bug report.
>>>
>>> Regarding the message, what matters is the number of threads for
>>> guest. So I would rework it to make it more meaning full for a user
>>> that does not know the internal.
>>>
>>> You might also want to move the message out of the if. So you have the
>>> message even when OP-TEE does not support the SMC.
>> In that other case I don't know how much treads OP-TEE really
>> supports... I think, I will need to rephrase that message. Or, better,
>> I'll add another message like "Suggesting that OP-TEE supports %d
>> threads per guest".
>
> Was there any OP-TEE released containing your Virtualization patches?
No, there was no releases with virtualization support.

> Depending on the answer, I would consider to mandate
> OPTEE_SMC_CONFIG_NUM_THREADS so we don't have to deal with a default
> value in Xen.
Makes sense, I think.

> Also, should we expose this call to the guest as well?
Yes, this a good point.

[...]

>>>> +static void put_std_call(struct optee_domain *ctx, struct optee_std_call *call)
>>>> +{
>>>> +    spin_lock(&ctx->lock);
>>>> +    ASSERT(call->in_flight);
>>>> +    unmap_xen_arg(call);
>>>
>>> Same question for the unmap.
>> Yeah, in normal circumstances guest should not try to resume call on
>> another vCPU, because we didn't returned from the original call on
>> current vCPU. But what if gust will try to do this? There are chances,
>> that current CPU will unmap buffer that was mapped by other CPU an
>> instance ago.
>
> Wasn't it the point to have the in_flight field? As soon as you set
> in_flight to true, then only one CPU can have the optee_std_call
> structure in hand.
>
> So, as long as you map/unmap within the section protected by
> "in_flight", you protected against any race. The lock is only here to
> protect the field in_flight and the list. Did I miss anything?

This is partially true. I can call map_xen_arg() after spin_unlock(), yes.

But then I need to call unmap_xen_arg() before spin_lock() in
put_std_call() function. If there were no ASSERT() that would be okay. But with
ASSERT() it is looking weird: firstly we are unmapping buffer and the we are
asserting that we had a right to do this. This is sort of "use before check"

And obviously, I can't call ASSERT() without holding the the spinlock.

On other hand, ASSERT() is a debugging feature, so we can pretend that is
not there... If you okay with this, I'll move mapping/unmapping out of
the spinlocks.

--
Best regards,Volodymyr Babchuk
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-03-20 17:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07 21:04 [PATCH v4 00/10] TEE mediator (and OP-TEE) support in XEN Volodymyr Babchuk
2019-03-07 21:04 ` [PATCH v4 01/10] xen/arm: add generic TEE mediator framework Volodymyr Babchuk
2019-03-15 15:03   ` Julien Grall
2019-03-07 21:04 ` [PATCH v4 04/10] xen/arm: optee: add fast calls handling Volodymyr Babchuk
2019-03-15 15:46   ` Julien Grall
2019-03-07 21:04 ` [PATCH v4 03/10] xen/arm: optee: add OP-TEE mediator skeleton Volodymyr Babchuk
2019-03-15 15:24   ` Julien Grall
2019-03-15 19:00     ` Volodymyr Babchuk
2019-03-15 20:18       ` Julien Grall
2019-03-15 15:47   ` Julien Grall
2019-03-07 21:04 ` [PATCH v4 02/10] xen/arm: optee: add OP-TEE header files Volodymyr Babchuk
2019-03-07 21:04 ` [PATCH v4 07/10] xen/arm: optee: add support for arbitrary shared memory Volodymyr Babchuk
2019-03-18 15:27   ` Julien Grall
2019-03-20 16:39     ` Volodymyr Babchuk
2019-03-20 17:47       ` Julien Grall
2019-03-20 19:37         ` Volodymyr Babchuk
2019-03-21 10:39           ` Julien Grall
2019-03-07 21:04 ` [PATCH v4 06/10] xen/arm: optee: add support for RPC SHM buffers Volodymyr Babchuk
2019-03-18 14:21   ` Julien Grall
2019-03-20 16:21     ` Volodymyr Babchuk
2019-03-20 16:52       ` Julien Grall
2019-03-20 17:09         ` Volodymyr Babchuk
2019-03-07 21:04 ` [PATCH v4 05/10] xen/arm: optee: add std call handling Volodymyr Babchuk
2019-03-18 13:50   ` Julien Grall
2019-03-20 16:14     ` Volodymyr Babchuk
2019-03-20 16:48       ` Julien Grall
2019-03-20 17:42         ` Volodymyr Babchuk [this message]
2019-03-20 18:08           ` Julien Grall
2019-03-07 21:04 ` [PATCH v4 09/10] tools/arm: tee: add "tee" option for xl.cfg Volodymyr Babchuk
2019-03-18 15:49   ` Julien Grall
2019-03-18 21:04     ` Achin Gupta
2019-03-20 16:18       ` Julien Grall
2019-03-20 15:27     ` Volodymyr Babchuk
2019-03-20 16:06       ` Julien Grall
2019-03-20 17:01         ` Volodymyr Babchuk
2019-03-20 18:35           ` Julien Grall
2019-04-05 10:25             ` Volodymyr Babchuk
2019-04-05 10:25               ` [Xen-devel] " Volodymyr Babchuk
2019-04-08 10:47               ` Julien Grall
2019-04-08 10:47                 ` [Xen-devel] " Julien Grall
2019-03-07 21:04 ` [PATCH v4 08/10] xen/arm: optee: add support for RPC commands Volodymyr Babchuk
2019-03-18 15:38   ` Julien Grall
2019-03-20 15:36     ` Volodymyr Babchuk
2019-03-20 16:27       ` Julien Grall
2019-03-20 16:47         ` Volodymyr Babchuk
2019-03-07 21:04 ` [PATCH v4 10/10] tools/arm: optee: create optee firmware node in DT if tee=native Volodymyr Babchuk
2019-03-18 15:50   ` Julien Grall

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=87imwd8msm.fsf@epam.com \
    --to=volodymyr_babchuk@epam.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=tee-dev@lists.linaro.org \
    --cc=vlad.babchuk@gmail.com \
    --cc=xen-devel@lists.xenproject.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.