From nobody Mon Dec 15 21:46:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1761998265; cv=pass; d=zohomail.com; s=zohoarc; b=PXOAmpO/GXKBIneMpA9bVXc+IZJfL4o+50BuowYtDSn8mEvTDZhjggL08Cr+4kFwKciJHBy5LXLcZsIVrnBKZ5K4vtbo5JpzhFvYfdTYq+55HmpkliF0ocb80sFJ/cyta0gn2j797ofY3r24MOhNdB+yvQ10k5Ita9wSEmlto70= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761998265; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ap5pNvfbZqnecfxDiQ1kPQR6h+0LuyG2cuRDI9rbD24=; b=L+qeIV8IkSrlRWAZ0kdmfo0I+2jRfLd9vEr6y7w5F8PFB2WgkEV5vrfpBDO/oWwszthScVztvr6JN2VCjsBTFbw5juPjA8FGGe4VT+T1gOXdBmsBix7JgPLuQNsbk2GAHF75bgrAV5moF2QqrnhDBL6Bvcih4b21baOKlcHnrfo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761998265003365.144344000204; Sat, 1 Nov 2025 04:57:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1154893.1484549 (Exim 4.92) (envelope-from ) id 1vFAEE-0002ci-4b; Sat, 01 Nov 2025 11:57:06 +0000 Received: by outflank-mailman (output) from mailman id 1154893.1484549; Sat, 01 Nov 2025 11:57:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vFAEE-0002cb-1a; Sat, 01 Nov 2025 11:57:06 +0000 Received: by outflank-mailman (input) for mailman id 1154893; Sat, 01 Nov 2025 11:57:04 +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 1vFAEC-0002Ar-GQ for xen-devel@lists.xenproject.org; Sat, 01 Nov 2025 11:57:04 +0000 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazlp170120005.outbound.protection.outlook.com [2a01:111:f403:c200::5]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e0ce5cc6-b719-11f0-980a-7dc792cee155; Sat, 01 Nov 2025 12:57:02 +0100 (CET) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by DBBPR03MB7130.eurprd03.prod.outlook.com (2603:10a6:10:20e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.16; Sat, 1 Nov 2025 11:56:56 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc%5]) with mapi id 15.20.9275.013; Sat, 1 Nov 2025 11:56:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: e0ce5cc6-b719-11f0-980a-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DgmJA3uAa49HE3Ve+scjSFzxgFXDeZboeCHqtZ6My4f91dxWBugrdGNyyoZ2r4B2XLNPiVi2ujbysZ9+YWjP2pZjhZvq0pgygUHV/IEorQTj4evl7OShGK8slnGk5hivZUNytwAX2Bx3yJoocpsp1gn2fWWfukG9VocgnUDxaQBqARH+CXC21rOFMA5iXSkTr3wQ3ypr/+CF74AI/9Fb0EYqHR4aGuQtu3gHvqIlghBCou6tkZHuQe6T2d7akxntdY4iRi2tZwpj6CSCq0COxyYuQlNNUOWYzGVJgVkRw2tuLL5qRUg1nWHcQhGwnTWmyGm9a49Iz2gSU8C4dlJw2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Ap5pNvfbZqnecfxDiQ1kPQR6h+0LuyG2cuRDI9rbD24=; b=vGGLGZF+DhHeiFyrH81ZlkDa2y8sOCp+DLr3dImfR9XdaRumdEJ6QsIYY/ip6p9j0XVgPYDN0lj8Wjp90C+2OfNF3CqjksVqm1/6ckGLR/TuNvN3R+vb16BC/s5HqUSnG0BAJOmgyBzSEQK1p5i1+2fKcee/aDskiQ/R1Ui/i0DM+mNVANYtX1R2EhDAWJHlh4Q39TI3RbtKdfSPnwskkGu/fumOrgw0NORJUZhbmtt4YnHgR11IdGDuev2kN9XrCvyigbS37dA14yOBhATfCSsYtvQ8Mc9BK1PyW374csxt0j2+nbxE4dmIP/okNwqCCsTqTLasCxincmQvhzxhcg== 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=Ap5pNvfbZqnecfxDiQ1kPQR6h+0LuyG2cuRDI9rbD24=; b=mAjQVZu4447JOHgdq2jMg95X+rnT9e/mGZi0zNXEDYzK0QwxgnZ/yMWtIvKaHPKK4xrvg9VX+tPkeNurSdbJPCFNgLqm4i9QD34UiZTSdg2Tj2pxeCdnMfV9ZXHSKaxJT5hRlw4Huhx06zOx1TYU4d1xlMXbv5mPVyxeY8dp4nr4GdyTbgqjFCnA2pMU3evG68spvechPxZj7JNZozCfDSL+rAohmG7xwXeUOcNUfKaVii50TzrwwxGGtzF9HDAIjeFCfJ2JkqXVO1msL4E5YzMqFSVgnuIMqG4pomMSAdiru97v1336pDIbTOK4uDziw5opiV3CF6fxG9XLNUHFPw== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko , Oleksii Moisieiev Subject: [PATCH v6 1/5] xen/domctl: extend XEN_DOMCTL_assign_device to handle not only iommu Thread-Topic: [PATCH v6 1/5] xen/domctl: extend XEN_DOMCTL_assign_device to handle not only iommu Thread-Index: AQHcSyafS16SOr0Uk0OkeRdy8jd8Cg== Date: Sat, 1 Nov 2025 11:56:56 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAVPR03MB8946:EE_|DBBPR03MB7130:EE_ x-ms-office365-filtering-correlation-id: ec32d77b-1be7-474f-876b-08de193dc187 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?zDDDDGvDmvRsu8STx5Y5Qc5dr8IWAWgWUw8n+/o2czaDi1VP9Fj1lWivTC?= =?iso-8859-1?Q?WjekNoafnE34dzslhqwURmCrryzltIhX1fv3KqPX6wTO2y8Aj5nwZMaiCW?= =?iso-8859-1?Q?TOjMt2hzvXhG4woZNC2xsxz/XygjsU+Zh62I0V6aa4Apj3C0/V9jxjPc4k?= =?iso-8859-1?Q?Se+3WH7LFKS/h5OYdZPISlcv5t2wqphbe1ggpA9ao0QO6lEtK34rRVF74q?= =?iso-8859-1?Q?KzqNdLXFliUr4PeQjUL6BLZj5Oi7m14PXTClpZ7LHMsXm6bjWbInQpvDNL?= =?iso-8859-1?Q?e1s2JCTnxPLlivfZVT9XUgFzHBhSSoFFARSbn9FUKc0KAGXtZIAf3eRCCJ?= =?iso-8859-1?Q?HN2AdKffGw4dFKoLfp5M2i44FtA2RTwCmw0ec/3NNbavMQM8oEpcfb5G4+?= =?iso-8859-1?Q?fYxLvJ8H/yoBFF3tmUjdVVBFOQgPVDWtxxMuRy4ZJq0nl3CzUcRLibf++o?= =?iso-8859-1?Q?jcYbjRuIEPXqwZQmRpoQSTXWYI8U8hdSDXZB67t99doZwV8Zp690s9TA/g?= =?iso-8859-1?Q?uaJWkd4DU3QrMevErC9wnaUzJfbm01owZkspjHqhXnoqtwh2zdZrIsCqE1?= =?iso-8859-1?Q?0uTRlgbauXRFk8gmFSM2Sk2/pGMp1E0pf4vsVq0dDc06E232ehzaunmX0n?= =?iso-8859-1?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ZjoPnsitG+7SOoalW1MELNVQd?= =?iso-8859-1?Q?4qSJ4pxqm7eHwMMildhbwIRLM+eY?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAVPR03MB8946.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(38070700021);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?3UM73ozT2ZXxVerZIzbhAYUvgKBvoIKortFJ2cZW5jWOoxGSxk7ny+oaMA?= =?iso-8859-1?Q?Kw4xS9LWFq+YUA1glNy1mq+utE1H/1gWwbPJ3MD4K3v8wWtDEsdvhcdi2C?= =?iso-8859-1?Q?hJoWKoGY3/o9DDox4EKKJe566RfdHQwA9jbdqS5HYjXgMR4QK0GyeyQQLa?= =?iso-8859-1?Q?x43ru1xqCEkEW/Zp1BacnlY4QtppHoTfy+wHvRDQ1qtGzS8u8vYcWGHgaA?= =?iso-8859-1?Q?xFLqwlTSJBK0Y0JU4XSD41e5v3OmSVGPiXfkZTeR3IkhF8c4fFVP/WknRO?= =?iso-8859-1?Q?jc0QZ3BkxOEcV3rWuWx6F+3n+6gpm0nEKpVRcIAJSd//qMGZ+vhiXqSdVc?= =?iso-8859-1?Q?5cgnaJyWO0gvugvky/vFmEm6r6VF7eTi9ejrVRjSz+BUTQ6CN5wAi8u6Be?= =?iso-8859-1?Q?Ouaj5uXD4AXGgl3omiC7YLSkVpO7Wij1G1tNc9Gj0f6gYbdv3MkoWxPF2P?= =?iso-8859-1?Q?H0p9V/VvChh1zMxo19Xb0bNRFAu+1WsA91PG1OygYtEJ/nTvlQGx2XD/hH?= =?iso-8859-1?Q?zDlMa2VzoQvYZP+EhucHka1Sjnu9PioBZjQkJC50C1TSatGOXgev8ELlKX?= =?iso-8859-1?Q?VpczCpx0GYWrzYA+HIFtrYusGoeWt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1?Q?/Q2mRiao21FDudlZxc8eHoBMTsFdM85d+muIxY5Lw2dYmCNlK7JadUYUlx?= =?iso-8859-1?Q?R3HTLbncg2yDZmgLKk4EjU1YM3KJA9QLDCaD4wu8WTgGVAlxN03sGZemHC?= =?iso-8859-1?Q?4CqZqnNy83YSmhyrrD6apK1JdjtUIBa/UUqvS5dK0qTMaBesvF6drUHw?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAVPR03MB8946.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec32d77b-1be7-474f-876b-08de193dc187 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2025 11:56:56.3165 (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: GwtNHkJbb24eWhfnwY1WIt9sUG+cWIhtzCzYig/7QyiEENpiImxaIKCAfWlTcAzUJfhOVXqiULLz3J6hMfCFJZ/ruHnQSYvp82a3R39B/d4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7130 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1761998266038158500 Content-Type: text/plain; charset="utf-8" From: Grygorii Strashko Add chained handling of assigned DT devices to support access-controller functionality through SCI framework, so DT device assign request can be passed to FW for processing and enabling VM access to requested device (for example, device power management through FW interface like SCMI). The SCI access-controller DT device processing is chained after IOMMU processing and expected to be executed for any DT device regardless of its protection by IOMMU (or if IOMMU is disabled). This allows to pass not only IOMMU protected DT device through xl.cfg:"dtdev" property for processing: dtdev =3D [ "/soc/video@e6ef0000", <- IOMMU protected device "/soc/i2c@e6508000", <- not IOMMU protected device ] The change is done in two parts: 1) update iommu_do_dt_domctl() to check for dt_device_is_protected() and not fail if DT device is not protected by IOMMU 2) add chained call to sci_do_domctl() in do_domctl() Signed-off-by: Grygorii Strashko Signed-off-by: Oleksii Moisieiev --- Changes in v6: - change iommu_do_domctl and sci_do_domctl command order and call sci_do_domctl first which will produce cleaner code path. Also dropped changing return code when iommu was disabled in iommu_do_domctl. Changes in v5: - return -EINVAL if mediator without assign_dt_device was provided - invert return code check for iommu_do_domctl in XEN_DOMCTL_assign_device domctl processing to make cleaner code - change -ENOTSUPP error code to -ENXIO in sci_do_domctl - handle -ENXIO return comde of iommu_do_domctl - leave !dt_device_is_protected check in iommu_do_dt_domctl to make code work the same way it's done in "handle_device" call while creating hwdom(dom0) and "handle_passthrough_prop" call for dom0less creation - drop return check from sci_assign_dt_device call as not needed - do not return EINVAL when addign_dt_device is not set. That is because this callback is optional and not implemented in single-agent driver xen/arch/arm/firmware/sci.c | 35 +++++++++++++++++++++++++ xen/arch/arm/include/asm/firmware/sci.h | 14 ++++++++++ xen/common/domctl.c | 26 ++++++++++++++++++ xen/drivers/passthrough/device_tree.c | 6 +++++ 4 files changed, 81 insertions(+) diff --git a/xen/arch/arm/firmware/sci.c b/xen/arch/arm/firmware/sci.c index aa93cda7f0..31a7e5c28b 100644 --- a/xen/arch/arm/firmware/sci.c +++ b/xen/arch/arm/firmware/sci.c @@ -126,6 +126,41 @@ int sci_assign_dt_device(struct domain *d, struct dt_d= evice_node *dev) return 0; } =20 +int sci_do_domctl(struct xen_domctl *domctl, struct domain *d, + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) +{ + struct dt_device_node *dev; + int ret =3D 0; + + switch ( domctl->cmd ) + { + case XEN_DOMCTL_assign_device: + ret =3D -ENXIO; + if ( domctl->u.assign_device.dev !=3D XEN_DOMCTL_DEV_DT ) + break; + + if ( !cur_mediator ) + break; + + if ( !cur_mediator->assign_dt_device ) + break; + + ret =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, + domctl->u.assign_device.u.dt.size, &de= v); + if ( ret ) + return ret; + + ret =3D sci_assign_dt_device(d, dev); + + break; + default: + /* do not fail here as call is chained with iommu handling */ + break; + } + + return ret; +} + static int __init sci_init(void) { struct dt_device_node *np; diff --git a/xen/arch/arm/include/asm/firmware/sci.h b/xen/arch/arm/include= /asm/firmware/sci.h index 3500216bc2..a2d314e627 100644 --- a/xen/arch/arm/include/asm/firmware/sci.h +++ b/xen/arch/arm/include/asm/firmware/sci.h @@ -146,6 +146,14 @@ int sci_dt_finalize(struct domain *d, void *fdt); * control" functionality. */ int sci_assign_dt_device(struct domain *d, struct dt_device_node *dev); + +/* + * SCI domctl handler + * + * Only XEN_DOMCTL_assign_device is handled for now. + */ +int sci_do_domctl(struct xen_domctl *domctl, struct domain *d, + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl); #else =20 static inline bool sci_domain_is_enabled(struct domain *d) @@ -195,6 +203,12 @@ static inline int sci_assign_dt_device(struct domain *= d, return 0; } =20 +static inline int sci_do_domctl(struct xen_domctl *domctl, struct domain *= d, + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_dom= ctl) +{ + return 0; +} + #endif /* CONFIG_ARM_SCI */ =20 #endif /* __ASM_ARM_SCI_H */ diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 954d790226..b89559ef7b 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -29,6 +29,7 @@ #include =20 #include +#include #include #include #include @@ -827,7 +828,32 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_= domctl) case XEN_DOMCTL_test_assign_device: case XEN_DOMCTL_deassign_device: case XEN_DOMCTL_get_device_group: + int ret1; + =20 + /* + * Add chained handling of assigned DT devices to support + * access-controller functionality through SCI framework, so + * DT device assign request can be passed to FW for processing and + * enabling VM access to requested device. + * The access-controller DT device processing is chained before IO= MMU + * processing preserving return code and expected to be executed f= or + * any DT device regardless if DT device is protected by IOMMU or + * not (or IOMMU is disabled). + */ + ret1 =3D sci_do_domctl(op, d, u_domctl); + ret =3D iommu_do_domctl(op, d, u_domctl); + if ( ret < 0 ) + return ret; + + /* + * If IOMMU processing was successful, check for SCI processing re= turn + * code and if it was failed then overwrite the return code to pro= pagate + * SCI failure back to caller. + */ + if ( ret1 !=3D -ENXIO ) + ret =3D ret1; + break; =20 case XEN_DOMCTL_get_paging_mempool_size: diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index f5850a2607..29a44dc773 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -379,6 +379,12 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, stru= ct domain *d, break; } =20 + if ( !dt_device_is_protected(dev) ) + { + ret =3D 0; + break; + } + ret =3D iommu_assign_dt_device(d, dev); =20 if ( ret ) --=20 2.34.1 From nobody Mon Dec 15 21:46:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1761998262; cv=pass; d=zohomail.com; s=zohoarc; b=FpRmP+AIzEky6jgT2Y8PqDLj9RIVR00Uyb3Sr5hSFa6FC7zoXWjEdoU57+MD3FSCn9LjLXucXbzUr3/lr8zrI1u6ae1bJcjy//7KCd8/HJ48UAkewCkv8fTWbn8Z+R1ZjZ1w6+8BZvqi4N/BUP1bOQmqWjk8GeZE8eVUUn2Mirk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761998262; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dUvvV+20T1UDiyfQPM2cyTTSiGchXAevlCVyA+kQh4I=; b=DQwQPHdQ/yesIiewEAMnCy347qFof0B17QY7p/IH8C/BkwU657VYdsYjPzojZBsDGwh/zLk3wSltPoThsxY8gV1CWr6sOMXAXlGrZpDuqAjodIqr1Sp2ZfvbsAoHfaf94X2GZ76qkK5H0pwLlNOPd48hvFhcwnax1j+ncSnkYf8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761998262678542.1727742633246; Sat, 1 Nov 2025 04:57:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1154894.1484555 (Exim 4.92) (envelope-from ) id 1vFAEE-0002jI-JL; Sat, 01 Nov 2025 11:57:06 +0000 Received: by outflank-mailman (output) from mailman id 1154894.1484555; Sat, 01 Nov 2025 11:57:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vFAEE-0002iE-Ev; Sat, 01 Nov 2025 11:57:06 +0000 Received: by outflank-mailman (input) for mailman id 1154894; Sat, 01 Nov 2025 11:57:05 +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 1vFAED-0002Ar-GT for xen-devel@lists.xenproject.org; Sat, 01 Nov 2025 11:57:05 +0000 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazlp170120005.outbound.protection.outlook.com [2a01:111:f403:c200::5]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e1c4a788-b719-11f0-980a-7dc792cee155; Sat, 01 Nov 2025 12:57:03 +0100 (CET) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by DBBPR03MB7130.eurprd03.prod.outlook.com (2603:10a6:10:20e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.16; Sat, 1 Nov 2025 11:56:56 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc%5]) with mapi id 15.20.9275.013; Sat, 1 Nov 2025 11:56:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: e1c4a788-b719-11f0-980a-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jri189mBFag8FhDcfy3TmD9GrO29VgCVLZcGK/R/SAQaZq7v6h+p/tCAVVYhFg7DUHiqozTwULYMfvHZT1WH+rCvtHKZlQuav9EyMwFG4gLeI3aPLOL8gjVX8CcxQ6Uh7vBRUSHPiuBbjj9xNSots7mRIS+CG3ItfhgobrLvyKwT8TlTYnQbkPi5VLRfgcTSgRq4X4H2REt0FFgnsMF5zu5ju1MFOnchEYQmv7CBVJDqBmD4XvvG85zB/OQi9ZaARvjROcI6igEcCXSKP3hRriDdu6P/BII5SY1pSpnm+ccQDl2eK6qpfiiHe8CpfbzRplceIkXaFKu5SXInWX5W4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=dUvvV+20T1UDiyfQPM2cyTTSiGchXAevlCVyA+kQh4I=; b=aRiAOFlb/f5W21MYtYnYy4+ZKhOEKfMdq0L1e6aI3Lqm9LJvTjdvdpAjOsmCdNBEybdVs506a4HhM5CCykJzdJGwlY/bTadID3x79Md6N/sVTKdiziEgoIizYGz36HDG/vASnIWDCnwFGjsYxAeKlw+rvgTRvnEW2h8M1MCD+KUokZBHCRYdMvFHLrYPUbJIFhKJgIIO4wSlxb/G1P/qB9K5ee2iNCo/jsIhDXJZ0hMPycQKLDnchm0Wsxa0CMEpbEihbtAIjT7DLslouCCPm6Mnu7Id1eiypNHZbr0rhiRp96mmf7flaX0xgIswAAgZhb8zENRD3REii2n7zilYNA== 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=dUvvV+20T1UDiyfQPM2cyTTSiGchXAevlCVyA+kQh4I=; b=NXn2fAXYsj3BOd1ntHDLhTtBYx2snRtyGaCLG804MPYZPoEHqANEoWxB4HP1NoFyXBlBM5VDJ7/KbfbpOJoPEgFPE2WSVTJ09WxJlH0vzGoECrwzpJ5KMosH6O7DVmbWsDLnANmsneNJuKEiO6v5DBC26XnifDiBzK9/8DSBLQYA8ypwgUnBnWUAR5uV6ekPP5VJgakMEn2lYyyOWA9TK2tojGS0XKTCVyEeRDL+6/Yw2HjuO5eezF6ThEmh8W0W0FyZXBGX96JKjhZy5WZEorNMPDuCvgo+4eYnDvXjpj0isQlWx/gtYOAwjQMtdE3QEvWpmlEk4VgnXeILnyr85g== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Oleksii Moisieiev Subject: [PATCH v6 2/5] xen: arm: smccc: add INVALID_PARAMETER error code Thread-Topic: [PATCH v6 2/5] xen: arm: smccc: add INVALID_PARAMETER error code Thread-Index: AQHcSyafAwJzYUogvkSNS1XBVcix4A== Date: Sat, 1 Nov 2025 11:56:56 +0000 Message-ID: <1134e144eab87f645c5c1e6e60ba26886d77044f.1761998077.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAVPR03MB8946:EE_|DBBPR03MB7130:EE_ x-ms-office365-filtering-correlation-id: b6dab78e-54f1-4b34-6335-08de193dc1d4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?HAxodcUN/SkkOY8tYQ78MpY/ussK70Se88RzR+THk/ZmJqnnMnegx8yYp9?= =?iso-8859-1?Q?a16lvJM1K9F/pnubScnVsbMfUkt/SlLobDfExGDROfIFFBopz6t2EA1Hfd?= =?iso-8859-1?Q?j7Bd1f9HAJhm4hbjDXqqRIYJTPh5WB00ewr6U+jIbdWB8Fe0tS2YLF3UBC?= =?iso-8859-1?Q?lt8QA3628TqoSdAwrrD1B3HM3eEzl4S/C8RE6Wk+hCCzGQmGu2APZCP1hd?= =?iso-8859-1?Q?dqgMispxawXimilyM4F0DzXaS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so-8859-1?Q?HV9/zyZhLevbTXxuUzxE0nMiuSd4pv4hFu0rZ5o2ee85jWpzhRerWlsBXh?= =?iso-8859-1?Q?RpcXQBlMtHI5D9v6BqWZz9oWZ2tjeCFKjiWCK34rJ8NFWdy44tObUOIDZU?= =?iso-8859-1?Q?HOMeecamUichJD8cGBam7L50+iNNWem58t30jIvBy/OUaLNoyQBekiQ7yf?= =?iso-8859-1?Q?Ja/zOz7uorYo8vFvXa3FRLKW++0ClMoeghKVI5+Ve/FfiMpRYiULV+GFXR?= =?iso-8859-1?Q?ndqfCrKsRM/4ojVnD1q9qtyb5LRfeiAXy1JpyaOxdtV2y+ASMycZsjkOBD?= =?iso-8859-1?Q?vQD0+gaP0iI/43zQCi83M6QQIrzPtVkubcXin8OenqJ2jxWXyTeVe2IZ16?= =?iso-8859-1?Q?GYoK6LoREtIdxW3SSY8b5y7KUtziqR2ITDr5yBm6sMt8xryiU2wjthTHS2?= =?iso-8859-1?Q?x8NTa+5sO8TlF0QsIkWYTcncmE+/?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAVPR03MB8946.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(38070700021);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?TGczb823Tix0x6W373DtM894ru+CnnZtNSNcPxp/O1aQpVpr/cqNS5wMem?= =?iso-8859-1?Q?Kjr5c+txxhSIyzZoIw9JrWPO2QTn2jTeHnbeTjtbrLi6iIPtiCNJvYcMB/?= =?iso-8859-1?Q?WUG9xjWt/Vu6FRv334TWUQVbcge6Jd2yKAoCzLioEKUI/QqnGXM34kYMyA?= =?iso-8859-1?Q?RwwcgWlBD/LFE0+TaOPwTKIWVLFzWRxszbfLOgQC6xHTXw0CiOn+1oKlFz?= =?iso-8859-1?Q?uBm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7AlV+myNK24?= =?iso-8859-1?Q?3AB8y/Nch1rdFRVeLo4ioJxDcyyWtF10jn6fs9107rQhWm7WiSNtEMNmsG?= =?iso-8859-1?Q?T/JMAyRwZryGrxyvFi31Wir//1jgRg+zzHz3Hiz5VRdv5uX9gxQiBr9bNz?= =?iso-8859-1?Q?pgtwMjJMJZi45q6B3nFecDVxgq+ufXYg9gLVSMxCuAk7A47+ozV66tNr17?= =?iso-8859-1?Q?boIgvojubm5HhtOKSO9OPv9kCSoTycwc+Muxv7zKUCWiD06I8ONkjHPFQO?= =?iso-8859-1?Q?Bi64GDl84sae7j3jMjUYwIuJAz8zLlKJyVfKb0ac0qHZ70tq8jtE30siGm?= =?iso-8859-1?Q?kTPtx571XWlF98GaYRqNjHPUUhiCOsn4LfSPFAmzxQLy9D/qnkkRKw/KUl?= =?iso-8859-1?Q?hKXiSbviQ1itQQSVJSWq87ZvejvAxkX0DYj2wueeWYs++ZNzjEGC3+j6At?= =?iso-8859-1?Q?8MsELrp7e4uxCQnQK5GZvH9FqB1PzEeW7TWs2kP+RCtKxTPfKyU5EhOKkb?= =?iso-8859-1?Q?LqANBUHV3WD0PJyvIVQn5wuuTYX2cVDTfwk1OFqTj/X85rAmqLLIOPmw?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAVPR03MB8946.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6dab78e-54f1-4b34-6335-08de193dc1d4 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2025 11:56:56.7960 (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: V2ucjCilb8ajYH7jROvjly4qU6nGR2i2OFe9PB+It+xjHhJ+WwCZP8subZ1x9ILS8CiQDrCKWz/tlgzmWFL2nCP3InYBDl15rl5OE76yVEE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7130 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1761998267953158500 Content-Type: text/plain; charset="utf-8" According to the "7.1 Return Codes" section of DEN0028 [1] INVALID_PARAMETER code (-3) is returned when one of the call parameters has a non-supported value. Adding this error code to the common smccc header file. [1]: https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6 Signed-off-by: Oleksii Moisieiev --- xen/arch/arm/include/asm/smccc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/arm/include/asm/smccc.h b/xen/arch/arm/include/asm/sm= ccc.h index a289c48b7f..dc6af94db1 100644 --- a/xen/arch/arm/include/asm/smccc.h +++ b/xen/arch/arm/include/asm/smccc.h @@ -381,6 +381,7 @@ void arm_smccc_1_2_smc(const struct arm_smccc_1_2_regs = *args, 0x3FFF) =20 /* SMCCC error codes */ +#define ARM_SMCCC_INVALID_PARAMETER (-3) #define ARM_SMCCC_NOT_REQUIRED (-2) #define ARM_SMCCC_ERR_UNKNOWN_FUNCTION (-1) #define ARM_SMCCC_NOT_SUPPORTED (-1) --=20 2.34.1 From nobody Mon Dec 15 21:46:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1761998255; cv=pass; d=zohomail.com; s=zohoarc; b=kSTx7sQyeVGS+TCIBMjkkhWpQCjdkEbLP1ChFAHwMrsMjIeEJ8tWTqoXdK/xo5lkLV45np2pD29FneIkEXceSBCwEq/aocHUxuAIjFTYVlgHKwTXfIqxtfURuZawUeSe6Kc9yr5XXHrMPKEYy00D+cfw59AqYBBYBaKbgxTQfos= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761998255; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cT/yEXmI45eBiggl8I8upOczw/AqEfdB0lot1gsx/GM=; b=csxR5627jiuAi8fG+Eedyv9u9NsHJQJe9F87cRPhv8hi/1bYjIgZjGyiz3H1eoUaVNzGXOVMHZa+fKWndy88RjNMDMNpVjMpeV4tTYioFNKyTxU12Fjeh8voYRk27M5g3a7E90yQWzlB7+mZLq+DKVLOdcAEL8tmw11jlsfRDJ4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761998255308757.2114980036437; Sat, 1 Nov 2025 04:57:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1154891.1484529 (Exim 4.92) (envelope-from ) id 1vFAEC-0002B9-G8; Sat, 01 Nov 2025 11:57:04 +0000 Received: by outflank-mailman (output) from mailman id 1154891.1484529; Sat, 01 Nov 2025 11:57:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vFAEC-0002B2-CT; Sat, 01 Nov 2025 11:57:04 +0000 Received: by outflank-mailman (input) for mailman id 1154891; Sat, 01 Nov 2025 11:57:03 +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 1vFAEA-0002Ar-Qi for xen-devel@lists.xenproject.org; Sat, 01 Nov 2025 11:57:03 +0000 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazlp170120005.outbound.protection.outlook.com [2a01:111:f403:c200::5]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id df81880c-b719-11f0-980a-7dc792cee155; Sat, 01 Nov 2025 12:57:00 +0100 (CET) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by DBBPR03MB7130.eurprd03.prod.outlook.com (2603:10a6:10:20e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.16; Sat, 1 Nov 2025 11:56:57 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc%5]) with mapi id 15.20.9275.013; Sat, 1 Nov 2025 11:56:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: df81880c-b719-11f0-980a-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l/DfiffdbKObjs4etChOzVJKvrCIeyB0WwYaBI9w1ZG2xQZhsudFDPWR27U2CVC8GO+y02EHA2KNg7XctyLl8qB1DPTE9cgiReyE0HL/0zMyC2g0SQ+gidmHNXCHpWUxzIWjU5Oaquk6dMgyuYKlkEfNdNwenvnGjAyp7m3BNjpuwfBAdgum/SvXLlukUMEbWViKkslPy1aK1YnyneBqx4UGJfD9dnq2cykYZh8amK1dUDZzHsNLgOnxDcQR7v36+SUui0jYb0kzhNZmSXNaokATqb2vVhPU9Ujqmb6UgcRzxPpe1eO8VXYEUud9CDNxJe629kqz+lJbhAPUtJ6LNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=cT/yEXmI45eBiggl8I8upOczw/AqEfdB0lot1gsx/GM=; b=C9YU1UFeFyW6Pm9bRw1tATjNWqvmB4IqlJtjfy1FwLIW+ESuCBesI3ZI/Ba/phKqyoDx/3jb/mgHMybQGfBNivecgydy2ElQ/o737iKcG+nBCrIScy4hfU1L6nN7nYA3eNkGGWB7AFFYXtuN9TNMSSp3UnFj336656M51F8SIRpLsMy5auxIA5bWnrztCxCJra03gC1gZ9w2tDv2o0a+Cnh8rA0qXqb4DomL80BI5a4E+sGVGmlzgDhygkZ+XaPJsPFduUmVf7xBoMtawyWL2RA/ecRMTjEHEqaKpy7asgPDrwfqc9+lrLVZyr7JoZIsEukt2tut0iKmqthWxetegg== 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=cT/yEXmI45eBiggl8I8upOczw/AqEfdB0lot1gsx/GM=; b=ekTXNkd7WjEEVhHfCcc0zaOXl+4Le3/lm4N04ACxF0gjBeRjV7jpR8fenRRuyfeemGpvm3RysvekUlCR7MYYKewKR3IbPUTgoBXTHrsQT6ZW1sNxvqKgcPsdkFMcl7L6izgejOKEVo+csP7weDse09aZsh+CchJg+Se3+J1dQtUHl1hQ+wWZvjrgkqU4Z5IT/W554psb6My49BNV+/lKFt4tkQRfzpK+UKONqT0RSf9X6t2YHU9PDL4aXpZrGvx5W73rgL5LKc7hohBkVZgyqaBdkCUXH0NGejnYJN3Cd4wuQHaF5UZdOe/jrOIFnxQ058EiqzDjuxixf8Dy9JbDsg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Oleksii Moisieiev Subject: [PATCH v6 3/5] lib/arm: Add I/O memory copy helpers Thread-Topic: [PATCH v6 3/5] lib/arm: Add I/O memory copy helpers Thread-Index: AQHcSyafwNcBoMRdYEm2n7tK7o4JtQ== Date: Sat, 1 Nov 2025 11:56:57 +0000 Message-ID: <33372689f3097b0dde1d47b81a1bb8176b35d20c.1761998077.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAVPR03MB8946:EE_|DBBPR03MB7130:EE_ x-ms-office365-filtering-correlation-id: fafdac47-cdc8-4cdd-084d-08de193dc220 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?ycyjRMQses7+NDsdmDGv0AxCz0UuFMlbivqEL73pyo5D0K3581wE2qF65s?= =?iso-8859-1?Q?7vUbiM0RS9XPaytNYfTQhhk4g9hdnzEGxYzaV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onlf3jbcGW7JHAmaGPdcgOO3t6GL4uarA1azn9NdD3Kkb3FwGdO?= =?iso-8859-1?Q?/JmAxqJiHVLowjQJxLBl70Zl1Kd768D4/DlQaDaUnfNMWAndLbksUF104w?= =?iso-8859-1?Q?xPPjV1mAL+gNVjmR4uCmITg8WBFxdHdBhpCRgwga7lFE11CE7Jdj8b6V2W?= =?iso-8859-1?Q?RSUV5sTwEi0EhsiRYqz3YnUCDujilctzScRAfhJblbiLXV/7ewrRchvfe4?= =?iso-8859-1?Q?b32Etll5x/wtN9zHlwhjI0ns2C/pH+HusUSdk0uNGVWnZKOw37QVuAEpx/?= =?iso-8859-1?Q?klNKMHYtktbj80i+I3VrIHzVG0feDpFeE/6S6ArgZefczowpO9QEyHAVGi?= =?iso-8859-1?Q?UolzfxJgLh5aLngi3TUQJanjlbgKXhOmGtP7LzfxXIg3Sbr9zYR535A0T1?= =?iso-8859-1?Q?x/Z1Xh7w5rqIrA+VtITB9F/LFekA+bWnHJVZ1jgdsYEqYHCRpfXMMXLB08?= =?iso-8859-1?Q?Ey/nhNtFrtc80UZXnTslZiY6fKFtFnQZ4wmmmOmJjLM8xK1jTCrnp/0V6F?= =?iso-8859-1?Q?6lEnUjzKMzWJmOOl6WgypfDfeYkr3oezkAUAmBpuE+lU2QZlTUJTBlVDUP?= =?iso-8859-1?Q?9XYz21JE0iwZQpE5YT7+Ltk5bCpt?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAVPR03MB8946.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(38070700021);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?MWSHB+Gy3u+21RQ8N6BPGKmQtjTL8VKzsT6S2WCPCZwxJELO1wFUyM5bwh?= =?iso-8859-1?Q?yh8dXqn8+rpkPwNuC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s6nlrKx?= =?iso-8859-1?Q?4tiRljQ7MkA/FkTZWDknkBEaD3JOLWrV8dtQQmvXzwm0p9qwUbajpO9Syr?= =?iso-8859-1?Q?iki4ELkEvCuCpfxKvyb89c/MXHZ01jhdwB89MGEXK1Hie+9g3O4rSGTwrx?= =?iso-8859-1?Q?sImjxHYPKcbIjwSjj6GF+zLX4WudLi2EtgJ9jSs3eh013XYUv0IhMZQ83c?= =?iso-8859-1?Q?a5pqB3IBpAXfIhybz0yBoR2sFqb0D0RxbvPmsm+W+EPYufgHIdbxk976ra?= =?iso-8859-1?Q?cKuOz7cg6hTx5UzcoBr15KsfJPnQHbvvMWMRkKTTzAhmO2P21E0Wlt2lIf?= =?iso-8859-1?Q?wiQOt7ZY2BdSUqzk5dsNFVhrLyrzyD2eBI1r7TjMH6mD4NBokK/iEUvsVz?= =?iso-8859-1?Q?eVI5nj9gXGW4Bz24tDyujmTu+TfuARkCTAwPLLYSzRtLE8jY848xLgT8yW?= =?iso-8859-1?Q?J/OGqQmdrZAf1kIbTel61P7SXyDYzXVlzfUBiQ1bStHqn87JEz8LUMHQJu?= =?iso-8859-1?Q?qRd/go2D2SiqB3tkFrD1pCDJg1b8BH3QAqg4q6JaneVkL50PsPzK/QM0uO?= =?iso-8859-1?Q?kX+pSdo2oM0ro6h8YqgoWts7n1sp21A6jKyr+7YuD8iwSU3JjhIHSwEFKf?= =?iso-8859-1?Q?qq3XejOjAysfiWPjXb5KSwBzQjDyV5AkG7paRvw8x32bX6r7awaZC5lDcb?= =?iso-8859-1?Q?EiPpBjf9ysFpgElR1arUjmJlaat28lChNTUuCXMC9MZqJWZigusZsatw?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAVPR03MB8946.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fafdac47-cdc8-4cdd-084d-08de193dc220 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2025 11:56:57.3554 (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: MrNyCxpbZbT2jGEB6X+8psSJ7X4yox0a8+/MGA3ZUYdkcSSXNZpDXDk2HXLkaddCxRzi+6LUGaTlbYIVISvB4TiyOwP5sD9z2jaYwlChLtI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7130 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1761998256416158500 Content-Type: text/plain; charset="utf-8" This commit introduces two helper functions, `__memcpy_fromio` and `__memcpy_toio`, to provide a robust mechanism for copying data between standard memory and memory-mapped I/O (MMIO) space for the ARM architecture. These functions are designed to handle memory transfers safely, accounting for potential address alignment issues to ensure correctness and improve performance where possible. The implementation is specific to ARM and uses relaxed I/O accessors. __memcpy_fromio: Copies a block of data from an I/O memory source to a destination in standard ("real") memory. The implementation first handles any unaligned bytes at the beginning of the source buffer individually using byte-wise reads. It then copies the bulk of the data using 32-bit reads for efficiency, and finally processes any remaining bytes at the end of the buffer. __memcpy_toio: Copies a block of data from standard memory to a destination in I/O memory space. It follows a similar strategy, handling any initial unaligned portion of the destination buffer byte-by-byte before using more efficient 32-bit writes for the main, aligned part of the transfer. Any trailing bytes are also handled individually. The double underscore (__) prefix follows the Linux kernel convention for low-level or "raw" implementation functions that: 1. Indicate internal/low-level implementation: The __ prefix signals that t= hese are the actual implementation functions, not wrapper macros or inline he= lpers. On x86, memcpy_fromio/memcpy_toio are simply #defined as memcpy (see xen/arch/x86/dmi_scan.c), but on ARM they require special handling. 2. Architecture-specific behavior: Unlike x86 where IO memory can be access= ed like regular memory, ARM requires specific IO accessor functions (readl_= relaxed, writel_relaxed, etc.) to ensure proper memory barriers and hardware sema= ntics. 3. Prevent accidental misuse: The __ prefix warns developers that these fun= ctions: - Have specific alignment and ordering requirements - Must not be confused with regular memcpy() - Are meant for IO memory regions only (marked with __iomem) 4. Consistent with Linux kernel style: This naming convention is inherited = from the Linux kernel's ARM implementation (see linux/arch/arm/include/asm/io= .h), maintaining compatibility and familiarity for developers working across = both codebases. Signed-off-by: Oleksii Moisieiev --- Changes in v6: - sorted objs in Makefile alhabetically - added newline at the end of Makefile - used uint{N}_t intead of u{N} - add comment about why 32 bit IO operations were used - updated cast opertaions to avoid dropping constness which is wrong - move function definitions to generic place so the could be reused by other arch - add SPDX tag to io.c Changes in v5: - move memcpy_toio/fromio to the generic place xen/include/xen/lib/io.h | 83 +++++++++++++++++++++++++++++++ xen/lib/Makefile | 1 + xen/lib/arm/Makefile | 1 + xen/lib/arm/io.c | 102 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 xen/include/xen/lib/io.h create mode 100644 xen/lib/arm/Makefile create mode 100644 xen/lib/arm/io.c diff --git a/xen/include/xen/lib/io.h b/xen/include/xen/lib/io.h new file mode 100644 index 0000000000..16758691b8 --- /dev/null +++ b/xen/include/xen/lib/io.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Generic I/O memory copy function prototypes. + * + * These functions provide low-level implementation for copying data betwe= en + * regular memory and I/O memory regions. Each architecture must provide i= ts + * own implementation based on the specific requirements of the architectu= re's + * memory model and I/O access patterns. + * + * Architecture-specific implementations: + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Each architecture should implement these functions in xen/lib//io= .c + * based on their hardware requirements: + * + * - ARM/ARM64: Requires special I/O accessors (readl_relaxed, writel_rela= xed) + * with proper memory barriers and alignment handling. + * See xen/lib/arm/io.c for implementation. + * + * - x86/x86_64: I/O memory is directly accessible, so typically uses: + * #define memcpy_fromio memcpy + * #define memcpy_toio memcpy + * See xen/arch/x86/dmi_scan.c for example usage. + * + * - Other architectures (RISC-V, PowerPC, MIPS, etc.): Should provide the= ir + * own implementations following the function signatures defined below. + * + * Naming Convention: + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * The double underscore (__) prefix indicates these are low-level "raw" + * implementation functions, following the Linux kernel convention for + * architecture-specific primitives. This warns developers that these + * functions have specific requirements and should not be confused with + * regular memcpy(). + */ + +#ifndef _XEN_LIB_IO_H +#define _XEN_LIB_IO_H + +#include + +/* + * __memcpy_fromio - Copy data from I/O memory space to regular memory + * @to: Destination buffer in regular memory + * @from: Source address in I/O memory space (must be marked __iomem) + * @count: Number of bytes to copy + * + * This function handles copying from memory-mapped I/O regions using + * architecture-appropriate I/O accessor functions. It ensures proper: + * - Memory ordering and barriers + * - Alignment requirements + * - Hardware-specific access semantics + * + * Each architecture provides its own implementation that may: + * - Use special I/O accessor functions (ARM: readl_relaxed, readb_relaxed) + * - Implement alignment handling for devices requiring specific access si= zes + * - Add memory barriers to ensure ordering with other I/O operations + * - Or simply map to memcpy() if the architecture allows direct I/O access + */ +extern void __memcpy_fromio(void *to, const volatile void __iomem *from, + size_t count); + +/* + * __memcpy_toio - Copy data from regular memory to I/O memory space + * @to: Destination address in I/O memory space (must be marked __iomem) + * @from: Source buffer in regular memory + * @count: Number of bytes to copy + * + * This function handles copying to memory-mapped I/O regions using + * architecture-appropriate I/O accessor functions. It ensures proper: + * - Memory ordering and barriers + * - Alignment requirements + * - Hardware-specific access semantics + * + * Each architecture provides its own implementation that may: + * - Use special I/O accessor functions (ARM: writel_relaxed, writeb_relax= ed) + * - Implement alignment handling for devices requiring specific access si= zes + * - Add memory barriers to ensure ordering with other I/O operations + * - Or simply map to memcpy() if the architecture allows direct I/O access + */ +extern void __memcpy_toio(volatile void __iomem *to, const void *from, + size_t count); + +#endif /* _XEN_LIB_IO_H */ diff --git a/xen/lib/Makefile b/xen/lib/Makefile index 5ccb1e5241..6bb0491d89 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -1,3 +1,4 @@ +obj-$(CONFIG_ARM) +=3D arm/ obj-$(CONFIG_X86) +=3D x86/ =20 lib-y +=3D bsearch.o diff --git a/xen/lib/arm/Makefile b/xen/lib/arm/Makefile new file mode 100644 index 0000000000..8a7b6cfd59 --- /dev/null +++ b/xen/lib/arm/Makefile @@ -0,0 +1 @@ +obj-y +=3D io.o diff --git a/xen/lib/arm/io.c b/xen/lib/arm/io.c new file mode 100644 index 0000000000..fbce204775 --- /dev/null +++ b/xen/lib/arm/io.c @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include +#include + +/* + * These functions use 32-bit (uint32_t) IO operations rather than 64-bit = for + * the following reasons: + * + * 1. ARM32/ARM64 compatibility: On ARM32, there is no atomic 64-bit IO ac= cessor + * (readq_relaxed). Only readq_relaxed_non_atomic() exists, which inter= nally + * performs two separate 32-bit reads. Using it would not provide any + * performance benefit and could introduce ordering issues. + * + * 2. Hardware compatibility: Many IO devices only support 32-bit aligned = accesses. + * 64-bit accesses might not be supported or could cause bus errors on = some + * hardware. + * + * 3. Simplicity: Using 32-bit operations keeps the code simple, maintaina= ble, + * and consistent across both ARM32 and ARM64 architectures without + * architecture-specific conditionals. + * + * The performance difference between 32-bit and 64-bit operations in this + * context is negligible compared to the IO access latency itself. + */ + +/* + * memcpy_fromio - Copy data from IO memory space to "real" memory space. + * @to: Where to copy to + * @from: Where to copy from + * @count: The size of the area. + */ +void __memcpy_fromio(void *to, const volatile void __iomem *from, + size_t count) +{ + while ( count && !IS_ALIGNED((unsigned long)from, 4) ) + { + *(uint8_t *)to =3D readb_relaxed(from); + from++; + to++; + count--; + } + + while ( count >=3D 4 ) + { + *(uint32_t *)to =3D readl_relaxed(from); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + while ( count ) + { + *(uint8_t *)to =3D readb_relaxed(from); + from++; + to++; + count--; + } +} + +/* + * memcpy_toio - Copy data from "real" memory space to IO memory space. + * @to: Where to copy to + * @from: Where to copy from + * @count: The size of the area. + */ +void __memcpy_toio(volatile void __iomem *to, const void *from, + size_t count) +{ + while ( count && !IS_ALIGNED((unsigned long)to, 4) ) + { + writeb_relaxed(*(const uint8_t *)from, to); + from++; + to++; + count--; + } + + while ( count >=3D 4 ) + { + writel_relaxed(*(const uint32_t *)from, to); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + while ( count ) + { + writeb_relaxed(*(const uint8_t *)from, to); + from++; + to++; + count--; + } +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: t + * End: + */ --=20 2.34.1 From nobody Mon Dec 15 21:46:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1761998252; cv=pass; d=zohomail.com; s=zohoarc; b=XMCf7FVNkLf0/ZQG8zVUCN/f9y0bGAh7VP75euEY3wZODEfPx/4/yTLseFi+KN0yyI73oprNhbFj1pZcmMdxHnkK1d795XmgeplKaoZGSzgD3FUMYiP5W0WJoaBDIfjWCf00b1UoQRyr0OIuGJAUikgOzvhT3lykZzLJFwHPy3s= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761998252; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WJhgedX0Vpjmv8NLnFLtcyoAuFv8Q79conSP7vqx7l0=; b=FLgokZRx4/USi3jd1hBa48wjMfz4/nLrEx/tU9MKIDTHZafcN04hHPqbKsnWQhuRJTxEyDTITMfbhUorbym+qU/Q2A1toTdWv1/UyfmLbHneawU1VLOYNV8zblxGbQlDpgmOCw2fe7Dce3xxh0BrJ0VBgr+FnKF42sOqhljSGUI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761998252536761.3104767039383; Sat, 1 Nov 2025 04:57:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1154895.1484569 (Exim 4.92) (envelope-from ) id 1vFAEH-00037I-TN; Sat, 01 Nov 2025 11:57:09 +0000 Received: by outflank-mailman (output) from mailman id 1154895.1484569; Sat, 01 Nov 2025 11:57:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vFAEH-000379-Oa; Sat, 01 Nov 2025 11:57:09 +0000 Received: by outflank-mailman (input) for mailman id 1154895; Sat, 01 Nov 2025 11:57:08 +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 1vFAEG-0002Ar-8Z for xen-devel@lists.xenproject.org; Sat, 01 Nov 2025 11:57:08 +0000 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazlp170120005.outbound.protection.outlook.com [2a01:111:f403:c200::5]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e29c865f-b719-11f0-980a-7dc792cee155; Sat, 01 Nov 2025 12:57:05 +0100 (CET) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by DBBPR03MB7130.eurprd03.prod.outlook.com (2603:10a6:10:20e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.16; Sat, 1 Nov 2025 11:56:58 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc%5]) with mapi id 15.20.9275.013; Sat, 1 Nov 2025 11:56:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: e29c865f-b719-11f0-980a-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VW7JX/eqMNkukstvC1yJm4dJ9FdWthITT2XruADUOr0CAbU1KfoR2sMwwXC189DdILq/vwAHwK9ysqWot2l1mhmMXYwmo9dgN3wsgaN/4jZvcfU8hdjWiUpSSxoa2P3hq5U19lim5ggdFHYF7Ihl6mISp5FakG++7JB1TMgpgBT+NGk3p9ppdcTMonMXnPf7KupmvWiCdApLfCyumnJR1QZSB+RbtnlEEjpYJ788ii4tZxsajI9ci5s3LLxAFjD4FteOHFI5WVjcW/Z0gqY6zFW0p8GJ8oaMUdaek+34xZRuJOnRltx4y9F541n1aOSTL93wMiewtEv37nsc81jU1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=WJhgedX0Vpjmv8NLnFLtcyoAuFv8Q79conSP7vqx7l0=; b=Tl7n8WDFs/IMaqyoGwkz4w3yg+VY20KNAqf5uC/+/AQ9FbE/uY37XrVzCRDcWU4W3YPzzFy7tDsO3FJwwxYAo6UXzqAb5ERrZn2rSM8lGDbmvt6a5lSRHlqkrehL17kx05nYDnsa4NkQvHPrbcfUHwfIaYcJc87/qTaJVVlPGs2Y+XGdUsnmbBTsoOXnluPODH0Q4AEzpBRBtxV7q6gIjJ8BQb0k7VhHr0QQKy9RLaDJ2CnDaM0jNX1awZCvu3KkahOH29a6L44IOe2XG8GWAgUD0RRmjkccDvC/79hB5oVz4GeD1eH8/jLrXWseL8KXnAo14/x6vfMV7dWCShIOnA== 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=WJhgedX0Vpjmv8NLnFLtcyoAuFv8Q79conSP7vqx7l0=; b=EV5wKlXbSvBNrLVdVXZCGyRlThJblrPaEC9eGYVe2P5MYj63Kqt76E5CeR7iQiYFBcRIPJPLk7R/ZlWbmm7VjelzoyVgwM4CpNxoKB22j/mvfzr5O3pBTIhrnCQEBACqwD0FWbg6DeVLO9onPWZkLdyDANmiNs72kAJVxdzBf5BcSMsQ4lV0Wl7wDbJusVQt3dDqCbCvJKxSzRDyAV1J+09rTsX7VNOCnHPLb/+rTZFhINEht0NdHin774sbLAZ5n17uQU/Sy+TDZT0BUkw9sIluSIhd2V2pF2tHmeXnqCShoWqze307BxJaZL3cjc7P9gigLs75tplZt225crpouw== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Oleksii Moisieiev , Grygorii Strashko Subject: [PATCH v6 4/5] xen/arm: scmi: introduce SCI SCMI SMC multi-agent driver Thread-Topic: [PATCH v6 4/5] xen/arm: scmi: introduce SCI SCMI SMC multi-agent driver Thread-Index: AQHcSyafF7w2yrI9QUiIBj5xG1SGAQ== Date: Sat, 1 Nov 2025 11:56:57 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAVPR03MB8946:EE_|DBBPR03MB7130:EE_ x-ms-office365-filtering-correlation-id: 923cdd2a-73f9-4477-df8d-08de193dc275 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?q8FSVuF7EZ+hey9qaZKsmhHqOYvdfE04EgbW470v9BE30zIyIeZLQFawrL?= =?iso-8859-1?Q?W6N7WyYuifF79I7f054aLs5d8KrcAfdAcP+Lhb77xkOQwim/bFfPT7o0Yg?= =?iso-8859-1?Q?VNshvRxUZsf0L9YAS07O1zfPK2iWUZBOzfTT4VvOZeNHWIKEBLF94Af+fz?= =?iso-8859-1?Q?mArsD5zMp+YlOB8FHBj9mYRSPGJikBrZVMkTv++i6MEmo8bWLSJY/5YNnX?= =?iso-8859-1?Q?JZZiLxqQcaWPSvY7io05l/aK8UPYl/1BfJ1nzBmn1ST+sBlYULbFVuAhDl?= =?iso-8859-1?Q?MYlKHAhwKwfBHQBPt9YTvKPi4KRj8ZX+E5efz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fBbw6q2wrX54rNQtF7lbguwMnazoUqLwBzkA0g2LxqIavRG3NU+LitBK?= =?iso-8859-1?Q?ySAzUulGkx8j14/Zb2u47Rl6BA/LWwdPgA6zACXV68+aOYQhX10l/dGEPj?= =?iso-8859-1?Q?4sMfjgF47ZuN9aIamgQYqh0/Mp3iAHcR8G/I3Fmo2r1r+6apZEY6xm7Dtq?= =?iso-8859-1?Q?V+mRQkjnG0AgDOHe/MwaQDoWIs8Y4XzmXl4dAZVa/Z87GQo8FpztQKV5DC?= =?iso-8859-1?Q?KwYEB/rR0zDY3MQRmO1c9Cw7yz41l1L+EdVBXWfqdXeNKkLghehpcLbT2R?= =?iso-8859-1?Q?kGS2x394XLJwPhGTVrVCiRzJ8KFrX+Pa6UsE/HhHZbiwr8b05djRXN69dq?= =?iso-8859-1?Q?nbp5XNWIP1Jnuun6/1qUTYcfpya3?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAVPR03MB8946.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(38070700021);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?3fphoX39BAfJhq+lRjyrYtISAZMZmlXyvUwvEB4Y36/NVZ0+8+VLpxh26i?= =?iso-8859-1?Q?eWlk2LU5kn7HTX9Cms7wi3z6UUCdq09R5qTPRrVU9zQYyR6L2deM3nkYbF?= =?iso-8859-1?Q?QwnjX7Z9KRaSINbeYQ3v1rH2m0uLKBt/bsKteLmFe2u74ZvBQDENx8gNdm?= =?iso-8859-1?Q?BEaMiRxvk0pGVcBg0wYo3S07L4MZRffqwGySsjwoS6ppKDxP9MtpwBFmZm?= =?iso-8859-1?Q?ZVFUV5fV/GhRXN7eZRsNMcIpL33Z51qYJoWusPgd8nZnri18Ve4O8hLRha?= =?iso-8859-1?Q?IT5px3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= =?iso-8859-1?Q?feV74Dox3oA/85hKLZPa0IGlq+Yl77Ha9HN9uC+WL2i9xArUHB4uaqtOme?= =?iso-8859-1?Q?rweX9B91qvXrIYDPntVhf9mZI+aVoiXMgmuxxE5PJpBtI1u1rETsuRPpjT?= =?iso-8859-1?Q?DNjErEbCKqQGzvSWpTCEvdsp3orDRjCv3a+hKqd3GtWJU67VbJJktfbCBa?= =?iso-8859-1?Q?b5OtfCTpnvOkIDM4umyuZiGQ9M4lRCgFASHU0FZgQGN+mXqrqJOWItC9A6?= =?iso-8859-1?Q?WGgfVOOg+wM2otQzmLwIvQIp9da9/GwmAcroRuSxuQjgZQf3ZH65R/UIAR?= =?iso-8859-1?Q?oIifWizq2mO5lZEj0+M4UxiccyIBGv/m59CLu9MSZt9vf0C7oJYIc+jLqM?= =?iso-8859-1?Q?aOf7N4aFkf+NXme7THPv0kQKGpZ5gFrbau/HgTKv5CGCfKdfTkGT8f/Hmr?= =?iso-8859-1?Q?UWj5aT2YhgCx1ybj//rzWG91gnT1GY8RuGtp61DKUT5Jo9xFzNXCU86w?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAVPR03MB8946.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 923cdd2a-73f9-4477-df8d-08de193dc275 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2025 11:56:57.9276 (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: sQTTJZ+91M+HdaKztKdUKBG/uR4gb/W0Cl/PE2s1LFnVdAEu5yt7t7xvlaZPExJTNn1Lx4GViuRnBsAucxFzr6s1M7/CM6gHdTNl1oNGF9k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7130 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1761998255251154100 Content-Type: text/plain; charset="utf-8" This patch introduces SCI driver to support for ARM EL3 Trusted Firmware-A (TF-A) which provides SCMI interface with multi-agent support, as shown below. +-----------------------------------------+ | | | EL3 TF-A SCMI | +-------+--+-------+--+-------+--+-------++ |shmem1 | |shmem0 | |shmem2 | |shmemX | +-----+-+ +---+---+ +--+----+ +---+---+ smc-id1 | | | | agent1 | | | | +-----v--------+---------+-----------+----+ | | | | | | | | | | +--------------+---------+-----------+----+ smc-id0 | smc-id2| smc-idX| agent0 | agent2 | agentX | | | | +----v---+ +--v-----+ +--v-----+ | | | | | | | Dom0 | | Dom1 | | DomX | | | | | | | | | | | | | +--------+ +--------+ +--------+ The EL3 SCMI multi-agent firmware is expected to provide SCMI SMC shared memory transport for every Agent in the system. The SCMI Agent transport channel defined by pair: - smc-id: SMC id used for Doorbell - shmem: shared memory for messages transfer, Xen page aligned. Shared memort is mapped with the following flags: MT_DEVICE_nGnRE. The follwoing SCMI Agents are expected to be defined by SCMI FW to enable S= CMI multi-agent functionality under Xen: - Xen management agent: trusted agents that accesses to the Base Protocol commands to configure agent specific permissions - OSPM VM agents: non-trusted agent, one for each Guest domain which is allowed direct HW access. At least one OSPM VM agent has to be provided by FW if HW is handled only by Dom0 or Driver Domain. The EL3 SCMI FW is expected to implement following Base protocol messages: - BASE_DISCOVER_AGENT (optional if agent_id was provided) - BASE_RESET_AGENT_CONFIGURATION (optional) - BASE_SET_DEVICE_PERMISSIONS (optional) The SCI SCMI SMC multi-agent driver implements following functionality: - The driver is initialized based on the ``xen,config`` node under ``chosen= `` (only one SCMI interface is supported), which describes the Xen management agent SCMI interface. scmi_shm_1: sram@47ff1000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x47ff1000 0x0 0x1000>; }; scmi_xen: scmi { compatible =3D "arm,scmi-smc"; arm,smc-id =3D <0x82000003>; <--- Xen management agent smc-id #address-cells =3D < 1>; #size-cells =3D < 0>; #access-controller-cells =3D < 1>; shmem =3D <&scmi_shm_1>; <--- Xen management agent shmem }; - The driver obtains Xen specific SCMI Agent's configuration from the Host = DT, probes Agents and builds SCMI Agents list. The Agents configuration is taken from "scmi-sec= ondary-agents" property where first item is "arm,smc-id", second - "arm,scmi-shmem" phan= dle and third is optional "agent_id": chosen { ranges; xen,config { ranges; scmi-secondary-agents =3D < 0x82000003 &scmi_shm_0 0 0x82000004 &scmi_shm_2 2 0x82000005 &scmi_shm_3 3 0x82000006 &scmi_shm_4 4>; #scmi-secondary-agents-cells =3D <3>; <--- optional, default 3 scmi_shm_0 : sram@47ff0000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x47ff0000 0x0 0x1000>; }; scmi_shm_2: sram@47ff2000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x47ff2000 0x0 0x1000>; }; scmi_shm_3: sram@47ff3000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x47ff3000 0x0 0x1000>; }; scmi_shm_4: sram@47ff4000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x47ff4000 0x0 0x1000>; }; // Xen SCMI management channel scmi_shm_1: sram@47ff1000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x47ff1000 0x0 0x1000>; }; scmi_xen: scmi { compatible =3D "arm,scmi-smc"; arm,smc-id =3D <0x82000002>; <--- Xen management agent smc-id #address-cells =3D < 1>; #size-cells =3D < 0>; #access-controller-cells =3D < 1>; shmem =3D <&scmi_shm_1>; <--- Xen management agent shmem }; }; }; /{ // Host SCMI OSPM channel - provided to the Dom0 as is if SCMI enabled = for it scmi_shm: sram@47ff0000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x47ff0000 0x0 0x1000>; }; firmware { scmi: scmi { compatible =3D "arm,scmi-smc"; arm,smc-id =3D <0x82000002>; <--- Host OSPM agent smc-id #address-cells =3D < 1>; #size-cells =3D < 0>; shmem =3D <&scmi_shm>; <--- Host OSPM agent shmem protocol@X{ }; }; }; }; This approach allows defining multiple SCMI Agents by adding Xen-specific p= roperties under the ``/chosen`` node to the Host Device Tree, leaving the main part unchang= ed. The Host DT SCMI channel will be passed to Dom0. The Xen management agent is described as a ``scmi_xen`` node under the ``/c= hosen`` node, which is used by Xen to control other SCMI Agents in the system. All secondary agents' configurations are provided in the ``scmi-secondary-a= gents`` property with an optional ``agent_id`` field. The ``agent_id`` from the ``scmi-secondary-agents`` property is used to ide= ntify the agent in the system and can be omitted by setting ``#scmi-secondary-agents-cells =3D <2>= ``, so the Secondary Agents configuration will look like this: chosen { xen,config { scmi-secondary-agents =3D < 0x82000003 &scmi_shm_0 0x82000004 &scmi_shm_2 0x82000005 &scmi_shm_3 0x82000006 &scmi_shm_4>; #scmi-secondary-agents-cells =3D <2>; }; } In this case, Xen will use the ``SCMI_BASE_DISCOVER_AGENT`` call to discove= r the ``agent_id`` for each secondary agent. Providing the ``agent_id`` in the ``scmi-secondar= y-agents`` property allows skipping the discovery call, which is useful when the secondary agen= t's shared memory is not accessible by Xen or when boot time is important because it allows skip= ping the agent discovery procedure. Note that Xen is the only one entry in the system which need to know about SCMI multi-agent support. - It implements the SCI subsystem interface required for configuring and enabling SCMI functionality for Dom0/hwdom and Guest domains. To enable SCMI functionality for domain it has to be configured with unique supported SCMI Agent_id and use corresponding SCMI SMC shared memory transport [smc-id, shmem] defined for this SCMI Agent_id. - Once Xen domain is configured it can communicate with EL3 SCMI FW: -- zero-copy, the guest domain puts SCMI message in shmem; -- the guest triggers SMC exception with smc-id (doorbell); -- the Xen driver catches exception, do checks and synchronously forwards it to EL3 FW. - the Xen driver sends BASE_RESET_AGENT_CONFIGURATION message to Xen management agent channel on domain destroy event. This allows to reset resources used by domain and so implement use-case like domain reboot. Dom0 Enable SCMI SMC: - pass dom0_scmi_agent_id=3D in Xen command line. if not provided SCMI will be disabled for Dom0 and all SCMI nodes removed from Dom0 DT. The driver updates Dom0 DT SCMI node "arm,smc-id" value and fix up shmem node according to assigned agent_id. Guest domains enable SCMI SMC: - xl.cfg: add configuration option as below arm_sci =3D "type=3Dscmi_smc_multiagent,agent_id=3D2" - xl.cfg: enable access to the "arm,scmi-shmem" which should correspond as= signed agent_id for the domain, for example: iomem =3D [ "47ff2,1@22001", ] - DT: add SCMI nodes to the Driver domain partial device tree as in the below example. The "arm,smc-id" should correspond assigned agent_id for th= e domain: passthrough { scmi_shm_0: sram@22001000 { compatible =3D "arm,scmi-shmem"; reg =3D <0x0 0x22001000 0x0 0x1000>; }; firmware { compatible =3D "simple-bus"; scmi: scmi { compatible =3D "arm,scmi-smc"; arm,smc-id =3D <0x82000004>; shmem =3D <&scmi_shm_0>; ... } } } SCMI "4.2.1.1 Device specific access control" The XEN SCI SCMI SMC multi-agent driver performs "access-controller" provid= er function in case EL3 SCMI FW implements SCMI "4.2.1.1 Device specific access control= " and provides the BASE_SET_DEVICE_PERMISSIONS command to configure the devices that an agents= have access to. The DT SCMI node should "#access-controller-cells=3D<1>" property and DT de= vices should be bound to the Xen SCMI. &i2c1 { access-controllers =3D <&scmi 0>; }; The Dom0 and dom0less domains DT devices will be processed automatically th= rough sci_assign_dt_device() call, but to assign SCMI devices from toolstack the = xl.cfg:"dtdev" property shall be used: dtdev =3D [ "/soc/i2c@e6508000", ] xl.cfg:dtdev will contain all nodes which are under SCMI management (not on= ly those which are behind IOMMU). [1] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/= tree/Documentation/devicetree/bindings/firmware/arm,scmi.yaml [2] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/= tree/Documentation/devicetree/bindings/access-controllers/access-controller= s.yaml Signed-off-by: Grygorii Strashko Signed-off-by: Oleksii Moisieiev --- Changes in v6: - updated scmi-shmem to use io.h from generic location - update scmi_agent_id parameter to be provided inside dom0=3D parameter list and have the following format "dom0=3Dsci-agent-id=3D0" This change was done as a response for Stefano comment and requires a lot of code changes, but produces much cleaner solution that's why I've added it to the code. - fix file comments and return codes - fix lenght checks in shmem_{get,put}_message to use offsetof - remove len member from scmi_channel structure as it is not used - set scmi-secondary-agents property to be mandatory since if no secondary agents were provided then there is no sence to enable scmi when no secondary agents are populated to the Domains - update documentation in booting.txt, added xen_scmi node to the example - adjust d->arch.sci_enabled value in scmi_domain_destroy - fix lock management in smc_create_channel call - avoid extra map_channel_memory command for Xen management channel because collect_agent_id call unmaps memory if DOMID_XEN is not set. So for Xen management channel we can init domain_id ad DOMID_XEN before calling collect_agent_id so memory shouldn't be unmapped. Changes in v5: - fix device-tree example format in booting.txt, added ";" after "}". - update define in scmi-proto.h - update define in scmi-shmem.h file - scmi_assign_device - do not ignore -EOPNOTSUPP return code of the do_smc_xfer - remove overwriting agent_channel->agent_id after SCMI_BASE_DISCOVER_AGENT call - add multi-agent files to the MAINTAINERS - add SCMI multi-agent description to the SUPPORT.md - handle ARM_SMCCC_INVALID_PARAMETER return code and return -EINVAL for smc call - updated collect_agents function. Set agent_id parameter as optional in scmi-secondary-agents device-tree property - introduce "#scmi-secondary-agents-cells" parameter to set if agent_id was provided - reanme xen,scmi-secondary-agents property to scmi-secondary-agents - move memcpu_toio/fromio for the generic place - update Xen to get management channel from /chosen/xen,config node - get hypervisor channnel from node instead of using hardcoded - update handling scmi and shmem nodes for the domain - Set multi-agent driver to support only Arm64 Changes in v4: - toolstack comments from Anthony PERARD - added dom0less support - added doc for "xen,scmi-secondary-agents" MAINTAINERS | 4 + SUPPORT.md | 11 + docs/man/xl.cfg.5.pod.in | 13 + docs/misc/arm/device-tree/booting.txt | 103 +++ docs/misc/xen-command-line.pandoc | 19 +- tools/libs/light/libxl_arm.c | 4 + tools/libs/light/libxl_types.idl | 4 +- tools/xl/xl_parse.c | 12 + xen/arch/arm/dom0less-build.c | 11 + xen/arch/arm/domain_build.c | 26 +- xen/arch/arm/firmware/Kconfig | 12 + xen/arch/arm/firmware/Makefile | 1 + xen/arch/arm/firmware/scmi-proto.h | 164 ++++ xen/arch/arm/firmware/scmi-shmem.c | 115 +++ xen/arch/arm/firmware/scmi-shmem.h | 45 ++ xen/arch/arm/firmware/scmi-smc-multiagent.c | 794 ++++++++++++++++++++ xen/include/public/arch-arm.h | 3 + 17 files changed, 1338 insertions(+), 3 deletions(-) create mode 100644 xen/arch/arm/firmware/scmi-proto.h create mode 100644 xen/arch/arm/firmware/scmi-shmem.c create mode 100644 xen/arch/arm/firmware/scmi-shmem.h create mode 100644 xen/arch/arm/firmware/scmi-smc-multiagent.c diff --git a/MAINTAINERS b/MAINTAINERS index ecd3f40df8..4ad1d818a6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -532,6 +532,10 @@ R: Oleksii Moisieiev S: Supported F: xen/arch/arm/firmware/sci.c F: xen/arch/arm/include/asm/firmware/sci.h +F: xen/arch/arm/firmware/scmi-smc-multiagent.c +F: xen/arch/arm/firmware/scmi-shmem.c +F: xen/arch/arm/firmware/scmi-shmem.h +F: xen/arch/arm/firmware/scmi-proto.h =20 SEABIOS UPSTREAM M: Wei Liu diff --git a/SUPPORT.md b/SUPPORT.md index 491f9ecd1b..7c8951d67b 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -956,6 +956,17 @@ by hwdom. Some platforms use SCMI for access to system= -level resources. =20 Status: Supported =20 +### Arm: SCMI SMC multi-agent support + +Enable support for the multi-agent configuration of the EL3 Firmware, which +allows Xen to provide an SCMI interface to the Domains. +Xen manages access permissions to the HW resources and provides an SCMI in= terface +to the Domains. Each Domain is represented as a separate Agent, which can +communicate with EL3 Firmware using a dedicated shared memory region, and +notifications are passed through by Xen. + + Status, ARM64: Tech Preview + ### ARM: Guest PSCI support =20 Emulated PSCI interface exposed to guests. We support all mandatory diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index ad1553c5e9..4fc3e12939 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -3156,8 +3156,21 @@ single SCMI OSPM agent support. Should be used together with B Xen command line option. =20 +=3Ditem B + +Enables ARM SCMI SMC multi-agent support for the guest by enabling SCMI ov= er +SMC calls forwarding from domain to the EL3 firmware (like Trusted Firmwar= e-A) +with a multi SCMI OSPM agent support. The SCMI B should be +specified for the guest. + =3Dback =20 +=3Ditem B + +Specifies a non-zero ARM SCI agent id for the guest. This option is mandat= ory +if the SCMI SMC support is enabled for the guest. The agent ids of domains +existing on a single host must be unique and in the range [1..255]. + =3Dback =20 =3Dback diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index 977b428608..6fd7e4a16b 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -322,6 +322,20 @@ with the following properties: Should be used together with scmi-smc-passthrough Xen command line option. =20 + - "scmi_smc_multiagent" + + Enables ARM SCMI SMC multi-agent support for the guest by enabling SCM= I over + SMC calls forwarding from domain to the EL3 firmware (like ARM + Trusted Firmware-A) with a multi SCMI OSPM agent support. + The SCMI agent_id should be specified for the guest with "xen,sci-agen= t-id" + property. + +- "xen,sci-agent-id" + + Specifies ARM SCMI agent id for the guest. This option is mandatory if= the + SCMI SMC "scmi_smc_multiagent" support is enabled for the guest. The a= gent ids + of guest must be unique and in the range [0..255]. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. =20 @@ -824,3 +838,92 @@ The automatically allocated static shared memory will = get mapped at 0x80000000 in DomU1 guest physical address space, and at 0x90000000 in Dom= U2 guest physical address space. DomU1 is explicitly defined as the owner dom= ain, and DomU2 is the borrower domain. + +SCMI SMC multi-agent support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + +For enabling the ARM SCMI SMC multi-agent support (enabled by CONFIG_SCMI_= SMC_MA) +the Xen specific SCMI Agent's configuration shall be provided in the Host = DT +according to the SCMI compliant EL3 Firmware specification with +ARM SMC/HVC transport using property "scmi-secondary-agents" placed in "xe= n,config" +node under "chosen" node: + +- scmi-secondary-agents + + Defines a set of SCMI agents configuration supported by SCMI EL3 FW and + available for Xen. Each Agent defined as triple consisting of: + SMC/HVC function_id assigned for the agent transport ("arm,smc-id"), + phandle to SCMI SHM assigned for the agent transport ("arm,scmi-shmem"= ), + SCMI agent_id (optional) if not set - Xen will determine Agent ID for + each provided channel using BASE_DISCOVER_AGENT message. + +As an example: + +/{ +chosen { + xen,config { + scmi_shm_0 : sram@47ff0000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff0000 0x0 0x1000>; + }; + // Xen SCMI management channel + scmi_shm_1: sram@47ff1000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff1000 0x0 0x1000>; + }; + scmi_shm_2: sram@47ff2000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff2000 0x0 0x1000>; + }; + scmi_shm_3: sram@47ff3000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff3000 0x0 0x1000>; + }; + scmi_shm_3: sram@47ff4000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff4000 0x0 0x1000>; + }; + scmi-secondary-agents =3D < + 0x82000002 &scmi_shm_0 0 + 0x82000004 &scmi_shm_2 2 + 0x82000005 &scmi_shm_3 3 + 0x82000006 &scmi_shm_4 4>; + #scmi-secondary-agents-cells =3D <3>; + }; + + scmi_xen: scmi { + compatible =3D "arm,scmi-smc"; + arm,smc-id =3D <0x82000002>; <--- Xen management agent smc-id + #address-cells =3D < 1>; + #size-cells =3D < 0>; + #access-controller-cells =3D < 1>; + shmem =3D <&scmi_shm_1>; <--- Xen management agent shmem + }; + + }; +}; + +- #scmi-secondary-agents-cells + + Defines whether Agent_id is set in the "scmi-secondary-agents" propert= y. + Possible values are: 2, 3. + When set to 3 (the default), expect agent_id to be present in the seco= ndary + agents list. + When set to 2, agent_id will be discovered for each channel using + BASE_DISCOVER_AGENT message. + + +Example: + +/{ +chosen { + xen,config { + scmi-secondary-agents =3D < + 0x82000003 &scmi_shm_1 + 0x82000004 &scmi_shm_2 + 0x82000005 &scmi_shm_3 + 0x82000006 &scmi_shm_4>; + #scmi-secondary-agents-cells =3D <2>; + }; + }; +}; diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 34004ce282..5541c4a4ed 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -835,7 +835,7 @@ Specify the bit width of the DMA heap. cpuid-faulting=3D, msr-relaxed=3D, pf-fixup=3D ] (x86) =20 - =3D List of [ sve=3D ] (Arm64) + =3D List of [ sve=3D, sci-agent-id=3D ] (Arm) =20 Controls for how dom0 is constructed on x86 systems. =20 @@ -923,6 +923,14 @@ Enables features on dom0 on Arm systems. option is provided with a positive non zero value, but the platform do= esn't support SVE. =20 +* The `sci-agent-id` integer parameter enables ARM SCMI (System Control = and + Management Interface) functionality for Dom0 when `CONFIG_SCMI_SMC_MA`= is + compiled in. This parameter specifies the SCMI agent ID for Dom0. + A value equal to 0xFF (or omitted) disables SCMI for Dom0, which is us= eful + for thin Dom0 or dom0less use-cases. Values from 0 to 254 specify the = SCMI + agent ID. The agent IDs of domains existing on a single host must be u= nique. + Example: `dom0=3Dsci-agent-id=3D0` to enable SCMI with agent ID 0 for = Dom0. + ### dom0-cpuid =3D List of comma separated booleans =20 @@ -1107,6 +1115,15 @@ affinities to prefer but be not limited to the speci= fied node(s). =20 Pin dom0 vcpus to their respective pcpus =20 +### scmi-smc-passthrough (ARM) +> `=3D ` + +The option is available when `CONFIG_SCMI_SMC` is compiled in, and allows = to +enable SCMI SMC single agent interface for any, but only one guest domain, +which serves as Driver domain. The SCMI will be disabled for Dom0/hwdom and +SCMI nodes removed from Dom0/hwdom device tree. +(for example, thin Dom0 with Driver domain use-case). + ### dtuart (ARM) > `=3D path [:options]` =20 diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index e4407d6e3f..be0e6263ae 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -240,6 +240,10 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, case LIBXL_ARM_SCI_TYPE_SCMI_SMC: config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC; break; + case LIBXL_ARM_SCI_TYPE_SCMI_SMC_MULTIAGENT: + config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC_M= A; + config->arch.arm_sci_agent_id =3D d_config->b_info.arch_arm.arm_sc= i.agent_id; + break; default: LOG(ERROR, "Unknown ARM_SCI type %d", d_config->b_info.arch_arm.arm_sci.type); diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 4a958f69f4..9bfbf09145 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -554,11 +554,13 @@ libxl_sve_type =3D Enumeration("sve_type", [ =20 libxl_arm_sci_type =3D Enumeration("arm_sci_type", [ (0, "none"), - (1, "scmi_smc") + (1, "scmi_smc"), + (2, "scmi_smc_multiagent") ], init_val =3D "LIBXL_ARM_SCI_TYPE_NONE") =20 libxl_arm_sci =3D Struct("arm_sci", [ ("type", libxl_arm_sci_type), + ("agent_id", uint8) ]) =20 libxl_rdm_reserve =3D Struct("rdm_reserve", [ diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 1cc41f1bff..0c389d25f9 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1306,6 +1306,18 @@ static int parse_arm_sci_config(XLU_Config *cfg, lib= xl_arm_sci *arm_sci, } } =20 + if (MATCH_OPTION("agent_id", ptr, oparg)) { + unsigned long val =3D parse_ulong(oparg); + + if (!val || val > 255) { + fprintf(stderr, "An invalid ARM_SCI agent_id specified (%l= u). Valid range [1..255]\n", + val); + ret =3D ERROR_INVAL; + goto out; + } + arm_sci->agent_id =3D val; + } + ptr =3D strtok(NULL, ","); } =20 diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 4181c10538..ddadc89148 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -299,6 +299,17 @@ static int __init domu_dt_sci_parse(struct dt_device_n= ode *node, d_cfg->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; else if ( !strcmp(sci_type, "scmi_smc") ) d_cfg->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC; + else if ( !strcmp(sci_type, "scmi_smc_multiagent") ) + { + uint32_t agent_id =3D 0; + + if ( !dt_property_read_u32(node, "xen,sci-agent-id", &agent_id) || + agent_id > UINT8_MAX ) + return -EINVAL; + + d_cfg->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC_MA; + d_cfg->arch.arm_sci_agent_id =3D agent_id; + } else { printk(XENLOG_ERR "xen,sci_type in not valid (%s) for domain %s\n", diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index fb8fbb1650..794ea1aa42 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -55,6 +55,10 @@ boolean_param("ext_regions", opt_ext_regions); static u64 __initdata dom0_mem; static bool __initdata dom0_mem_set; =20 +/* SCMI agent ID for dom0, parsed from dom0=3Dsci-agent-id=3D */ +#define SCMI_AGENT_ID_INVALID 0xFF +static uint8_t __initdata opt_dom0_scmi_agent_id =3D SCMI_AGENT_ID_INVALID; + static int __init parse_dom0_mem(const char *s) { dom0_mem_set =3D true; @@ -83,6 +87,16 @@ int __init parse_arch_dom0_param(const char *s, const ch= ar *e) #endif } =20 + if ( !parse_signed_integer("sci-agent-id", s, e, &val) ) + { + if ( (val >=3D 0) && (val <=3D UINT8_MAX) ) + opt_dom0_scmi_agent_id =3D val; + else + printk(XENLOG_INFO "'sci-agent-id=3D%lld' value out of range!\= n", val); + + return 0; + } + return -EINVAL; } =20 @@ -509,7 +523,8 @@ static int __init write_properties(struct domain *d, st= ruct kernel_info *kinfo, dt_property_name_is_equal(prop, "linux,uefi-mmap-start") = || dt_property_name_is_equal(prop, "linux,uefi-mmap-size") || dt_property_name_is_equal(prop, "linux,uefi-mmap-desc-siz= e") || - dt_property_name_is_equal(prop, "linux,uefi-mmap-desc-ver= ")) + dt_property_name_is_equal(prop, "linux,uefi-mmap-desc-ver= ") || + dt_property_name_is_equal(prop, "xen,config") ) continue; =20 if ( dt_property_name_is_equal(prop, "xen,dom0-bootargs") ) @@ -2067,6 +2082,15 @@ void __init create_dom0(void) dom0_cfg.arch.tee_type =3D tee_get_type(); dom0_cfg.max_vcpus =3D dom0_max_vcpus(); =20 + /* Set up SCMI agent ID if specified in dom0=3D command line */ + if ( opt_dom0_scmi_agent_id !=3D SCMI_AGENT_ID_INVALID ) + { + dom0_cfg.arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC_= MA; + dom0_cfg.arch.arm_sci_agent_id =3D opt_dom0_scmi_agent_id; + } + else + dom0_cfg.arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + if ( iommu_enabled ) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 diff --git a/xen/arch/arm/firmware/Kconfig b/xen/arch/arm/firmware/Kconfig index 5c5f0880c4..972cd9b173 100644 --- a/xen/arch/arm/firmware/Kconfig +++ b/xen/arch/arm/firmware/Kconfig @@ -29,6 +29,18 @@ config SCMI_SMC driver domain. Use with EL3 firmware which supports only single SCMI OSPM agent. =20 +config SCMI_SMC_MA + bool "Enable ARM SCMI SMC multi-agent driver" + depends on ARM_64 + select ARM_SCI + help + Enables SCMI SMC/HVC multi-agent in XEN to pass SCMI requests from Doma= ins + to EL3 firmware (TF-A) which supports multi-agent feature. + This feature allows to enable SCMI per Domain using unique SCMI agent_i= d, + so Domain is identified by EL3 firmware as an SCMI Agent and can access + allowed platform resources through dedicated SMC/HVC Shared memory based + transport. + endchoice =20 endmenu diff --git a/xen/arch/arm/firmware/Makefile b/xen/arch/arm/firmware/Makefile index 71bdefc24a..37927e690e 100644 --- a/xen/arch/arm/firmware/Makefile +++ b/xen/arch/arm/firmware/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_ARM_SCI) +=3D sci.o obj-$(CONFIG_SCMI_SMC) +=3D scmi-smc.o +obj-$(CONFIG_SCMI_SMC_MA) +=3D scmi-shmem.o scmi-smc-multiagent.o diff --git a/xen/arch/arm/firmware/scmi-proto.h b/xen/arch/arm/firmware/scm= i-proto.h new file mode 100644 index 0000000000..49f63cfc0a --- /dev/null +++ b/xen/arch/arm/firmware/scmi-proto.h @@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Arm System Control and Management Interface definitions + * Version 3.0 (DEN0056C) + * + * Copyright (c) 2025 EPAM Systems + */ + +#ifndef ARM_FIRMWARE_SCMI_PROTO_H_ +#define ARM_FIRMWARE_SCMI_PROTO_H_ + +#include + +#define SCMI_SHORT_NAME_MAX_SIZE 16 + +/* SCMI status codes. See section 4.1.4 */ +#define SCMI_SUCCESS 0 +#define SCMI_NOT_SUPPORTED (-1) +#define SCMI_INVALID_PARAMETERS (-2) +#define SCMI_DENIED (-3) +#define SCMI_NOT_FOUND (-4) +#define SCMI_OUT_OF_RANGE (-5) +#define SCMI_BUSY (-6) +#define SCMI_COMMS_ERROR (-7) +#define SCMI_GENERIC_ERROR (-8) +#define SCMI_HARDWARE_ERROR (-9) +#define SCMI_PROTOCOL_ERROR (-10) + +/* Protocol IDs */ +#define SCMI_BASE_PROTOCOL 0x10 + +/* Base protocol message IDs */ +#define SCMI_BASE_PROTOCOL_VERSION 0x0 +#define SCMI_BASE_PROTOCOL_ATTIBUTES 0x1 +#define SCMI_BASE_PROTOCOL_MESSAGE_ATTRIBUTES 0x2 +#define SCMI_BASE_DISCOVER_AGENT 0x7 +#define SCMI_BASE_SET_DEVICE_PERMISSIONS 0x9 +#define SCMI_BASE_RESET_AGENT_CONFIGURATION 0xB + +typedef struct scmi_msg_header { + uint8_t id; + uint8_t type; + uint8_t protocol; + uint32_t status; +} scmi_msg_header_t; + +/* Table 2 Message header format */ +#define SCMI_HDR_ID GENMASK(7, 0) +#define SCMI_HDR_TYPE GENMASK(9, 8) +#define SCMI_HDR_PROTO GENMASK(17, 10) + +#define SCMI_FIELD_GET(_mask, _reg) = \ + ((typeof(_mask))(((_reg) & (_mask)) >> (ffs64(_mask) - 1))) +#define SCMI_FIELD_PREP(_mask, _val) = \ + (((typeof(_mask))(_val) << (ffs64(_mask) - 1)) & (_mask)) + +static inline uint32_t pack_scmi_header(scmi_msg_header_t *hdr) +{ + return SCMI_FIELD_PREP(SCMI_HDR_ID, hdr->id) | + SCMI_FIELD_PREP(SCMI_HDR_TYPE, hdr->type) | + SCMI_FIELD_PREP(SCMI_HDR_PROTO, hdr->protocol); +} + +static inline void unpack_scmi_header(uint32_t msg_hdr, scmi_msg_header_t = *hdr) +{ + hdr->id =3D SCMI_FIELD_GET(SCMI_HDR_ID, msg_hdr); + hdr->type =3D SCMI_FIELD_GET(SCMI_HDR_TYPE, msg_hdr); + hdr->protocol =3D SCMI_FIELD_GET(SCMI_HDR_PROTO, msg_hdr); +} + +static inline int scmi_to_xen_errno(int scmi_status) +{ + if ( scmi_status =3D=3D SCMI_SUCCESS ) + return 0; + + switch ( scmi_status ) + { + case SCMI_NOT_SUPPORTED: + return -EOPNOTSUPP; + case SCMI_INVALID_PARAMETERS: + return -EINVAL; + case SCMI_DENIED: + return -EACCES; + case SCMI_NOT_FOUND: + return -ENOENT; + case SCMI_OUT_OF_RANGE: + return -ERANGE; + case SCMI_BUSY: + return -EBUSY; + case SCMI_COMMS_ERROR: + return -ENOTCONN; + case SCMI_GENERIC_ERROR: + return -EIO; + case SCMI_HARDWARE_ERROR: + return -ENXIO; + case SCMI_PROTOCOL_ERROR: + return -EBADMSG; + default: + return -EINVAL; + } +} + +/* PROTOCOL_VERSION */ +#define SCMI_VERSION_MINOR GENMASK(15, 0) +#define SCMI_VERSION_MAJOR GENMASK(31, 16) + +struct scmi_msg_prot_version_p2a { + uint32_t version; +} __packed; + +/* BASE PROTOCOL_ATTRIBUTES */ +#define SCMI_BASE_ATTR_NUM_PROTO GENMASK(7, 0) +#define SCMI_BASE_ATTR_NUM_AGENT GENMASK(15, 8) + +struct scmi_msg_base_attributes_p2a { + uint32_t attributes; +} __packed; + +/* + * BASE_DISCOVER_AGENT + */ +#define SCMI_BASE_AGENT_ID_OWN 0xFFFFFFFF + +struct scmi_msg_base_discover_agent_a2p { + uint32_t agent_id; +} __packed; + +struct scmi_msg_base_discover_agent_p2a { + uint32_t agent_id; + char name[SCMI_SHORT_NAME_MAX_SIZE]; +} __packed; + +/* + * BASE_SET_DEVICE_PERMISSIONS + */ +#define SCMI_BASE_DEVICE_ACCESS_ALLOW BIT(0, UL) + +struct scmi_msg_base_set_device_permissions_a2p { + uint32_t agent_id; + uint32_t device_id; + uint32_t flags; +} __packed; + +/* + * BASE_RESET_AGENT_CONFIGURATION + */ +#define SCMI_BASE_AGENT_PERMISSIONS_RESET BIT(0, UL) + +struct scmi_msg_base_reset_agent_cfg_a2p { + uint32_t agent_id; + uint32_t flags; +} __packed; + +#endif /* ARM_FIRMWARE_SCMI_PROTO_H_ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/firmware/scmi-shmem.c b/xen/arch/arm/firmware/scm= i-shmem.c new file mode 100644 index 0000000000..c681e3c476 --- /dev/null +++ b/xen/arch/arm/firmware/scmi-shmem.c @@ -0,0 +1,115 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * SMC/HVC shmem transport implementation used by + * SCI SCMI multi-agent driver. + * + * Oleksii Moisieiev + * Copyright (c) 2025 EPAM Systems + */ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +#include "scmi-proto.h" +#include "scmi-shmem.h" + +static inline int +shmem_channel_is_free(const volatile struct scmi_shared_mem __iomem *shmem) +{ + return (readl(&shmem->channel_status) & + SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE) ? 0 : -EBUSY; +} + +int shmem_put_message(volatile struct scmi_shared_mem __iomem *shmem, + scmi_msg_header_t *hdr, void *data, int len) +{ + int ret; + + if ( (len + offsetof(struct scmi_shared_mem, msg_payload)) > + SCMI_SHMEM_MAPPED_SIZE ) + { + printk(XENLOG_ERR "scmi: Wrong size of smc message. Data is invali= d\n"); + return -EINVAL; + } + + ret =3D shmem_channel_is_free(shmem); + if ( ret ) + return ret; + + writel_relaxed(0x0, &shmem->channel_status); + /* Writing 0x0 right now, but "shmem"_FLAG_INTR_ENABLED can be set */ + writel_relaxed(0x0, &shmem->flags); + writel_relaxed(sizeof(shmem->msg_header) + len, &shmem->length); + writel(pack_scmi_header(hdr), &shmem->msg_header); + + if ( len > 0 && data ) + __memcpy_toio(shmem->msg_payload, data, len); + + return 0; +} + +int shmem_get_response(const volatile struct scmi_shared_mem __iomem *shme= m, + scmi_msg_header_t *hdr, void *data, int len) +{ + int recv_len; + int ret; + int pad =3D sizeof(hdr->status); + + if ( len >=3D SCMI_SHMEM_MAPPED_SIZE - + offsetof(struct scmi_shared_mem, msg_payload) ) + { + printk(XENLOG_ERR + "scmi: Wrong size of input smc message. Data may be invalid= \n"); + return -EINVAL; + } + + ret =3D shmem_channel_is_free(shmem); + if ( ret ) + return ret; + + recv_len =3D readl(&shmem->length) - sizeof(shmem->msg_header); + + if ( recv_len < 0 ) + { + printk(XENLOG_ERR + "scmi: Wrong size of smc message. Data may be invalid\n"); + return -EINVAL; + } + + unpack_scmi_header(readl(&shmem->msg_header), hdr); + + hdr->status =3D readl(&shmem->msg_payload); + recv_len =3D recv_len > pad ? recv_len - pad : 0; + + ret =3D scmi_to_xen_errno(hdr->status); + if ( ret ) + { + printk(XENLOG_DEBUG "scmi: Error received: %d\n", ret); + return ret; + } + + if ( recv_len > len ) + { + printk(XENLOG_ERR + "scmi: Not enough buffer for message %d, expecting %d\n", + recv_len, len); + return -EINVAL; + } + + if ( recv_len > 0 ) + __memcpy_fromio(data, shmem->msg_payload + pad, recv_len); + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/firmware/scmi-shmem.h b/xen/arch/arm/firmware/scm= i-shmem.h new file mode 100644 index 0000000000..7313cb6b26 --- /dev/null +++ b/xen/arch/arm/firmware/scmi-shmem.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Arm System Control and Management Interface definitions + * Version 3.0 (DEN0056C) + * Shared Memory based Transport + * + * Copyright (c) 2024 EPAM Systems + */ + +#ifndef ARM_FIRMWARE_SCMI_SHMEM_H_ +#define ARM_FIRMWARE_SCMI_SHMEM_H_ + +#include + +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE BIT(0, UL) +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR BIT(1, UL) + +struct scmi_shared_mem { + uint32_t reserved; + uint32_t channel_status; + uint32_t reserved1[2]; + uint32_t flags; + uint32_t length; + uint32_t msg_header; + uint8_t msg_payload[]; +}; + +#define SCMI_SHMEM_MAPPED_SIZE PAGE_SIZE + +int shmem_put_message(volatile struct scmi_shared_mem __iomem *shmem, + scmi_msg_header_t *hdr, void *data, int len); + +int shmem_get_response(const volatile struct scmi_shared_mem __iomem *shme= m, + scmi_msg_header_t *hdr, void *data, int len); +#endif /* ARM_FIRMWARE_SCMI_SHMEM_H_ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/firmware/scmi-smc-multiagent.c b/xen/arch/arm/fir= mware/scmi-smc-multiagent.c new file mode 100644 index 0000000000..8e532798a6 --- /dev/null +++ b/xen/arch/arm/firmware/scmi-smc-multiagent.c @@ -0,0 +1,794 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * SCI SCMI multi-agent driver, using SMC/HVC shmem as transport. + * + * Oleksii Moisieiev + * Copyright (c) 2025 EPAM Systems + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "scmi-proto.h" +#include "scmi-shmem.h" + +#define SCMI_AGENT_ID_INVALID 0xFF + +#define SCMI_SECONDARY_AGENTS "scmi-secondary-agents" + +struct scmi_channel { + uint32_t agent_id; + uint32_t func_id; + domid_t domain_id; + uint64_t paddr; + struct scmi_shared_mem __iomem *shmem; + spinlock_t lock; + struct list_head list; +}; + +struct scmi_data { + struct list_head channel_list; + spinlock_t channel_list_lock; + uint32_t func_id; + bool initialized; + uint32_t shmem_phandle; + uint32_t hyp_channel_agent_id; + struct dt_device_node *dt_dev; +}; + +static struct scmi_data scmi_data; + +static int send_smc_message(struct scmi_channel *chan_info, + scmi_msg_header_t *hdr, void *data, int len) +{ + struct arm_smccc_res resp; + int ret; + + ret =3D shmem_put_message(chan_info->shmem, hdr, data, len); + if ( ret ) + return ret; + + arm_smccc_1_1_smc(chan_info->func_id, 0, 0, 0, 0, 0, 0, 0, &resp); + + if ( resp.a0 =3D=3D ARM_SMCCC_INVALID_PARAMETER ) + return -EINVAL; + + if ( resp.a0 ) + return -EOPNOTSUPP; + + return 0; +} + +static int do_smc_xfer(struct scmi_channel *chan_info, scmi_msg_header_t *= hdr, + void *tx_data, int tx_size, void *rx_data, int rx_s= ize) +{ + int ret =3D 0; + + ASSERT(chan_info && chan_info->shmem); + + if ( !hdr ) + return -EINVAL; + + spin_lock(&chan_info->lock); + + printk(XENLOG_DEBUG + "scmi: agent_id =3D %d msg_id =3D %x type =3D %d, proto =3D %x\= n", + chan_info->agent_id, hdr->id, hdr->type, hdr->protocol); + + ret =3D send_smc_message(chan_info, hdr, tx_data, tx_size); + if ( ret ) + goto clean; + + ret =3D shmem_get_response(chan_info->shmem, hdr, rx_data, rx_size); + +clean: + printk(XENLOG_DEBUG + "scmi: get smc response agent_id =3D %d msg_id =3D %x proto =3D= %x res=3D%d\n", + chan_info->agent_id, hdr->id, hdr->protocol, ret); + + spin_unlock(&chan_info->lock); + + return ret; +} + +static struct scmi_channel *get_channel_by_id(uint32_t agent_id) +{ + struct scmi_channel *curr; + bool found =3D false; + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry(curr, &scmi_data.channel_list, list) + { + if ( curr->agent_id =3D=3D agent_id ) + { + found =3D true; + break; + } + } + + spin_unlock(&scmi_data.channel_list_lock); + if ( found ) + return curr; + + return NULL; +} + +static struct scmi_channel *acquire_scmi_channel(struct domain *d, + uint32_t agent_id) +{ + struct scmi_channel *curr; + struct scmi_channel *ret =3D ERR_PTR(-ENOENT); + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry(curr, &scmi_data.channel_list, list) + { + if ( curr->agent_id =3D=3D agent_id ) + { + if ( curr->domain_id !=3D DOMID_INVALID ) + { + ret =3D ERR_PTR(-EEXIST); + break; + } + + curr->domain_id =3D d->domain_id; + ret =3D curr; + break; + } + } + + spin_unlock(&scmi_data.channel_list_lock); + + return ret; +} + +static void relinquish_scmi_channel(struct scmi_channel *channel) +{ + ASSERT(channel !=3D NULL); + + spin_lock(&scmi_data.channel_list_lock); + channel->domain_id =3D DOMID_INVALID; + spin_unlock(&scmi_data.channel_list_lock); +} + +static int map_channel_memory(struct scmi_channel *channel) +{ + ASSERT(channel && channel->paddr); + channel->shmem =3D ioremap_nocache(channel->paddr, SCMI_SHMEM_MAPPED_S= IZE); + if ( !channel->shmem ) + return -ENOMEM; + + channel->shmem->channel_status =3D SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE; + printk(XENLOG_DEBUG "scmi: Got shmem %lx after vmap %p\n", channel->pa= ddr, + channel->shmem); + + return 0; +} + +static void unmap_channel_memory(struct scmi_channel *channel) +{ + ASSERT(channel && channel->shmem); + iounmap(channel->shmem); + channel->shmem =3D NULL; +} + +static struct scmi_channel *smc_create_channel(uint32_t agent_id, + uint32_t func_id, uint64_t = addr) +{ + struct scmi_channel *channel, *curr; + + spin_lock(&scmi_data.channel_list_lock); + + /* Check if channel already exists while holding the lock */ + list_for_each_entry(curr, &scmi_data.channel_list, list) + { + if ( curr->agent_id =3D=3D agent_id ) + { + spin_unlock(&scmi_data.channel_list_lock); + return ERR_PTR(-EEXIST); + } + } + + channel =3D xmalloc(struct scmi_channel); + if ( !channel ) + { + spin_unlock(&scmi_data.channel_list_lock); + return ERR_PTR(-ENOMEM); + } + + spin_lock_init(&channel->lock); + channel->agent_id =3D agent_id; + channel->func_id =3D func_id; + channel->domain_id =3D DOMID_INVALID; + channel->shmem =3D NULL; + channel->paddr =3D addr; + list_add_tail(&channel->list, &scmi_data.channel_list); + + spin_unlock(&scmi_data.channel_list_lock); + return channel; +} + +static void free_channel_list(void) +{ + struct scmi_channel *curr, *_curr; + + list_for_each_entry_safe(curr, _curr, &scmi_data.channel_list, list) + { + list_del(&curr->list); + xfree(curr); + } +} + +static int __init +scmi_dt_read_hyp_channel_addr(struct dt_device_node *scmi_node, u64 *addr, + u64 *size) +{ + struct dt_device_node *shmem_node; + const __be32 *prop; + + prop =3D dt_get_property(scmi_node, "shmem", NULL); + if ( !prop ) + return -EINVAL; + + shmem_node =3D dt_find_node_by_phandle(be32_to_cpu(*prop)); + if ( IS_ERR_OR_NULL(shmem_node) ) + { + printk(XENLOG_ERR + "scmi: Device tree error, can't parse reserved memory %ld\n= ", + PTR_ERR(shmem_node)); + return PTR_ERR(shmem_node); + } + + return dt_device_get_address(shmem_node, 0, addr, size); +} + +/* + * Handle Dom0 SCMI specific DT nodes + * + * Make a decision on copying SCMI specific nodes into Dom0 device tree. + * For SCMI multi-agent case: + * - shmem nodes will not be copied and generated instead if SCMI + * is enabled for Dom0 + * - scmi node will be copied if SCMI is enabled for Dom0 + */ +static bool scmi_dt_handle_node(struct domain *d, struct dt_device_node *n= ode) +{ + static const struct dt_device_match shmem_matches[] __initconst =3D { + DT_MATCH_COMPATIBLE("arm,scmi-shmem"), + { /* sentinel */ }, + }; + static const struct dt_device_match scmi_matches[] __initconst =3D { + DT_MATCH_PATH("/firmware/scmi"), + { /* sentinel */ }, + }; + + if ( !scmi_data.initialized ) + return false; + + /* skip scmi shmem node for dom0 if scmi not enabled */ + if ( dt_match_node(shmem_matches, node) && !sci_domain_is_enabled(d) ) + { + dt_dprintk(" Skip scmi shmem node\n"); + return true; + } + + /* drop scmi if not enabled */ + if ( dt_match_node(scmi_matches, node) && !sci_domain_is_enabled(d) ) + { + dt_dprintk(" Skip scmi node\n"); + return true; + } + + return false; +} + +static int scmi_assign_device(uint32_t agent_id, uint32_t device_id, + uint32_t flags) +{ + struct scmi_msg_base_set_device_permissions_a2p tx; + struct scmi_channel *channel; + scmi_msg_header_t hdr; + + channel =3D get_channel_by_id(scmi_data.hyp_channel_agent_id); + if ( !channel ) + return -EINVAL; + + hdr.id =3D SCMI_BASE_SET_DEVICE_PERMISSIONS; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + tx.agent_id =3D agent_id; + tx.device_id =3D device_id; + tx.flags =3D flags; + + return do_smc_xfer(channel, &hdr, &tx, sizeof(tx), NULL, 0); +} + +static int scmi_dt_assign_device(struct domain *d, + struct dt_phandle_args *ac_spec) +{ + struct scmi_channel *agent_channel; + uint32_t scmi_device_id =3D ac_spec->args[0]; + int ret; + + if ( !d->arch.sci_data ) + return 0; + + /* The access-controllers is specified for DT dev, but it's not a SCMI= */ + if ( ac_spec->np !=3D scmi_data.dt_dev ) + return 0; + + agent_channel =3D d->arch.sci_data; + + spin_lock(&agent_channel->lock); + + ret =3D scmi_assign_device(agent_channel->agent_id, scmi_device_id, + SCMI_BASE_DEVICE_ACCESS_ALLOW); + if ( ret ) + { + printk(XENLOG_ERR + "scmi: could not assign dev for %pd agent:%d dev_id:%u (%d)= ", + d, agent_channel->agent_id, scmi_device_id, ret); + } + + spin_unlock(&agent_channel->lock); + return ret; +} + +static int collect_agent_id(struct scmi_channel *agent_channel) +{ + int ret; + scmi_msg_header_t hdr; + struct scmi_msg_base_discover_agent_p2a da_rx; + struct scmi_msg_base_discover_agent_a2p da_tx; + + ret =3D map_channel_memory(agent_channel); + if ( ret ) + return ret; + + hdr.id =3D SCMI_BASE_DISCOVER_AGENT; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + da_tx.agent_id =3D agent_channel->agent_id; + + ret =3D do_smc_xfer(agent_channel, &hdr, &da_tx, sizeof(da_tx), &da_rx, + sizeof(da_rx)); + if ( agent_channel->domain_id !=3D DOMID_XEN ) + unmap_channel_memory(agent_channel); + if ( ret ) + return ret; + + printk(XENLOG_DEBUG "id=3D0x%x name=3D%s\n", da_rx.agent_id, da_rx.nam= e); + agent_channel->agent_id =3D da_rx.agent_id; + return 0; +} + +static __init int collect_agents(struct dt_device_node *scmi_node) +{ + const struct dt_device_node *config_node; + const __be32 *prop; + uint32_t len; + const __be32 *end; + uint32_t cells_per_entry =3D 3; /* Default to 3 cells if property is a= bsent. */ + + config_node =3D dt_find_node_by_path("/chosen/xen,config"); + if ( !config_node ) + { + printk(XENLOG_WARNING "scmi: /chosen/xen,config node not found, no= agents to collect.\n"); + return -ENOENT; + } + + /* Check for the optional '#scmi-secondary-agents-cells' property. */ + if ( dt_property_read_u32(config_node, "#scmi-secondary-agents-cells", + &cells_per_entry) ) + { + if ( cells_per_entry !=3D 2 && cells_per_entry !=3D 3 ) + { + printk(XENLOG_ERR "scmi: Invalid #scmi-secondary-agents-cells = value: %u\n", + cells_per_entry); + return -EINVAL; + } + } + + prop =3D dt_get_property(config_node, SCMI_SECONDARY_AGENTS, &len); + if ( !prop ) + { + printk(XENLOG_ERR "scmi: No %s property found, no agents to collec= t.\n", + SCMI_SECONDARY_AGENTS); + return -EINVAL; + } + + /* Validate that the property length is a multiple of the cell size. */ + if ( len =3D=3D 0 || len % (cells_per_entry * sizeof(uint32_t)) !=3D 0= ) + { + printk(XENLOG_ERR "scmi: Invalid length of %s property: %u for %u = cells per entry\n", + SCMI_SECONDARY_AGENTS, len, cells_per_entry); + return -EINVAL; + } + + end =3D (const __be32 *)((const u8 *)prop + len); + + for ( ; prop < end; ) + { + uint32_t agent_id; + uint32_t smc_id; + uint32_t shmem_phandle; + struct dt_device_node *node; + u64 addr, size; + int ret; + struct scmi_channel *agent_channel; + + smc_id =3D be32_to_cpu(*prop++); + shmem_phandle =3D be32_to_cpu(*prop++); + + if ( cells_per_entry =3D=3D 3 ) + agent_id =3D be32_to_cpu(*prop++); + else + agent_id =3D SCMI_BASE_AGENT_ID_OWN; + + node =3D dt_find_node_by_phandle(shmem_phandle); + if ( !node ) + { + printk(XENLOG_ERR "scmi: Could not find shmem node for agent %= u\n", + agent_id); + return -EINVAL; + } + + ret =3D dt_device_get_address(node, 0, &addr, &size); + if ( ret ) + { + printk(XENLOG_ERR + "scmi: Could not read shmem address for agent %u: %d\n", + agent_id, ret); + return ret; + } + + if ( !IS_ALIGNED(size, SCMI_SHMEM_MAPPED_SIZE) ) + { + printk(XENLOG_ERR "scmi: shmem memory is not aligned\n"); + return -EINVAL; + } + + agent_channel =3D smc_create_channel(agent_id, smc_id, addr); + if ( IS_ERR(agent_channel) ) + { + printk(XENLOG_ERR "scmi: Could not create channel for agent %u= : %ld\n", + agent_id, PTR_ERR(agent_channel)); + return PTR_ERR(agent_channel); + } + + if ( cells_per_entry =3D=3D 2 ) + { + ret =3D collect_agent_id(agent_channel); + if ( ret ) + return ret; + } + + printk(XENLOG_DEBUG "scmi: Agent %u SMC %X addr %lx\n", agent_chan= nel->agent_id, + smc_id, (unsigned long)addr); + } + + return 0; +} + +static int scmi_domain_init(struct domain *d, + struct xen_domctl_createdomain *config) +{ + struct scmi_channel *channel; + int ret; + + if ( !scmi_data.initialized ) + return 0; + + /* + * SCMI support is configured via: + * - For dom0: dom0=3Dsci-agent-id=3D in Xen command line + * - For dom0less: xen,sci-agent-id in device tree + * The config->arch.arm_sci_type and config->arch.arm_sci_agent_id + * are already set by domain_build.c or dom0less-build.c + */ + + if ( config->arch.arm_sci_type =3D=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE ) + return 0; + + channel =3D acquire_scmi_channel(d, config->arch.arm_sci_agent_id); + if ( IS_ERR(channel) ) + { + printk(XENLOG_ERR + "scmi: Failed to acquire SCMI channel for agent_id %u: %ld\= n", + config->arch.arm_sci_agent_id, PTR_ERR(channel)); + return PTR_ERR(channel); + } + + printk(XENLOG_INFO + "scmi: Acquire channel id =3D 0x%x, domain_id =3D %d paddr =3D = 0x%lx\n", + channel->agent_id, channel->domain_id, channel->paddr); + + /* + * Dom0 (if present) needs to have an access to the guest memory range + * to satisfy iomem_access_permitted() check in XEN_DOMCTL_iomem_permi= ssion + * domctl. + */ + if ( hardware_domain && !is_hardware_domain(d) ) + { + ret =3D iomem_permit_access(hardware_domain, paddr_to_pfn(channel-= >paddr), + paddr_to_pfn(channel->paddr + PAGE_SIZE = - 1)); + if ( ret ) + goto error; + } + + d->arch.sci_data =3D channel; + d->arch.sci_enabled =3D true; + + return 0; + +error: + relinquish_scmi_channel(channel); + return ret; +} + +int scmi_domain_sanitise_config(struct xen_domctl_createdomain *config) +{ + if ( config->arch.arm_sci_type !=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE && + config->arch.arm_sci_type !=3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC= _MA ) + { + dprintk(XENLOG_INFO, "scmi: Unsupported ARM_SCI type\n"); + return -EINVAL; + } + + return 0; +} + +static int scmi_relinquish_resources(struct domain *d) +{ + int ret; + struct scmi_channel *channel, *agent_channel; + scmi_msg_header_t hdr; + struct scmi_msg_base_reset_agent_cfg_a2p tx; + + if ( !d->arch.sci_data ) + return 0; + + agent_channel =3D d->arch.sci_data; + + spin_lock(&agent_channel->lock); + tx.agent_id =3D agent_channel->agent_id; + spin_unlock(&agent_channel->lock); + + channel =3D get_channel_by_id(scmi_data.hyp_channel_agent_id); + if ( !channel ) + { + printk(XENLOG_ERR + "scmi: Unable to get Hypervisor scmi channel for domain %d\= n", + d->domain_id); + return -EINVAL; + } + + hdr.id =3D SCMI_BASE_RESET_AGENT_CONFIGURATION; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + tx.flags =3D 0; + + ret =3D do_smc_xfer(channel, &hdr, &tx, sizeof(tx), NULL, 0); + if ( ret =3D=3D -EOPNOTSUPP ) + return 0; + + return ret; +} + +static void scmi_domain_destroy(struct domain *d) +{ + struct scmi_channel *channel; + + if ( !d->arch.sci_data ) + return; + + channel =3D d->arch.sci_data; + spin_lock(&channel->lock); + + relinquish_scmi_channel(channel); + printk(XENLOG_DEBUG "scmi: Free domain %d\n", d->domain_id); + + d->arch.sci_data =3D NULL; + d->arch.sci_enabled =3D false; + + spin_unlock(&channel->lock); +} + +static bool scmi_handle_call(struct cpu_user_regs *regs) +{ + uint32_t fid =3D (uint32_t)get_user_reg(regs, 0); + struct scmi_channel *agent_channel; + struct domain *d =3D current->domain; + struct arm_smccc_res resp; + bool res =3D false; + + if ( !sci_domain_is_enabled(d) ) + return false; + + agent_channel =3D d->arch.sci_data; + spin_lock(&agent_channel->lock); + + if ( agent_channel->func_id !=3D fid ) + { + res =3D false; + goto unlock; + } + + arm_smccc_1_1_smc(fid, + get_user_reg(regs, 1), + get_user_reg(regs, 2), + get_user_reg(regs, 3), + get_user_reg(regs, 4), + get_user_reg(regs, 5), + get_user_reg(regs, 6), + get_user_reg(regs, 7), + &resp); + + set_user_reg(regs, 0, resp.a0); + set_user_reg(regs, 1, resp.a1); + set_user_reg(regs, 2, resp.a2); + set_user_reg(regs, 3, resp.a3); + res =3D true; +unlock: + spin_unlock(&agent_channel->lock); + + return res; +} + +static const struct sci_mediator_ops scmi_ops =3D { + .domain_init =3D scmi_domain_init, + .domain_destroy =3D scmi_domain_destroy, + .relinquish_resources =3D scmi_relinquish_resources, + .handle_call =3D scmi_handle_call, + .dom0_dt_handle_node =3D scmi_dt_handle_node, + .domain_sanitise_config =3D scmi_domain_sanitise_config, + .assign_dt_device =3D scmi_dt_assign_device, +}; + +static int __init scmi_check_smccc_ver(void) +{ + if ( smccc_ver < ARM_SMCCC_VERSION_1_1 ) + { + printk(XENLOG_WARNING + "scmi: No SMCCC 1.1 support, SCMI calls forwarding disabled= \n"); + return -ENOSYS; + } + + return 0; +} + +static int __init scmi_dt_hyp_channel_read(struct dt_device_node *scmi_nod= e, + struct scmi_data *scmi_data, + u64 *addr) +{ + int ret; + u64 size; + + if ( !dt_property_read_u32(scmi_node, "arm,smc-id", &scmi_data->func_i= d) ) + { + printk(XENLOG_ERR "scmi: unable to read smc-id from DT\n"); + return -ENOENT; + } + + ret =3D scmi_dt_read_hyp_channel_addr(scmi_node, addr, &size); + if ( IS_ERR_VALUE(ret) ) + return -ENOENT; + + if ( !IS_ALIGNED(size, SCMI_SHMEM_MAPPED_SIZE) ) + { + printk(XENLOG_ERR "scmi: shmem memory is not aligned\n"); + return -EINVAL; + } + + return 0; +} + +static __init int scmi_probe(struct dt_device_node *scmi_node, const void = *data) +{ + u64 addr; + int ret; + struct scmi_channel *channel; + unsigned int n_agents; + scmi_msg_header_t hdr; + struct scmi_msg_base_attributes_p2a rx; + + ASSERT(scmi_node !=3D NULL); + + INIT_LIST_HEAD(&scmi_data.channel_list); + spin_lock_init(&scmi_data.channel_list_lock); + + if ( !acpi_disabled ) + { + printk(XENLOG_WARNING "scmi: is not supported when using ACPI\n"); + return -EINVAL; + } + + ret =3D scmi_check_smccc_ver(); + if ( ret ) + return ret; + + ret =3D scmi_dt_hyp_channel_read(scmi_node, &scmi_data, &addr); + if ( ret ) + return ret; + + scmi_data.dt_dev =3D scmi_node; + + channel =3D smc_create_channel(SCMI_BASE_AGENT_ID_OWN, scmi_data.func_= id, addr); + if ( IS_ERR(channel) ) + goto out; + + /* Mark as Xen management channel before collecting agent ID */ + channel->domain_id =3D DOMID_XEN; + + /* Request agent id for Xen management channel */ + ret =3D collect_agent_id(channel); + if ( ret ) + goto error; + + /* Save the agent id for Xen management channel */ + scmi_data.hyp_channel_agent_id =3D channel->agent_id; + + hdr.id =3D SCMI_BASE_PROTOCOL_ATTIBUTES; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + ret =3D do_smc_xfer(channel, &hdr, NULL, 0, &rx, sizeof(rx)); + if ( ret ) + goto error; + + n_agents =3D SCMI_FIELD_GET(SCMI_BASE_ATTR_NUM_AGENT, rx.attributes); + printk(XENLOG_DEBUG "scmi: Got agent count %d\n", n_agents); + ret =3D collect_agents(scmi_node); + if ( ret ) + goto error; + + ret =3D sci_register(&scmi_ops); + if ( ret ) + { + printk(XENLOG_ERR "SCMI: mediator already registered (ret =3D %d)\= n", + ret); + return ret; + } + + scmi_data.initialized =3D true; + goto out; + +error: + unmap_channel_memory(channel); + free_channel_list(); +out: + return ret; +} + +static const struct dt_device_match scmi_smc_match[] __initconst =3D { + DT_MATCH_PATH("/chosen/xen,config/scmi"), + { /* sentinel */ }, +}; + +DT_DEVICE_START(scmi_smc_ma, "SCMI SMC MEDIATOR", DEVICE_FIRMWARE) + .dt_match =3D scmi_smc_match, + .init =3D scmi_probe, +DT_DEVICE_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 095b1a23e3..30e46de6d7 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -329,6 +329,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); =20 #define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 #define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC 1 +#define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC_MA 2 =20 struct xen_arch_domainconfig { /* IN/OUT */ @@ -355,6 +356,8 @@ struct xen_arch_domainconfig { uint32_t clock_frequency; /* IN */ uint8_t arm_sci_type; + /* IN */ + uint8_t arm_sci_agent_id; }; #endif /* __XEN__ || __XEN_TOOLS__ */ =20 --=20 2.34.1 From nobody Mon Dec 15 21:46:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1761998261; cv=pass; d=zohomail.com; s=zohoarc; b=JaUteYcYW2qvQhuIIMHPx4MTqUo5dKriBhTsQ9OMDSytDbVx99fac/tKS1YZL4wkAXXvxVrI0y9DxRlo16aOvi+8/fQ/mYgUWszrVcDk4fMMtSKGduY494fI9SeUPCUPygnFUKdDjkV7aCRpUA2q5olbnGjMJeBYpd670aI37XE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761998261; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W6KaeGL/ozdDe1zYV8MxRWrxwFnXOEXM0wJwDhyqRUw=; b=PIAY3z6W34p8mhQDRtkiTrSnXCovqanL9G6zEvVSjGmz5P0N3FRxRIOupJcWb2cVZhYZbCYPL2nqaSYRnRfVL8IUtzQ9tOdF84IjdU33j3RC40LuZg/XeJAIFhjetHHkAx1Fjnp5UYC05W6i8V/Py3GbYkDA+uuiFUalqCTyMY4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761998261358355.56067711111666; Sat, 1 Nov 2025 04:57:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1154896.1484579 (Exim 4.92) (envelope-from ) id 1vFAEJ-0003Mc-BV; Sat, 01 Nov 2025 11:57:11 +0000 Received: by outflank-mailman (output) from mailman id 1154896.1484579; Sat, 01 Nov 2025 11:57:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vFAEJ-0003MS-7q; Sat, 01 Nov 2025 11:57:11 +0000 Received: by outflank-mailman (input) for mailman id 1154896; Sat, 01 Nov 2025 11:57:10 +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 1vFAEI-0002Ar-2y for xen-devel@lists.xenproject.org; Sat, 01 Nov 2025 11:57:10 +0000 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazlp170120005.outbound.protection.outlook.com [2a01:111:f403:c200::5]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e4575ee5-b719-11f0-980a-7dc792cee155; Sat, 01 Nov 2025 12:57:08 +0100 (CET) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by DBBPR03MB7130.eurprd03.prod.outlook.com (2603:10a6:10:20e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.16; Sat, 1 Nov 2025 11:56:58 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc%5]) with mapi id 15.20.9275.013; Sat, 1 Nov 2025 11:56:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: e4575ee5-b719-11f0-980a-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ii4x2NAUlEgfK30z/jJSSS69ocZa7VVPcIe9O/7HUqzCAqeiQUS6JdlKE9Tt/yTlnS4JcShtTtODFFEk5cam88Q2v4E/7IvoMuNGnLZXgDSSCWiIGuloe/5uel0f5zmzHFDW3PtxiZ9lmKV9dfdmlMWa3mRoyICPkA28idY4UeBNR3oFXHuGXHU3L70+blJT3VtxeXCsw9SsXKkJgGIwDf0Nh/Y8iwSLgWwkWVQ5Bp4un9PcStglywObgF3P+R6ukXo2HxaxP3y9oQ+aJkuUDxxUxiATg9kmBEcSPGZUGc3yralIE20iTsbhUHYFY05Ka+81ek0PnBFEsBs09q99SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=W6KaeGL/ozdDe1zYV8MxRWrxwFnXOEXM0wJwDhyqRUw=; b=niC07Bied4WSJMKG5xMuEMoQk4WZlDvQVd2kwiQ6V0Y/kgk61Ur7sBxgSnhI/JYlttXNPXuA8ll9TH2n/luZ4nPwZq+WNyv3ICRNR94EPTaHXCAcAGE7ggtfdT2ulBtyaEQ+KNmHMDXq8Y3ZuRyGwH95UYUP0JsqeCpPfWPfWJkSBb5HnhZFywUgRFZpmK+mVPTXzYDKcMDki6YRVGM8uS76ZoDCHV43T7HuUif1CVZEZl0ch6Sqls5VTvF/VXuekdNNcdVmQ9f2wpWTWphBhY7o86snvu/7jgsc74ESFFy2Zxg/asHf60QSJ+DMZvjlRtQxKnNXSrvvUKkZHg8P7w== 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=W6KaeGL/ozdDe1zYV8MxRWrxwFnXOEXM0wJwDhyqRUw=; b=J3sD/UdrKonMFV5bbBn+ywAqAN8miYW/KS6Q5KeT88kGnqB1y4bEv5S+XxKi+UJsQ1gkk7MtmNsento2107yv0BibwD6jed6X7N+FBKr+6zR6gGLCIC1Vk+llpwewOHSvCzjsvb7bO7r6CwkJXV4vbeD+Onx5qbxAgO/bGj1blYqj0TkVDPQLjbRn1rNJB7xmcrWbY3fzeYnUzDAbXoHbt/Il1fo9FK46K3PrfG+SlGHhSnUv/TC1eOs2XYmZ6LeLkrOHYZ1POw4r5DRPYNsVY2yk3DFASJsFo4DwibIgAVdLd2Ulh0pugIeFHTBizLxWAMh/G3Jya0Bd2iFzTxiuA== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko , Oleksii Moisieiev Subject: [PATCH v6 5/5] docs: arm: add SCI SCMI SMC multi-agent driver docs Thread-Topic: [PATCH v6 5/5] docs: arm: add SCI SCMI SMC multi-agent driver docs Thread-Index: AQHcSyag7wGCc3+7TESSMpmt+RnGqw== Date: Sat, 1 Nov 2025 11:56:58 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAVPR03MB8946:EE_|DBBPR03MB7130:EE_ x-ms-office365-filtering-correlation-id: 969c4652-0190-4213-bf08-08de193dc2cb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?KUONrZfVyNXWEzj9Tq/jo9DyBzyFip4n3x9hVUUb+3qM857LCsref1ZTB4?= =?iso-8859-1?Q?9vNeIiKSPUujNGoZMH7z4z5mREhAMKo/GaKDJqgGVAA9P3+FsoYvV56kM/?= =?iso-8859-1?Q?M0E+eve3djhgqpzrXdjXI/D28ESM0uhFEaItRUuOfCgiaRVc6HFX9+EOKU?= =?iso-8859-1?Q?a08pL3N2rEmj4s807vsThknIYljSWBq/U8NwPH8nUimEz/IcKu8qLwiEvY?= =?iso-8859-1?Q?4oXRR5ur/yNMtn1oCJhhM0XPCsCPSI89eB9JcN2ybEd6l5rIKc5MiP+is5?= =?iso-8859-1?Q?FyFvxveLXyun3h/TGveMnvyC6is5sJINilix4LbEPJR2K/Y5JHxeUrxaIJ?= =?iso-8859-1?Q?oQEG9b/efhuFO3G643t+DtHNwiWmsPLbZDo/NiIc+gGxFdS9gm2kknEV1u?= =?iso-8859-1?Q?A9wQHgs5BG/UYpCfIACRn99DlAdOs9Wn4yhr1+4GN6xZRG0/elzKpEimqi?= =?iso-8859-1?Q?0WECbhAIAzjvgUEQYcq7HC8gwDkbObGUUylkrtVhEcBdjHcQc84BZ/6HJr?= =?iso-8859-1?Q?Bdjc+j83DL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IQH?= =?iso-8859-1?Q?gPdo3B6pKyDh+kqA082723lUhhgkZU/MfSG47YMzHkyFtiVddkF0O2yGho?= =?iso-8859-1?Q?tVnXBYXkmnsa0Hqw9meCi66ksAFcBlpCrEGTdIeSI+PDa8O7aHSi4mgKK5?= =?iso-8859-1?Q?R98hD9ZIN3So2IbqG0agkNEf2OyG?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAVPR03MB8946.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(38070700021);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?aKl4K1WD8XPYl+Z5v25mu2ClPqn4S27lQgIWXNnNevGwzV/Rq0rMggrigP?= =?iso-8859-1?Q?vBCYiL4TYsdva6qmc03yWBCIl/k4KfO+lECwA4Fk/KVYZd1VKafaDDa5q5?= =?iso-8859-1?Q?2WAROFHdHW2yRdyKvX0MRhUe4DlmHiULD8e7xDCjyRt1BFsiJiqT0jegO6?= =?iso-8859-1?Q?nfA7Q7xVjCiVz3l6f5SEAJFdml5EM4aC9pfqAnw+DpBr5M1UWvtnUh+t72?= =?iso-8859-1?Q?DROl1kayt53+b6lvW/5KDsGVn0A4s/LruPvxhISPX/c9UGUx7noOUCb9ok?= =?iso-8859-1?Q?yQLGMh2id/euXJoixlQ5pysLT8S1k2Y8DwMFDrHq4H0rdKUJq+wThTFPYB?= =?iso-8859-1?Q?rmhNBKqN80iDSCrE7fckVC3xk88j3aUBPXni7dXbqVtSJLLZg+F2Us/LBM?= =?iso-8859-1?Q?LyEBadU7m972QNHN4K6WYBJgYU2Kkz9+RFOLgGND6+vOnq7RtO3/JuDAkL?= =?iso-8859-1?Q?mlAotsqSWGm6b4feI1PjLSHXDOSB+qgHPsHSjF6G7NxsX15AD4oc3pFVax?= =?iso-8859-1?Q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VXVA7/dg51Jr?= =?iso-8859-1?Q?FzoP7QnDTXSe6W5I0yoME5Q0QaRFrr5jI9ZaCz97z5XkeNCcJ7NUM7O4Qj?= =?iso-8859-1?Q?gYz7HwmdI4AbDovEtXDZH999Jmc5PyJerZigFYFjZGxuymDEcihJbHKVT5?= =?iso-8859-1?Q?Uxk1ye7HEwVbNLxjSxiBw5Uoq5y4Fx/YLf/GknFlwPH8xH1QTna+z5hQ4+?= =?iso-8859-1?Q?vtKhJ/iEEW+QIL7pLzr0ahLsFPgdnP3ZyRiLblFWBbto/ndVY5MGAxWQ?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAVPR03MB8946.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 969c4652-0190-4213-bf08-08de193dc2cb X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2025 11:56:58.4662 (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: A5d7Rgj9+YczjHgbVsAvsHvFlycZ3AQwchwpGnXbXZT2TqoqlDJSrTZj36yX8E/KI+jNBd/kt/FfWIfaQLJuelG3glYiw0ZcINRVoQnG/Xo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7130 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1761998263103154100 Content-Type: text/plain; charset="utf-8" From: Grygorii Strashko Add SCI SCMI SMC multi-agent driver documentation. It includes a detailed description of the SCMI multi-agent driver. This document explains the driver's functionality, configuration, and the compilation process. The Xen SCMI multi-agent driver is designed to provide SCMI access to system resources from different domains. Signed-off-by: Grygorii Strashko Signed-off-by: Oleksii Moisieiev --- Changes in v6: - remove all HVC mentions from the multi-agent doc - update sci-agent-id parameter description in the documentation - add missing Sign-of - minor fixes across the document Changes in v5: - rework multi-agent driver to leave Host Device-tree unmodified .../arm/firmware/arm-scmi.rst | 341 ++++++++++++++++++ 1 file changed, 341 insertions(+) diff --git a/docs/hypervisor-guide/arm/firmware/arm-scmi.rst b/docs/hypervi= sor-guide/arm/firmware/arm-scmi.rst index d9698f4e4b..630965fef3 100644 --- a/docs/hypervisor-guide/arm/firmware/arm-scmi.rst +++ b/docs/hypervisor-guide/arm/firmware/arm-scmi.rst @@ -36,6 +36,8 @@ The below sections describe SCMI support options availabl= e for Xen. =20 | [1] `Arm SCMI `_ | [2] `System Control and Management Interface (SCMI) bindings `_ +| [3] `Generic Domain Access Controllers bindings `_ + =20 Simple SCMI over SMC calls forwarding driver (EL3) ------------------------------------------------------ @@ -189,3 +191,342 @@ except explicitly enabling SCMI with "arm_sci" xl.cfg= option. -> xen,reg =3D <0x0 0x47ff0000 0x0 0x1000 0x0 0x22001000>; -> xen,force-assign-without-iommu; }; + +SCMI SMC multi-agent driver (EL3) +------------------------------------- + +The SCMI SMC multi-agent driver enables support for ARM EL3 Trusted Firmwa= re-A (TF-A) which +provides SCMI interface with multi-agent support, as shown below. + +:: + + +-----------------------------------------+ + | | + | EL3 TF-A SCMI | + +-------+--+-------+--+-------+--+-------++ + |shmem1 | |shmem0 | |shmem2 | |shmemX | + +-----+-+ +---+---+ +--+----+ +---+---+ + smc-id1 | | | | + agent1 | | | | + +-----v--------+---------+-----------+----+ + | | | | | + | | | | | + +--------------+---------+-----------+----+ + smc-id0 | smc-id2| smc-idX| + agent0 | agent2 | agentX | + | | | + +----v---+ +--v-----+ +--v-----+ + | | | | | | + | Dom0 | | Dom1 | | DomX | + | | | | | | + | | | | | | + +--------+ +--------+ +--------+ + +The EL3 SCMI multi-agent firmware is expected to provide SCMI SMC shared-m= emory transport +for every Agent in the system. The SCMI Agent transport channel defined by= pair: + +- smc-id: SMC function id used for Doorbell +- shmem: shared memory for messages transfer, **Xen page aligned**. + Shared memory is mapped with the following flags: MT_DEVICE_nGnRE and _P= AGE_DEVICE, indicating that this + memory is mapped as device memory. + +The following SCMI Agents are expected to be defined by SCMI FW to enable = SCMI multi-agent functionality +under Xen: + +- Xen management agent: trusted agents that accesses to the Base Protocol = commands to configure + agent specific permissions +- OSPM VM agents: non-trusted agent, one for each Guest domain which is a= llowed direct HW access. + At least one OSPM VM agent has to be provided by FW if HW is handled onl= y by Dom0 or Driver Domain. + +The EL3 SCMI FW is expected to implement following Base protocol messages: + +- BASE_DISCOVER_AGENT (optional if agent_id was provided) +- BASE_RESET_AGENT_CONFIGURATION (optional) +- BASE_SET_DEVICE_PERMISSIONS (optional) + +The number of supported SCMI agents and their transport specifications are= SCMI FW implementation +specific. + +Compiling with multi-agent support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To build with the SCMI SMC multi-agent driver support, enable Kconfig opti= on: + +:: + + CONFIG_SCMI_SMC_MA + + +Driver functionality +^^^^^^^^^^^^^^^^^^^^ + +The SCI SCMI SMC multi-agent driver implements following functionality: + +- The driver is initialized based on the ``xen,config`` node under ``chose= n`` + (only one SCMI interface is supported), which describes the Xen manageme= nt + agent SCMI interface. + +.. code-block:: dts + + scmi_shm_1: sram@47ff1000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff1000 0x0 0x1000>; + }; + scmi_xen: scmi { + compatible =3D "arm,scmi-smc"; + arm,smc-id =3D <0x82000002>; <--- Xen management agent smc-id + #address-cells =3D < 1>; + #size-cells =3D < 0>; + #access-controller-cells =3D < 1>; + shmem =3D <&scmi_shm_1>; <--- Xen management agent shmem + }; + +- The driver obtains Xen specific SCMI Agent's configuration from the Host= DT, probes Agents and + builds SCMI Agents list. The Agents configuration is taken from "scmi-se= condary-agents" + property where first item is "arm,smc-id", second - "arm,scmi-shmem" pha= ndle and third is + optional "agent_id": + +.. code-block:: dts + + chosen { + ranges; <--- set default ranges so address can be translated when pa= rsing scmi_shm node + xen,config { + ranges; <--- set default ranges so address can be translated when = parsing scmi_shm node + scmi-secondary-agents =3D < + 0x82000003 &scmi_shm_0 0 + 0x82000004 &scmi_shm_2 2 + 0x82000005 &scmi_shm_3 3 + 0x82000006 &scmi_shm_4 4>; + #scmi-secondary-agents-cells =3D <3>; <--- optional, default 3 + + scmi_shm_0 : sram@47ff0000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff0000 0x0 0x1000>; + }; + + scmi_shm_2: sram@47ff2000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff2000 0x0 0x1000>; + }; + scmi_shm_3: sram@47ff3000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff3000 0x0 0x1000>; + }; + scmi_shm_4: sram@47ff4000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff4000 0x0 0x1000>; + }; + + // Xen SCMI management channel + scmi_shm_1: sram@47ff1000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff1000 0x0 0x1000>; + }; + + scmi_xen: scmi { + compatible =3D "arm,scmi-smc"; + arm,smc-id =3D <0x82000002>; <--- Xen management agent smc-id + #address-cells =3D < 1>; + #size-cells =3D < 0>; + #access-controller-cells =3D < 1>; + shmem =3D <&scmi_shm_1>; <--- Xen management agent shmem + }; + }; + }; + + /{ + // Host SCMI OSPM channel - provided to the Dom0 as is if SCMI ena= bled for it + scmi_shm: sram@47ff1000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff1000 0x0 0x1000>; + }; + + firmware { + scmi: scmi { + compatible =3D "arm,scmi-smc"; + arm,smc-id =3D <0x82000003>; <--- Host OSPM agent smc-id + #address-cells =3D < 1>; + #size-cells =3D < 0>; + shmem =3D <&scmi_shm>; <--- Host OSPM agent shmem + + protocol@X{ + }; + }; + }; + }; + + This approach allows defining multiple SCMI Agents by adding Xen-specifi= c properties under + the ``/chosen`` node to the Host Device Tree, leaving the main part unch= anged. The Host DT + SCMI channel will be passed to Dom0. + + The Xen management agent is described as a ``scmi_xen`` node under the `= `/chosen`` node, which + is used by Xen to control other SCMI Agents in the system. + + All secondary agents' configurations are provided in the ``scmi-secondar= y-agents`` property with + an optional ``agent_id`` field. + + The ``agent_id`` from the ``scmi-secondary-agents`` property is used to = identify the agent in the + system and can be omitted by setting ``#scmi-secondary-agents-cells =3D = <2>``, so the Secondary + Agents configuration will look like this: + +... code-block:: dts + + chosen { + xen,config { + scmi-secondary-agents =3D < + 0x82000003 &scmi_shm_0 + 0x82000004 &scmi_shm_2 + 0x82000005 &scmi_shm_3 + 0x82000006 &scmi_shm_4>; + #scmi-secondary-agents-cells =3D <2>; + }; + } + + In this case, Xen will use the ``SCMI_BASE_DISCOVER_AGENT`` call to disc= over the ``agent_id`` + for each secondary agent. Providing the ``agent_id`` in the ``scmi-secon= dary-agents`` property + allows skipping the discovery call, which is useful when the secondary a= gent's shared memory is + not accessible by Xen or when boot time is important because it allows s= kipping the agent + discovery procedure. + +.. note:: + + Note that Xen is the only one entry in the system which need to know a= bout SCMI multi-agent support. + +- The driver implements the SCI subsystem interface required for configuri= ng and enabling SCMI + functionality for Dom0/hwdom and Guest domains. To enable SCMI functiona= lity for guest domain + it has to be configured with unique supported SCMI Agent_id and use corr= esponding SCMI SMC + shared-memory transport ``[smc-id, shmem]`` defined for this SCMI Agent_= id. + +- Once Xen domain is configured it can communicate with EL3 SCMI FW: + + - zero-copy, the guest domain puts/gets SCMI message in/from shmem; + - the guest triggers SMC exception with agent "smc-id" (doorbell); + - the Xen driver catches exception, do checks and synchronously forwards= it to EL3 FW. + +- the Xen driver sends BASE_RESET_AGENT_CONFIGURATION message to Xen manag= ement agent channel on + domain destroy event. This allows to reset resources used by domain and = so implement use-case + like domain reboot. + + +Configure SCMI for Dom0 +^^^^^^^^^^^^^^^^^^^^^^^ +The **"dom0=3Dsci-agent-id=3D"** parameter in the Xen comma= nd line is used to enable +SCMI functionality for Dom0. If not provided, SCMI will be disabled for Do= m0 and all SCMI nodes +removed from Dom0 DT. + +Example: **dom0=3Dsci-agent-id=3D0** to enable SCMI with agent ID 0 for Do= m0. + +Xen utilizes Host DT SCMI node to configure Dom0 SCMI Agent so the device-= tree remains unchanged +except for the Xen specific properties under ``/chosen`` node. If Xen devi= ce-tree doesn't include +``/firmware/scmi`` node or it's disabled, the Dom0 SCMI Agent will not be = configured. + +.. note:: + + The **sci-agent-id** value should match the ``func_id`` and ``shmem`` = in the ``/firmware/scmi`` node + to set the correct Dom0 SCMI Agent. + +Configure SCMI for for guest domain with toolstack +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* In domain's xl.cfg file add **"arm_sci"** option as below + +:: + + arm_sci =3D "type=3Dscmi_smc_multiagent,agent_id=3D2" + +* In domain's xl.cfg file enable access to the "arm,scmi-shmem" which shou= ld correspond + assigned "agent_id" for the domain, for example: + +:: + + iomem =3D [ + "47ff2,1@22001", + ] + +.. note:: It's up to the user to select guest IPA for mapping SCMI shared-= memory. + +* Add SCMI nodes to the Driver domain partial device tree as in the below = example. + The "arm,smc-id" should correspond assigned agent_id for the domain: + +.. code:: + + passthrough { + scmi_shm_0: sram@22001000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x22001000 0x0 0x1000>; + }; + + firmware { + compatible =3D "simple-bus"; + scmi: scmi { + compatible =3D "arm,scmi-smc"; + arm,smc-id =3D <0x82000004>; + shmem =3D <&scmi_shm_0>; + ... + } + } + } + +**Device specific access control** + +The XEN SCMI SMC multi-agent driver performs "access-controller" provider = function in case +EL3 SCMI FW implements SCMI "4.2.1.1 Device specific access control" and p= rovides the +BASE_SET_DEVICE_PERMISSIONS command to configure the devices that an agent= s have access to. +The Host DT SCMI node should have "#access-controller-cells=3D<1>" propert= y and DT devices should +be bound to the SCMI node using Access Controllers bindings [3]. + +For example: + +.. code-block:: dts + + &i2c1 { + access-controllers =3D <&scmi 0>; + }; + +Use domain's xl.cfg file **"dtdev"** property to assign SCMI devices from = toolstack to the guest: + +:: + + dtdev =3D [ + "/soc/i2c@e6508000", + ] + +.. note:: + + xl.cfg:"dtdev" need contain all nodes which are under SCMI management = (not only those which are + behind IOMMU) and passed-through to the guest domain. + +Configure SCMI for predefined domains (dom0less) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* add "xen,sci_type" and "xen,sci-agent-id" properties for required DomU (= "xen,domain") node + +:: + + xen,sci_type=3D"scmi_smc_multiagent" + xen,sci-agent-id=3D2 + +* add scmi nodes to the Driver domain partial device tree the same way as = above (toolstack case) and + enable access to the "arm,scmi-shmem" according to the dom0less document= ation. For example: + +.. code-block:: dts + + scmi_shm_0: sram@22001000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x00 0x22001000 0x00 0x1000>; + -> xen,reg =3D <0x0 0x47ff0000 0x0 0x1000 0x0 0x22001000>; + -> xen,force-assign-without-iommu; + }; + +* For SCMI device access control configure pass-through devices in the gue= st partial DT according to + the dom0less documentation and ensure that devices SCMI management has "= xen,path" property set: + +.. code-block:: dts + + i2c@e6508000 { + ... + reg =3D <0x00 0xe6508000 0x00 0x1000>; + -> xen,path =3D "/soc/i2c@e6508000" + -> xen,reg =3D <0x0 0xe6508000 0x0 0x1000 0x0 0xe6508000>; + -> xen,force-assign-without-iommu; + }; --=20 2.34.1