From nobody Fri Oct 31 09:46:44 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=1747669888; cv=pass; d=zohomail.com; s=zohoarc; b=meMjmxRnoR1OcDhzewHiliZ+aUQMsG9lHkY9Yl5EEyY4cc8DzHS+9S+jub6pU+ZJY5c4ku0gNOHNMibe6XH1tjdw0qTfeBBc6aWXkNqAgudTGSBwn12a42LPM/0ltz6QyAlssMc9WXrEb7+jjtakUaApDEsdZoWYNtNrM1sovKk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669888; 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=GuRaKSb2E1086xvD0ZVG5GfhbsL6SY92mOveYINGGu8=; b=fEKlrFolaVPoQFRfTKWB4VFntEasjPmX+TP7eu2B+3WhdmjaNV/BcnCXgbCfmXwna6E4KkS38R0pyn7imYS0dPhdYaGXzZ2gVT0eIIHu0rDfM0WjmparyT5tXXEi0k4dAHKLArwnZcZTDuxxSlgkS+cGFjTaTG46w/m6dfhJ6Nc= 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 174766988828779.82105256208592; Mon, 19 May 2025 08:51:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989962.1373936 (Exim 4.92) (envelope-from ) id 1uH2le-0005ck-Bb; Mon, 19 May 2025 15:51:06 +0000 Received: by outflank-mailman (output) from mailman id 989962.1373936; Mon, 19 May 2025 15:51: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 1uH2le-0005bx-8D; Mon, 19 May 2025 15:51:06 +0000 Received: by outflank-mailman (input) for mailman id 989962; Mon, 19 May 2025 15:51: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 1uH2ld-00055d-EW for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:05 +0000 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on20612.outbound.protection.outlook.com [2a01:111:f403:260c::612]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 11047c03-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:51:03 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50: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%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50: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: 11047c03-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i9e9pUtkNdyQQ2vuBZGPSTatUP4QVa4nureL9CDHBZosASAjN25rFgyTfASzPCZgyd/xefeaSvm7u5UQDRwcJF5nBrFTAOZz7ccJf9Efws3e4x2PNghKeSf92e74cFBkN1y+t7ZGQUUcqkgHgFk/7tI6yBQpIlELT8FGEQsUm+XghjehAweZY6ot054Z76MS7Ow/WvEORl/HSXOj/F7QvF66C29G1YKXhH53/VUplr2f9z8vpv8s2AGXNVgsqjOhS/3W7UYaan6RoOG7fZhD/gBhYwlLIrLaPOLJHayyMMMpQTfGE+qh3Foru2xzoURSS45CUemnz7grMNJoByQ7Pg== 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=GuRaKSb2E1086xvD0ZVG5GfhbsL6SY92mOveYINGGu8=; b=uyg0PNph68ansj5aYWlV03+TtFjBeudxE+QDDTWqLYcr8OUS8kt27eXHOXUSfpS6BdyfKaV2kSFCgfzmcB01480ptuvkJSX1r9KZLXZcnboNIriBRec5rGAXdT3Vs6u7fdaOD8REY7f3fQQpaziuGYLCpBXg7T2fDlQRmK9s+Cf8bGvD9ad/ywpJFxoQUrCuDSTnijeMEpuEbmSWpypcaLojkbR+RQvCP0wX1PxEU9IKSBsqDS7KA49vzPax7ah82S8KNXS4MMh5UEdYdAbOc6fmbEjf3DnVP3LKZgMbVTRWgKu/vvO31vMIiqxbdalSL4xtsRIOTQgvKR7pRM2tww== 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=GuRaKSb2E1086xvD0ZVG5GfhbsL6SY92mOveYINGGu8=; b=Z7SH5iP6W88/OMHeKK2oDQuHY1yd3oX59p1ybCeZVSq/XGlUbyPqlBoRGROa+MaRoflU/slQWDdHI42IlJWSrF3VOQBkftIxlLBsqxiBNzD/K/0hNs9Tww3xKqoA0YoVtD08ySRt+zrfAaslUF9UKuxoPQKP2hQkz5RqeuXeGG0qN5e0eVsDa8SBybue+qmOguM45q8tJuh8HSM5QzA5EDktkryEjy1lo4+BEpTMDyEVv4U2wxKJwkGRW7R8BMyRfshDupxnORUcaW63mmV9j8vrEdoQOGqpVzPba7/+wD0fs0nwCiGqTLxiAPDl0aS4wWi2OAf9PF71N6YFsgcSVw== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 1/8] xen/arm: add generic SCI subsystem Thread-Topic: [RFC PATCH v4 1/8] xen/arm: add generic SCI subsystem Thread-Index: AQHbyNXOqELJ9X0XaEyNPLqmNXa/uQ== Date: Mon, 19 May 2025 15:50:56 +0000 Message-ID: <48b70b34c576d8dfcf6156d1997bc3c0f7cbbceb.1747669845.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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: 38b27eff-4e97-4ad9-f4cb-08dd96ecf1a4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?B4JgUr7hUJy44i0uFVHkp60oUcZIbSu3q8qfVpGGk1aGqcqIv1Cq/Hly6r?= =?iso-8859-1?Q?Vn1OInDADFVJR8jEDBMefemod8vVafktj0vv6QOY/9zEVfLonY3eQ+OHbJ?= =?iso-8859-1?Q?t4gHx5ShIxxqXMzoXtg9xqfwKu2eFa7+q+h+pkyG1Sggq90J7LxwdMGZ3i?= =?iso-8859-1?Q?6Xv1e8blGadjOkeVhFan8YWlWIqOpllazrZg0GnV8QDQ/eEbCZ1ZT9jaoQ?= =?iso-8859-1?Q?+BbuLkKEeK5/1auticE3IoZqF+tdguX9oTXhCFcSsdjRN0AFBlCJSQOEEw?= =?iso-8859-1?Q?n/CMszWq/HBkYPcM2sSvIg+SQm98n4ujnDMV82854udbNOlTH/bwzEn9f5?= =?iso-8859-1?Q?5GDehtuC41qTNbG3MmlvrNDCHpjrNrmscFXGJGsG5hPWOoJEZeWY51DAOZ?= =?iso-8859-1?Q?5QcAP16bDOCgjMar2CdTjDft0NjyNfOiDA0JVZkff+znWr+kifiVX0oTYZ?= =?iso-8859-1?Q?5CbialbivaLiyYYg3/Lw8PvvbOV9cNZrKj6qcEXefuiJRSh8HzOX729WbR?= =?iso-8859-1?Q?ZqSS3szz9+VpF+ua4RKfpYZhBmHHJLPWIKDmEjQ1O91XqhXH75w4BrAvo9?= =?iso-8859-1?Q?6GEf448DziHuG2NFkZU0xzqR8yubdSObSvXde8tWhyr7QWFvDS+BcL6Y+2?= =?iso-8859-1?Q?UhOTxLWaqG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eH7366DmwX?= =?iso-8859-1?Q?sV/aVEs=3D?= 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)(376014)(366016)(7416014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?pXfQZC2pgA2DrlsMeS/Wc18g7eAQRGE9Zk5vDvHxZKUIH5Q3Zzvr/K7Vds?= =?iso-8859-1?Q?OlJehgGEMUAJ/L5rZYARYW9jVcVeEDcyzWKNUQHTTS/3gagRW/h4ss8HNT?= =?iso-8859-1?Q?DjgM0rrQlSKsPkngcT0gaYJXpn+8rwJ7uX3bldXtOhVeqWKKFySYnqPetK?= =?iso-8859-1?Q?P8oBYdhGaGlz8EhNzScgVHwxXmIHcHIYZKlH9ggulR1FJSlYZK7UlNte1P?= =?iso-8859-1?Q?ZBvfyA6qcB1c31soqJSWqutJC6H9zyjVl0073Yi5k7SHbjRvthNMgK2kCg?= =?iso-8859-1?Q?yvBZ4XjSw8bDUzKgWQKDCi15sdRsMPsaYEe1gYu/P5hCakzGRhhYhlnTSm?= =?iso-8859-1?Q?vl6UxdiqKDKkPkoi0GCuGSPtH3dmm1tI7CpCMEVy1NuBZ8+pN5lTSkfYoL?= =?iso-8859-1?Q?RpjHE1Z7iBoOrdEi3g9dIS6dX8FUEZJJ8F5zwcCUdVIUpfvSInyv6pH0XZ?= =?iso-8859-1?Q?eIHNWP5/4vlpmWWQ0d5ylNAJ8h+DrWh7tf5X4dfVFAC4tJDttWgWs/pDfm?= =?iso-8859-1?Q?f/CNzDzoWEduUBVaRaB+eeyQki3roFpypFgABdyFJqecSsZxdzFS2AhHrm?= =?iso-8859-1?Q?HeB6wl5cqzzLt7EknkvthecNX1/iVsEKTaNXRflbcxVG/Neo+jyJXMkpjr?= =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6LbrTAALvEpq4WMEb1C0qEz6Ix?= =?iso-8859-1?Q?II3yEJ8EgKvBUeutYZgqtrNNcRSC4N1Hd6na6FbiB13+ySJBjFzOakE2TJ?= =?iso-8859-1?Q?pCDAljM7qy2hKPsY9N3kRR0iZD2CvArLhw0NnkJ/1pct7KArXPhYXDLw?= =?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: 38b27eff-4e97-4ad9-f4cb-08dd96ecf1a4 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:56.1740 (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: JR021mEIK9xc+Alyw57gKDXyuu/TMWWbXxFG+JbS9Uyg5DjP0PINFmGfDtQ4hxFMjfWdj5RHe59u5fiL7GriPulCUD5D/W7tM5tsT6KMx+E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669889438116600 Content-Type: text/plain; charset="utf-8" This patch adds the basic framework for ARM SCI mediator. SCI is System Control Interface, which is designed to redirect requests from the Domains to ARM specific Firmware (for example SCMI). This will allow the devices, passed-through to the different Domains, to access to the System resources (such as clocks/resets etc) by sending requests to the firmware. ARM SCI subsystem allows to implement different SCI drivers to handle specific ARM firmware interfaces (like ARM SCMI) and mediate requests between the Domains and the Firmware. Also it allows SCI drivers to perform proper action during Domain creation/destruction which is vital for handling use cases like Domain reboot. This patch introduces new DEVICE_FIRMWARE device subclass for probing SCI drivers basing on device tree, SCI drivers register itself with DT_DEVICE_START/END macro. On init - the SCI drivers should register its SCI ops with sci_register(). Only one SCI driver can be supported. At run-time, the following SCI API calls are introduced: - sci_domain_sanitise_config() called from arch_sanitise_domain_config() - sci_domain_init() called from arch_domain_create() - sci_relinquish_resources() called from domain_relinquish_resources() - sci_domain_destroy() called from arch_domain_destroy() - sci_handle_call() called from vsmccc_handle_call() - sci_dt_handle_node() sci_dt_finalize() called from handle_node() (Dom0 DT) Signed-off-by: Oleksii Moisieiev Signed-off-by: Grygorii Strashko Reviewed-by: Stefano Stabellini --- Changes in v4: - fix SPDX-License - rename DEVICE_ARM_SCI DT device class to FIRMWARE_DEVICE - move XEN_DOMCTL_assign_device code in separate patch - Add documentation for SCI SCMI drivers MAINTAINERS | 6 + xen/arch/arm/device.c | 5 + xen/arch/arm/dom0less-build.c | 7 + xen/arch/arm/domain.c | 12 +- xen/arch/arm/domain_build.c | 8 + xen/arch/arm/firmware/Kconfig | 8 + xen/arch/arm/firmware/Makefile | 1 + xen/arch/arm/firmware/sci.c | 154 ++++++++++++++++++ xen/arch/arm/include/asm/domain.h | 5 + xen/arch/arm/include/asm/firmware/sci.h | 200 ++++++++++++++++++++++++ xen/arch/arm/vsmc.c | 3 + xen/include/asm-generic/device.h | 1 + xen/include/public/arch-arm.h | 4 + 13 files changed, 413 insertions(+), 1 deletion(-) create mode 100644 xen/arch/arm/firmware/sci.c create mode 100644 xen/arch/arm/include/asm/firmware/sci.h diff --git a/MAINTAINERS b/MAINTAINERS index c11b82eca9..f5e3c48b96 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -507,6 +507,12 @@ R: George Dunlap S: Supported F: xen/common/sched/ =20 +SCI MEDIATORS +M: Oleksii Moisieiev +S: Supported +F: xen/arch/arm/firmware/sci.c +F: xen/arch/arm/include/asm/firmware/sci.h + SEABIOS UPSTREAM M: Wei Liu S: Supported diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 5610cddcba..bdab96a408 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -13,6 +13,7 @@ #include #include =20 +#include #include =20 int map_irq_to_domain(struct domain *d, unsigned int irq, @@ -303,6 +304,10 @@ int handle_device(struct domain *d, struct dt_device_n= ode *dev, p2m_type_t p2mt, return res; } } + + res =3D sci_assign_dt_device(d, dev); + if ( res ) + return res; } =20 res =3D map_device_irqs_to_domain(d, dev, own_device, irq_ranges); diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 49d1f14d65..a09c4c4bd7 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include =20 @@ -321,6 +322,10 @@ static int __init handle_passthrough_prop(struct kerne= l_info *kinfo, return -EINVAL; } =20 + res =3D sci_assign_dt_device(kinfo->d, node); + if ( res ) + return res; + res =3D map_device_irqs_to_domain(kinfo->d, node, true, NULL); if ( res < 0 ) return res; @@ -970,6 +975,8 @@ void __init create_domUs(void) if ( !llc_coloring_enabled && llc_colors_str ) panic("'llc-colors' found, but LLC coloring is disabled\n"); =20 + d_cfg.arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + /* * The variable max_init_domid is initialized with zero, so here i= t's * very important to use the pre-increment operator to call diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 3ba959f866..652aeb7a55 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -694,7 +695,7 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) return -EINVAL; } =20 - return 0; + return sci_domain_sanitise_config(config); } =20 int arch_domain_create(struct domain *d, @@ -786,6 +787,9 @@ int arch_domain_create(struct domain *d, d->arch.sve_vl =3D config->arch.sve_vl; #endif =20 + if ( (rc =3D sci_domain_init(d, config)) !=3D 0 ) + goto fail; + return 0; =20 fail: @@ -846,6 +850,7 @@ void arch_domain_destroy(struct domain *d) domain_vgic_free(d); domain_vuart_free(d); free_xenheap_page(d->shared_info); + sci_domain_destroy(d); #ifdef CONFIG_ACPI free_xenheap_pages(d->arch.efi_acpi_table, get_order_from_bytes(d->arch.efi_acpi_len)); @@ -1039,6 +1044,7 @@ enum { PROG_p2m_root, PROG_p2m, PROG_p2m_pool, + PROG_sci, PROG_done, }; =20 @@ -1098,6 +1104,10 @@ int domain_relinquish_resources(struct domain *d) ret =3D relinquish_p2m_mapping(d); if ( ret ) return ret; + PROGRESS(sci): + ret =3D sci_relinquish_resources(d); + if ( ret ) + return ret; =20 PROGRESS(p2m_root): /* diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 7b47abade1..36d28b52a4 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -1888,6 +1889,9 @@ static int __init handle_node(struct domain *d, struc= t kernel_info *kinfo, return 0; } =20 + if ( sci_dt_handle_node(d, node) ) + return 0; + /* * The vGIC does not support routing hardware PPIs to guest. So * we need to skip any node using PPIs. @@ -1988,6 +1992,10 @@ static int __init handle_node(struct domain *d, stru= ct kernel_info *kinfo, if ( res ) return res; =20 + res =3D sci_dt_finalize(d, kinfo->fdt); + if ( res ) + return res; + /* * Create a second memory node to store the ranges covering * reserved-memory regions. diff --git a/xen/arch/arm/firmware/Kconfig b/xen/arch/arm/firmware/Kconfig index 817da745fd..fc7918c7fc 100644 --- a/xen/arch/arm/firmware/Kconfig +++ b/xen/arch/arm/firmware/Kconfig @@ -1,3 +1,11 @@ +config ARM_SCI + bool + depends on ARM + help + This option enables generic Arm SCI (System Control Interface) mediators + support. It allows domains to control system resources via one of + Arm SCI mediators drivers implemented in XEN, like SCMI. + menu "Firmware Drivers" =20 config SCMI_SMC diff --git a/xen/arch/arm/firmware/Makefile b/xen/arch/arm/firmware/Makefile index a5e4542666..71bdefc24a 100644 --- a/xen/arch/arm/firmware/Makefile +++ b/xen/arch/arm/firmware/Makefile @@ -1 +1,2 @@ +obj-$(CONFIG_ARM_SCI) +=3D sci.o obj-$(CONFIG_SCMI_SMC) +=3D scmi-smc.o diff --git a/xen/arch/arm/firmware/sci.c b/xen/arch/arm/firmware/sci.c new file mode 100644 index 0000000000..e1522e10e2 --- /dev/null +++ b/xen/arch/arm/firmware/sci.c @@ -0,0 +1,154 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Generic part of the SCI (System Control Interface) subsystem. + * + * Oleksii Moisieiev + * Copyright (c) 2025 EPAM Systems + */ + +#include +#include +#include +#include +#include + +#include + +static const struct sci_mediator_ops __read_mostly *cur_mediator; + +int sci_register(const struct sci_mediator_ops *ops) +{ + if ( cur_mediator ) + return -EEXIST; + + if ( !ops->domain_init || !ops->domain_destroy || !ops->handle_call ) + return -EINVAL; + + cur_mediator =3D ops; + + return 0; +}; + +bool sci_handle_call(struct cpu_user_regs *args) +{ + if ( unlikely(!cur_mediator) ) + return false; + + return cur_mediator->handle_call(args); +} + +int sci_domain_init(struct domain *d, struct xen_domctl_createdomain *conf= ig) +{ + if ( !cur_mediator ) + return 0; + + return cur_mediator->domain_init(d, config); +} + +int sci_domain_sanitise_config(struct xen_domctl_createdomain *config) +{ + if ( !cur_mediator ) + return 0; + + if ( !cur_mediator->domain_sanitise_config ) + return 0; + + return cur_mediator->domain_sanitise_config(config); +} + +void sci_domain_destroy(struct domain *d) +{ + if ( !cur_mediator ) + return; + + cur_mediator->domain_destroy(d); +} + +int sci_relinquish_resources(struct domain *d) +{ + if ( !cur_mediator ) + return 0; + + if ( !cur_mediator->relinquish_resources ) + return 0; + + return cur_mediator->relinquish_resources(d); +} + +bool sci_dt_handle_node(struct domain *d, struct dt_device_node *node) +{ + if ( !cur_mediator ) + return 0; + + if ( !cur_mediator->dom0_dt_handle_node ) + return 0; + + return cur_mediator->dom0_dt_handle_node(d, node); +} + +int sci_dt_finalize(struct domain *d, void *fdt) +{ + if ( !cur_mediator ) + return 0; + + if ( !cur_mediator->dom0_dt_finalize ) + return 0; + + return cur_mediator->dom0_dt_finalize(d, fdt); +} + +int sci_assign_dt_device(struct domain *d, struct dt_device_node *dev) +{ + struct dt_phandle_args ac_spec; + int index =3D 0; + int ret; + + if ( !cur_mediator ) + return 0; + + if ( !cur_mediator->assign_dt_device ) + return 0; + + while ( !dt_parse_phandle_with_args(dev, "access-controllers", + "#access-controller-cells", index, + &ac_spec) ) + { + printk(XENLOG_DEBUG "sci: assign device %s to %pd\n", + dt_node_full_name(dev), d); + + ret =3D cur_mediator->assign_dt_device(d, &ac_spec); + if ( ret ) + return ret; + + index++; + } + + return 0; +} + +static int __init sci_init(void) +{ + struct dt_device_node *np; + unsigned int num_sci =3D 0; + int rc; + + dt_for_each_device_node(dt_host, np) + { + rc =3D device_init(np, DEVICE_FIRMWARE, NULL); + if ( !rc && num_sci ) + { + printk(XENLOG_ERR + "SCMI: Only one SCI controller is supported. found seco= nd %s\n", + np->name); + return -EOPNOTSUPP; + } + else if ( !rc ) + num_sci++; + else if ( rc !=3D -EBADF && rc !=3D -ENODEV ) + return rc; + } + + return 0; +} + +__initcall(sci_init); diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index f1d72c6e48..fa0898b7cf 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -118,6 +118,11 @@ struct arch_domain #ifdef CONFIG_TEE void *tee; #endif +#ifdef CONFIG_ARM_SCI + bool sci_enabled; + /* ARM SCI driver's specific data */ + void *sci_data; +#endif =20 } __cacheline_aligned; =20 diff --git a/xen/arch/arm/include/asm/firmware/sci.h b/xen/arch/arm/include= /asm/firmware/sci.h new file mode 100644 index 0000000000..71fb54852e --- /dev/null +++ b/xen/arch/arm/include/asm/firmware/sci.h @@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Generic ARM SCI (System Control Interface) subsystem. + * + * Oleksii Moisieiev + * Copyright (c) 2025 EPAM Systems + */ + +#ifndef __ASM_ARM_SCI_H +#define __ASM_ARM_SCI_H + +#include +#include +#include +#include +#include + +#ifdef CONFIG_ARM_SCI + +struct sci_mediator_ops { + /* + * Called during domain construction. If it is requested to enable + * SCI support, so SCI driver can create own structures for the new do= main + * and inform firmware about new domain (if required). + * Mandatory. + */ + int (*domain_init)(struct domain *d, + struct xen_domctl_createdomain *config); + + /* + * Called during domain construction. The SCI driver uses + * it to sanitize domain SCI configuration parameters. + * Optional. + */ + int (*domain_sanitise_config)(struct xen_domctl_createdomain *config); + + /* + * Called during domain destruction, releases all resources, that + * were allocated for domain. + * Mandatory. + */ + void (*domain_destroy)(struct domain *d); + + /* + * Called during domain destruction to relinquish resources used + * by SCI driver itself and request resources releasing from firmware. + * Optional. + */ + int (*relinquish_resources)(struct domain *d); + + /* SMC/HVC Handle callback */ + bool (*handle_call)(struct cpu_user_regs *regs); + + /* + * Dom0 DT nodes handling callback so SCI driver can detect DT nodes it + * need to handle and decide if those nodes need to be provided to Dom= 0. + * Optional. + */ + bool (*dom0_dt_handle_node)(struct domain *d, struct dt_device_node *n= ode); + + /* + * SCI driver callback called at the end of Dom0 DT generation, so + * it can perform steps to modify DT to enable/disable SCI + * functionality for Dom0. + */ + int (*dom0_dt_finalize)(struct domain *d, void *fdt); + + /* + * SCI driver callback called when DT device is passed through to gues= t, + * so SCI driver can enable device access to the domain if SCI FW prov= ides + * Device specific access control functionality. + * Optional. + */ + int (*assign_dt_device)(struct domain *d, struct dt_phandle_args *ac_s= pec); +}; + + +static inline bool sci_domain_is_enabled(struct domain *d) +{ + return d->arch.sci_enabled; +} + +/* + * Register SCI subsystem ops. + * + * Register SCI drivers operation and so enable SCI functionality. + * Only one SCI driver is supported. + */ +int sci_register(const struct sci_mediator_ops *ops); + +/* + * Initialize SCI functionality for domain if configured. + * + * Initialization routine to enable SCI functionality for the domain. + * The SCI configuration data and decision about enabling SCI functionality + * for the domain is SCI driver specific. + */ +int sci_domain_init(struct domain *d, struct xen_domctl_createdomain *conf= ig); + +/* + * Sanitise domain configuration parameters. + * + */ +int sci_domain_sanitise_config(struct xen_domctl_createdomain *config); + +/* + * Destroy SCI domain instance. + */ +void sci_domain_destroy(struct domain *d); + +/* + * Free resources assigned to the certain domain. + */ +int sci_relinquish_resources(struct domain *d); + +/* + * SMC/HVC Handle callback. + * + * SCI driver acts as SMC/HVC server for the registered domains and + * does redirection of the domain calls to the SCI firmware, + * such as ARM TF-A or similar. + */ +bool sci_handle_call(struct cpu_user_regs *regs); + +/* + * Dom0 DT nodes handling function. + * + * Allows SCI driver to detect DT nodes it need to handle and decide if + * those nodes need to be provided to Dom0. + */ +bool sci_dt_handle_node(struct domain *d, struct dt_device_node *node); + +/* + * Dom0 DT generation finalize. + * + * Called at the end of Dom0 DT generation, so SCI driver can perform steps + * to modify DT to enable/disable SCI functionality for Dom0. + */ +int sci_dt_finalize(struct domain *d, void *fdt); + +/* + * Assign DT device to domain. + * + * Called when DT device is passed through to guest, so SCI driver can ena= ble + * device access to the domain if SCI FW provides "Device specific access + * control" functionality. + */ +int sci_assign_dt_device(struct domain *d, struct dt_device_node *dev); +#else + +static inline bool sci_domain_is_enabled(struct domain *d) +{ + return false; +} + +static inline int sci_domain_init(struct domain *d, + struct xen_domctl_createdomain *config) +{ + return 0; +} + +static inline int +sci_domain_sanitise_config(struct xen_domctl_createdomain *config) +{ + return 0; +} + +static inline void sci_domain_destroy(struct domain *d) +{} + +static inline int sci_relinquish_resources(struct domain *d) +{ + return 0; +} + +static inline bool sci_handle_call(struct cpu_user_regs *args) +{ + return false; +} + +static inline bool sci_dt_handle_node(struct domain *d, + struct dt_device_node *node) +{ + return false; +} + +static inline int sci_dt_finalize(struct domain *d, void *fdt) +{ + return false; +} + +static inline int sci_assign_dt_device(struct domain *d, + struct dt_device_node *dev) +{ + return 0; +} + +#endif /* CONFIG_ARM_SCI */ + +#endif /* __ASM_ARM_SCI_H */ diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c index 62d8117a12..51b3c02973 100644 --- a/xen/arch/arm/vsmc.c +++ b/xen/arch/arm/vsmc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -300,6 +301,8 @@ static bool vsmccc_handle_call(struct cpu_user_regs *re= gs) break; case ARM_SMCCC_OWNER_SIP: handled =3D handle_sip(regs); + if ( !handled ) + handled =3D sci_handle_call(regs); break; case ARM_SMCCC_OWNER_TRUSTED_APP ... ARM_SMCCC_OWNER_TRUSTED_APP_E= ND: case ARM_SMCCC_OWNER_TRUSTED_OS ... ARM_SMCCC_OWNER_TRUSTED_OS_END: diff --git a/xen/include/asm-generic/device.h b/xen/include/asm-generic/dev= ice.h index 1acd1ba1d8..e96c5558c2 100644 --- a/xen/include/asm-generic/device.h +++ b/xen/include/asm-generic/device.h @@ -18,6 +18,7 @@ enum device_class DEVICE_IOMMU, DEVICE_INTERRUPT_CONTROLLER, DEVICE_PCI_HOSTBRIDGE, + DEVICE_FIRMWARE, /* Use for error */ DEVICE_UNKNOWN, }; diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 24840eeaa6..55eed9992c 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -327,6 +327,8 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_TEE_OPTEE 1 #define XEN_DOMCTL_CONFIG_TEE_FFA 2 =20 +#define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 + struct xen_arch_domainconfig { /* IN/OUT */ uint8_t gic_version; @@ -350,6 +352,8 @@ struct xen_arch_domainconfig { * */ uint32_t clock_frequency; + /* IN */ + uint8_t arm_sci_type; }; #endif /* __XEN__ || __XEN_TOOLS__ */ =20 --=20 2.34.1 From nobody Fri Oct 31 09:46:44 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=1747669882; cv=pass; d=zohomail.com; s=zohoarc; b=JJ4TsXgJN/F+IA47WAY2SZ1tt/GQNJ8vKae/CY8vGbWP4DatGWvJZ6mT9/+KxhA3DD6UNNxydHY6vRvfkNyB9KWrpTyGhSPTa12jopEgYcuGguXzitqOQx1MY5A5hsQyuWor99Hd0V9QuVr6ODcghQJjLbpGieqNq7zRU1LU2dI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669882; 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=Fk5Gs0tS92nr5rjRn//mXLL1DtK3sxSAdDHVHneMlgQ=; b=LaPQpm3zjEfB/RQWkoKcVOp+BDBX8FTqY+Kui5exa+2WTd/TAzTTabjyeXEl4tsHibrXTIxqKbCQZNpjufjhPMOFJosFETFk2fXY6UsfwP3vPodL8oHUW9nsMFhk5RigC41Ke4NGp9h3pUoWhYo9/K7jJo7uEyhN8IkMADAx4E8= 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 1747669882600959.81570668417; Mon, 19 May 2025 08:51:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989960.1373921 (Exim 4.92) (envelope-from ) id 1uH2lb-0005Jb-N4; Mon, 19 May 2025 15:51:03 +0000 Received: by outflank-mailman (output) from mailman id 989960.1373921; Mon, 19 May 2025 15:51:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uH2lb-0005JR-Jq; Mon, 19 May 2025 15:51:03 +0000 Received: by outflank-mailman (input) for mailman id 989960; Mon, 19 May 2025 15:51:02 +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 1uH2la-00055d-Lh for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:02 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20625.outbound.protection.outlook.com [2a01:111:f403:260e::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1008bc5b-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:51:01 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50: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%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50: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: 1008bc5b-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nyLDAoIahHy3xrUhup8FivNBw6/vv1fgnmocpFcmatiuFnFFTbfOZk5//Ynf/ejappjOktwVhcv5V5c1GHKK0Dw/lKgsuJgCCcFvA8mygygUskMih0TlL1OAYCHTYMvqWzcsuNmm20YLfoA1EMJKMcdilJCctv1923ugi3lhLG9hLrSupuKLzranfGR310+LY1Mr618ueF4JPjrFuUz86daqncC5o55mjI/9wesi3hwPDymLPgO3ivR5xIGgi0xF5KSx9oC5qSU4L6Rc6ChMnXMBjgm1/zq3kK/1LAJtzH0QJ6PZniOx5UO15gKyvOSVdGr8WXjOUl3xM7auWfwKBw== 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=Fk5Gs0tS92nr5rjRn//mXLL1DtK3sxSAdDHVHneMlgQ=; b=PYEWSQpruE9CrzMnBu/nkOUGv3dg4+7+WGDyAjVnJbsIMNA2VFz55Z04eHvkSj04VC74cRtrzAn+TXRFcC556LnQlEKZKZg8RoKWlUGede6j15hiczJZUOH2gRhsHCyZjMmR4oVB8A+Ksd2u4QUk7SVic8p7FOcJo19jp42hXm8QWiyteLMpLTywdyzpdQPbnu808a0uM4hpf332tkoWaNoLFOVO+nheQtdWABzIRD22mMtfQj+L96ig+DqmWJJKfWr7Ea0XkoRiLrMbZAQqJYgSVR802byUeLJEcnFOpflLmSqRh0HhzeUQQnYI0EcxuZ/5cxxdCoCcEsjA+kajEA== 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=Fk5Gs0tS92nr5rjRn//mXLL1DtK3sxSAdDHVHneMlgQ=; b=CyzM5+tHsZu/GgQPVatc68oxjaAVk4gash6tLbEuR8+Vg0I0+5Db5u2MQV2DqmZer9QVXhFKxLF0jZT2pNGM/sxxY7u34OuRmgaJbJCEt85hRibOhwFqc0jtCkEfv1o6qVDl4tVw0nLfdH8aiSECtbU+nhLOmd639b/szx8RLOZXQAFadr5nqfe66Ryvt+PaUKMuWr00Jgi+THtoiQIYX3JnDzDH8nq61ZxOTLC1MWAHiQxuCOUKE1UgUfPX4K1jLWddl/Y7MKxfRnSVioj1zTI2d8ZVGK+S2tmXDmwY4VWCFhG4QqRapqtNSSf4QjN7OEpCeIIaMik9U2HE7gQVbg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 2/8] xen/arm: scmi-smc: update to be used under sci subsystem Thread-Topic: [RFC PATCH v4 2/8] xen/arm: scmi-smc: update to be used under sci subsystem Thread-Index: AQHbyNXPRF0tCFj/sEGmRLZ+kuwLjw== Date: Mon, 19 May 2025 15:50:56 +0000 Message-ID: <21bdecf961b60fb0094b1f722444a45228aef878.1747669845.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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: 2d345ae3-acfd-44a4-d9f7-08dd96ecf1cb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?ZZEf7nhsvJc4orGtNmwSE3GYCpExG7xmMdr/9yp0koxdtuO4QMahIH4/o+?= =?iso-8859-1?Q?LnyPJA8ZChNu1FbOQ5WqdM4X1JsXqIWFoEDzA5vfCUhiBheP1ume79o6me?= =?iso-8859-1?Q?QCst1GXZxCXG4bhP7Kbr8CvcVFJE+p61RvnKXZjDt/gO45qfa9JlJ+pHC6?= =?iso-8859-1?Q?txMBr2s3iBI73qJTMN1gpKw8kt8es5FEKCNVjgKp/0wzAwbTH6T8TnAs8U?= =?iso-8859-1?Q?TGGSCcNi9jq8D9SIOFR14A1kdqNTe2kaRS9h1GypkUhN+gEUvC8YUwqqdE?= =?iso-8859-1?Q?e5XdEJWX9NofgcQAV0aSk8/Z713yOZPJp/OtpKN4ALJy55Ithqa2Re2/tF?= =?iso-8859-1?Q?tJXVfy1GpvYfqYNnFU6pK7icMJ0/7i9M7HQK37qvqTo5gtfdXTryLcU3xs?= =?iso-8859-1?Q?0ORi/wvBwOaejRknAZ6kCJOYEbW6KlSUmHOLZmi71mW6oKBusZxqPjPBYT?= =?iso-8859-1?Q?ertn3/1CYTK+3HfvSffQATOjtc2PHzC0z8dEx63qBwzjjDDKRqDyZn3Msy?= =?iso-8859-1?Q?8vWnySqiBmp5bcLfWRMH+As0tj+/kpgmCPcuALM3pbvNpHVXfzHnaeishQ?= =?iso-8859-1?Q?mMrj+KvFsdggCEQx/WFM/4l8M6ylI7GhJwCq+3yCNb8wJSRBp1m00WP/mN?= =?iso-8859-1?Q?7WT+HZUMsfhQACNJC1is/nMZcfQvvebAJ5m9VUG3c5phHjNEd63Tt3R1yT?= =?iso-8859-1?Q?uuu6UxpkZz9h9tVcShaLogwpVAyXgj9pZI6TB4fpfSOyoYKgiBUvEaW24F?= =?iso-8859-1?Q?om3PwezHe68oHLmtBwzDvI3GQqJSaJfnDi+3QUAOKq5vqld4vXEtMyIpLv?= =?iso-8859-1?Q?1WUfNcbawfUVzWdLrOk0FKdhrMeSPeBDMJeml94mTVZPEtX8KO5yrhEAxY?= =?iso-8859-1?Q?tcVbUzeCaHlrF0xD8liNZ3ZdK+u/NEQb95lufCMyR0tAr3o6Kdk0R85YuY?= =?iso-8859-1?Q?NjYfSoo6U4yYCkp9dWyOaEigxf9wC9vujpy4cQ2jao2+ue1FVfYRqCAdtn?= =?iso-8859-1?Q?1sevP33tkea1/mCWjJpDAZLg1h9IAImrk0KjppAGgqy+vqLUpUrMzkW/VT?= =?iso-8859-1?Q?cVdxfW2huqaw/AFBGbwL95w8K9WOUvGxsKIS6rUG+6X4Pd6+MJy4RoF2xy?= =?iso-8859-1?Q?sp6AJI5lCfC/N25UTIfFAPwUurMtag5esDrwHQv7NpnQXid6jA3RtA58Vb?= =?iso-8859-1?Q?6v+Af+Ub7UmAKwhe7su1JgdgCJ3IT+bfZxOWbWOuVr2kHyKG+F4kMSrOft?= =?iso-8859-1?Q?NlB46ohAu6RuoomgfGnsp3qEN7cujBBQZ/WVk+uLuenUm4LKvvBG0CVuWj?= =?iso-8859-1?Q?ZsEPpRoMI5jI7U9mSwpz9tDZDOeRnHGGDPcEARUP+o9QdU/7t7JHOYgX0n?= =?iso-8859-1?Q?qI78jSPftiM6RD5A2lPeadU0j1Uol9GzrKru+LoK3KFvi42zV3ruFviafj?= =?iso-8859-1?Q?W3xCIb3hENc2EdX1v6YlMfTJ88pMDmoG8QNxxp4TsV0Cl5phdQEoZAF6c/?= =?iso-8859-1?Q?mIdMAPcrwS73XIXb1CNGr4pbtCACTJPNeNgDPuOPFdYJH1v22jE03rT/a0?= =?iso-8859-1?Q?d4GmQPc=3D?= 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)(376014)(366016)(7416014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?uXO2gwt9+dnb2bkxFIQOYIBXsg09mwXvFfegzKOnWJFSNp4XXDrT8cycD0?= =?iso-8859-1?Q?PJ5vGbF4/7XYLXWkBp4wUt01rJpHCLE1QQwy9z9yFbvh3bo984DAylIXIG?= =?iso-8859-1?Q?W9sYR4IjPlN+yZ0eGJDz0A6BIpP4M0Gz8+h3dq5gpyeOjSPYGOlhSJvxC1?= =?iso-8859-1?Q?BFEmZZ05YGPPGghLbRu5pgRQsIZD+ooUhQxK17HQ2xDPRTQR1c7L8eCiJ0?= =?iso-8859-1?Q?XSmq5AYp3ENRQXNq3O1D2bCDEuaYW786jvwj1+tnGO9xQchNg7PFz3LAgj?= =?iso-8859-1?Q?YAW664LSKi2//ax2hL983XbU2REI7fpYr9mrsDv/v7v/WXrG4WQeCx0oy6?= =?iso-8859-1?Q?J4qGfjeYl9LUQbw+vm63WtFRa3xsW5RRuqEaDzVyg+n2drgaw05JD/Al02?= =?iso-8859-1?Q?JHElecsPcDmyDGZ0Q33WzdVoHfG1m2t/JpfG5ocavEseSWd9xs0NxNk/Um?= =?iso-8859-1?Q?G4gucwdITr3QjNFgZHnuRHokRurz1VtrOYQak5PZ8wUvuVz2dz2nDK3jWw?= =?iso-8859-1?Q?5/0TEul9/N+SjE0wwRAA3VI2MlH+oPYBN3+F5Ip9JdArXBQnRY9PhxI1NA?= =?iso-8859-1?Q?dvx+H534ZWjCHopY7tFcGtVT3bYd+Dl5Fn68fhEpe9/TQ6CsXHOcEOZe34?= =?iso-8859-1?Q?ypeh0U4KrrwUG/WzmUHSN5Ys51LvRanI0/Skn9ycvZrz5f9eeLtUoMvymS?= =?iso-8859-1?Q?9wQIBrWTBW7jJNj52u6vRjUR6AX0PY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MA4lzOLLpS9QDnDvMQU+d67lAphj1XgCbAe0Rf4m3F24tcfh57uYKaOA?= =?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: 2d345ae3-acfd-44a4-d9f7-08dd96ecf1cb X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:56.4809 (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: ZFLy79QpGYhsxpLOEcw4g1j9kKyl+veX1ge3CfyuiNnX7+NJiz68EiOuDvR72pK7DKmW1d9KdAz3yjW/d29T78EpRmcKDI4nN1mzgTqp3Uc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669885151116600 Content-Type: text/plain; charset="utf-8" From: Grygorii Strashko The introduced SCI (System Control Interface) subsystem provides unified interface to integrate in Xen SCI drivers which adds support for ARM firmware (EL3, SCP) based software interfaces (like SCMI) that are used in system management. The SCI subsystem allows to add drivers for different FW interfaces or have different drivers for the same FW interface (for example, SCMI with different transports). This patch updates SCMI over SMC calls handling layer, introduced by commit 3e322bef8bc0 ("xen/arm: firmware: Add SCMI over SMC calls handling layer"), to be SCI driver: - convert to DT device; - convert to SCI Xen interface. There are no functional changes in general, the driver is just adopted to the SCI interface. Signed-off-by: Grygorii Strashko Signed-off-by: Oleksii Moisieiev Reviewed-by: Stefano Stabellini --- xen/arch/arm/firmware/Kconfig | 13 ++- xen/arch/arm/firmware/scmi-smc.c | 93 +++++++++++--------- xen/arch/arm/include/asm/firmware/scmi-smc.h | 41 --------- xen/arch/arm/vsmc.c | 5 +- xen/include/public/arch-arm.h | 1 + 5 files changed, 64 insertions(+), 89 deletions(-) delete mode 100644 xen/arch/arm/include/asm/firmware/scmi-smc.h diff --git a/xen/arch/arm/firmware/Kconfig b/xen/arch/arm/firmware/Kconfig index fc7918c7fc..bbf88fbb9a 100644 --- a/xen/arch/arm/firmware/Kconfig +++ b/xen/arch/arm/firmware/Kconfig @@ -8,9 +8,18 @@ config ARM_SCI =20 menu "Firmware Drivers" =20 +choice + prompt "ARM SCI driver type" + default SCMI_SMC + help + Choose which ARM SCI driver to enable. + +config ARM_SCI_NONE + bool "none" + config SCMI_SMC bool "Forward SCMI over SMC calls from hwdom to EL3 firmware" - default y + select ARM_SCI help This option enables basic awareness for SCMI calls using SMC as doorbell mechanism and Shared Memory for transport ("arm,scmi-smc" @@ -18,4 +27,6 @@ config SCMI_SMC firmware node is used to trap and forward corresponding SCMI SMCs to firmware running at EL3, for calls coming from the hardware domain. =20 +endchoice + endmenu diff --git a/xen/arch/arm/firmware/scmi-smc.c b/xen/arch/arm/firmware/scmi-= smc.c index 33473c04b1..13d1137592 100644 --- a/xen/arch/arm/firmware/scmi-smc.c +++ b/xen/arch/arm/firmware/scmi-smc.c @@ -9,6 +9,7 @@ * Copyright 2024 NXP */ =20 +#include #include #include #include @@ -16,12 +17,11 @@ #include #include =20 +#include #include -#include =20 #define SCMI_SMC_ID_PROP "arm,smc-id" =20 -static bool __ro_after_init scmi_enabled; static uint32_t __ro_after_init scmi_smc_id; =20 /* @@ -41,14 +41,11 @@ static bool scmi_is_valid_smc_id(uint32_t fid) * * Returns true if SMC was handled (regardless of response), false otherwi= se. */ -bool scmi_handle_smc(struct cpu_user_regs *regs) +static bool scmi_handle_smc(struct cpu_user_regs *regs) { uint32_t fid =3D (uint32_t)get_user_reg(regs, 0); struct arm_smccc_res res; =20 - if ( !scmi_enabled ) - return false; - if ( !scmi_is_valid_smc_id(fid) ) return false; =20 @@ -78,49 +75,45 @@ bool scmi_handle_smc(struct cpu_user_regs *regs) return true; } =20 -static int __init scmi_check_smccc_ver(void) +static int scmi_smc_domain_init(struct domain *d, + struct xen_domctl_createdomain *config) { - if ( smccc_ver < ARM_SMCCC_VERSION_1_1 ) - { - printk(XENLOG_WARNING - "SCMI: No SMCCC 1.1 support, SCMI calls forwarding disabled= \n"); - return -ENOSYS; - } + if ( !is_hardware_domain(d) ) + return 0; =20 + d->arch.sci_enabled =3D true; + printk(XENLOG_DEBUG "SCMI: %pd init\n", d); return 0; } =20 -static int __init scmi_dt_init_smccc(void) +static void scmi_smc_domain_destroy(struct domain *d) { - static const struct dt_device_match scmi_ids[] __initconst =3D - { - /* We only support "arm,scmi-smc" binding for now */ - DT_MATCH_COMPATIBLE("arm,scmi-smc"), - { /* sentinel */ }, - }; - const struct dt_device_node *scmi_node; - int ret; + if ( !is_hardware_domain(d) ) + return; =20 - /* If no SCMI firmware node found, fail silently as it's not mandatory= */ - scmi_node =3D dt_find_matching_node(NULL, scmi_ids); - if ( !scmi_node ) - return -EOPNOTSUPP; + printk(XENLOG_DEBUG "SCMI: %pd destroy\n", d); +} =20 - ret =3D dt_property_read_u32(scmi_node, SCMI_SMC_ID_PROP, &scmi_smc_id= ); - if ( !ret ) +static int __init scmi_check_smccc_ver(void) +{ + if ( smccc_ver < ARM_SMCCC_VERSION_1_1 ) { - printk(XENLOG_ERR "SCMI: No valid \"%s\" property in \"%s\" DT nod= e\n", - SCMI_SMC_ID_PROP, scmi_node->full_name); - return -ENOENT; + printk(XENLOG_WARNING + "SCMI: No SMCCC 1.1 support, SCMI calls forwarding disabled= \n"); + return -ENOSYS; } =20 - scmi_enabled =3D true; - return 0; } =20 +static const struct sci_mediator_ops scmi_smc_ops =3D { + .handle_call =3D scmi_handle_smc, + .domain_init =3D scmi_smc_domain_init, + .domain_destroy =3D scmi_smc_domain_destroy, +}; + /* Initialize the SCMI layer based on SMCs and Device-tree */ -static int __init scmi_init(void) +static int __init scmi_dom0_init(struct dt_device_node *dev, const void *d= ata) { int ret; =20 @@ -134,22 +127,36 @@ static int __init scmi_init(void) if ( ret ) return ret; =20 - ret =3D scmi_dt_init_smccc(); - if ( ret =3D=3D -EOPNOTSUPP ) - return ret; + ret =3D dt_property_read_u32(dev, SCMI_SMC_ID_PROP, &scmi_smc_id); + if ( !ret ) + { + printk(XENLOG_ERR "SCMI: No valid \"%s\" property in \"%s\" DT nod= e\n", + SCMI_SMC_ID_PROP, dt_node_full_name(dev)); + return -ENOENT; + } + + ret =3D sci_register(&scmi_smc_ops); if ( ret ) - goto err; + { + printk(XENLOG_ERR "SCMI: mediator already registered (ret =3D %d)\= n", + ret); + return ret; + } =20 printk(XENLOG_INFO "Using SCMI with SMC ID: 0x%x\n", scmi_smc_id); =20 return 0; - - err: - printk(XENLOG_ERR "SCMI: Initialization failed (ret =3D %d)\n", ret); - return ret; } =20 -__initcall(scmi_init); +static const struct dt_device_match scmi_smc_match[] __initconst =3D { + DT_MATCH_COMPATIBLE("arm,scmi-smc"), + { /* sentinel */ }, +}; + +DT_DEVICE_START(scmi_smc, "SCMI SMC DOM0", DEVICE_FIRMWARE) + .dt_match =3D scmi_smc_match, + .init =3D scmi_dom0_init, +DT_DEVICE_END =20 /* * Local variables: diff --git a/xen/arch/arm/include/asm/firmware/scmi-smc.h b/xen/arch/arm/in= clude/asm/firmware/scmi-smc.h deleted file mode 100644 index 6b1a164a40..0000000000 --- a/xen/arch/arm/include/asm/firmware/scmi-smc.h +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * xen/arch/arm/include/asm/firmware/scmi-smc.h - * - * ARM System Control and Management Interface (SCMI) over SMC - * Generic handling layer - * - * Andrei Cherechesu - * Copyright 2024 NXP - */ - -#ifndef __ASM_SCMI_SMC_H__ -#define __ASM_SCMI_SMC_H__ - -#include - -struct cpu_user_regs; - -#ifdef CONFIG_SCMI_SMC - -bool scmi_handle_smc(struct cpu_user_regs *regs); - -#else - -static inline bool scmi_handle_smc(struct cpu_user_regs *regs) -{ - return false; -} - -#endif /* CONFIG_SCMI_SMC */ - -#endif /* __ASM_SCMI_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c index 51b3c02973..b33c69a1c2 100644 --- a/xen/arch/arm/vsmc.c +++ b/xen/arch/arm/vsmc.c @@ -21,7 +21,6 @@ #include #include #include -#include =20 /* Number of functions currently supported by Hypervisor Service. */ #define XEN_SMCCC_FUNCTION_COUNT 3 @@ -233,7 +232,7 @@ static bool handle_sip(struct cpu_user_regs *regs) if ( platform_smc(regs) ) return true; =20 - return scmi_handle_smc(regs); + return sci_handle_call(regs); } =20 /* @@ -301,8 +300,6 @@ static bool vsmccc_handle_call(struct cpu_user_regs *re= gs) break; case ARM_SMCCC_OWNER_SIP: handled =3D handle_sip(regs); - if ( !handled ) - handled =3D sci_handle_call(regs); break; case ARM_SMCCC_OWNER_TRUSTED_APP ... ARM_SMCCC_OWNER_TRUSTED_APP_E= ND: case ARM_SMCCC_OWNER_TRUSTED_OS ... ARM_SMCCC_OWNER_TRUSTED_OS_END: diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 55eed9992c..095b1a23e3 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -328,6 +328,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_TEE_FFA 2 =20 #define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 +#define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC 1 =20 struct xen_arch_domainconfig { /* IN/OUT */ --=20 2.34.1 From nobody Fri Oct 31 09:46:44 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=1747669891; cv=pass; d=zohomail.com; s=zohoarc; b=ihf9uY305RV0wXsAGIA7hyiV+GesfWRNX5MyriK66Y9PSUxD7qjVYT3iPTjBw4FTE6NBMVXI7TS2xL6k1hZkKXIUgQivQyHN7TUR11pPWJa2W4AhP9WiTMZtI00my0z5UU0Y57AJUeyrC8bgGTskfA8+5pMhPVYhaYa4XLTJbiQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669891; 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=W8pCd32735DZkbJkk0J7H/LgxlewCXbsG9CT2RHeX0c=; b=JnUOEYtcomTZhymnT0QIqJSMt3rGcmB9ND/ThV4SJknPK9YfMm51xWAwgRicmAzQtyqucl+biI85x7DFf9xhkOYQZnqjNAflt0iTJTvE7FSx91jSa0RRmVMEGny9MyzXkmBTXDIV5Tq3CW7MWsqsxQZleXEqbegCWOmdctYtajY= 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 1747669891687147.55268494636584; Mon, 19 May 2025 08:51:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989959.1373911 (Exim 4.92) (envelope-from ) id 1uH2la-00055q-Bg; Mon, 19 May 2025 15:51:02 +0000 Received: by outflank-mailman (output) from mailman id 989959.1373911; Mon, 19 May 2025 15:51:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uH2la-00055j-8h; Mon, 19 May 2025 15:51:02 +0000 Received: by outflank-mailman (input) for mailman id 989959; Mon, 19 May 2025 15:51:01 +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 1uH2lZ-00055d-KX for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:01 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20625.outbound.protection.outlook.com [2a01:111:f403:260e::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0ecb8684-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:50:59 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50: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%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50: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: 0ecb8684-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RryLzWZbIsJo6b1rJskZ7YYToVMkIPM/j1E1nn5pwHowdDghahrjTFLoikh450/w7uHEJDRWBmBqyrUf7LePsO5hfWEN2Z11ZCWkDjQo7eRGMHdm3z++Ij4lH3E+pWmzLCcR04w14t1+6eUiHg3NnHgZFMZire/BJgN0fMEBrRaxKPFYvC5+1zx6qp7iwePKxIZs36+ug8/wtImaoLNZy03EpthBCucG6Fk7gnG72Q1eRuZoM9HNjrI9ufFhpA+ztwVEn3y8Y4DDfA5nVx9q1C0T1MwsxxhOzUOSvfP9JSwR/0zwgavxbOWCHvLhqBQ92s1WPQ/H4FO8G83kJE79rQ== 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=W8pCd32735DZkbJkk0J7H/LgxlewCXbsG9CT2RHeX0c=; b=T6SSteX+rr9vSV/4oWuR8jOFSTjJkom9+vo9la56MXrSyjWjFicQbn6oHdWsI/Ck92JgAk7JG7l7lPnlZnq23RyMxSFVkL7d4rXrZAqMKuoBJVrDM4TGtAaEIxby20DHoc0Rz+ZhCz6BFjqtSUev+1ezRnoOk1xxZhfiExZgMDGasF+PsSCR/q5btD/Lk2ef602DMO/YDkjCthyeF/MaGf3mlpiq8IULtfyCm6c8pmb9Sz0ayAGSLt6omyD5aW57iag+qSrdL0mwjnRx+J0EvTN41BkVB4wgZUtwbt7Eg7OvBDBFuaEPNSDTuWJT1FRVYSjaiQ3+7P1s4h+xMZjgoQ== 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=W8pCd32735DZkbJkk0J7H/LgxlewCXbsG9CT2RHeX0c=; b=tdpXAT8qouXfxbKdYTvvOvUFlLGo6tncuN12fNRUrAUho5Di7Bf0xD+7V1Myf4MOlGanUcuGcm5ub/nfk3hxMiFF1Y98qALsYkMOl4cANPg0tCM1w2Wu0xUyWH9VYgEwwMPc3I36NxF24ZTrX7xKsdUmDn/FIEbvIb/MhIJOs3IQlzHSqI5/1lFCbyqlcGhczYbxdjGfGQ1aNeQn7wHHuDfYBrpy+iObOw0lHgD2kiLY+jRnC9Z3RxqMwhThA7m/dxQ6107WQrbU4UDoMZlX4Hlm/yLJpC796dXYXgAIUwYmVvzQFGUs00FH1dDg8bMOj14xCwPJQWcigGP4CU5Feg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 3/8] xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent Thread-Topic: [RFC PATCH v4 3/8] xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent Thread-Index: AQHbyNXP6iFNbvP7Mk2Ziw3Fypk2NQ== Date: Mon, 19 May 2025 15:50: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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: 136e7324-6871-43b5-f1f9-08dd96ecf1e9 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?+YB7kXEZb1MlHtVF5MciDrZg8XQpSuEDIt/3hNavNOpPgh4iDDudf5rVey?= =?iso-8859-1?Q?K1Heao3egCMeF//OEtsys5C9WxMABilK/KI6I5qCDC+THLcqDyszGoeUsO?= =?iso-8859-1?Q?kZij6lPcWcy6o+i8IuDrXxIXEwOETVbKe+/SF2Ex2nyerOAbwVAU2vqIkd?= =?iso-8859-1?Q?mG4fga8Qa+ALTS9GVY+J8XKFDFiFR2PQrfIeynr84oDJudy3RURJ47dnEu?= =?iso-8859-1?Q?rn+3MDDnHnEwt1rp7nBB6ICs+HWFZ8B0BmnuoPlEm6stWw8hLcTFGTTIXo?= =?iso-8859-1?Q?AU+qO4TxNWIZl4RE2M59lOoXvJAKs3+c7a9kUS3F0aqPhqSU4OPb1PYApe?= =?iso-8859-1?Q?VgQUnrOmOJDO6ImAr5rCausTEr2q1kFcvjV0/M1c5P4h+g0Z4JuSqow0Vr?= =?iso-8859-1?Q?HNwxIBI6YPm/qv3g5s0bVg1tIPe3ZK6H5JgUbvAKhxLJsYDhTdq2C3b7pV?= =?iso-8859-1?Q?rwpgbac9+qtD60fSBOV4/cqxSBEGkWW3fRAmdUioKNRMCYGfP9ey2K5Q4z?= =?iso-8859-1?Q?aQJBqk6h43dcZsrwFmwfjv6oVREcY4SyJ716KU68jv20O9EmFd1Zwoc73d?= =?iso-8859-1?Q?U0ebLh2xRSpzs/rpRToCWVYV12dWdsv83EdTfvRZFjPHyyOeQP/laQUcYC?= =?iso-8859-1?Q?M0Ug9hHgLOxFa9p/Q6quWbDzibTtLTO0i4sh99hNAhxWVJ7wTVcsEW1Ete?= =?iso-8859-1?Q?WA7l9ayMcahieW91AbFEMPow0959LDWDfaLloIxgo8P1CtrlNfNQLWoMc+?= =?iso-8859-1?Q?/QOvq5FdBDw8IyiwsKXw5e6MWH5DZ4tIFWpE3L1rkOF+OX6hU0VCFrZ1tB?= =?iso-8859-1?Q?v3xMxi2awr2wxpiqmyxoiISz13YHc6nAP6JxvB/U6WXBDp67fgLV9w1gb3?= =?iso-8859-1?Q?37xv33Wr2WThcYgOCjYDpvISFKYeeZXsSbcNwO1KrgvAFGvRaXb9gVLBvC?= =?iso-8859-1?Q?WgaC2CWw4W9pYuMInN0dZBMYvvu5ZPUrdrRR1a7QlgQQI3me1Xd/EfFtBb?= =?iso-8859-1?Q?Jz8EpKHqIEvPZIpnVij2NsSxcYPpIXw2f7XGg7P13S+WfVkk48ZBvu+Mxj?= =?iso-8859-1?Q?ptmJPO+rdVlWzyTp0e301+wuSLfhlGHei+rTxxDIDBcnRvz07LuiKdfgwv?= =?iso-8859-1?Q?ufw6HAvapiTrpQYycj9vf18Ynx3btqFF8ynvXKbOkU9AEWSFQG781cShPi?= =?iso-8859-1?Q?18F9pVHu00qxMXsjHNUMI9evX7XBKM8vgKbA3nsZgcWyz72xZxJHGND/S1?= =?iso-8859-1?Q?/grR18PfKo2TMhqTELEhv6VLm7u7VsbqxEFBRPc0Mq88dD2QtjMoZuq5Jw?= =?iso-8859-1?Q?oawbSP1MGbA2Dcaht+NHazqHvXV5l5LM55o77XgvithlH9dWCyT4kDiLkY?= =?iso-8859-1?Q?h6i426wzV0H18E6V2+vetFq4/f7r5zJP/SEPVjSaEVC+4sbDJzr09hsIJA?= =?iso-8859-1?Q?XwwX8ILfS3ni7t9PW4HnSCjyUQ2oej2Z4EZXCbILWtVE2MikQDkkHc2L4P?= =?iso-8859-1?Q?nFgqrA6VF/yIggDM9I78lJz8YEzR3DBC9LBijH87Uyrw//4+TELcxRJTYY?= =?iso-8859-1?Q?9gGVVQ4=3D?= 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)(376014)(366016)(7416014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?sM6adaUoG6n5t05kQG23I1Y88LloOemG1ktX3x438fcVjygK+eRps/IJ14?= =?iso-8859-1?Q?NvU92GifetE8KbEiutm+0BlS9XJ5/iJqORUOl+ZkB+x+U9payRKShPGAwX?= =?iso-8859-1?Q?iWHeGetZT6do9UryYZ0T1kEe4lknICATL/AO62y6FgHbWR2/5uA59FTC6D?= =?iso-8859-1?Q?IZ3bm96ff53jFMEKaQ7FyN4AQHKc3TbzpNkRi+00mdF7ssCE3h1jpeIAY0?= =?iso-8859-1?Q?xmnW3KBbXJFUHU9yQThtIkfDQDdaXheXBhAhDji+5Eavj8LENWZQrbjtvw?= =?iso-8859-1?Q?utnGIhPaDT7IGZX/itVx33s7YHJHrXhwItL5n7o27rbBSn9NP2c9IGlV6Y?= =?iso-8859-1?Q?ZSf1v4TkZIZxvbPj9645z9dSdcngz/TbjmDbbIVsmMBEdJJiSNd9Jk1XWk?= =?iso-8859-1?Q?BCqfHIjOSMs4RLBAiyiCiIMoKS4V28gFUjOJ8zgTGKV4dWI64uqZWBGI3M?= =?iso-8859-1?Q?SGqqZkKREHPzYfK4LmlEJ7F6VGzH0c+ma9AGy4hSAZtUXZpARogShlkbFY?= =?iso-8859-1?Q?Y0Ca8CxgvU26tQbjKJNLIlR6AK1U8GmcZ1i5qgJD3tTKH76hveJZRHhzMW?= =?iso-8859-1?Q?O6RGD1h5Y72XKktWJ3JrP5VKN17yi1Gf1hXtnbDZvNQL0azKJ/6fCE7gaL?= =?iso-8859-1?Q?XI69cbD0x3jthjPNRYxEgVgwiKg3HEhNheoubtjrUIVayg0IODdU6pN/dP?= =?iso-8859-1?Q?F3QlI4LgdUA0rogNTmEHCnz8kCQpyLnirLR188t3y42EYTbAtqCj7A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/ij6oVAyBphZNvxGvxw?= =?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: 136e7324-6871-43b5-f1f9-08dd96ecf1e9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:56.7823 (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: P1oExcoDz+9OYdvdYTCS4JCjf7kYyT+g152tiYi/7Ny+EcLclzLaBV4ohuV8Zzvino0+Ds39FQ24BsOGq6gbiyTYGXPNIFclEdBpIXZEPHc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669893170116600 Content-Type: text/plain; charset="utf-8" From: Grygorii Strashko The commit 3e322bef8bc0 ("xen/arm: firmware: Add SCMI over SMC calls handling layer") introduces simple driver which forwards SCMI over SMC calls from hwdom/dom0 to EL3 firmware (TF-A) with a single SCMI OSPM agent support. While it is working gracefully for hwdom/dom0 use case it doesn't cover "thin Dom0 with guest domain, which serves as Driver domain" use-case. In this case HW need to be enable in Driver domain and dom0 is performing only control functions. The EL3 SCMI firmware (TF-A) with a single SCMI OSPM agent support is pretty generic case for the default vendors SDK and new platforms. This patch enables passthrough of SCMI SMC single agent interface to the one guest domain serving as Driver domain. Configure Dom0 to enable SCMI passthrough: - dom0: add dom0_scmi_smc_passthrough to the Xen Command Line Enabled SCMI passthrough for guest using toolstack in the following way: - domD: xl.cfg add "arm_sci" option as below arm_sci =3D "type=3Dscmi_smc" - domD: xl.cfg enable access to the "arm,scmi-shmem" iomem =3D [ "47ff0,1@22001", ] - domD: add SCMI nodes to the Driver domain partial device tree as in the below example: 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"; shmem =3D <&scmi_shm_0>; ... } } } dom0less case configuration: - add "xen,sci_type" property for required DomU ("xen,domain") node xen,sci_type=3D"scmi_smc" - add scmi nodes to the Driver domain partial device tree the same way as above and enable access to the "arm,scmi-shmem" according to dom0less documentation. For example: 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; }; The SCMI SMC single agent interface can be enabled for one and only one domain. In general, the configuration is similar to any other HW passthrough, except explicitly enabling SCMI with "arm_sci" xl.cfg option. Note that "arm,scmi-smc" and "arm,scmi-shmem" nodes will be removed from dom0/hwdom DT in case of Signed-off-by: Grygorii Strashko Signed-off-by: Oleksii Moisieiev --- Changes in v4: - xl.cfg doc - fix comments from Stefano Stabellini - fix toolstack code as sugested by Anthony PERARD - use MATCH_OPTION() - move arm_sci struct and cfg params in "arch_arm" - add SCMI passthrough for dom0less case docs/man/xl.cfg.5.pod.in | 34 ++++++++ docs/misc/arm/device-tree/booting.txt | 15 ++++ docs/misc/xen-command-line.pandoc | 9 +++ tools/include/libxl.h | 5 ++ tools/libs/light/libxl_arm.c | 14 ++++ tools/libs/light/libxl_types.idl | 10 +++ tools/xl/xl_parse.c | 36 +++++++++ xen/arch/arm/dom0less-build.c | 33 +++++++- xen/arch/arm/firmware/Kconfig | 4 +- xen/arch/arm/firmware/scmi-smc.c | 112 +++++++++++++++++++++++++- 10 files changed, 267 insertions(+), 5 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 8e1422104e..1ccf50b8ea 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -3092,6 +3092,40 @@ Otherwise, the value specified by the `nr_spis` para= meter will be used. The number of SPIs should match the highest interrupt ID that will be assigned to the domain. =20 +=3Ditem B + +Set ARM_SCI specific options for the guest. ARM SCI is System +Control Protocol allows domain to manage various functions that are provid= ed +by HW platform firmware. + +B is a comma separated list of C settings, +from the following list: + +=3Dover 4 + +=3Ditem B + +Specifies an ARM SCI type for the guest. + +=3Dover 4 + +=3Ditem B + +Don't allow guest to use ARM SCI if present on the platform. This is the +default value. + +=3Ditem B + +Enables ARM SCMI SMC support for the guest by enabling SCMI over SMC calls +forwarding from domain to the EL3 firmware (like Trusted Firmware-A) with a +single SCMI OSPM agent support. +Should be used together with B Xen command line +option. + +=3Dback + +=3Dback + =3Dback =20 =3Dhead3 x86 diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index 9c881baccc..8943c04173 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -281,6 +281,21 @@ with the following properties: passed through. This option is the default if this property is missing and the user does not provide the device partial device tree for the d= omain. =20 +- xen,sci_type + + A string property specifying an ARM SCI type for the guest. + + - "none" + Don't allow guest to use ARM SCI if present on the platform. This is t= he + default value. + + - "scmi_smc" + Enables ARM SCMI SMC support for the guest by enabling SCMI over SMC c= alls + forwarding from domain to the EL3 firmware (like Trusted Firmware-A) w= ith a + single SCMI OSPM agent support. + Should be used together with dom0_scmi_smc_passthrough Xen command line + option. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. =20 diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 9bbd00baef..8e50f6b7c7 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1082,6 +1082,15 @@ affinities to prefer but be not limited to the speci= fied node(s). =20 Pin dom0 vcpus to their respective pcpus =20 +### dom0_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/include/libxl.h b/tools/include/libxl.h index f8fe4afd7d..5fa43637ab 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -313,6 +313,11 @@ */ #define LIBXL_HAVE_BUILDINFO_ARCH_NR_SPIS 1 =20 +/* + * libxl_domain_build_info has the arch_arm.sci* fields. + */ +#define LIBXL_HAVE_BUILDINFO_ARCH_ARM_SCI 1 + /* * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing * 'soft reset' for domains and there is 'soft_reset' shutdown reason diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 28cea1f643..28ba9eb787 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -222,6 +222,20 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, config->arch.sve_vl =3D d_config->b_info.arch_arm.sve_vl / 128U; } =20 + switch (d_config->b_info.arch_arm.arm_sci.type) { + case LIBXL_ARM_SCI_TYPE_NONE: + config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + break; + case LIBXL_ARM_SCI_TYPE_SCMI_SMC: + config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC; + break; + default: + LOG(ERROR, "Unknown ARM_SCI type %d", + d_config->b_info.arch_arm.arm_sci.type); + return ERROR_FAIL; + } + LOG(DEBUG, " - SCI type=3D%u", config->arch.arm_sci_type); + return 0; } =20 diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 33c9cfc1a2..aa2190ab5b 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -551,6 +551,15 @@ libxl_sve_type =3D Enumeration("sve_type", [ (2048, "2048") ], init_val =3D "LIBXL_SVE_TYPE_DISABLED") =20 +libxl_arm_sci_type =3D Enumeration("arm_sci_type", [ + (0, "none"), + (1, "scmi_smc") + ], init_val =3D "LIBXL_ARM_SCI_TYPE_NONE") + +libxl_arm_sci =3D Struct("arm_sci", [ + ("type", libxl_arm_sci_type), + ]) + libxl_rdm_reserve =3D Struct("rdm_reserve", [ ("strategy", libxl_rdm_reserve_strategy), ("policy", libxl_rdm_reserve_policy), @@ -725,6 +734,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), ("nr_spis", uint32), + ("arm_sci", libxl_arm_sci), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 9a3679c023..bd22be9d33 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1284,6 +1284,36 @@ out: if (rc) exit(EXIT_FAILURE); } =20 +static int parse_arm_sci_config(XLU_Config *cfg, libxl_arm_sci *arm_sci, + const char *str) +{ + int ret =3D 0; + char *buf2, *ptr; + char *oparg; + + if (NULL =3D=3D (buf2 =3D ptr =3D strdup(str))) + return ERROR_NOMEM; + + ptr =3D strtok(buf2, ","); + while (ptr !=3D NULL) + { + if (MATCH_OPTION("type", ptr, oparg)) { + ret =3D libxl_arm_sci_type_from_string(oparg, &arm_sci->type); + if (ret) { + fprintf(stderr, "Unknown ARM_SCI type: %s\n", oparg); + ret =3D ERROR_INVAL; + goto parse_error; + } + } + + ptr =3D strtok(NULL, ","); + } + +parse_error: + free(buf2); + return ret; +} + void parse_config_data(const char *config_source, const char *config_data, int config_len, @@ -2981,6 +3011,12 @@ skip_usbdev: if (!xlu_cfg_get_long (config, "nr_spis", &l, 0)) b_info->arch_arm.nr_spis =3D l; =20 + if (!xlu_cfg_get_string(config, "arm_sci", &buf, 1)) { + if (parse_arm_sci_config(config, &b_info->arch_arm.arm_sci, buf)) { + exit(EXIT_FAILURE); + } + } + parse_vkb_list(config, d_config); =20 d_config->virtios =3D NULL; diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index a09c4c4bd7..0a00f03a25 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -815,6 +815,36 @@ static int __init construct_domU(struct domain *d, return rc; } =20 +int __init domu_dt_sci_parse(struct dt_device_node *node, + struct xen_domctl_createdomain *d_cfg) +{ + const char *sci_type =3D NULL; + int ret; + + d_cfg->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + + if ( !IS_ENABLED(CONFIG_ARM_SCI) || + !dt_property_read_bool(node, "xen,sci_type") ) + return 0; + + ret =3D dt_property_read_string(node, "xen,sci_type", &sci_type); + if ( ret ) + return ret; + + if ( !strcmp(sci_type, "none") ) + 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 + { + printk(XENLOG_ERR "xen,sci_type in not valid (%s) for domain %s\n", + sci_type, dt_node_name(node)); + return -EINVAL; + } + + return 0; +} + void __init create_domUs(void) { struct dt_device_node *node; @@ -975,7 +1005,8 @@ void __init create_domUs(void) if ( !llc_coloring_enabled && llc_colors_str ) panic("'llc-colors' found, but LLC coloring is disabled\n"); =20 - d_cfg.arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + if ( domu_dt_sci_parse(node, &d_cfg) ) + panic("Error getting SCI configuration\n"); =20 /* * The variable max_init_domid is initialized with zero, so here i= t's diff --git a/xen/arch/arm/firmware/Kconfig b/xen/arch/arm/firmware/Kconfig index bbf88fbb9a..5c5f0880c4 100644 --- a/xen/arch/arm/firmware/Kconfig +++ b/xen/arch/arm/firmware/Kconfig @@ -25,7 +25,9 @@ config SCMI_SMC doorbell mechanism and Shared Memory for transport ("arm,scmi-smc" compatible only). The value of "arm,smc-id" DT property from SCMI firmware node is used to trap and forward corresponding SCMI SMCs - to firmware running at EL3, for calls coming from the hardware domain. + to firmware running at EL3, for calls coming from the hardware domain or + driver domain. + Use with EL3 firmware which supports only single SCMI OSPM agent. =20 endchoice =20 diff --git a/xen/arch/arm/firmware/scmi-smc.c b/xen/arch/arm/firmware/scmi-= smc.c index 13d1137592..7470a21505 100644 --- a/xen/arch/arm/firmware/scmi-smc.c +++ b/xen/arch/arm/firmware/scmi-smc.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include =20 @@ -22,7 +24,11 @@ =20 #define SCMI_SMC_ID_PROP "arm,smc-id" =20 +static bool __ro_after_init opt_dom0_scmi_smc_passthrough =3D false; +boolean_param("dom0_scmi_smc_passthrough", opt_dom0_scmi_smc_passthrough); + static uint32_t __ro_after_init scmi_smc_id; +static struct domain __read_mostly *scmi_dom; =20 /* * Check if provided SMC Function Identifier matches the one known by the = SCMI @@ -50,7 +56,7 @@ static bool scmi_handle_smc(struct cpu_user_regs *regs) return false; =20 /* Only the hardware domain should use SCMI calls */ - if ( !is_hardware_domain(current->domain) ) + if ( scmi_dom !=3D current->domain ) { gdprintk(XENLOG_WARNING, "SCMI: Unprivileged access attempt\n"); return false; @@ -75,12 +81,45 @@ static bool scmi_handle_smc(struct cpu_user_regs *regs) return true; } =20 +static int +scmi_smc_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= ) + return -EINVAL; + + return 0; +} + static int scmi_smc_domain_init(struct domain *d, struct xen_domctl_createdomain *config) { - if ( !is_hardware_domain(d) ) + /* + * scmi_passthrough is not enabled: + * - proceed only for hw_domain + * - fail if guest domain has SCMI enabled. + */ + if ( !opt_dom0_scmi_smc_passthrough && !is_hardware_domain(d) ) + { + if ( config->arch.arm_sci_type =3D=3D XEN_DOMCTL_CONFIG_ARM_SCI_SC= MI_SMC ) + return -EINVAL; + else + return 0; + } + /* + * scmi_passthrough is enabled: + * - ignore hw_domain + * - proceed only for domain with SCMI enabled. + */ + if ( opt_dom0_scmi_smc_passthrough && + (config->arch.arm_sci_type =3D=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE = || + is_hardware_domain(d)) ) return 0; =20 + if ( scmi_dom ) + return -EEXIST; + + scmi_dom =3D d; d->arch.sci_enabled =3D true; printk(XENLOG_DEBUG "SCMI: %pd init\n", d); return 0; @@ -88,12 +127,77 @@ static int scmi_smc_domain_init(struct domain *d, =20 static void scmi_smc_domain_destroy(struct domain *d) { - if ( !is_hardware_domain(d) ) + if ( scmi_dom && scmi_dom !=3D d ) return; =20 + scmi_dom =3D NULL; + d->arch.sci_enabled =3D false; printk(XENLOG_DEBUG "SCMI: %pd destroy\n", d); } =20 +/* + * Handle Dom0 SCMI SMC specific DT nodes + * + * if dom0_scmi_smc_passthrough=3Dfalse: + * - Copy SCMI nodes into Dom0 device tree. + * if dom0_scmi_smc_passthrough=3Dtrue: + * - skip SCMI nodes from Dom0 DT + * - give dom0 control access to SCMI shmem MMIO, so SCMI can be passed + * through to guest. + */ +static bool scmi_smc_dt_handle_node(struct domain *d, + struct dt_device_node *node) +{ + 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 */ }, + }; + + /* 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; + } + + /* + * skip scmi node for dom0 if scmi not enabled, but give dom0 control + * access to SCMI shmem + */ + if ( dt_match_node(scmi_matches, node) && !sci_domain_is_enabled(d) ) + { + struct dt_device_node *shmem_node; + const __be32 *prop; + u64 paddr, size; + int ret; + + /* give dom0 control access to SCMI shmem */ + prop =3D dt_get_property(node, "shmem", NULL); + if ( !prop ) + return true; + + shmem_node =3D dt_find_node_by_phandle(be32_to_cpup(prop)); + if ( !shmem_node ) + return true; + + ret =3D dt_device_get_address(shmem_node, 0, &paddr, &size); + if ( ret ) + return true; + + ret =3D iomem_permit_access(d, paddr_to_pfn(paddr), + paddr_to_pfn(paddr + size - 1)); + + dt_dprintk("Skip scmi node\n"); + return true; + } + + return false; +} + static int __init scmi_check_smccc_ver(void) { if ( smccc_ver < ARM_SMCCC_VERSION_1_1 ) @@ -108,8 +212,10 @@ static int __init scmi_check_smccc_ver(void) =20 static const struct sci_mediator_ops scmi_smc_ops =3D { .handle_call =3D scmi_handle_smc, + .domain_sanitise_config =3D scmi_smc_domain_sanitise_config, .domain_init =3D scmi_smc_domain_init, .domain_destroy =3D scmi_smc_domain_destroy, + .dom0_dt_handle_node =3D scmi_smc_dt_handle_node, }; =20 /* Initialize the SCMI layer based on SMCs and Device-tree */ --=20 2.34.1 From nobody Fri Oct 31 09:46:44 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=1747669883; cv=pass; d=zohomail.com; s=zohoarc; b=M+Cv/KvNTbcTMNmhmeJv569otQ5iTMblBCg99jfvKtsC3Z8YokCIIMereNL7RCLXbAD3GyJ4mAsPNroVsKX1m69ZOxvlLaRhisBu6z5GorDcGABOWL2HaB5L1XBZyVJ1aJs4tqA72OQPUyrSKKSrQpxcnyJaZnOIhrUlQo2BLsc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669883; 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=Pz/ZMdrRc7mCeJ8Rd8uhD1laT/igu+PIiYNbzkSXnXw=; b=aJVMZ4AL8k05kXfu13KGYfU+9nTjS72ULEdxm0WIzKLOnQlgYnomEnyT2+hjkqHKIRFj3wzPGadkWfD76fwzUPDLu4eAwTmlmBwoO8k1VzdumS205B3bUBTlr6EefxDUqXQkC+NobbIUXiYJiUcOw6tXP4LIY3KfQWSiBbWkhBM= 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 1747669882997201.89041431537885; Mon, 19 May 2025 08:51:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989963.1373943 (Exim 4.92) (envelope-from ) id 1uH2le-0005iV-P7; Mon, 19 May 2025 15:51:06 +0000 Received: by outflank-mailman (output) from mailman id 989963.1373943; Mon, 19 May 2025 15:51: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 1uH2le-0005h9-Gq; Mon, 19 May 2025 15:51:06 +0000 Received: by outflank-mailman (input) for mailman id 989963; Mon, 19 May 2025 15:51: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 1uH2ld-00055d-Ok for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:05 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20625.outbound.protection.outlook.com [2a01:111:f403:260e::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 11ca88c7-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:51:04 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50: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%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50: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: 11ca88c7-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XGg/9olLSQyFXp3WI5g+gqj1MIB07JU+yLK3Ts6j2cLNgHgEuiuW20D48yapSVv1MSFPqpPOA9ClHWtTCzniTKI5ZQw/AgqQozUqAiJkHgSmoAM9gIy3V3IO0fnqUXOUJkBa7lYNbIDrWfoVdWb8rE1dJap5cwCNtx5vZrw857b39AjEoWQR1WpVJ18qvcc/mFI9zaV9lMB0s6CPF2AORz6hZz2VzypjQuNC5VGjiWSrfSryzqAdilR/4qyjK4PXhyRYR360gIz0miuJ23j1REACtZOv3ZlR5cTmXSYsUeFbIVxPVt3D0Z7UAH4RnEs4hbHjpzgAh2Rt+VKfuhAVew== 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=Pz/ZMdrRc7mCeJ8Rd8uhD1laT/igu+PIiYNbzkSXnXw=; b=awZAs3EoEJ12YoBTjpzM/OQX5ydkFI3y2OXtaW3q3dULc/T6LU+FaA8cV3pCGahU2sac65TZiuf2JYAUN4baNLWXnGnoGL3snLTkGCBmrPH++IDwyV1OMiTXQNlAAlOIFM7HFUw8GVOf1nh8QDlj4s7a6mj6hz1eXS69No8+W5a1GU5sQRfIOP9aYmpGl4ygG9Y6fdPZ+o2rFGKsRaZHwezNKGY+1aR3FzD9fP0D7PdpFPYEbOugX8WQ3tyrfEtmPyIAoUFuIyoVvneISHhFfsfediy5b8Zop15re/ytHVLU9tsuEkGMcd/LGfBXgAGKP346odYcnI252bWzK9xWUg== 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=Pz/ZMdrRc7mCeJ8Rd8uhD1laT/igu+PIiYNbzkSXnXw=; b=tFyoNb38GDdxQWh9E0i6XSWddce2ipDDfWHSFNbOt8/8nq6iE5F0qVITv5LBuLqCDJtzJouVTPmN6hKW0cL3BEOxEFc08nkF4dWI70pZlGEJAy+ZHwzmA0TN/QALXWzQl5LKKjYE8s5Lwl6v//fuq5kvRZN+LqMc4Q+UKh4rSqQa2UOO/8lye8fbc+IV3kBb7nIbe6q/XLWI/lIsIfDs8B01+WdNVMmX/PyqPy7CBo6bkpmSoXm3reIYKchopiPchv8oUczK/L7ZWF07MYCh9fiD0/cU3DLdUklQSFQWdev2uM4X0Gw31misgoGpzikri6ri0p/VhSLrz9WwdEOr1g== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 4/8] docs: arm: add docs for SCMI over SMC calls forwarding driver Thread-Topic: [RFC PATCH v4 4/8] docs: arm: add docs for SCMI over SMC calls forwarding driver Thread-Index: AQHbyNXP0pQacOnhI0GW40rDQn7cHA== Date: Mon, 19 May 2025 15:50:57 +0000 Message-ID: <66d4472e46d94e4b64027986f004b98f610c4f1e.1747669845.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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: 33e991e4-a9a5-4dc6-930f-08dd96ecf219 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?z2dnIVCiRsGu9p73VfXaMrx2qE9yzZOPkZ5CMVe1S2cvzAXDLGA6IeHSk6?= =?iso-8859-1?Q?WpGsuCQPHKXNWF/KuqNmliXj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?= =?iso-8859-1?Q?a8u3HEVlkVmC4OP+R3YfVoE7PZ9tRsqzPxRyNSMKBSzKqKW9mSaK1n1Pxh?= =?iso-8859-1?Q?kaRZ9X96AZ8l/WtT2c3yzbYirJM8ayU7+XT3fraOASImswZQzTk+N4cBij?= =?iso-8859-1?Q?aU8aurIWBHBnx6BO9fdU07slTGTM9HAjXURGZy6VoICZ4MTINDXpN3rB+N?= =?iso-8859-1?Q?/CldQEx6blYDGlmooon7DUkAO1fPRPKNKCtgIpr/lZLgGa42RBAa0LFCZ0?= =?iso-8859-1?Q?gY3FrzlXAuMSr4PJik/g37rzeVyKEYJx/T24XlqMHOAIbef+tmk/IxYrXT?= =?iso-8859-1?Q?qfjqheQYFSyhwOSrzysnLeNvxnTbdSJGkHWIAh3+nd92ArpJ6T0lPYPPRk?= =?iso-8859-1?Q?uXbny86U1HbsBY5ibxiHPzBGp+TalwABiiAdmbpGJl/Q1ktIYTt9yvo8T1?= =?iso-8859-1?Q?Ys9DlrKjzVe1Vwvb/P79zYA+gFNWiStgEkdfHvKEY6zqmVoaUwqqgXSApj?= =?iso-8859-1?Q?92GIixOAhty/AFLLQhXu8C9IHu06n/HVZ7fwMfU0al7Kn3xRhJCRd+07Jp?= =?iso-8859-1?Q?c=3D?= 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)(376014)(366016)(7416014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?xZ128+rPSw8K2EvKIw5a8uaYM9e4GdKOYll0AJ87uVsGaPZ/cDxp4BeABC?= =?iso-8859-1?Q?EWkiXojaIhQBXjal1j3InLMjB8mflmqhrAJB79W0HcdRriXHKiJf3LzVup?= =?iso-8859-1?Q?ktDXZ6v9EqnLLqGmGcT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A7HKFG4RsYNoWxb?= =?iso-8859-1?Q?OombYBZxcREvtl6D7pCUY6/FeiOSdImotHBFom1W0YosKMnV8hyxJhyVad?= =?iso-8859-1?Q?GzYTCD8/Jv9F7t2Z5POx5ykheuvO6yFkjfIeks2J+IkIBOMKWMAasDgIiH?= =?iso-8859-1?Q?pk/EBMXm5ETjj+FNVLGorJcziOME8VJdd/uDMYeohksQQcvbptRtad/9lv?= =?iso-8859-1?Q?TCzwVWrAoqFMtOmjxDfZWHyDlu6linrmU9rtC5OP4HGiQXoqPb7VL8/A/o?= =?iso-8859-1?Q?r6/ZxMddqtiqxDLWtqUFYAAMAjcX75kR+m4eH3rlawtJc5jFzCFtU/abPZ?= =?iso-8859-1?Q?18oiJv0xQar0SjZK3e+99wPpZUVgtNS5dZlpmRZe8/aKvNRe9wMRtPX/l2?= =?iso-8859-1?Q?Qd4hhBcThZGFbGtatdea4wGhbdyNuoJ8yELEHKv3WZOaVU5j5IXdMatMHf?= =?iso-8859-1?Q?M6lMyQKLZOvOAjqz2pJZMhnp2iwzl8R0flc/3EofSpGYwjD2jDvZLeDuyT?= =?iso-8859-1?Q?y0VlfKSmEXBiWb2Twkurr1BDjvhBrcSpp/LXeHXxKXKJhFNZXTApCaeZHo?= =?iso-8859-1?Q?SCgyio3fvw1hp9y+zcPp5+gp7QIGCNK4sef8SlfkV2yHh6iizrgG708mfk?= =?iso-8859-1?Q?sixfYtq/iKuxi9gY9DO27S8mAcjA7woVwp8qtTfd2x45rTb49Aovyrjg?= =?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: 33e991e4-a9a5-4dc6-930f-08dd96ecf219 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:57.0715 (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: AR9ArqN9KAA43NJygCAs3IXpDgiZpyigFnGBsRgaX0dWWnz9pdY+3YRyFO5P9jJHwmaMdv7Frw+WNXP3AUH5azjxCT3uOXH/yetLS1b1MV8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669885103116600 Content-Type: text/plain; charset="utf-8" From: Grygorii Strashko Add documentation section for Simple Arm SCMI over SMC/HVC calls forwarding driver (EL3). Signed-off-by: Grygorii Strashko Signed-off-by: Oleksii Moisieiev --- .../arm/firmware/arm-scmi.rst | 177 ++++++++++++++++++ docs/hypervisor-guide/arm/index.rst | 9 + docs/hypervisor-guide/index.rst | 1 + 3 files changed, 187 insertions(+) create mode 100644 docs/hypervisor-guide/arm/firmware/arm-scmi.rst create mode 100644 docs/hypervisor-guide/arm/index.rst diff --git a/docs/hypervisor-guide/arm/firmware/arm-scmi.rst b/docs/hypervi= sor-guide/arm/firmware/arm-scmi.rst new file mode 100644 index 0000000000..bf6a458a6a --- /dev/null +++ b/docs/hypervisor-guide/arm/firmware/arm-scmi.rst @@ -0,0 +1,177 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +ARM System Control and Management Interface (SCMI) +=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +The System Control and Management Interface (SCMI) [1], which is a set of = operating +system-independent software interfaces that are used in system management.= SCMI currently +provides interfaces for: + +- Discovery and self-description of the interfaces it supports +- Power domain management +- Clock management +- Reset domain management +- Voltage domain management +- Sensor management +- Performance management +- Power capping and monitoring +- Pin control protocol. + +The SCMI compliant firmware could run: + +- as part of EL3 secure world software (like Trusted Firmware-A) with + ARM SMC/HVC shared-memory transport; +- on dedicated System Control Processor (SCP) with HW mailbox shared-memor= y transport + +The major purpose of enabling SCMI support in Xen is to enable guest domai= ns access to the SCMI +interfaces for performing management actions on passed-through devices (su= ch as clocks/resets etc) +without accessing directly to the System control HW (like clock controller= s) which in most cases +can't shared/split between domains. Or, at minimum, allow SCMI access for = dom0/hwdom (or guest +domain serving as Driver domain). + +The below sections describe SCMI support options available for Xen. + +[1] `Arm SCMI `_ + +Simple SCMI over SMC/HVC calls forwarding driver (EL3) +------------------------------------------------------ + +The EL3 SCMI firmware (TF-A) with a single SCMI OSPM agent support is pret= ty generic case for +the default vendors SDK and new platforms with SCMI support. Such EL3 SCMI= firmware supports only +single SCMI OSPM transport (agent) with Shared memory based transport and = SMC/HVC calls as doorbell. + +The SCMI over SMC/HVC calls forwarding driver solves major problem for thi= s case by allowing +SMC/HVC calls to be forwarded form guest to the EL3 SCMI firmware. + +By default, the SCMI over SMC/HVC calls forwarding is enabled for Dom0/hwd= om. + +:: + + +--------------------------+ + | | + | EL3 SCMI FW (TF-A) | + ++-------+--^--------------+ + |shmem | | smc-id + +----^--+ | + | | + +----|-+---+---+----------+ + | | | FWD | Xen | + | | +---^---+ | + +----|-----|--------------+ + | | smc-id + +----v-----+--+ +---------+ + | | | | + | Dom0/hwdom | | DomU | + | | | | + | | | | + +-------------+ +---------+ + + +The SCMI messages are passed directly through SCMI shared-memory (zero-cop= y) and driver only +forwards SMC/HVC calls. + +Compiling +^^^^^^^^^ + +To build with the SCMI over SMC/HVC calls forwarding enabled support, enab= le Kconfig option + +:: + + CONFIG_SCMI_SMC + +The ``CONFIG_SCMI_SMC`` is enabled by default. + +Pass-through SCMI SMC to domain which serves as Driver domain +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This section describes how to configure the SCMI over SMC/HVC calls forwar= ding driver to handle use +case "thin Dom0 with guest domain, which serves as Driver domain". In this= case HW need to be +enabled in Driver domain and dom0 is performing only control functions (wi= thout accessing FW) and so, +the SCMI need to be enabled in Driver domain. + +:: + + +--------------------------+ + |EL3 SCMI FW (TF-A) | + | | + +-------------^--+-------+-+ + smc-id| |shmem0 | + | +----^--+ + +-------------++------+|----+ + |Xen | FWD || | + | +--^----+| | + +----------------|-----|----+ + smc-id | | + +-----------+ +--+-----v-----+ + | | | | + | Dom0 | | Driver | + | Control | | domain | + | | | | + +-----------+ +--------------+ + +The SCMI can be enabled for one and only one guest domain. + +First. configure Dom0 to enable SCMI pass-through using Xen Command Line +**"dom0_scmi_smc_passthrough"** option. This will disable SCMI for Dom0/hw= dom and SCMI nodes will +be removed from Dom0/hwdom device tree. + +**Configure SCMI pass-through for guest domain with toolstack** + +* In domain's xl.cfg file add **"arm_sci"** option as below + +:: + + arm_sci =3D "type=3Dscmi_smc" + +* In domain's xl.cfg file enable access to the "arm,scmi-shmem" + +:: + + iomem =3D [ + "47ff0,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: + +.. 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"; + shmem =3D <&scmi_shm_0>; + ... + } + } + } + +In general, the configuration is similar to any other HW pass-through, exc= ept explicitly +enabling SCMI with "arm_sci" xl.cfg option. + +**Configure SCMI pass-through for predefined domain (dom0less)** + +* add "xen,sci_type" property for required DomU ("xen,domain") node + +:: + + xen,sci_type=3D"scmi_smc" + +* add scmi nodes to the Driver domain partial device tree the same way as = above and enable access + to the "arm,scmi-shmem" according to dom0less documentation. For exampl= e: + +.. code:: + + 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; + }; diff --git a/docs/hypervisor-guide/arm/index.rst b/docs/hypervisor-guide/ar= m/index.rst new file mode 100644 index 0000000000..7aae4a0a03 --- /dev/null +++ b/docs/hypervisor-guide/arm/index.rst @@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +ARM +=3D=3D=3D + +.. toctree:: + :maxdepth: 2 + + firmware/arm-scmi diff --git a/docs/hypervisor-guide/index.rst b/docs/hypervisor-guide/index.= rst index e4393b0697..520fe01554 100644 --- a/docs/hypervisor-guide/index.rst +++ b/docs/hypervisor-guide/index.rst @@ -9,3 +9,4 @@ Hypervisor documentation code-coverage =20 x86/index + arm/index \ No newline at end of file --=20 2.34.1 From nobody Fri Oct 31 09:46:44 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=1747669890; cv=pass; d=zohomail.com; s=zohoarc; b=IDNuURHo0/yunCdzNigMZ48scfRSFySup0QyxKwzxfwkWuEJ581KrVBNZM88Q8rH8E21NqlnQ5IDVl7fVwVnCk9csHsQaPjciZ/iEXBw+7tQdyy4VEjaZ1sqDa07E9fyFOg4pNUzeEgTGzIT8z+40dO8Vj/W69zAGtKz4wxNOJk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669890; 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=ngb/Uc83s7G/8aLrdtXV+MINpMrv6VMh+dzEgsn3NaQ=; b=Z/zpul/3poKBOK4lSedVBQbj9NyEG7aOlHVjes5Bn3puCay7856FvcLEO0tJLvBO1Q5nmqEpmJMTyV1jEm7Bz/lDRakoY6UAaH5+sQwLdQjI8gIxKT0wm+KVI0wsdYWQuDJMpnFsaWrg5px+vnPOiK4NfvUTQPP6T+jKH4bp3GM= 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 1747669890365563.3554271699089; Mon, 19 May 2025 08:51:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989964.1373961 (Exim 4.92) (envelope-from ) id 1uH2lh-0006Hh-2H; Mon, 19 May 2025 15:51:09 +0000 Received: by outflank-mailman (output) from mailman id 989964.1373961; Mon, 19 May 2025 15:51: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 1uH2lg-0006HI-Uo; Mon, 19 May 2025 15:51:08 +0000 Received: by outflank-mailman (input) for mailman id 989964; Mon, 19 May 2025 15:51:07 +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 1uH2le-00055d-W8 for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:07 +0000 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on20612.outbound.protection.outlook.com [2a01:111:f403:260c::612]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1298e768-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:51:05 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50: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%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50: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: 1298e768-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YvojqNmdAdi3vUx1VnPVkxS20qvzhQiT1gPOSfH6JYQ6WPFm5hrV86aa9tgLYADpA9x1rgTxzG3lwoTpMddrnH4UB3NDN3PVBsRCkVsgmDf48XAOOnI4EKa9NERYmHh/j6o3zS0jRvboFsjMgFDUs/kAv+Wqt/NT66yfNZLou3u6mY5XDJX2bic9/5ZBwTuclhiCLBPzq7eOGEohHmXT/NQ4tXf366LFCeBIbA7uzhmyhMjx1Lh/FqOHAvWInIbYOe16LDEMSegIbkPMyObwR1gku44y96AKKGeqwKA8iRyWVaABTDbWo3b901eKX4FYRe8oFzKW0DCK/yvBBfa8xw== 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=ngb/Uc83s7G/8aLrdtXV+MINpMrv6VMh+dzEgsn3NaQ=; b=lGQpMZCCs/+E6yag8SOhx3VcQYtLSPyBwhBBAKevjGgfJMmCLfAkWAt3twRlay7ksUzmrSnfPPZJvDKH0iSuZuZtjJqxcyqfTZaeRKf7/ZsqDNQApfI4IoxqqXvQQHBzM2qtafzdUTk5xOU8aioYjuetJmsMVBWYjZHKk6FaeqsC3vJymPNVNtLnlDeV06zBTsxXZ+TFzQxc6r9RHzEB8FzJIn7F63yqlRDKSoCdXMoNyOZrwVKna9nxXQvk2IAdJhBIwuzXqiTHfKPgpCT7olREfKVSqILF1Fe+6Vmu0+emqbALJetFS2brCMtX1glSzSSpubyS/pyhAAqif8Py4g== 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=ngb/Uc83s7G/8aLrdtXV+MINpMrv6VMh+dzEgsn3NaQ=; b=Ft705z1BLCkBkrSM8BF8su2/xJL5aQZdsQjzn+qMdzdu2tu++a/edXvc385LnkZ7u2M6JkMzJZHW2PD3Hdo5GiS0HjF0JNWlRZ6X2Sbwd5UblexmnzPQXW4hy4/yEgZXYOe1IKRCk+iQToRRNsZCDUqTGNAKM12fMVSdg3iH4Ze+wq84eGo+8PXobMxs24R0gwM4y/uJ0RSI7D9k1cbnvTN2w9ofFRMvoEzNKPNKLIbHRZYYM8jjOfNFaFVnBjkbwrlbjv/YuIHZ+xccDYI2lLjfhYNyBME6bI/NJFEGgTpbzSmithOZEpsgB47TaWpNFgwyyP4MPt75DkVMR8zHeg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 5/8] xen/domctl: extend XEN_DOMCTL_assign_device to handle not only iommu Thread-Topic: [RFC PATCH v4 5/8] xen/domctl: extend XEN_DOMCTL_assign_device to handle not only iommu Thread-Index: AQHbyNXPDXt2FT3RV02cltfdm/Dd7g== Date: Mon, 19 May 2025 15:50:57 +0000 Message-ID: <4f58bf9c47c40413ee9250c4cd21458382aac857.1747669845.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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: 4814fdba-2e4e-48bf-f582-08dd96ecf29f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?Fk61h06h5Zkt3QzB2qONmvJMJTHsQ+pMeJ4dlo4/aDhJkFIPsuvoYaD4Vf?= =?iso-8859-1?Q?nHV5wgoNXlLNAj9EwjekpRSYGbj5Uda7wS+R0Jpo2bdzBFaMjLrM1oMRvu?= =?iso-8859-1?Q?/P4MA/WTJjn0lWZ5ITLdgV7ttBZ6Y9j5FD3gBgirmHCAab+r/1WtDA1TJP?= =?iso-8859-1?Q?gpX3U02G5FAfvKfIvuIN7nBvCY6iMzSxCc1DCft4eeickLIC96OfxaBNSg?= =?iso-8859-1?Q?h7a74X3J83Ckau/1zS1q0HzX/r3cjAtgbwOOFaqkQE9J+kYc0ls/JHyHma?= =?iso-8859-1?Q?tygjuUL5IX7E7qe4AhjrBSuraOOc/ZqtfroXtnpgtcxuMAasbb3eT0zFUD?= =?iso-8859-1?Q?X2li12IvMyV90BSIL+S6R7eNqwLACwYEmGMC57933cFx9juU2NRxkopcIL?= =?iso-8859-1?Q?mLi9z2PwMBFf4F4xP7lD3bhlOlNYGqi7rT+KC/1uxqRulr4lHCRnZW3ioD?= =?iso-8859-1?Q?31P5xjDZpetQe0IK/1WVkrPjjohdtMt5KvyM5y4RHPvm20OzjnA76xcUnU?= =?iso-8859-1?Q?JhH1Ch1dG/3QZoCs9cOQYJs16Kru0pnbSongyYFJA4uyRoPqA2oaVnhauQ?= =?iso-8859-1?Q?tjbVTsvYp7TmRJ7k90y6Xo/syfDiW5OjirxzKUv2Y8NTO5TNW17f7d49rc?= =?iso-8859-1?Q?F4z3aanryNIlLHs1sma+w9CwHEGoKTZcRMkBZAHtaBcdY2JpihymK/K6iR?= =?iso-8859-1?Q?AfRWNdvO+e9bzpoWhxiNX3K/E/4kkAMbFCMs14E/l9pX/c5m6qsCWZVWFX?= =?iso-8859-1?Q?G+hHJ4sUz66RRlMHdHohkZUeku6iO80u5dn9fKaMOnoatDZU5xxaTje07S?= =?iso-8859-1?Q?5YewifXdYNSHoAI+pvRP3PrmxLclqvXpuiaWViCqJu/KYLG5to07rywcYF?= =?iso-8859-1?Q?S7/lNSm0BkypMJof4GsXHamZpd2qDcLo0hp9Sdvb4zrplflWqnJsD53fsO?= =?iso-8859-1?Q?T9mMz3gtIf+uBdbwJdU5rG/CdB1C/kDPgSZsYValEX8To7wjVnoPvaiss1?= =?iso-8859-1?Q?dMnqqXlTJgSMZHEC0gb/1rk2KjWlOe+pyoCQVDQA9mT6TRoH9lUWuYq5B7?= =?iso-8859-1?Q?cQiSYlibEntaV54B1VpOVlMQuLxy3O6WJ+ElY4NG3QbkAMkP4xAZickOPS?= =?iso-8859-1?Q?nHdjlg94Bfm6CZnIbLZPIp3evEYeKyycPUe8DNYPyy/Qs4nmWKjie2C2tG?= =?iso-8859-1?Q?8IQT9uL635PYZbwYWuvemIeE29CDeOu0kU1r9iY/XHTs80usuBOApIUqkW?= =?iso-8859-1?Q?3o+ghZgMpKr7onZkHCDFmB7UAW2vx8kwwy0fgvWOIMqsKPEA30C/w758N0?= =?iso-8859-1?Q?973FSifM8xSZJ+/Ra2wsapLKbmex6dDOdUDoLrSrj7e60E+vsDBVA2FiG7?= =?iso-8859-1?Q?Rgp8m7ZOE8dTPUkVjxz8lIj68FtozbTRbpEZ8IwgPEAp2tvZzF8J1F4lbV?= =?iso-8859-1?Q?iWDTZy5IBdz80EMXxfgbjvF6RqCf0c7al6U3i8hyaj0feKM5Mzff3gN0aO?= =?iso-8859-1?Q?U8BXrdhUnorl5iqLp9Q0nB5yMQ++SzZfxrNEx/NecLOVEXbGbV+fSOmWcC?= =?iso-8859-1?Q?HBen7TQ=3D?= 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)(376014)(366016)(7416014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?7qlLpp1diIGUrXgCIuBS2MIsAbGtWBHWNi8sPQzgYfzIcI5zd0oWamKCpD?= =?iso-8859-1?Q?hDZg8J4wn1YIEc9QwBIGGKMfWuSxwrBGgZI78oIaOo96RyQtT5zJxKOH56?= =?iso-8859-1?Q?BzFGyo+avEsRU3C8KHH3e+enzZSTNgOby8Bq7/28Y1dyttAr4ZID+ZtWSZ?= =?iso-8859-1?Q?tFPtnambdnxIl1wXC3H8OhXPCjmyKTJJtV4ELCe4Cm1gppU7vfUAC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dRnZH+bogrAbZriSBFKDKMsT/au2vWSv?= =?iso-8859-1?Q?KF0tme51thPVVWnB8GnPE+PIRi9nj6SRM/g9ONikTxm96PcWRH4FyCizXF?= =?iso-8859-1?Q?DN6FaZ68Mz6WAOc7U8uLln1zObEYnAaZTCvLiSh0Oe3fqvB5fa8P5h6Izn?= =?iso-8859-1?Q?i3BJSIYpEIgexbaCj/MRnmRc/V6fHq8/oM8VissgzT1b+VhnT6hd9DoVsm?= =?iso-8859-1?Q?mwOwrRRpL2S+xHmaFY625yeBeQuNYPtwskLg5HF49j+2xlQd3XVGgecNbi?= =?iso-8859-1?Q?O1+RzLPqUW+IyvN7NHO2Y5TIYItjJNjqaQP2Fdf3QhjH0RKKNwoHvIupDh?= =?iso-8859-1?Q?5Oy/qUsu+VKmsa89/ofjtZKcT8MJyJef8rUdvDsbni7U9hcpBjaUJms2h+?= =?iso-8859-1?Q?UdnZylzgDzMA4/XsFjN1m2+resSi4QTpg6KpE0IMb2TVirQRwKioexjK1n?= =?iso-8859-1?Q?u0Zkfg89L6C5qh8chpvdII9IZULGlsVUbTZzKPtdwjn0yHvktKgVI8FUUT?= =?iso-8859-1?Q?jxknycJXzesaD4I/+4ggtzi3E21mULuqdsjzZjlIK38mtaYy1nwQ8NJg?= =?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: 4814fdba-2e4e-48bf-f582-08dd96ecf29f X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:57.3512 (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: CqHYKHE03zuHq3KtnGYLIQQong7yhKITgflql5ORezTsKGv+tEN88sEcFlT2sY4i1UdsrUWo14GO77CLO+KUfou7s7fOXdq3V4zE+u+0Gtk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669890970116600 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 --- xen/arch/arm/firmware/sci.c | 37 +++++++++++++++++++++++++ xen/arch/arm/include/asm/firmware/sci.h | 14 ++++++++++ xen/common/domctl.c | 19 +++++++++++++ xen/drivers/passthrough/device_tree.c | 6 ++++ 4 files changed, 76 insertions(+) diff --git a/xen/arch/arm/firmware/sci.c b/xen/arch/arm/firmware/sci.c index e1522e10e2..8efd541c4f 100644 --- a/xen/arch/arm/firmware/sci.c +++ b/xen/arch/arm/firmware/sci.c @@ -126,6 +126,43 @@ 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 -EOPNOTSUPP; + 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); + if ( ret ) + break; + + 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 71fb54852e..b8d1bc8a62 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 05abb581a0..a74ee92067 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -851,6 +852,24 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_= domctl) case XEN_DOMCTL_deassign_device: case XEN_DOMCTL_get_device_group: ret =3D iommu_do_domctl(op, d, u_domctl); + + if ( !ret || ret =3D=3D -EOPNOTSUPP ) + { + int ret1; + /* + * 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 after= IOMMU + * processing and expected to be executed for any DT device + * regardless if DT device is protected by IOMMU or not (or IO= MMU + * is disabled). + */ + ret1 =3D sci_do_domctl(op, d, u_domctl); + if ( ret1 !=3D -EOPNOTSUPP ) + 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 075fb25a37..2624767e51 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -318,6 +318,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 Fri Oct 31 09:46:44 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=1747669897; cv=pass; d=zohomail.com; s=zohoarc; b=O/YZmqOtUpsCkMytS3+0vDkkp3LjUTGDaAuXpY+/7bEasra50vbZEICW343CENxMWGIroia6XnpP8ksglZcLUFbE34Rb6jY3RaS9RpjzBQXHrHBXz5taiVrnuxAM9ZrltoK9k6CcVBvUGlfgMfe22MxbLxBf5Wlp3LpxZ/YiuMA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669897; 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=T95PAVbCzhHKP7RYhZufYK99SRLDzb3IXsU04ArQbxs=; b=MQMWw14QOMfjx/g+GiS88RLDoNqNzNZgWYucTWMOK/xtzIfK0RNCaELv1i2tzfeByHE51XQNNBSU0l741ZTVnB+wKhmBC/DIp/mZre2LSypVyiPDJcMyin36mTA/agQgIDtPaCFY0FhWwukwu2SVowIsSdtyc1e5A1pXv7hDFys= 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 1747669897759679.0681857401672; Mon, 19 May 2025 08:51:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989965.1373965 (Exim 4.92) (envelope-from ) id 1uH2lh-0006K8-F9; Mon, 19 May 2025 15:51:09 +0000 Received: by outflank-mailman (output) from mailman id 989965.1373965; Mon, 19 May 2025 15:51: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 1uH2lh-0006JU-7Z; Mon, 19 May 2025 15:51:09 +0000 Received: by outflank-mailman (input) for mailman id 989965; Mon, 19 May 2025 15:51: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 1uH2lf-00055d-Pa for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:08 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20625.outbound.protection.outlook.com [2a01:111:f403:260e::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 12aab7cd-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:51:05 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50: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%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50: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: 12aab7cd-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D+LixnOzErXoe9vOhFNbjwBMYj0ImXWY/bX8L8BgaHgtiSRhrI45NROOWupKXcofNYmAZYr4kkzauuzn/L86bq2RoAJdyG+FnJ6YDfJj32X3FIAPTWE5QThAn/d5dUH3XBBXcaKFZQXdKZ4EWCE4uRdeoauHVjls6ky4REwDbNn1nsSYrKO9JoHfKptt0Cjvnksk6vzRwL9MnT8wfmrGtqxN+9sIUHseMDyBYGMILKQQf3sxzoL++RRZOWmdjWZeCMHXS4hVn5sr6CQ++TnaO0QiL1auUIOkFvdGqmgzAWl2p/D++p78SMzfPjzwXH2acV5/U4odZr7WG38fEnLJqg== 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=T95PAVbCzhHKP7RYhZufYK99SRLDzb3IXsU04ArQbxs=; b=YMS+rf692s1SjaRHChDcEJ2D3ygiax1GcfxGziDsD//kTJuWKSqRsj57sHEVhBX4Ktr4HShttnEmdIswr5ukeeBXZ2+QwWdWEPyO88F1rVvUD1ms5wzqtS4F6NZrBtQvf+NaZmVVwpahpI6eItqyz0B18zZ4LjtKtXi5o8f+jmHIoYLkw2KrWDsOIzdbvpIrtuzoLi2m7TH01JOGovwIBkwQxLW9mrAD6EA9plKVLlfu1zWSH7Sm22OyCw3JEi5t6dG7XGdCid3A/VsxSbj0AS5pv1QrwYlqdkzvcdlJAvI2UrGjH14VV40/orPBWO13hL8rUyp0ddwFLfQNHEsNbg== 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=T95PAVbCzhHKP7RYhZufYK99SRLDzb3IXsU04ArQbxs=; b=iFLy/SvxwbZr65v5iegU0aRE0KTemVy853sFIpFLRk8xrbuf1L/hFTQKho3utDK73KAcsRc7WqZAc37LOeG3cSLhQ14Ys7T977kORapDsHl+fLNBz/jgozxM4EAAK5CPSaZSGL/vgodoJujClSExP2QMvgprpyfKPzww0uPAVKlRq2B0CUmvB7Qd8KI5LvuhixCxcKBEu/fTfCiCsV0ZhZJMvukjmGzv1sFKS8XoI0LE8V6x6kv+Vh9CsXN0eGHkuVUdLPQ7huXXcMB2cjGzqSXXDsKonksonVf7wImp/EPEPXYZhpi4AR7Gkgq9KEn7BuNeasu//M2H652Xc8ZYuQ== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 6/8] xen/arm: scmi: introduce SCI SCMI SMC multi-agent driver Thread-Topic: [RFC PATCH v4 6/8] xen/arm: scmi: introduce SCI SCMI SMC multi-agent driver Thread-Index: AQHbyNXPHUV4T01ZEEC9Uxm0LaLKHQ== Date: Mon, 19 May 2025 15:50:57 +0000 Message-ID: <318044ae12f13b6b297b3f5fda577a1a6cd143da.1747669845.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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: f2c928e0-13ca-48f0-5537-08dd96ecf2d0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?d7lB4ovUmioDg3SccrXN98XKvMbJKTQcG3LC0ncbZIXKkQ6n7NMm1JcoaU?= =?iso-8859-1?Q?lwRX10fUCy0UxOWXEg2b/iHMEUYPHUa4I6AYCyhYm4XiGe6l2SMPQNtrGe?= =?iso-8859-1?Q?7c26iCKeBoKOn+lmn7ym0cphmljAobn4+Raf85ikUAYQm2OWxd4kXRdsdO?= =?iso-8859-1?Q?OWZtRxb2eid+YFjJ92Y/NFPunc7CkKDPSbMwX+PGokSyRvsat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7Uxig1oY3GuS/g/c+B0ODuUxsxwcotcRlziXR?= =?iso-8859-1?Q?4aNBcT/SsugI/gyYJVvJLDFGpiRfxwp0+dwKCkCNJf7hUJNXy13aE9YVko?= =?iso-8859-1?Q?I0cw/HOZZae31OPwGQYcSvQ6b4iz8gGsHLXi0ZDIhca5lbP/oG47qlYQla?= =?iso-8859-1?Q?ZGIqtuT/uIDav3kAZqbARffLd3B1Ub2ZexXDN2QT6fJT5PzboHFPwCaM05?= =?iso-8859-1?Q?u0/CAi09CjoIDe0IjkvKH+EHoNLTMW5JFDNU80ebS/MDU26WRAtInc8eNF?= =?iso-8859-1?Q?Olh6N/9K0FliBdNQFQ0McLPufH9L/3A4bTS0+oTN7NDv6fUpaRIHaLHrBB?= =?iso-8859-1?Q?s1amDPnxtozgXuvPUgFKBkURMtkcs/0ZnPQ8SN+h56jCZQga2bm51oFyO4?= =?iso-8859-1?Q?w=3D?= 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)(376014)(366016)(7416014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?Oip3u8uQMcD9avsLLj3/jjXNDaB9aGmWdmwbM5ExdMatVG/Ni/g99B6/8J?= =?iso-8859-1?Q?GvO8miS2U93l/MOtqytjPdCTHduSnSmIoNIf7c/8ExF5U3oCayO2s1hoEl?= =?iso-8859-1?Q?dOHAoLoi7RQMaQbV1PQeDfQtqL4VWgzRbQ+sEu7yLKzO/sR94NOVlKYQEj?= =?iso-8859-1?Q?ACZpeIROlppe6JJSgLm4NZ1OQF9iJm9sh1AgUl9EDsC1v2RkxmOUJWx6dq?= =?iso-8859-1?Q?01MfGfU4TzjY2y1KUdyqYfqfGxNbCLKD1x+QVFpNXNYC4zORDZwrX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qGr4IZZO/EqSZpCUUe1fFNKjwuF5VDkNubDRsc5+TNI?= =?iso-8859-1?Q?jokdV9bLapDWMpmVKFkAnSK/dSyyqs/2fR0i++qIA7RmxTfwZptguzIQi7?= =?iso-8859-1?Q?QlRFFrdjQ0GwGpDjFrVtfpq7kONm6JNIWwOfjT1f5xidwMLT48rt3bLyQR?= =?iso-8859-1?Q?Gk8M1X8tgZU7dFkurhznYr1+hIZTAv+Y5F0n4POx2i+hontAFL+3ZlK4n4?= =?iso-8859-1?Q?YZx/2n6OZc1QpRNWBydMi57ptVMG0q2wdUvOhg/ik1MgDZLXFwTDEgXL+Y?= =?iso-8859-1?Q?F116R0gf9NGksnSBpUkwrZPds1Z9kWMSx1gDngWYa6ky5rYCrZxn357tRr?= =?iso-8859-1?Q?PffLxbhVpLYS+66AKqPmGIrts6bHUuUZB88097J9jj6EuKhmRe/pZJhv0S?= =?iso-8859-1?Q?076BjtF6+jtKLnveo9+DRBbJa7RSaaEeAtdMmFsI7TtVjYmomR24bhUwt3?= =?iso-8859-1?Q?klBWo9Rf67r4RSBPH+7IIlWv/oNCzJVqfICZRfhi5UmFtFDqTYUtYgNA?= =?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: f2c928e0-13ca-48f0-5537-08dd96ecf2d0 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:57.7394 (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: +ZN2yV/Dgc1AZ5XoiZ4C+AJMCk5coysW6Ydddhf2krFNKd9ig8WTbhPSYF1+F1m6m1BcWfEvWsKOKHyQzK9LCJQAzFxnvc4LxYZzUls+S0o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669899272116600 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-agnet support, as shown below. +-----------------------------------------+ | | | EL3 TF-A SCMI | +-------+--+-------+--+-------+--+-------++ |shmem0 | |shmem1 | |shmem2 | |shmemX | +-----+-+ +---+---+ +--+----+ +---+---+ smc-id0 | | | | agent0 | | | | +-----v--------+---------+-----------+----+ | | | | | | | | | | +--------------+---------+-----------+----+ smc-id1 | smc-id2| smc-idX| agent1 | agent2 | agentX | | | | +----v---+ +--v-----+ +--v-----+ | | | | | | | Dom0 | | Dom1 | | DomX | | | | | | | | | | | | | +--------+ +--------+ +--------+ The EL3 SCMI multi-agent firmware expected to provide SCMI SMC/HVC shared memory transport for every Agent in the system. The SCMI Agent transport channel defined by pair: - smc-id: SMC/HVC id used for Doorbell - shmem: shared memory for messages transfer, Xen page aligned, p2m_mmio_direct_nc. The follwoing SCMI Agents expected to be defined by SCMI FW to enable SCMI multi-agent functionality under Xen: - Xen manegement 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 expected to implement following Base protocol messages: - BASE_DISCOVER_AGENT - BASE_RESET_AGENT_CONFIGURATION (optional) - BASE_SET_DEVICE_PERMISSIONS (optional) The SCI SCMI SMC multi-agent driver implements following functionality: - It's initialized based on the Host DT SCMI node (only one SCMI interface is supported) which describes Xen management agent SCMI interface. scmi_shm_0 : 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>; // Xen manegement agent smc-id \#address-cells =3D < 1>; \#size-cells =3D < 0>; \#access-controller - cells =3D < 1>; shmem =3D <&scmi_shm_0>; // Xen manegement agent shmem protocol@X{ }; }; }; - It obtains Xen specific SCMI Agent's configuration from the Host DT, probes Agents and build SCMI Agents list; The Agents configuration is taken= from: chosen { xen,scmi-secondary-agents =3D < 1 0x82000003 &scmi_shm_1 2 0x82000004 &scmi_shm_2 3 0x82000005 &scmi_shm_3 4 0x82000006 &scmi_shm_4>; } /{ 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>; }; } where first item is "agent_id", second - "arm,smc-id", and third - "arm,s= cmi-shmem" for this agent_id. 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/HVC 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/HVC 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 shell 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: Oleksii Moisieiev Signed-off-by: Grygorii Strashko --- Changes in v4: - toolstack comments from Anthony PERARD - added dom0less support - added doc for "xen,scmi-secondary-agents" docs/man/xl.cfg.5.pod.in | 13 + docs/misc/arm/device-tree/booting.txt | 60 ++ docs/misc/xen-command-line.pandoc | 9 + 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 | 3 +- xen/arch/arm/firmware/Kconfig | 11 + xen/arch/arm/firmware/Makefile | 1 + xen/arch/arm/firmware/scmi-proto.h | 164 ++++ xen/arch/arm/firmware/scmi-shmem.c | 173 ++++ xen/arch/arm/firmware/scmi-shmem.h | 45 + xen/arch/arm/firmware/scmi-smc-multiagent.c | 860 ++++++++++++++++++++ xen/include/public/arch-arm.h | 3 + 15 files changed, 1371 insertions(+), 2 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/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 1ccf50b8ea..302c46d8bc 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -3122,8 +3122,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 8943c04173..c8923ab8b2 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -296,6 +296,20 @@ with the following properties: Should be used together with dom0_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 a non-zero ARM SCI agent id for the guest. This option is + mandatory if the SCMI SMC "scmi_smc_multiagent" support is enabled for + the guest. The agent ids of guest must be unique and in the range [1..= 255]. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. =20 @@ -764,3 +778,49 @@ 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 shell be provided in the Host = DT +according to the SCMI compliant EL3 Firmware specification with +ARM SMC/HVC transport using property "xen,scmi-secondary-agents" under +the top-level "chosen" node: + +- xen,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: + SCMI agent_id, + SMC/HVC function_id assigned for the agent transport ("arm,smc-id"), + phandle to SCMI SHM assigned for the agent transport ("arm,scmi-shmem"= ). + +As an example: + +chosen { + xen,scmi-secondary-agents =3D < + 1 0x82000003 &scmi_shm_1 + 2 0x82000004 &scmi_shm_2 + 3 0x82000005 &scmi_shm_3 + 4 0x82000006 &scmi_shm_4>; +} + +/{ + 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>; + }; +} diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 8e50f6b7c7..bc3c64d6ec 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1091,6 +1091,15 @@ which serves as Driver domain. The SCMI will be disa= bled for Dom0/hwdom and SCMI nodes removed from Dom0/hwdom device tree. (for example, thin Dom0 with Driver domain use-case). =20 +### dom0_scmi_agent_id (ARM) +> `=3D ` + +The option is available when `CONFIG_SCMI_SMC_MA` is compiled in, and allo= ws to +enable SCMI functionality for Dom0 by specifying a non-zero ARM SCMI agent= id. +The SCMI will be disabled for Dom0 if this option is not specified +(for example, thin Dom0 or dom0less use-cases). +The agent ids of domains existing on a single host must be unique. + ### dtuart (ARM) > `=3D path [:options]` =20 diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 28ba9eb787..7712f53cd4 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -229,6 +229,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 aa2190ab5b..11e31ce786 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -553,11 +553,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 bd22be9d33..81aa3797e3 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 parse_error; + } + 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 0a00f03a25..43d21eb889 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -835,6 +835,17 @@ int __init domu_dt_sci_parse(struct dt_device_node *no= de, 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 ) + 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 36d28b52a4..0c9274a2b3 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -616,7 +616,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,scmi-secondary-agent= s") ) continue; =20 if ( dt_property_name_is_equal(prop, "xen,dom0-bootargs") ) diff --git a/xen/arch/arm/firmware/Kconfig b/xen/arch/arm/firmware/Kconfig index 5c5f0880c4..6b051c8ada 100644 --- a/xen/arch/arm/firmware/Kconfig +++ b/xen/arch/arm/firmware/Kconfig @@ -29,6 +29,17 @@ 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" + 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..3f4b9c5d6b --- /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) 2024 EPAM Systems + */ + +#ifndef XEN_ARCH_ARM_SCI_SCMI_PROTO_H_ +#define XEN_ARCH_ARM_SCI_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 /* XEN_ARCH_ARM_SCI_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..dd613ee0b5 --- /dev/null +++ b/xen/arch/arm/firmware/scmi-shmem.c @@ -0,0 +1,173 @@ +/* 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 + */ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include + +#include "scmi-proto.h" +#include "scmi-shmem.h" + +/* + * Copy data from IO memory space to "real" memory space. + */ +static void __memcpy_fromio(void *to, const volatile void __iomem *from, + size_t count) +{ + while ( count && !IS_ALIGNED((unsigned long)from, 4) ) + { + *(u8 *)to =3D readb_relaxed(from); + from++; + to++; + count--; + } + + while ( count >=3D 4 ) + { + *(u32 *)to =3D readl_relaxed(from); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + while ( count ) + { + *(u8 *)to =3D readb_relaxed(from); + from++; + to++; + count--; + } +} + +/* + * Copy data from "real" memory space to IO memory space. + */ +static void __memcpy_toio(volatile void __iomem *to, const void *from, + size_t count) +{ + while ( count && !IS_ALIGNED((unsigned long)to, 4) ) + { + writeb_relaxed(*(u8 *)from, to); + from++; + to++; + count--; + } + + while ( count >=3D 4 ) + { + writel_relaxed(*(u32 *)from, to); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + while ( count ) + { + writeb_relaxed(*(u8 *)from, to); + from++; + to++; + count--; + } +} + +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 + sizeof(shmem->msg_header)) > 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 - sizeof(shmem) ) + { + 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..2f8e23ff76 --- /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 XEN_ARCH_ARM_SCI_SCMI_SHMEM_H_ +#define XEN_ARCH_ARM_SCI_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 /* XEN_ARCH_ARM_SCI_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..e023bca3a1 --- /dev/null +++ b/xen/arch/arm/firmware/scmi-smc-multiagent.c @@ -0,0 +1,860 @@ +/* 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 + +static uint8_t __initdata opt_dom0_scmi_agent_id =3D SCMI_AGENT_ID_INVALID; +integer_param("dom0_scmi_agent_id", opt_dom0_scmi_agent_id); + +#define SCMI_SECONDARY_AGENTS "xen,scmi-secondary-agents" + +#define HYP_CHANNEL 0x0 + +struct scmi_channel { + uint32_t agent_id; + uint32_t func_id; + domid_t domain_id; + uint64_t paddr; + uint64_t len; + 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; + 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 ) + 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; + + channel =3D get_channel_by_id(agent_id); + if ( channel ) + return ERR_PTR(EEXIST); + + channel =3D xmalloc(struct scmi_channel); + if ( !channel ) + 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); + 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_cpup(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 skip_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; + + /* always drop shmem */ + if ( dt_match_node(skip_matches, node) ) + { + dt_dprintk(" Skip scmi shmem\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; +} + +/* + * Finalize Dom0 SCMI specific DT nodes + * + * if SCMI is enabled for Dom0: + * - generate shmem node + * - map SCMI shmem MMIO into Dom0 + */ +static int scmi_dt_finalize(struct domain *d, void *fdt) +{ + __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; + struct scmi_channel *channel; + int nodeoffset; + __be32 *cells; + __be32 val; + char buf[64]; + int res, rc; + + if ( !sci_domain_is_enabled(d) ) + return 0; + + channel =3D d->arch.sci_data; + + /* + * Replace "arm,smc-id" with proper value assigned for Dom0 SCMI chann= el + */ + nodeoffset =3D fdt_node_offset_by_compatible(fdt, -1, "arm,scmi-smc"); + if ( nodeoffset < 0 ) + return -ENODEV; + + cells =3D (__be32 *)&val; + dt_set_cell(&cells, 1, channel->func_id); + res =3D fdt_setprop_inplace(fdt, nodeoffset, "arm,smc-id", &val, sizeo= f(val)); + if ( res ) + return -EINVAL; + + /* + * All SCMI shmem nodes should be removed from Dom0 DT at this point, = so + * the shmem node for Dom0 need to be generated from SCMI channel assi= gned + * to Dom0. + * The original SCMI shmem node from platform DT is used by Xen SCMI d= river + * itself as privileged channel (agent_id=3D0) to manage other SCMI + * agents (domains). + */ + snprintf(buf, sizeof(buf), "scmi-shmem@%lx", channel->paddr); + + res =3D fdt_begin_node(fdt, buf); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", "arm,scmi-shmem"); + if ( res ) + return res; + + cells =3D ®[0]; + + dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_C= ELLS, + channel->paddr, SCMI_SHMEM_MAPPED_SIZE); + + res =3D fdt_property(fdt, "reg", reg, sizeof(reg)); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "phandle", scmi_data.shmem_phandle); + if ( res ) + return res; + + res =3D fdt_end_node(fdt); + if ( res ) + return res; + + /* + * Map SCMI shmem into Dom0 here as shmem nodes are excluded from + * generic Dom0 DT processing + */ + res =3D iomem_permit_access(d, paddr_to_pfn(channel->paddr), + paddr_to_pfn(channel->paddr + + SCMI_SHMEM_MAPPED_SIZE - 1)); + if ( res ) + return res; + + res =3D map_regions_p2mt(d, gaddr_to_gfn(channel->paddr), + PFN_UP(SCMI_SHMEM_MAPPED_SIZE), + maddr_to_mfn(channel->paddr), p2m_mmio_direct_n= c); + if ( res ) + { + rc =3D iomem_deny_access(d, paddr_to_pfn(channel->paddr), + paddr_to_pfn(channel->paddr + + SCMI_SHMEM_MAPPED_SIZE - 1)); + if ( rc ) + printk(XENLOG_ERR "scmi: Unable to deny iomem access , err =3D= %d\n", + rc); + } + + return res; +} + +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; + int ret; + + channel =3D get_channel_by_id(HYP_CHANNEL); + 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; + + ret =3D do_smc_xfer(channel, &hdr, &tx, sizeof(tx), NULL, 0); + if ( ret =3D=3D -EOPNOTSUPP ) + return 0; + + return ret; +} + +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 __init int collect_agents(struct dt_device_node *scmi_node) +{ + const struct dt_device_node *chosen_node; + const __be32 *prop; + uint32_t len, i; + + chosen_node =3D dt_find_node_by_path("/chosen"); + if ( !chosen_node ) + { + printk(XENLOG_ERR "scmi: chosen node not found\n"); + return -ENOENT; + } + + prop =3D dt_get_property(chosen_node, SCMI_SECONDARY_AGENTS, &len); + if ( !prop ) + { + printk(XENLOG_WARNING "scmi: No %s property found\n", + SCMI_SECONDARY_AGENTS); + return -ENODEV; + } + + if ( len % (3 * sizeof(uint32_t)) ) + { + printk(XENLOG_ERR "scmi: Invalid length of %s property: %d\n", + SCMI_SECONDARY_AGENTS, len); + return -EINVAL; + } + + for ( i =3D 0; i < len / (3 * sizeof(uint32_t)); i++ ) + { + uint32_t agent_id =3D be32_to_cpu(*prop++); + uint32_t smc_id =3D be32_to_cpu(*prop++); + uint32_t shmem_phandle =3D be32_to_cpu(*prop++); + struct dt_device_node *node =3D dt_find_node_by_phandle(shmem_phan= dle); + u64 addr, size; + int ret; + + if ( !node ) + { + printk(XENLOG_ERR "scmi: Could not find shmem node for agent %= d\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 %d: %d", + 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; + } + + ret =3D PTR_RET(smc_create_channel(agent_id, smc_id, addr)); + if ( ret ) + { + printk(XENLOG_ERR "scmi: Could not create channel for agent %d= : %d", + agent_id, ret); + return ret; + } + + printk(XENLOG_DEBUG "scmi: Agent %d SMC %X addr %lx\n", agent_id, + smc_id, 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; + + /* + * Special case for Dom0 - the SCMI support is enabled basing on + * "dom0_sci_agent_id" Xen command line parameter + */ + if ( is_hardware_domain(d) ) + { + if ( opt_dom0_scmi_agent_id !=3D SCMI_AGENT_ID_INVALID ) + { + config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_S= MC_MA; + config->arch.arm_sci_agent_id =3D opt_dom0_scmi_agent_id; + } + else + config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + } + + 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; + } + else if ( config->arch.arm_sci_type =3D=3D + XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC_MA && + config->arch.arm_sci_agent_id =3D=3D 0 ) + { + dprintk(XENLOG_INFO, + "scmi: A zero ARM SCMI agent_id is not supported\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(HYP_CHANNEL); + 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 true; + + 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, + .dom0_dt_finalize =3D scmi_dt_finalize, + .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 __init int scmi_probe(struct dt_device_node *scmi_node, const void = *data) +{ + u64 addr, size; + int ret, i; + struct scmi_channel *channel, *agent_channel; + 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; + + if ( !dt_property_read_u32(scmi_node, "arm,smc-id", &scmi_data.func_id= ) ) + { + printk(XENLOG_ERR "scmi: unable to read smc-id from DT\n"); + return -ENOENT; + } + + /* save shmem phandle and re-use it fro Dom0 DT shmem node */ + if ( !dt_property_read_u32(scmi_node, "shmem", &scmi_data.shmem_phandl= e) ) + { + printk(XENLOG_ERR "scmi: unable to read shmem phandle 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; + } + + scmi_data.dt_dev =3D scmi_node; + + channel =3D smc_create_channel(HYP_CHANNEL, scmi_data.func_id, addr); + if ( IS_ERR(channel) ) + goto out; + + ret =3D map_channel_memory(channel); + if ( ret ) + goto out; + + channel->domain_id =3D DOMID_XEN; + + 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; + + i =3D 1; + + list_for_each_entry(agent_channel, &scmi_data.channel_list, list) + { + 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 ) + goto error; + + 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), &d= a_rx, + sizeof(da_rx)); + if ( agent_channel->domain_id !=3D DOMID_XEN ) + unmap_channel_memory(agent_channel); + if ( ret ) + goto error; + + printk(XENLOG_DEBUG "id=3D0x%x name=3D%s\n", da_rx.agent_id, da_rx= .name); + + agent_channel->agent_id =3D da_rx.agent_id; + + if ( i > n_agents ) + break; + + i++; + } + + 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_COMPATIBLE("arm,scmi-smc"), + { /* 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 Fri Oct 31 09:46:44 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=1747669888; cv=pass; d=zohomail.com; s=zohoarc; b=ew3Fk02+FZkKW5EcjK83EclaI7Re5xew/yEKZsCEDa8rFw4ymRIPaIyVrKgHQqWaF93g0cfqFSXTjk9ZSeL7uq67BppaVeBiRTrY6RwVtfKPBMp9/pZJ6EjvrVHm3x5mLmyBzapXgmm4HyDuInsnLoPEsmu0OIgsRZcRlvAG0fM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669888; 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=fiZyyBp5vPFXU/i3NtVXScDoBYnysWozlVWCFXbrvnU=; b=aN9pRYbaznn3R2hz8fknU6Y46XswtX9KXBRIdTFlVzJoW2d+nahzn2YA962cd4wlsGWB0K8iPc3KHSMqtAKqqGNKOXQ3RNJrx3hBlGB+hqa0n+biU3I8+b7jsOf+EligcETQug4koNMxi+TsQ+Z3qnyS4R480fhLYjCgxcjRKiE= 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 1747669888110691.3073506782533; Mon, 19 May 2025 08:51:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989966.1373973 (Exim 4.92) (envelope-from ) id 1uH2li-0006VM-61; Mon, 19 May 2025 15:51:10 +0000 Received: by outflank-mailman (output) from mailman id 989966.1373973; Mon, 19 May 2025 15:51:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uH2lh-0006TK-Vf; Mon, 19 May 2025 15:51:09 +0000 Received: by outflank-mailman (input) for mailman id 989966; Mon, 19 May 2025 15:51: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 1uH2lg-00055d-Iw for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:08 +0000 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on20612.outbound.protection.outlook.com [2a01:111:f403:260c::612]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1385b636-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:51:07 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50:59 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50: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: 1385b636-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=StCd4X8kFsxYQtaujbffGTSrnSTEnadfSHwI4OmQ7ww6FxCGDZTHkMdLmB8K5eypiTUcjJ9qniD3c0TE2Qtt9abdIX/DcGBKqEmVlQ/H02E9KO+veZofJ5bZE241fDDbf+Xhb3Pct7yG+zIFMVjudFtgdBU4Nwrzxle+OyOTde7Gq1YWs6nhdT2d7/thA6YW6LYJ/wKROBPZRRVJwzrZBkcqAqE/dWh/Qmpx3TAuHM3Pqflh7i3mMrQpqd6vK80SYduKu6H4edhUTwFuzVPD3JkW9/TdMIpS8y0IFbe35QwnxRjJCCRgCV4pqnFZ8zRj/g11vpE0kOQaymmmq8uRKA== 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=fiZyyBp5vPFXU/i3NtVXScDoBYnysWozlVWCFXbrvnU=; b=jvUvPb78x1PItVx+bvFurzUIwZVo3XEo4IBObdpx6cO/8QjvjCbMERmozz4/HwXOAiqlWdcuSTU6Q240XRywnAfBFSiJU9L7+BE5IpwNHGVyXuYsClSJfJ3VA7xfv5icdH2Qt84E8mqz85i0AXfO/KhilgWJiQN1sNmSJel1NzTPKcPyDWgmcYeEAE0o+mwiYhV1RIJ8fRFhjKl1lPRZMBkC4j2+tJan6xfRePtD6wsBi7SNmywztgHyS0rHY2XW/q72EJiGsGHOaRC+hbjNZI/hU+ZYBIq/b67CEK5c7wbUi7QIEwccG0U14zz3Tih7ES+eOK36XWY+aZc/XOTwkg== 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=fiZyyBp5vPFXU/i3NtVXScDoBYnysWozlVWCFXbrvnU=; b=axrUxhiRF3zrqy+P2YNW8D8J7duPfECqhjQD5uYhtjFy8wlQAfq8AsjTxEHdYTGcgnSnpHOs4CrGg4eR4oILxtLFg+MZNvAw7IhXidoaswMCHKZjYy0EFDotL7YwxSqohuBNzHtqSOWX33KiSgN1dIA9W9PVhdH1UYLjWhpFysdGCgmaLRNwMUsuhdDvWOGNUcZQ45e5JM5P0bXPOZ21bvnk+o9klvUfTAJstTM2ISWC2GymcIqGrIS31PBsvXRT1stlrZju0EqZTyRG7OE/WmSm1pykXSFCI+GtqIEdNRmDyYdgi/f3Chy19stE5XrpsE+JJneTmPiz4v60lPSoYg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 7/8] docs: arm: add SCI SCMI SMC multi-agent driver docs Thread-Topic: [RFC PATCH v4 7/8] docs: arm: add SCI SCMI SMC multi-agent driver docs Thread-Index: AQHbyNXP28/MAaIPLEugDxuikDXW5w== Date: Mon, 19 May 2025 15:50:57 +0000 Message-ID: <6778db411b06a1f30d3983d94f3f23fc579b8382.1747669845.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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: c3e4958e-2404-4873-2ad9-08dd96ecf2f7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018|13003099007; x-microsoft-antispam-message-info: =?iso-8859-1?Q?yowmkBXagC67KWTAHUfQduceAFzhvkfvgEkzuxd52zQe3LEib/txx9CMq5?= =?iso-8859-1?Q?heggBHKKI91ADDvwbeHuzvQgnX/ms6QUNQcXAi3XSKTYsWdjN86r1FoH00?= =?iso-8859-1?Q?j7R1Vnp1rbaOV41JiatcLc4YTLXG9297GzB2H7Y8HsjGiJS6h46ehoxY4L?= =?iso-8859-1?Q?ilBld8h5KW8EX9KRuEqhUhSNJZu2TXW4jtlwRhg0tfINP1w8t9qS2bPfN0?= =?iso-8859-1?Q?W6T1qr7rIdikY2JG1EilwjEUKtLs6z7hO5IMAl3Mn9lNpAw1kTBp1TVIlK?= =?iso-8859-1?Q?PMKet5ltAbDXyJqBTa0eJEZ5T+SIaEaJWWOXtQG1/lAAh/dMttkS4+fBJ2?= =?iso-8859-1?Q?dK983PacyKXFVtI8zcQaWlNG3QGWfVRrbkq62DIAOVfOzJ0Ur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3PAvCDONhlJXqLi76UCFlunIoB7tGJ5aa+cIbbPf5?= =?iso-8859-1?Q?1MaTeRVelTeTRV/7/TzN5mx/JJAtL1IDSYl0TnWdu9GOQ+Nu6EekVtOaTn?= =?iso-8859-1?Q?mrJIxkNbxDCGV4SY7agpRZiSFUfh0q59NNhlwxi4Vt5m9OwsrLcLT2T4mU?= =?iso-8859-1?Q?1nTgR5lCI9xjjLPo3S89sEBQSuAd3KC7wi4xDAgQEj2HXoEsagGHzM80cx?= =?iso-8859-1?Q?4=3D?= 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)(376014)(366016)(7416014)(38070700018)(13003099007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?UvP9iTv7vK8tZ6wl8fMtxVUOzrDm9lRuprtENu4msawNAO8VqhifFRsdH7?= =?iso-8859-1?Q?HXconBvLEPvbs0cKPxfHQIdDePljuIP//2VYpcMaovlXNBKAIxnvWfGrRy?= =?iso-8859-1?Q?/vBv8BO42wvoJVso86gPFFFbEMbKTv1r8oZLTounabAnYKe8zzC98MAM5k?= =?iso-8859-1?Q?XpEeCz9XqsQwvU++mT06G5aQ/527Zwz29XaVbu/xJgUV08hrvnMEPc8Jot?= =?iso-8859-1?Q?sL/14+c7WbZINCd29W5dLLC9vF2oIjY1++fY/QB9gLDVe0ZM9jIBGUXgRa?= =?iso-8859-1?Q?C94lZUBZbYF7kWa0nk8EOjWgiS+8g4c8lInaYNnFFi7gIicnfKViLT0iPG?= =?iso-8859-1?Q?BI0qPVg+fy63so52MmxF/o1ggfkYY3DQj4v9dE3Hm0675N86gI1Wmu0Cen?= =?iso-8859-1?Q?CNMChrJqASi43b7lbqo6hlS16TDGB+Gj90BxRlG3rjcksmthjyUdAwap5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b3zYg1127Fv/BXIXAR3Y0IubgG1n?= =?iso-8859-1?Q?CGcOaa+jigCofky7naeDYw2MCHKBPIUtMC4P77+81upoVG8n9zioay6Vfm?= =?iso-8859-1?Q?OktcYmNKMN90neqzgy9/JJvapk4TrQskOE201VfQHBTVYlwXyXTyeSx56Q?= =?iso-8859-1?Q?ktcH36SgB1WxMSkCgkOqWZSpGoKeNRbkhUWN7YdFD7Zqzrm7O6YLWc+it8?= =?iso-8859-1?Q?41fNA1P0tjMetkwjFMFacUtboCAnrcIWZmpwQ7JQzXQIBvpq2jNaunGqD7?= =?iso-8859-1?Q?ee3JFLpGJmSxKQWuyu2mTBmQsfyFZlP280QF/dVIiu07/936yD8D5DHA?= =?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: c3e4958e-2404-4873-2ad9-08dd96ecf2f7 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:57.9840 (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: pKRg4yWK8CR6vkhNzANJvjOsloh9hdyiX/MotpzML1fjiGG+2LLTyLEWRs3ABglBkzd1SeI4AW3BNXI+EVW+Y3xaWWXqHODz5d6sgfDypvw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669889424116600 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 --- .../arm/firmware/arm-scmi.rst | 267 +++++++++++++++++- 1 file changed, 266 insertions(+), 1 deletion(-) diff --git a/docs/hypervisor-guide/arm/firmware/arm-scmi.rst b/docs/hypervi= sor-guide/arm/firmware/arm-scmi.rst index bf6a458a6a..27739015d5 100644 --- a/docs/hypervisor-guide/arm/firmware/arm-scmi.rst +++ b/docs/hypervisor-guide/arm/firmware/arm-scmi.rst @@ -31,7 +31,10 @@ domain serving as Driver domain). =20 The below sections describe SCMI support options available for Xen. =20 -[1] `Arm SCMI `_ +| [1] `Arm SCMI `_ +| [2] `System Control and Management Interface (SCMI) bindings `_ +| [3] `Generic Domain Access Controllers bindings `_ + =20 Simple SCMI over SMC/HVC calls forwarding driver (EL3) ------------------------------------------------------ @@ -175,3 +178,265 @@ enabling SCMI with "arm_sci" xl.cfg option. -> xen,reg =3D <0x0 0x47ff0000 0x0 0x1000 0x0 0x22001000>; -> xen,force-assign-without-iommu; }; + +SCMI SMC/HVC multi-agent driver (EL3) +------------------------------------- + +The SCMI SMC/HVC multi-agent driver enables support for ARM EL3 Trusted Fi= rmware-A (TF-A) which +provides SCMI interface with multi-agnet support, as shown below. + +:: + + +-----------------------------------------+ + | | + | EL3 TF-A SCMI | + +-------+--+-------+--+-------+--+-------++ + |shmem0 | |shmem1 | |shmem2 | |shmemX | + +-----+-+ +---+---+ +--+----+ +---+---+ + smc-id0 | | | | + agent0 | | | | + +-----v--------+---------+-----------+----+ + | | | | | + | | | | | + +--------------+---------+-----------+----+ + smc-id1 | smc-id2| smc-idX| + agent1 | agent2 | agentX | + | | | + +----v---+ +--v-----+ +--v-----+ + | | | | | | + | Dom0 | | Dom1 | | DomX | + | | | | | | + | | | | | | + +--------+ +--------+ +--------+ + +The EL3 SCMI multi-agent firmware expected to provide SCMI SMC/HVC shared-= memory transport +for every Agent in the system. The SCMI Agent transport channel defined by= pair: + +- smc-id: SMC/HVC function id used for Doorbell +- shmem: shared memory for messages transfer, **Xen page aligned** with ma= pping``p2m_mmio_direct_nc``. + +The following SCMI Agents 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 expected to implement following Base protocol messages: + +- BASE_DISCOVER_AGENT +- 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 +^^^^^^^^^ + +To build with the SCMI SMC/HVC multi-agent driver support, enable Kconfig = option: + +:: + + CONFIG_SCMI_SMC_MA + + +Driver functionality +^^^^^^^^^^^^^^^^^^^^ + +The SCI SCMI SMC multi-agent driver implements following functionality: + +- The driver is initialized based on the Host DT SCMI node (only one SCMI = interface is supported) + which describes Xen management agent SCMI interface. + +.. code:: + + scmi_shm_0 : 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>; <--- Xen manegement agent smc-= id + \#address-cells =3D < 1>; + \#size-cells =3D < 0>; + \#access-controller - cells =3D < 1>; + shmem =3D <&scmi_shm_0>; <--- Xen manegement agent shmem + + protocol@X{ + }; + }; + }; + +- 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 "xen,scm= i-secondary-agents" + property where first item is SCMI "agent_id", second - "arm,smc-id", and + third - "arm,scmi-shmem" phandle for this "agent_id": + +.. code:: + + chosen { + xen,scmi-secondary-agents =3D < + 1 0x82000003 &scmi_shm_1 + 2 0x82000004 &scmi_shm_2 + 3 0x82000005 &scmi_shm_3 + 4 0x82000006 &scmi_shm_4>; + } + + /{ + 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_4: sram@47ff4000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff4000 0x0 0x1000>; + }; + } + + +.. 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/HVC + 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/HVC 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_scmi_agent_id=3D"** Xen command line is used to= enable SCMI functionality for +Dom0. if not provided SCMI will be disabled for Dom0 and all SCMI nodes re= moved from Dom0 DT. + +The driver updates Dom0 DT SCMI node "arm,smc-id" property with value and = fixes up "shmem" property +according to the assigned for Dom0 SCMI "agent_id". + +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/HVC multi-agent driver performs "access-controller" provi= der 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:: + + &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:: + + 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:: + + 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 From nobody Fri Oct 31 09:46:44 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=1747669893; cv=pass; d=zohomail.com; s=zohoarc; b=WZ2HTWBnrmgTLd2tM1jn/N/wRHTUdkxIUkOlEj0ZNbZ+fmttEevcM7ydt+BjIcsH/pdh5E1u/3m68l9pdWP6YmIUzEVEGnDcL4uwfB88RWOZDjqmGU6ZYW0ZhOT8MeBRHgiqgi2L/0cKpG4EI6lvGg9DdjsQi3IQoyXCLg8VaBU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747669893; h=Content-ID: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=Jx3fLHSwk7VgFQnLSwZrpE1wKHHCAxXq7JgHsDxezbE=; b=R/GJpyoOrWxrFxSCqbqCeww1uwqBsgM6MuCLHV7ZvCbU6DaMPENIIkCJwsCAn/AYsm/zRaDKdTYSHQbrwLjH2kj2mq8X5Lj+ODkeAocL77hkZ/Jkp0d663aD6Fzg4WZX9veR7tEh1QgZIxgaI7VND5Q4buB9X+W4ssoCK/R1EII= 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 1747669893726576.2887876694522; Mon, 19 May 2025 08:51:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.989967.1373988 (Exim 4.92) (envelope-from ) id 1uH2lj-0006tb-LV; Mon, 19 May 2025 15:51:11 +0000 Received: by outflank-mailman (output) from mailman id 989967.1373988; Mon, 19 May 2025 15:51: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 1uH2lj-0006sj-D4; Mon, 19 May 2025 15:51:11 +0000 Received: by outflank-mailman (input) for mailman id 989967; Mon, 19 May 2025 15:51:09 +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 1uH2lh-00055d-Ey for xen-devel@lists.xenproject.org; Mon, 19 May 2025 15:51:09 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20625.outbound.protection.outlook.com [2a01:111:f403:260e::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 13f9ea66-34c9-11f0-b892-0df219b8e170; Mon, 19 May 2025 17:51:07 +0200 (CEST) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AS8PR03MB9023.eurprd03.prod.outlook.com (2603:10a6:20b:5b7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.29; Mon, 19 May 2025 15:50:59 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::f12d:7394:bbe3:dfc%4]) with mapi id 15.20.8722.031; Mon, 19 May 2025 15:50:59 +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: 13f9ea66-34c9-11f0-b892-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B+qpqXHemeHdhUk5bNtkj670k9kwlq9bz8R4ud466fq8HEfo37GRF5c1LdaI9ehawN5vW3bHzWxEwA+WfNU8jhrsm1njo9bG8RKJMT112lWfbNWon9lNnWG06DTsOITCgc7GgdmlonHkX4jCTJFjI0RMIdaw0uQyD+NDeaqN0B6j5k7ZkLA2SvejwnCIJdD6j26AgwqswnYZm2l4ozxLSIJBoXayjdLtqgsJFQSMAPqlmITz9EZ8clPAN8yfuQm3842724XwYz/iGtE+4UGojNDv7uK9D8tlG/RkD9EFgP8i4rIDAjfW6yOCTiX38JtEZy3f8L3OStHAecwuOLglxg== 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=Jx3fLHSwk7VgFQnLSwZrpE1wKHHCAxXq7JgHsDxezbE=; b=v146IgmU/T1k7BOfqGeff1jZjNgNN0jyr//gG6kV+BK7A7k7iAtwSFO0uRzK9dn2Wp2rXzMUhxBy6BVAYAoeXZKpb5zXk90VXdWNwy9mGpyye3vmLUytEA6sK6bTakMR9IU0Os4nLaFWQ5fPPUQ8kYpqvMb3I9S6ddDo/HsAYZ9Vnmv82hM+vW7GueflZF/U8EeL3Et86pKGfAAxm9go0pmWhJzdIM1va5RytixRwkUZmTc6RG11cohAsAJM1/PXcpG/B6bhpunoYRZCwaPM3ebB+IHRdZkOO+BqB0YriO6wZ3UmG8NKwBIWMbwtSUVHC7GlIiNSD6Lwv9GKqmk6Ng== 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=Jx3fLHSwk7VgFQnLSwZrpE1wKHHCAxXq7JgHsDxezbE=; b=si3nX9+xO3BMFrsTFWYVQKGV2jtEn4JzH347aVU45h/dnG3LKk/Qy3n4pSDffYOs+dszNa0nQlGD2zY7x8OobL/c9ZWnBiVDTqtdVizsqGVkyVGJUsair+chl702sRGxCMNa5042NZIu21U1xEo15lUeDk/+P0oNh5N88mQdZHYeiRFLw7tcU0bQSHGt6/7CESiuEWHUSuWo+GjQQyP6y1EfhEBAR8PEKHlEmWTMBXlDSvIMaohppSd8LkXIu5ywNI6P1/p4cNUPHGxuYwaqvpDPqV1eZgHb0Vd/wMONZo5uDTmRLgJLvFC+rOwS+fZGWbuRIiHgERXp2//wbpinhw== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Anthony PERARD , Bertrand Marquis , Jan Beulich , Juergen Gross , Julien Grall , Michal Orzel , Oleksii Moisieiev , =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= , Stefano Stabellini , Volodymyr Babchuk , Grygorii Strashko Subject: [RFC PATCH v4 8/8] docs: arm: proposal to add separate SCMI node for Xen agent Thread-Topic: [RFC PATCH v4 8/8] docs: arm: proposal to add separate SCMI node for Xen agent Thread-Index: AQHbyNXQTZOEYVEinUiuxBk1KdhKoA== Date: Mon, 19 May 2025 15:50:58 +0000 Message-ID: <3f7e1e99f5d1018064f3c4825aff16bd487cf558.1747669845.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_|AS8PR03MB9023:EE_ x-ms-office365-filtering-correlation-id: 14106a3a-8921-49fa-a2b8-08dd96ecf319 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|38070700018|3613699012; x-microsoft-antispam-message-info: =?utf-8?B?bEk4UW45bThteXBjdFBtNStUL1pLb1NKTjBRcGg3U1Y5b1h2RDRKYzVwcVZx?= =?utf-8?B?dEZNK2xsMjU3M2U4enRyZDlMcjc1VUlqMkxJTDRNcnRQTC80S2d5a0lrTE5y?= =?utf-8?B?dkdtOFJIbGhZY0NBMTN5ZkpaYkRsc3hQdHNKaEd3OE1wcFBkQWFCTEtKZDBX?= =?utf-8?B?dkgvaVdsM0xQdUVTMEFHSmtuSUxjRDk4S3A4UHBqUFhabmlQN1AwTFZoN0gw?= =?utf-8?B?NGR1UC9oVEVlZ3pibHoxRFFZeWV4VUpOQWV3M1YzbGlDSmZsVXkraTNvcUpk?= =?utf-8?B?TkZGZ3dBQnFuTzB0TVhESnkzQzc2ZjdKUEd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NSPM;H:PAVPR03MB8946.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(7416014)(38070700018)(3613699012);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?B?Qk1yRnl0U2xNRjdDMjFoVzJCdXZDaDl5WHk2U2hhZUJoQmhSbDI1c3hSeFdX?= =?utf-8?B?aGttT2JWYWh0eWtPVTl5bnk3ZzhhODN1SHNVVFp3UGJKayt5UTBMaGZGRWMw?= =?utf-8?B?S1pvOFUwL0Vnb3ZWc2MrdnFIM0ZJKzd0ZTk4QzNPeXhtRkExVk8yS0tQamhL?= =?utf-8?B?MGVxQ2FGeFRrSXByQSttc05uRzhObFB3MEtnQkF5TTYzQzRmSklLWTRrUyt2?= =?utf-8?B?U05nNk0zVi93SHZBaE9NdkIwSkoxQnVDZFFwWXcveFM2UmVtbDEwSFRmaHZa?= =?utf-8?B?VUlINFgwc3VBb2FUOHYwMFhSQzNILzFGSENSdDlPd216ZzdHQi93TVNobS94?= =?utf-8?B?QklPUHBWV3VnVmZCR2V3aGFKcys1SHZIT3N4eitTdCsvVzNReWFVbnBJdmJw?= =?utf-8?B?clNIc1YzT0tsODNSd0FESEJaUzl1b2U5S3JPR1dkVHJmSGVpc0RYM05qcnJD?= =?utf-8?B?WVFaa08wcjlla2hzdlFydDNpWCtISnRjMXR1RmlNRy92a2JITzFFaUdUejJO?= =?utf-8?B?YW9aTzE1ckJhN0NBRHpNNTY5T0ltUkEzSXBCa25SRkZXc2VxbXBXS1E1aWhs?= =?utf-8?B?K0NPbFpXRUxWbXVrUFhEWHVtQWNvanY5YVE2b1NOSVcrcmNlQmFYRG1UdzFR?= =?utf-8?B?RXNYY2h2cG5wd2NLZWQxSFlVRVorTHNYMEhaTVNhY3JxZExGL1J0Ui95T0V6?= =?utf-8?B?T0dMc3Z0NDZJRzdySXc5MHU2NDdSN2hWMUFUZGh5eEEyaVp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JPVDIwNG93SVFvSnE1dXBXNTFJNnFXRFdq?= =?utf-8?B?dzkxQU1WMFF5VzNYeWtXYlVsZng5K0tab290YnhrOHd3KytWOWYyMGJQRUxF?= =?utf-8?B?RkV3Mm5oQnNJaVpjUUp0QlY5cHVBSHpuMW1NNVJEOEZQalp5akJNK3N5Rnpr?= =?utf-8?B?dHdsYUxiUjdhVTBTdE50OFlVT2ZCcTFGZ1FKVFR2WExPMHhCYkxNY0ZJUGVZ?= =?utf-8?B?NGoydFFITTlXVlk5c2ZVTzNIb05wODZndFg4Slk3bFFVelhHLzVTU0dJc2Jh?= =?utf-8?B?bU1zOXZQVzlBVUdKV3FHN0xUYVdCdW1iaTZHZkhCVGVHVmlBZGJZRVE3Vkxi?= =?utf-8?B?SmFMcFdQbTdWbnRkUy84OGJsdWpDOTBvN0RmMkRXN3JBa1VQelFzbnRwNG11?= =?utf-8?B?VWxoT1BENFdLM3BpOTMrbk4rT1FrMk9OSy85MjNIanRJVXU0SFVFUG9PN3kw?= =?utf-8?B?dk1KU2VES0NoYzM3ZllyK0JmempaYVNWTzVaMEVWWlp5ZE52QWYreHRZbVRi?= =?utf-8?B?ZGc9PQ==?= Content-Type: text/plain; charset="utf-8" Content-ID: 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: 14106a3a-8921-49fa-a2b8-08dd96ecf319 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2025 15:50:58.4182 (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: +USJlQBwp9TbfU5wIY/0M+9IagxRXCfnmYfStOR/FAXZvwd4EGgd140ZuYoq7E2eTEhWuoFvq+yYevUQ7aDNcmWuzf7SdyF/PLZLlHjXYJY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB9023 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1747669895163116600 From: Grygorii Strashko Proposal description to add separate SCMI DT node for Xen management agent under "chosen" or xen-config node, like Hyperlaunch "xen,config". This proposal introduces a new approach to the Xen multi-domain configuration, where all Xen-specific configuration has been moved under the "/chosen" node. This requires less Dom0 device tree manipulation and isolates Xen configuration from domain configuration. This approach provides the following device tree (DT) parameters: - "xen,scmi-secondary-agents": A Xen-specific parameter under the "/chosen" node, which describes the SCMI agent configuration for the domains. - the SCMI configuration for Xen (privileged agent) and the shared memory configuration for all agents are provided under the "/chosen" node and are used strictly by Xen for its initial configuration. - the scmi_shm and SCMI configuration for Dom0 are placed in the "/firmware/scmi" node so that they can be moved to Dom0 without any changes. This configuration allows the use of Xen-specific nodes to provide information strictly needed by Xen while using the default SCMI configuration for Dom0 and other domains. As a result, no additional bindings need to be introduced to the device tree. Signed-off-by: Grygorii Strashko Signed-off-by: Oleksii Moisieiev --- .../arm/firmware/arm-scmi-proposal.rst | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 docs/hypervisor-guide/arm/firmware/arm-scmi-proposal.rst diff --git a/docs/hypervisor-guide/arm/firmware/arm-scmi-proposal.rst b/doc= s/hypervisor-guide/arm/firmware/arm-scmi-proposal.rst new file mode 100644 index 0000000000..fcc2ed2b65 --- /dev/null +++ b/docs/hypervisor-guide/arm/firmware/arm-scmi-proposal.rst @@ -0,0 +1,224 @@ + +Proposal for SCMI multi-agent driver bindings +=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=3D=3D=3D=3D=3D=3D=3D=3D + +Now the Xen configuration for SCMI multi-agent support is done in a bit co= mplicated way, especially +from SCMI multi-agent driver initialization and Dom0 DT manipulation point= of view. +Also it does not take into account future requirements to support SCP SCMI= FW. + +To enable SCMI multi-agent user need: + +* take host DT with basic SCMI enabled +* add SCMI shared-memory nodes for all agents +* update SCMI node to point on SCMI Xen management channel (``[smc-id, shm= em]``) +* add "xen,scmi-secondary-agents" property to the "\chosen" node + +.. code:: + + chosen { + xen,scmi-secondary-agents =3D < + 1 0x82000003 &scmi_shm_1 + 2 0x82000004 &scmi_shm_2 + 3 0x82000005 &scmi_shm_3 + 4 0x82000006 &scmi_shm_4>; + } + + /{ + // SCMI shared-memory nodes for all agents + scmi_shm_0 : sram@47ff0000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff0000 0x0 0x1000>; + }; + 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_4: sram@47ff4000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff4000 0x0 0x1000>; + }; + + firmware { + scmi: scmi { + compatible =3D "arm,scmi-smc"; + arm, smc - id =3D <0x82000002>; <--- Xen management ag= ent channel "smc-id" + #address-cells =3D < 1>; + #size-cells =3D < 0>; + #access-controller-cells =3D < 1>; + shmem =3D <&scmi_shm_0>; <--- Xen management agent cha= nnel "shmem" + + protocol@X{ + }; + }; + }; + } + +Important thing to note is that all information about multi-channel suppor= t is strictly Xen specific. + +During initialization the SCMI multi-agent driver uses Host DT SCMI node a= nd +"xen,scmi-secondary-agents" property to init itself and then, during Dom0 = creation, manipulates +Dom0 DT to remove Xen specific SCMI info and update dom0 SCMI nodes with D= om0 SCMI agent specific +information. + +There are two negative points: + +1) Double DT modification - one is user to set up SCMI Xen support in Host= DT, second - + Dom0 DT manipulation. +2) In case of future support of mailbox shared-memory transport there coul= d be up to 4 mailboxes and + up to 2 shared-memories per SCMI agent channel. + +Hence SCMI multi-agent support is Xen specific knowledge there is a propos= al to add it as Xen +specific DT definitions and so minimize Host and Dom0 DT manipulations. +Those definitions can be added in "/chosen" or, ideally, in "xen,config" n= ode (like in Hyperlaunch design). + +The SCMI binding stays generic, just two SCMI nodes defined - one for Xen = management channel and +one for Host Dom0 OSPM. + +Example of using "chosen" for configuration: + +.. code:: + + /{ + + chosen { + ... + + // Xen SCMI management channel + scmi_shm_0 : sram@47ff0000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff0000 0x0 0x1000>; + }; + scmi_xen: scmi { + compatible =3D "arm,scmi-smc"; + arm,smc-id =3D <0x82000002>; <--- Xen manegement agent smc= -id + #address-cells =3D < 1>; + #size-cells =3D < 0>; + #access-controller-cells =3D < 1>; + shmem =3D <&scmi_shm_0>; <--- Xen manegement agent shmem + }; + + // SCMI multi-agent configuration + 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-secondary-agents =3D < + 1 0x82000003 &scmi_shm + 2 0x82000004 &scmi_shm_2 + 3 0x82000005 &scmi_shm_3 + 4 0x82000006 &scmi_shm_4>; + }; + + // 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{ + }; + }; + }; + } + + +In the above case: + +1) Xen SCMI multi-agent can be probed with DT configuration from "chosen" = (or special "xen,config") + node and all Xen related nodes can be easily dropped from Dom0 DT. +2) Host SCMI OSPM channel DT nodes can be copied to Dom0 DT without change= s if SCMI enabled for it. +3) Future support for mailbox shared-memory transport (SCP SCMI FW) can be= simplified as no more + manipulation required with Dom0 SCMI "arm,smc-id" and "shmem" DT proper= ties. + + +Example of using "xen,config" for configuration: + +.. code:: + + hypervisor { + compatible =3D =E2=80=9Chypervisor,xen=E2=80=9D + + // Configuration container + config { + compatible =3D "xen,config"; + ... + + // Xen SCMI management channel + scmi_shm_0 : sram@47ff0000 { + compatible =3D "arm,scmi-shmem"; + reg =3D <0x0 0x47ff0000 0x0 0x1000>; + }; + scmi_xen: scmi { + compatible =3D "arm,scmi-smc"; + arm,smc-id =3D <0x82000002>; <--- Xen manegement agent smc= -id + #address-cells =3D < 1>; + #size-cells =3D < 0>; + #access-controller-cells =3D < 1>; + shmem =3D <&scmi_shm_0>; <--- Xen manegement agent shmem + }; + + // SCMI multi-agent configuration + 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-secondary-agents =3D < + 1 0x82000003 &scmi_shm + 2 0x82000004 &scmi_shm_2 + 3 0x82000005 &scmi_shm_3 + 4 0x82000006 &scmi_shm_4>; + }; + }; + + /{ + // 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{ + }; + }; + }; + } --=20 2.34.1