From patchwork Fri May 31 17:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13681977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DBE8C25B75 for ; Fri, 31 May 2024 17:50:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.733814.1140115 (Exim 4.92) (envelope-from ) id 1sD6O8-0007nY-0N; Fri, 31 May 2024 17:50:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 733814.1140115; Fri, 31 May 2024 17:49:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sD6O7-0007nR-U3; Fri, 31 May 2024 17:49:59 +0000 Received: by outflank-mailman (input) for mailman id 733814; Fri, 31 May 2024 17:49:58 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sD6O6-0007nL-8X for xen-devel@lists.xenproject.org; Fri, 31 May 2024 17:49:58 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 301e7011-1f76-11ef-b4bb-af5377834399; Fri, 31 May 2024 19:49:55 +0200 (CEST) Received: from pps.filterd (m0174676.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44VDM4JX026259; Fri, 31 May 2024 17:49:40 GMT Received: from eur02-db5-obe.outbound.protection.outlook.com (mail-db5eur02lp2104.outbound.protection.outlook.com [104.47.11.104]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3yffce8vpd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 May 2024 17:49:39 +0000 (GMT) Received: from GV1PR03MB10456.eurprd03.prod.outlook.com (2603:10a6:150:16a::21) by DU2PR03MB9970.eurprd03.prod.outlook.com (2603:10a6:10:46c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Fri, 31 May 2024 17:49:36 +0000 Received: from GV1PR03MB10456.eurprd03.prod.outlook.com ([fe80::a41e:5aa8:e298:757e]) by GV1PR03MB10456.eurprd03.prod.outlook.com ([fe80::a41e:5aa8:e298:757e%3]) with mapi id 15.20.7633.001; Fri, 31 May 2024 17:49:36 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 301e7011-1f76-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eL+HlJy51J6ROJzPKFw/eK/1v50bmA9Aqzbir+NkX8xxWvWQbNA2EgOM6q9o9Oh0fqaxloAERE/yaDDmlzfd0N5wDv47AlZ4RdA83JwdwkbUZ2mtpud+c0E48H4wli/PgXS0kx+daM61k/j7SdGHc/0DoajRw0v1pthM0L+BORrndkCggX39myX3c369DTtsKuBh3SKt8gzVkmzeApIt2SNBJa9CbdJAJdW8UMCHe5cST33tL4zd6xFwYjfyS9/GqDJiwz3bNxtsbDv37xsoyUlvV2Ce/e7wpqupDNZataTgMmviuKqVRUg91JnbeDr80xxh4o7uuky5qhpaNAvkvA== 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=2CL11dFNt49tELnrbAYGB/LEe0N9IS3YfQ7Qsks3K5Y=; b=nU1X970wB78GzEyOMvlv+9C6T214iI8/y5IdenEHj97Aj6zYt0dQ+AEWu/tQ/OVZB4Yta/P3NgcnZyImHr9Ht/Avf8tTHiwc5prcZpkL5G4IOhoIq9HbssNeI/AqcaPZEzJ0vEPE1fFLca7GIkOXv+G17klt19c5muKflz+Zk/cgNucwYuFl4jNbU9Go96inPXOflqPqwP2Yj49LLj3ifgkbbSNjnDQyl1BN0RM2fxKs1qoc7r8TiO7489U/TIEZnmKohdTYfFiVHFrG8lIMb5HWslHKbVCQB3woYbX0AxUeC1MkkarVjHJMsj1lpRZvMD81GyBaBgo6TQfKSdz9Aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2CL11dFNt49tELnrbAYGB/LEe0N9IS3YfQ7Qsks3K5Y=; b=X7H6PHnZAD8FF8tKgMbMxN00RI8Avhlr9LOhCGg8kMp36VlS8JTf0KNdA4D794roR02ZuQaVEycRWO2bnM2WfsPzr0l7t3c3wNkCpjYuFePISRdnWB4Z8ZI+oXuyKWaVSrzDk2tEPoBAvI5tTWZMH/dHAt4Fzs36yjhBv0IZNBFHnDTx5pLCe7nrtn6cgLowyklMYQCUdTQUnBkEId8p6an4KboYbUdDrdZcErjJqCgEMh13qO/SEenLwIn278YB79MgFJcCvfkPBi/HxV6qrZVvoUWAwBJFEm6UuxpTJWJxoJEngCLId0hwv5lcrjDfINah+DQDrXzeCD7YaCmC8w== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [RFC PATCH v2] arm: dom0less: add TEE support Thread-Topic: [RFC PATCH v2] arm: dom0less: add TEE support Thread-Index: AQHas4LmA3+MKr53jE6Kc+pdYgdQGA== Date: Fri, 31 May 2024 17:49:36 +0000 Message-ID: <20240531174915.1679443-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.45.1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: GV1PR03MB10456:EE_|DU2PR03MB9970:EE_ x-ms-office365-filtering-correlation-id: c41824e4-2e25-47f9-cf7b-08dc819a0953 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230031|376005|1800799015|366007|38070700009; x-microsoft-antispam-message-info: =?iso-8859-1?q?v6Fbscfp+joX2Gs0rp++8Vmzhj?= =?iso-8859-1?q?3lZ/+UycxfQ1FKkhuk8D3s99tr1dm/snbfJ7UdWg8A+NRAGJ6lB0PheTO5Oy?= =?iso-8859-1?q?JhwiCZa7lhaDujmqEAcaUXuxCyBF/VrCOFM0IJGsu2pycTe9Ex3DRPB+PhUB?= =?iso-8859-1?q?WAMvShd6K4/isBLC8ysv0E6ETl2n+YTRvUYpBiUGDmSOIYluHeOl4GrtklLK?= =?iso-8859-1?q?H8k4t/DVKF1Gf1QP55qfsidLeKNE73R6a5fBZ5XKFtyzBm3qsHP9ssyr8rmk?= =?iso-8859-1?q?GdP9ITen0IgRhvG5OVc/bKRstam2LyuKNpAROfn0OOVO9VvsnRbyD6h9iVKg?= =?iso-8859-1?q?qY/tpPiQ0G74sBVv87AtPKPO2ztuqH5F4pOlq2e1Jf2BreEA/wONLpxr3FTf?= =?iso-8859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gjBSdEWQLZgy4uXibh6JOFcXfNLqZPOcRfIvt?= =?iso-8859-1?q?dDJjCv45DCZJTk5758NJaFDWtny34NtK8q/AojSdcZzvNUQpuRZsOo2b1oAN?= =?iso-8859-1?q?KmOOiXrgthQ996JvMVmA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR03MB10456.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(366007)(38070700009);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?IFQz9aCHIug/BIpKTZH2LDB?= =?iso-8859-1?q?Dh19hnzHRlqSYNUrYxF2y/sZH3LpNcBnXNVKzvtMRLLL6RPNEPfcGSvD68uH?= =?iso-8859-1?q?Bt5tAyv/Ua6L187zsZGe3/+mrSsCZtKEsikFSbtuqqyrRXCW9Ult8xF3T/kQ?= =?iso-8859-1?q?UYGmjndTRVXQukvbryc8N6aIAfXnu/hHRjHaepErIiXX+IIQrJNDOrSR8IdT?= =?iso-8859-1?q?nsj8/5YnhNzwr22nNdqese9HsQoATgXDFESolPdBPLhbldxIGyBUlRxnVZ4G?= =?iso-8859-1?q?thiNtpBaWzcMOLL4TEmYobIn9pEZSYsdbhev7Fu+l92c5B6M8LoJiDuJkl0Q?= =?iso-8859-1?q?8RtrgQSm9qYm/lj/yx8Rx7cxGjruYyjaver0bzPVg0PtoQuxWNnBEU/TKY1T?= =?iso-8859-1?q?FFSWr3ndC+v5OInK/SdrVJEdGN0Rr4TZOk1leArEera3c5yJc9uNGociD5KO?= =?iso-8859-1?q?yWFJ7r2KzBLLw8IX73kNBikCDuNh2aX8UaHd78QU8iyfzvfWQsZNW/a977EV?= =?iso-8859-1?q?Wd+kOpwaf6wZNHM+GOYM0OTvEFy74wvvzcNfefPGLFzDxowQ9sbyi6NaMwwK?= =?iso-8859-1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venzIXq7IRlyWajR1UlETGczz9FYXg695XLzv?= =?iso-8859-1?q?LpaRhMfpvmfCwEwEwd5tZZU9IHJ9sqDyL6jFDSqCtk3xkEa/Ulnl71N135k2?= =?iso-8859-1?q?Xq1yTSTuOmFkAiqlLNlgVkov7hRlij7l3NP09yjAa/IS3cb8NrbEuSO60rYJ?= =?iso-8859-1?q?bahsbLxhWeZOg2JAGw2L4g4yVTBbwS0cvY7qlOg=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: GV1PR03MB10456.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c41824e4-2e25-47f9-cf7b-08dc819a0953 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 May 2024 17:49:36.0781 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8NAts/c48ICppE65oL3AhLdvSHBwXVD4b/caml5xu6uDj5WlUgoCtlXYtd9yA/sARrnwt+O2GvZwA278Fms+x2kizh0PQaRQGmsnM7tO85g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR03MB9970 X-Proofpoint-ORIG-GUID: FKuM9b5En1rrGkDo6Wd6YHpdg1cJrxEy X-Proofpoint-GUID: FKuM9b5En1rrGkDo6Wd6YHpdg1cJrxEy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-31_12,2024-05-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2405310135 Extend TEE mediator interface with two functions : - tee_get_type_from_dts() returns TEE type based on input string - tee_make_dtb_node() creates a DTB entry for the selected TEE mediator Use those new functions to parse "xen,tee" DTS property for dom0less guests and enable appropriate TEE mediator. Signed-off-by: Volodymyr Babchuk --- This is still RFC because I am not happy how I decide if tee_make_dtb_node() needs to be called. TEE type is stored in d_cfg, but d_cfg is not passed to construct_domU()->prepare_dtb_domU(). So right now I am relying on fact that every TEE mediator initilizes d->arch.tee. Also I am sorry about previous completely botched version of this patch. I really messed it up, including absence of [RFC] tag :( --- docs/misc/arm/device-tree/booting.txt | 17 +++++++++++++ xen/arch/arm/dom0less-build.c | 19 +++++++++++++++ xen/arch/arm/include/asm/tee/tee.h | 13 ++++++++++ xen/arch/arm/tee/ffa.c | 8 ++++++ xen/arch/arm/tee/optee.c | 35 +++++++++++++++++++++++++++ xen/arch/arm/tee/tee.c | 21 ++++++++++++++++ 6 files changed, 113 insertions(+) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index bbd955e9c2..711a6080b5 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -231,6 +231,23 @@ with the following properties: In the future other possible property values might be added to enable only selected interfaces. +- xen,tee + + A string property that describes what TEE mediator should be enabled + for the domain. Possible property values are: + + - "none" (or missing property value) + No TEE will be available in the VM. + + - "OP-TEE" + VM will have access to the OP-TEE using classic OP-TEE SMC interface. + + - "FF-A" + VM will have access to a TEE using generic FF-A interface. + + In the future other TEE mediators may be added, extending possible + values for this property. + - xen,domain-p2m-mem-mb Optional. A 32-bit integer specifying the amount of megabytes of RAM diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index fb63ec6fd1..13fdd44eef 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -15,6 +15,7 @@ #include #include #include +#include bool __init is_dom0less_mode(void) { @@ -650,6 +651,10 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) if ( ret ) goto err; + /* We are making assumption that every mediator sets d->arch.tee */ + if ( d->arch.tee ) + tee_make_dtb_node(kinfo->fdt); + /* * domain_handle_dtb_bootmodule has to be called before the rest of * the device tree is generated because it depends on the value of @@ -871,6 +876,7 @@ void __init create_domUs(void) unsigned int flags = 0U; uint32_t val; int rc; + const char *tee_name; if ( !dt_device_is_compatible(node, "xen,domain") ) continue; @@ -881,6 +887,19 @@ void __init create_domUs(void) if ( dt_find_property(node, "xen,static-mem", NULL) ) flags |= CDF_staticmem; + tee_name = dt_get_property(node, "xen,tee", NULL); + if ( tee_name ) + { + rc = tee_get_type_from_dts(tee_name); + if ( rc < 0) + panic("Can't enable requested TEE for domain: %d\n", rc); + d_cfg.arch.tee_type = rc; + } + else + { + d_cfg.arch.tee_type = XEN_DOMCTL_CONFIG_TEE_NONE; + } + if ( dt_property_read_bool(node, "direct-map") ) { if ( !(flags & CDF_staticmem) ) diff --git a/xen/arch/arm/include/asm/tee/tee.h b/xen/arch/arm/include/asm/tee/tee.h index da324467e1..9626667545 100644 --- a/xen/arch/arm/include/asm/tee/tee.h +++ b/xen/arch/arm/include/asm/tee/tee.h @@ -36,6 +36,9 @@ struct tee_mediator_ops { int (*domain_init)(struct domain *d); int (*domain_teardown)(struct domain *d); + /* Make DTB node that describes TEE. Used when creating a dom0less domain */ + int (*make_dtb_node)(void *fdt); + /* * Called during domain destruction to relinquish resources used * by mediator itself. This function can return -ERESTART to indicate @@ -65,7 +68,9 @@ bool tee_handle_call(struct cpu_user_regs *regs); int tee_domain_init(struct domain *d, uint16_t tee_type); int tee_domain_teardown(struct domain *d); int tee_relinquish_resources(struct domain *d); +int tee_make_dtb_node(void *fdt); uint16_t tee_get_type(void); +int tee_get_type_from_dts(const char* prop_value); #define REGISTER_TEE_MEDIATOR(_name, _namestr, _type, _ops) \ static const struct tee_mediator_desc __tee_desc_##_name __used \ @@ -105,6 +110,14 @@ static inline uint16_t tee_get_type(void) return XEN_DOMCTL_CONFIG_TEE_NONE; } +static inline int tee_get_type_from_dts(const char* prop_value) +{ + if ( !strcmp(prop_value, "none") ) + return XEN_DOMCTL_CONFIG_TEE_NONE; + + return -ENODEV; +} + #endif /* CONFIG_TEE */ #endif /* __ARCH_ARM_TEE_TEE_H__ */ diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c index 0793c1c758..f315d6eef6 100644 --- a/xen/arch/arm/tee/ffa.c +++ b/xen/arch/arm/tee/ffa.c @@ -1752,6 +1752,13 @@ err_free_ffa_rx: return false; } +static int ffa_make_dtb_node(void *fdt) +{ + /* FF-A is not configured via dtb */ + + return 0; +} + static const struct tee_mediator_ops ffa_ops = { .probe = ffa_probe, @@ -1759,6 +1766,7 @@ static const struct tee_mediator_ops ffa_ops = .domain_teardown = ffa_domain_teardown, .relinquish_resources = ffa_relinquish_resources, .handle_call = ffa_handle_call, + .make_dtb_node = ffa_make_dtb_node, }; REGISTER_TEE_MEDIATOR(ffa, "FF-A", XEN_DOMCTL_CONFIG_TEE_FFA, &ffa_ops); diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index 5151bd90ed..5eb5d01813 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1722,6 +1723,39 @@ static bool optee_handle_call(struct cpu_user_regs *regs) } } +static int __init optee_make_dtb_node(void *fdt) +{ + int res; + + res = fdt_begin_node(fdt, "firmware"); + if ( res ) + return res; + + res = fdt_begin_node(fdt, "optee"); + if ( res ) + return res; + + res = fdt_property_string(fdt, "compatible", "linaro,optee-tz"); + if ( res ) + return res; + + res = fdt_property_string(fdt, "method", "hvc"); + if ( res ) + return res; + + /* end of "optee" */ + res = fdt_end_node(fdt); + if ( res ) + return res; + + /* end of "firmware" */ + res = fdt_end_node(fdt); + if ( res ) + return res; + + return 0; +} + static const struct tee_mediator_ops optee_ops = { .probe = optee_probe, @@ -1729,6 +1763,7 @@ static const struct tee_mediator_ops optee_ops = .domain_teardown = optee_domain_teardown, .relinquish_resources = optee_relinquish_resources, .handle_call = optee_handle_call, + .make_dtb_node = optee_make_dtb_node, }; REGISTER_TEE_MEDIATOR(optee, "OP-TEE", XEN_DOMCTL_CONFIG_TEE_OPTEE, &optee_ops); diff --git a/xen/arch/arm/tee/tee.c b/xen/arch/arm/tee/tee.c index ddd17506a9..6388166e17 100644 --- a/xen/arch/arm/tee/tee.c +++ b/xen/arch/arm/tee/tee.c @@ -68,6 +68,14 @@ int tee_relinquish_resources(struct domain *d) return cur_mediator->ops->relinquish_resources(d); } +int tee_make_dtb_node(void *fdt) +{ + if ( !cur_mediator ) + return -ENODEV; + + return cur_mediator->ops->make_dtb_node(fdt); +} + uint16_t tee_get_type(void) { if ( !cur_mediator ) @@ -76,6 +84,19 @@ uint16_t tee_get_type(void) return cur_mediator->tee_type; } +int tee_get_type_from_dts(const char* prop_value) +{ + if ( !strcmp(prop_value, "none") ) + return XEN_DOMCTL_CONFIG_TEE_NONE; + + if ( !cur_mediator ) + return -ENODEV; + + if ( !strcmp(prop_value, cur_mediator->name) ) + return cur_mediator->tee_type; + + return -ENODEV; +} static int __init tee_init(void) {