From patchwork Mon Sep 30 11:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 13815920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C731BCF6497 for ; Mon, 30 Sep 2024 11:47:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.807253.1218597 (Exim 4.92) (envelope-from ) id 1svEsM-0000jj-8T; Mon, 30 Sep 2024 11:47:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 807253.1218597; Mon, 30 Sep 2024 11:47:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1svEsM-0000im-3U; Mon, 30 Sep 2024 11:47:38 +0000 Received: by outflank-mailman (input) for mailman id 807253; Mon, 30 Sep 2024 11:47:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1svEsL-0000Cy-Ke for xen-devel@lists.xenproject.org; Mon, 30 Sep 2024 11:47:37 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20603.outbound.protection.outlook.com [2a01:111:f403:2613::603]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c9445154-7f21-11ef-a0ba-8be0dac302b0; Mon, 30 Sep 2024 13:47:36 +0200 (CEST) Received: from PA4PR04MB9565.eurprd04.prod.outlook.com (2603:10a6:102:26b::13) by AS8PR04MB8357.eurprd04.prod.outlook.com (2603:10a6:20b:3f1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Mon, 30 Sep 2024 11:47:34 +0000 Received: from PA4PR04MB9565.eurprd04.prod.outlook.com ([fe80::d8ae:2e16:5a97:1709]) by PA4PR04MB9565.eurprd04.prod.outlook.com ([fe80::d8ae:2e16:5a97:1709%4]) with mapi id 15.20.8005.024; Mon, 30 Sep 2024 11:47:33 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c9445154-7f21-11ef-a0ba-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xm+o2I8NUtHsZTt1Y1ueSqpRH+16cETNR6Bow8ZnJPMVCsq8UyhnprbruzcQvrnUOpt7Kaa0ZmNoL976kL3wcUeQbB4QOfLStP3JqBjWZQLNnYU/0nNJSva66T1Tb2YeSwfpOPtrjwgkt9eNjbeQLa5lhDNcU0tj+rTkZuxdqQdjmR9CtsrdYOiXEqeT96/e4ZVTbb7f2S7s9eovorAhoUQC5q8/22iFmhbR8YI5mpwOwfaGySgUzwiuY1zcmkw1YR6XMGUlUx8afQ7L81/XilPo6KnXAN4VMOweRbGz9TLhm5Wr6rQIMlbFQF2WZKC2oPxIdBx4bd3NfKuuJOTV7Q== 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=6y/NKPJmOcBVTeXUQHUvTBNywNYLbjwPhMoJ6DJlPcY=; b=AosIIBCy8M5jBn6Rc0RhUtkTZP/eCf6sjtxUBZx3Z5nqkqfRBxZ6+sTe5tAf5LO52e8v6ja0nnK//MOt5IXK59aSyZ45Fg/E+FX1WmWc3NKLPQWR+YGnGscuqOO4lMhYbKcWtctK2O3xr+tZW6aLPKJ1Ykohz4emzIZmXAGcjJUETE2UupOqPzTTxuC5bH2QATUdIC02IMIEeh2YPoRuMaKrdb/Xwslbg9BKldseFtalL4h+CLtjsRXOMbJ+XP2q51RY75hJSa+Nkd/0TGaJ9u4Yvelhc/cvQqHn2xKXtYvxBYDSISynMWBAM+Z/2qza0rJcMoDT7sPNzmQGGLM32g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6y/NKPJmOcBVTeXUQHUvTBNywNYLbjwPhMoJ6DJlPcY=; b=JXdciUNgtYOCIL0hEi6fsCHoSW+2w5lmLHz+UcrfADE+e81BXJVt54Vp+cV4Y/wGmw4v+saRjVsSFkv2Szn/l9TzaVB7itcZdEibwkD7SyhyO4AEoGlUWEKMTpe1ewDVmAG6jBeQMuYgbG6/iuaHGPTAG6EfBDzyjxd7WE82dBna/vLkv5LrAziF8ICHkztRVhYGnbwetB0SHlIBl3oiKCGX32pMT07S+otA4RSb8OAUiABsVjNrIcoCUhaINQLXzDPaxS7B1RDH6bhhDK/engWvnZ2lOsw6dplRH3EaEN0q+v43Jt51d/2LzjF+Lnzcf9aF9BbdifCpDwlKhGLw+A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Andrei Cherechesu (OSS)" To: xen-devel@lists.xenproject.org Cc: andrei.cherechesu@oss.nxp.com, S32@nxp.com, Andrei Cherechesu , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v2 3/8] xen/arm: Add SCMI over SMC calls handling layer Date: Mon, 30 Sep 2024 14:47:09 +0300 Message-ID: <20240930114715.642978-4-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930114715.642978-1-andrei.cherechesu@oss.nxp.com> References: <20240930114715.642978-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR10CA0016.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::26) To PA4PR04MB9565.eurprd04.prod.outlook.com (2603:10a6:102:26b::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9565:EE_|AS8PR04MB8357:EE_ X-MS-Office365-Filtering-Correlation-Id: 1219c388-7294-4ce3-2c00-08dce145ac24 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: rkxtPpvcfCBPXx0XJJ4PyPGxSCcfZWHECTmOj/QBppX3UXidsSxfJIRUQ9XgbqNj60q2W0d7Qe5DVfupBVI0FYCgzmO+9hmOkzcBBo3gmOk5vrvVYWVhw7jaWhNL8NU2pstqC3aZsFdBKvUPSRWrV7NGP0v0/LY140geZrVosB7ynkBj1vZeIFzd7mpd6j9/D2xQC6bIN+nvPIn5450Dd7WX3b+QqfNRf8pjdz4oDBR546n2vuxfmMiZcj1cfHFq7qThyblbfq/juK2u0fLMARSElAcrj81LyIqYI9RL5H6KA9VxX7NeeC11bYd83ZpZcsBhNoUef3MZNxJmi16XBHWMTN6W9vAUzZP78a0gAehLoyw+CbaHCy3GiwDp8zfiTrwqdkPfx839QC+7OGftbnhvewS7dWxD9IRDYE4DqZh396OseU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XzxdjQKhQO7mTrLxKmNOqsBmqybJUBKRXk+NksJOfjF0LFZY4d/gZFYtrvq73XZA+pKbEH46blr5UE/3Nw/ZKIHM1H9b4S3Z80x6/WDymGCNnvMSpROwt4579iDQ5N8yaSyVGSDNRljzapycw5Ofq4ZHFbBy9FbPvV3FGr1AIXElb+oScj3xfyhSbrpFGvURaG7BL76wpZQDhHN0QQnQH7N6gqqqcMyc6seZU9/5WPt96+Uy313fgdSO4L21AHjsph731pipj6QQ+/ZjMrKjAgeSGxE6bs9HSW7XFNhFRDOdLbcaXe0QqzsyDZgnLI7X/qS1xDbs4eHyKLFWzMzwILptoJm69p8s2mvkWqD84DxytWLPE7p6dkcE1atB0zAdDaUfvUWF8irKC3Un2jMRKWFFCUGQoct56sOTqBzuCvw+v6jHIW0PR0xrwFkokPVAiCF/DJAdpIn5G0t4vVBA/hr+RlI+m3KxkY7d37UrKSZ1ODgFzio/EFyZKa22WdgZkK86UA5oIV6xbMtQWFhIXJkLWKLnimgAN1fzM6jZ4oNobxZy37m5ndO5r/jZ9lKrGC53HrAmjyPjsXO5vw9SEC608Sp/gWLKTIHd6GkudpX1wOu6x1eROTQruXc3Vriw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1219c388-7294-4ce3-2c00-08dce145ac24 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9565.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 11:47:33.9135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WNmPZTRZGzEXgxXI0ncRT7H0U892NdjTA78EqCQqYusXWUb2EDPqy6NsoZsK+FrH7yuuTeGU7JfCYHL3j9fZgEtxA76xq3QKof/izrUvn8I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8357 From: Andrei Cherechesu Introduce the SCMI layer to have some basic degree of awareness about SMC calls that are based on the ARM System Control and Management Interface (SCMI) specification (DEN0056E). The SCMI specification includes various protocols for managing system-level resources, such as: clocks, pins, reset, system power, power domains, performance domains, etc. The clients are named "SCMI agents" and the server is named "SCMI platform". Only support the shared-memory based transport with SMCs as the doorbell mechanism for notifying the platform. Also, this implementation only handles the "arm,scmi-smc" compatible, requiring the following properties: - "arm,smc-id" (unique SMC ID) - "shmem" (one or more phandles pointing to shmem zones for each channel) The initialization is done as 'presmp_initcall', since we need SMCs and PSCI should already probe EL3 FW for supporting SMCCC. If no "arm,scmi-smc" compatible node is found in Dom0's DT, the initialization fails silently, as it's not mandatory. Otherwise, we get the 'arm,smc-id' DT property from the node, to know the SCMI SMC ID we handle. The 'shmem' memory ranges are not validated, as the SMC calls are only passed through to EL3 FW if coming from Dom0 and as if Dom0 would be natively running. Signed-off-by: Andrei Cherechesu Reviewed-by: Stefano Stabellini --- xen/arch/arm/Kconfig | 10 ++ xen/arch/arm/Makefile | 1 + xen/arch/arm/include/asm/scmi-smc.h | 52 +++++++++ xen/arch/arm/scmi-smc.c | 163 ++++++++++++++++++++++++++++ 4 files changed, 226 insertions(+) create mode 100644 xen/arch/arm/include/asm/scmi-smc.h create mode 100644 xen/arch/arm/scmi-smc.c diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 323c967361..adf53e2de1 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -245,6 +245,16 @@ config PARTIAL_EMULATION not been emulated to their complete functionality. Enabling this might result in unwanted/non-spec compliant behavior. +config SCMI_SMC + bool "Enable forwarding SCMI over SMC calls from Dom0 to EL3 firmware" + default y + help + This option enables basic awareness for SCMI calls using SMC as + 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, if the call comes from Dom0. + endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 7792bff597..b85ad9c13f 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -45,6 +45,7 @@ obj-y += platform_hypercall.o obj-y += physdev.o obj-y += processor.o obj-y += psci.o +obj-$(CONFIG_SCMI_SMC) += scmi-smc.o obj-y += setup.o obj-y += shutdown.o obj-y += smp.o diff --git a/xen/arch/arm/include/asm/scmi-smc.h b/xen/arch/arm/include/asm/scmi-smc.h new file mode 100644 index 0000000000..c6c0079e86 --- /dev/null +++ b/xen/arch/arm/include/asm/scmi-smc.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/arch/arm/include/asm/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 +#include + +#ifdef CONFIG_SCMI_SMC + +bool scmi_is_enabled(void); +bool scmi_is_valid_smc_id(uint32_t fid); +bool scmi_handle_smc(struct cpu_user_regs *regs); + +#else + +static inline bool scmi_is_enabled(void) +{ + return false; +} + +static inline bool scmi_is_valid_smc_id(uint32_t fid) +{ + return false; +} + +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/scmi-smc.c b/xen/arch/arm/scmi-smc.c new file mode 100644 index 0000000000..373ca7ba5f --- /dev/null +++ b/xen/arch/arm/scmi-smc.c @@ -0,0 +1,163 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/arch/arm/scmi-smc.c + * + * ARM System Control and Management Interface (SCMI) over SMC + * Generic handling layer + * + * Andrei Cherechesu + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define SCMI_SMC_ID_PROP "arm,smc-id" + +static bool scmi_support; +static uint32_t scmi_smc_id; + +/* Check if SCMI layer correctly initialized and can be used. */ +bool scmi_is_enabled(void) +{ + return scmi_support; +} + +/* + * Check if provided SMC Function Identifier matches the one known by the SCMI + * layer, as read from DT prop 'arm,smc-id' during initialiation. + */ +bool scmi_is_valid_smc_id(uint32_t fid) +{ + return (fid == scmi_smc_id); +} + +/* + * Generic handler for SCMI-SMC requests, currently only forwarding the + * request to FW running at EL3 if it came from Dom0. Is called from the vSMC + * layer for SiP SMCs, since SCMI calls are usually provided this way. + * Can also be called from `platform_smc()` plat-specific callback. + * + * Returns true if SMC was handled (regardless of response), false otherwise. + */ +bool scmi_handle_smc(struct cpu_user_regs *regs) +{ + struct arm_smccc_res res; + + /* Only the hardware domain should use SCMI calls */ + if ( !is_hardware_domain(current->domain) ) + { + gprintk(XENLOG_ERR, "SCMI: Unprivileged d%d cannot use SCMI.\n", + current->domain->domain_id); + return false; + } + + /* For the moment, forward the SCMI Request to FW running at EL3 */ + arm_smccc_1_1_smc(scmi_smc_id, + 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), + &res); + + set_user_reg(regs, 0, res.a0); + set_user_reg(regs, 1, res.a1); + set_user_reg(regs, 2, res.a2); + set_user_reg(regs, 3, res.a3); + + return true; +} + +static int __init scmi_check_smccc_ver(void) +{ + if ( smccc_ver < ARM_SMCCC_VERSION_1_1 ) + { + printk(XENLOG_ERR + "SCMI: No SMCCC 1.1 support, SCMI calls forwarding disabled\n"); + return -ENOSYS; + } + + return 0; +} + +static int __init scmi_dt_init_smccc(void) +{ + static const struct dt_device_match scmi_ids[] __initconst = + { + /* We only support "arm,scmi-smc" binding for now */ + DT_MATCH_COMPATIBLE("arm,scmi-smc"), + { /* sentinel */ }, + }; + const struct dt_device_node *scmi_node; + const char *smc_id_prop = SCMI_SMC_ID_PROP; + int ret; + + /* If no SCMI firmware node found, fail silently as it's not mandatory */ + scmi_node = dt_find_matching_node(NULL, scmi_ids); + if ( !scmi_node ) + return -EOPNOTSUPP; + + ret = dt_property_read_u32(scmi_node, smc_id_prop, &scmi_smc_id); + if ( !ret ) + { + printk(XENLOG_ERR "SCMI: No valid \"%s\" property in \"%s\" DT node\n", + smc_id_prop, scmi_node->full_name); + return -ENOENT; + } + + scmi_support = true; + + return 0; +} + +/* Initialize the SCMI layer based on SMCs and Device-tree */ +static int __init scmi_init(void) +{ + int ret; + + if ( !acpi_disabled ) + { + printk("SCMI is not supported when using ACPI\n"); + return -EINVAL; + } + + ret = scmi_check_smccc_ver(); + if ( ret ) + goto err; + + ret = scmi_dt_init_smccc(); + if ( ret == -EOPNOTSUPP ) + return ret; + if ( ret ) + goto err; + + printk(XENLOG_INFO "Using SCMI with SMC ID: 0x%x\n", scmi_smc_id); + + return 0; + +err: + printk(XENLOG_ERR "SCMI: Initialization failed (ret = %d)\n", ret); + return ret; +} + +presmp_initcall(scmi_init); + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */