[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] arm: dom0less: add TEE support


  • To: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 30 May 2024 09:40:33 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RERca++Jkv+bFKsXzSH4ddrRDHhcxvb/w+O8l/W0HLM=; b=LhLeH4Cy4WZgDo54HA9c4NCt8qWdnAqAVolRaQGCOK9xWkWhcgTbpgdwG2ovyg6HrmI/29ebS/cMnGqiYVCw3QNI/o6s71FFe2b3zNWXJQCcC75Ov3BQf97AJsplF8YchsJFLPgsu0rCyZhQqJGIzGs+tE3WPvgtmA1PYV3s3OBEyp4MvTAFvFwyzIt2PvUQmbiLxG0ZQuWdD0rh/JXdV8AJ6dvTndAj7zoO7YbU1vJGFhaulvOE2OLN3PAmj+ynd3sKQt4mtVmvTxi1zvAtrTxB3UzwwAJuM8wxRpM8RJoNN3QVeUQbtmR90a8v7/wjN8oUVVzCeB04YEtgeuDzNA==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RERca++Jkv+bFKsXzSH4ddrRDHhcxvb/w+O8l/W0HLM=; b=FhDKbGctvvHsUA79WVdtpAFAHnCVOrB+cWBDImnUSaNqsb+NHpEBjEH88pdk92z8HXp/gtMSqviuPaf1vCO3MS9Pb/Ksa0FbRqHXDciRDzDbaWrxecSYOrnVF9LY9GKbgjAVak9feqan9VXN92lEu1slYAahDzw5BOob6/jrBySp6LFOfwcrFp8ROgjUj8Qa4r6uVYjl83fA2RVFBEKpXDCvUEE9G2hdZA45JX1q4tZgzmt62aJewdd6jfMdZaT0nmLiCKxC71gNNdYBvVD8GXRwYNc8++pxy2SY9pE7OzduHekXRpBOtj7Qqv1azZqlfD6zeCkgX3l0AEu9o3a5yw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=EX8AXS8dlzrpgaEfTKCePlXy+HEwrTPcXFB09Wkl2+hDVnYt5e3kTUrhI8EuC3f6FfM9LTrLwaeNA/01YjsRFxA3nZr935gZE0FnzEa7PYbTDpOPmLpZP9DUuGbHgjBAGmZgMhA+A3drnMntHNOemly2aJdy0yrlVhXOZJuiJnWi0atimPHEcTllqwjP3iTRJ0mD3YlPoIXtyxL7NNiF4q1s+APlM4h2Xukl9nSuXe9LkT4P9RjwNHw2zLn6OfphpwC5Dj0vLQC7HJxK+mFEAg8is91m7RE22WJowJ7gwDHiXqc4NMspOjQ5sfPRb2M8kq4pB76YaSwDqEYNLuOSJA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuzZGisy3/XVMCNDMTNUFaEhAXiwoR6/M8Ed1GvskTmnDttqnKWKF4ty+GtUbk33c3JLGkolwLvU9OFCcDlkHhOjT8UozZGCV3e9tpTPRm06eoDMBHn5VaWf2D6ATpAYP7g8eUXIvOj7S4hag2+K3vFPcOKytWcKybKuBurJD/B+dTYxtrjB7N6jVoLkjqhSHPzhEPE74vAtlGCa3pMNNWKCXhxwqgm6lbiww5NaReiEoMH95iAsn/mO+IkY4ouKxop2YLpH9E+D2vhBkZ0RbOqaei7xBZyzpLsWFLI6rtFYS+lPlsvMEma9owRA4guR5GrDcuzRRq3wCJXtVNnJgA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Thu, 30 May 2024 09:41:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHasgjZKwS4pdCyJUe9LewXYMLHeLGutaSAgAAAkICAANCCAA==
  • Thread-topic: [PATCH] arm: dom0less: add TEE support

Hi Volodomyr,

First: thanks a lot for this as having a solution for selecting the tee
for guests on a dom0less configuration was something needed.

Let me answer a bit more on the rest of the patch,

> On 29 May 2024, at 23:34, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx> 
> wrote:
> 
> 
> Hi Julien,
> 
> Julien Grall <julien@xxxxxxx> writes:
> 
>> Hi Volodymyr,
>> 
>> Can you clarify whether this is intended for the next release cycle?
> 
> Well, I don't think that this patch should be committed ASAP if this is
> what you are asking about.
> 
>> On 29/05/2024 21:43, Volodymyr Babchuk wrote:
>>> Allow to provide TEE type for a Dom0less guest via "xen,tee"
>>> property. Create appropriate nodes in the guests' device tree and
>>> initialize tee subsystem for it.
>> 
>> The new property needs to be documented in
>> docs/misc/arm/device-tree/booting.txt.
>> 
> 
> Yes, missed that.
> 
>>> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
>>> ---
>>>  xen/arch/arm/dom0less-build.c     | 69 +++++++++++++++++++++++++++++++
>>>  xen/arch/arm/include/asm/kernel.h |  3 ++
>>>  2 files changed, 72 insertions(+)
>>> diff --git a/xen/arch/arm/dom0less-build.c
>>> b/xen/arch/arm/dom0less-build.c
>>> index fb63ec6fd1..1ea3ecc45c 100644
>>> --- a/xen/arch/arm/dom0less-build.c
>>> +++ b/xen/arch/arm/dom0less-build.c
>>> @@ -15,6 +15,7 @@
>>>  #include <asm/domain_build.h>
>>>  #include <asm/static-memory.h>
>>>  #include <asm/static-shmem.h>
>>> +#include <asm/tee/tee.h>
>>>    bool __init is_dom0less_mode(void)
>>>  {
>>> @@ -277,6 +278,42 @@ static int __init make_vpl011_uart_node(struct 
>>> kernel_info *kinfo)
>>>  }
>>>  #endif
>>>  +#ifdef CONFIG_OPTEE
>>> +static int __init make_optee_node(struct kernel_info *kinfo)
>> 
>> Please introduce a callback in the TEE framework that will create the
>> OPTEE node.
> 
> This is the reason why this is RFC. I wanted to discuss the right method
> of doing this. "optee" node should reside in "/firmware/" node as per
> device tree bindings. But "/firmware/" node can contain additional
> entries, for example linux device tree bindings also define
> "/firmware/sdei". So, probably correct solution is to implement function
> "make_firmware_node()" in this file, which in turn will call TEE
> framework.
> 

I think we need something in tee.c calling on the right tee implementation
depending on what is enabled for the guest as Julien suggested.


> But we are making assumption that all TEE implementation will have its
> node inside "/firmware/". I am not 100% sure that this is correct. For
> example I saw that Google Trusty uses "/trusty" node (directly inside
> the DTS root). On other hand, it is not defined in dts bindings, as far
> as I know.


Regarding the firmware part you can easily handle that by looking for /firmware
and create it if it does not exist before creating your sub-node and this should
be node in the optee node creation function not in tee.c.

> 
>>>  /*
>>>   * Scan device tree properties for passthrough specific information.
>>>   * Returns < 0 on error
>>> @@ -650,6 +687,15 @@ static int __init prepare_dtb_domU(struct domain *d, 
>>> struct kernel_info *kinfo)
>>>      if ( ret )
>>>          goto err;
>>>  +#ifdef CONFIG_OPTEE
>>> +    if ( kinfo->tee_type == XEN_DOMCTL_CONFIG_TEE_OPTEE)
>>> +    {
>>> +        ret = make_optee_node(kinfo);
>>> +        if ( ret )
>>> +            goto err;
>>> +    }
>>> +#endif
>>> +
>>>      /*
>>>       * domain_handle_dtb_bootmodule has to be called before the rest of
>>>       * the device tree is generated because it depends on the value of
>>> @@ -743,6 +789,9 @@ static int __init construct_domU(struct domain *d,
>>>  {
>>>      struct kernel_info kinfo = {};
>>>      const char *dom0less_enhanced;
>>> +#ifdef CONFIG_TEE
>>> +    const char *tee;
>>> +#endif
>>>      int rc;
>>>      u64 mem;
>>>      u32 p2m_mem_mb;
>>> @@ -786,6 +835,18 @@ static int __init construct_domU(struct domain *d,
>>>      else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") )
>>>          kinfo.dom0less_feature = DOM0LESS_ENHANCED_NO_XS;
>>>  +#ifdef CONFIG_TEE
>> 
>> I would rather prefer if this code is implemented in tee.c. We also...

ack

>> 
>>> +    rc = dt_property_read_string(node, "xen,tee", &tee);
>> 
>> ... want to return an error if "xen,tee" exists because CONFIG_TEE is
>> not set.

ack

>> 
>>> +    if ( rc == -EILSEQ ||
>>> +         rc == -ENODATA ||
>>> +         (rc == 0 && !strcmp(tee, "none")) )
>>> +    {
>>> +        if ( !hardware_domain )
>> 
>> 
>> I don't understand this check. Why would we require dom0 for OP-TEE?
> 
> OP-TEE is enabled for Dom0 unconditionally in create_dom0(void);
> 
> This is another topic I wanted to discuss, actually, Should we use the
> same "xen,tee" for Dom0? In this case we might want to alter Dom0 DTB to
> remove TEE entry if user wants it to be disabled.

This is only called for domU anyway so i do not think this check makes sense.

More than that, the fact that we are enabling optee support by default in dom0
might need shortly to be revisited as one might want to have a Xen compiled
with both optee and FF-A so we should have a solution to select which one
(if any) is enabled in dom0 (command line argument or device tree entry).

> 
>> In any case we should avoid to hide a feature behind the user back. At
>> minimum, we should print a message, but I would rather prefer a
>> panic() because the user asks for a feature and we denied it.

ack for the panic.

>> 
>>> +            kinfo.tee_type = XEN_DOMCTL_CONFIG_TEE_NONE;
>> Why don't we have a else case? Are you assuming that tee_type is
>> initialized to TEE_NONE (which luckily happens to be 0)? If so, why do
>> we need the check above?
> 
> Yes, you are right, I'll rework this part.
> 
> [...]
> 
>>> +    if ( kinfo.tee_type )
>>> +    {
>>> +        rc = tee_domain_init(d, kinfo.tee_type);
>> 
>> Can you explain why do you need to call tee_domain_init() rather than
>> setting d_cfg.arch.tee_type just before domain_create() is called and
>> rely on the latter to call the former?
>> 
> 
> Because I was not familiar with dom0less code good enough. Your proposal
> is much better, I'll rework this.
> 
> -- 
> WBR, Volodymyr

Cheers
Bertrand




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.