xen/arm: scmi: introduce SCI SCMI SMC single-agent support
v6 cover xen/arm: scmi: introduce SCI SCMI SMC single-agent support
Inroducing V6 patch series on top of the Xen version 4.20-rc2 which includes implementation of the SCI SCMI SMC single-agent support.
This patch series is the first chunk of the
"xen/arm: scmi: introduce SCI SCMI SMC multi-agent support" which can be found at [0]
SCMI-multiagent support will be provided as the followup patch series.
[0] https://lore.kernel.org/xen-devel/[email protected]/
Patch 1 "xen/arm: add generic SCI subsystem"
- rebased and refactored
- introduced DEVICE_ARM_SCI DT device class and used for SCI drivers probing instead of custom,
linker sections based implementation.
- added SCI API for Dom0 DT handling, instead of manipulating with ARM arch dom0 code directly.
- RFC changes in XEN_DOMCTL_assign_device OP processing
- Introduce arch_handle_passthrough_prop call to handle arm specific nodes
Patch 2 "xen/arm: scmi-smc: update to be used under sci subsystem"
- update driver introduced by commit 3e322bef8bc0 ("xen/arm: firmware: Add SCMI over SMC calls
handling layer") be used under sci subsystem.
- no functional changes in general
Patch 3 "xen/arm: scmi-smc: passthrough SCMI SMC to guest domain This is new change which allows passthrough SCMI SMC, single agent interface to guest domain
cover use case "thin Dom0 with guest domain, which serves as Driver domain". See patch commit message for full description.
Patch 4 - docs: arm: add docs for SCMI over SMC calls forwarding driver
- add documentation section for Simple Arm SCMI over SMC calls forwarding driver.
Code can be found at:
https://github.com/oleksiimoisieiev/xen/tree/scmi_upstrv5
[1] RFC v2:
http://patchwork.kernel.org/project/xen-devel/cover/[email protected]/
[2] RFC v3:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]
SCMI spec:
https://developer.arm.com/documentation/den0056/e/?lang=en
SCMI bindings:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/access-controllers/access-controllers.yaml
Reference EL3 FW:
RPI5: https://github.com/xen-troops/arm-trusted-firmware/commits/rpi5_dev/
Renesas v4h:
https://github.com/GrygiriiS/arm-trusted-firmware/commits/rcar_gen4_v2.7_v4x-scmi_upd/
base-commit: dbe60f244c (Update Xen to 4.21, 2025-02-21)
Changes in v6:
- rebase on top of the latest master
- fix return value of sci_dt_finalize() call
- add R-b tag
- added generated helpers and types go files
- rename cmdline parameter to scmi-smc-passthrough
- fix goto tag in parse_arm_sci_config
- add link to the scmi bindings used in the doc
- remove mentions about HVC calls from doc
- rename cmdline parameter to scmi-smc-passthrough
Changes in v5:
- update Maintainers file. Set role as a Reviewer
- rebased on the latest master branch
- Introduce arch_handle_passthrough_prop call to handle arm specific nodes
- rename dom0_scmi_smc_passthrough to scmi_smc_passthrough
- rename dom0_scmi_smc_passthrough in documentation
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
- 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
Grygorii Strashko (3):
xen/arm: scmi-smc: update to be used under sci subsystem xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent
docs: arm: add docs for SCMI over SMC calls forwarding driver
Oleksii Moisieiev (1):
xen/arm: add generic SCI subsystem
MAINTAINERS | 6 + .../arm/firmware/arm-scmi.rst | 180 ++++++++++++++++ docs/hypervisor-guide/arm/index.rst | 9 + docs/hypervisor-guide/index.rst | 1 + docs/man/xl.cfg.5.pod.in | 34 +++ docs/misc/arm/device-tree/booting.txt | 15 ++ docs/misc/xen-command-line.pandoc | 9 + tools/golang/xenlight/helpers.gen.go | 41 ++++ tools/golang/xenlight/types.gen.go | 12 ++ 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/device.c | 5 + xen/arch/arm/dom0less-build.c | 40 ++++ xen/arch/arm/domain.c | 12 +- xen/arch/arm/domain_build.c | 8 + xen/arch/arm/firmware/Kconfig | 25 ++- xen/arch/arm/firmware/Makefile | 1 + xen/arch/arm/firmware/sci.c | 154 ++++++++++++++ xen/arch/arm/firmware/scmi-smc.c | 191 +++++++++++++---- xen/arch/arm/include/asm/domain.h | 5 + xen/arch/arm/include/asm/firmware/sci.h | 200 ++++++++++++++++++ xen/arch/arm/include/asm/firmware/scmi-smc.h | 41 ---- xen/arch/arm/vsmc.c | 4 +- xen/common/device-tree/dom0less-build.c | 4 + xen/include/asm-generic/device.h | 1 + xen/include/public/arch-arm.h | 5 + xen/include/xen/dom0less-build.h | 9 + 29 files changed, 992 insertions(+), 85 deletions(-) create mode 100644 docs/hypervisor-guide/arm/firmware/arm-scmi.rst create mode 100644 docs/hypervisor-guide/arm/index.rst create mode 100644 xen/arch/arm/firmware/sci.c create mode 100644 xen/arch/arm/include/asm/firmware/sci.h delete mode 100644 xen/arch/arm/include/asm/firmware/scmi-smc.h
Signature · 1 line
2.34.1
PATCH v6 1/4 xen/arm: add generic SCI subsystem
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)
---
Changes in v6:
- rebase on top of the latest master
- fix return value of sci_dt_finalize() call
Changes in v5:
- update Maintainers file. Set role as a Reviewer
- rebased on the latest master branch
- Introduce arch_handle_passthrough_prop call to handle arm specific nodes
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 | 8 + 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/common/device-tree/dom0less-build.c | 4 + xen/include/asm-generic/device.h | 1 + xen/include/public/arch-arm.h | 4 + xen/include/xen/dom0less-build.h | 9 ++ 15 files changed, 427 insertions(+), 1 deletion(-) create mode 100644 xen/arch/arm/firmware/sci.c create mode 100644 xen/arch/arm/include/asm/firmware/sci.h
MAINTAINERS +6 -0
@@ -509,6 +509,12 @@ R: George Dunlap <[email protected]> S: Supported F: xen/common/sched/ +SCI MEDIATORS +R: Oleksii Moisieiev <[email protected]> +S: Supported +F: xen/arch/arm/firmware/sci.c +F: xen/arch/arm/include/asm/firmware/sci.h + SEABIOS UPSTREAM M: Wei Liu <[email protected]> S: Supported
xen/arch/arm/device.c +5 -0
@@ -13,6 +13,7 @@#include <xen/iocap.h> #include <xen/lib.h> +#include <asm/firmware/sci.h> #include <asm/setup.h> int map_irq_to_domain(struct domain *d, unsigned int irq,
@@ -303,6 +304,10 @@ int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt,return res; } } + + res =sci_assign_dt_device (d, dev); +if ( res ) +return res; } res =map_device_irqs_to_domain (d, dev, own_device, irq_ranges);
xen/arch/arm/dom0less-build.c +8 -0
@@ -22,6 +22,7 @@#include <asm/arm64/sve.h> #include <asm/domain_build.h> +#include <asm/firmware/sci.h> #include <asm/grant_table.h> #include <asm/setup.h>
@@ -272,6 +273,12 @@ int __init init_vuart(struct domain *d, struct kernel_info *kinfo,return rc; } +int __init arch_handle_passthrough_prop (struct kernel_info *kinfo, +struct dt_device_node *node) +{ +return sci_assign_dt_device (kinfo->bd.d, node); +} +int __init arch_parse_dom0less_node (struct dt_device_node *node,struct boot_domain *bd) {
@@ -281,6 +288,7 @@ int __init arch_parse_dom0less_node(struct dt_device_node *node, d_cfg->arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE ; d_cfg->flags |= XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap; + d_cfg->arch.arm_sci_type =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ;if ( !dt_property_read_u32 (node,"nr_spis" , &d_cfg->arch.nr_spis) ) {
xen/arch/arm/domain.c +11 -1
@@ -24,6 +24,7 @@#include <asm/platform.h> #include <asm/procinfo.h> #include <asm/regs.h> +#include <asm/firmware/sci.h> #include <asm/tee/tee.h> #include <asm/vfp.h> #include <asm/vgic.h>
@@ -699,7 +700,7 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)return -EINVAL ; } -return 0 ; +return sci_domain_sanitise_config (config); } int arch_domain_create(struct domain *d,
@@ -791,6 +792,9 @@ int arch_domain_create(struct domain *d, d->arch.sve_vl = config->arch.sve_vl;#endif +if ( (rc =sci_domain_init (d, config)) !=0 ) + goto fail; +return 0 ; fail:
@@ -851,6 +855,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));
@@ -1044,6 +1049,7 @@ enum { PROG_p2m_root, PROG_p2m, PROG_p2m_pool, + PROG_sci, PROG_done, };
@@ -1103,6 +1109,10 @@ int domain_relinquish_resources(struct domain *d) ret =relinquish_p2m_mapping (d);if ( ret )return ret; + PROGRESS(sci): + ret =sci_relinquish_resources (d); +if ( ret ) +return ret; PROGRESS(p2m_root):/*
xen/arch/arm/domain_build.c +8 -0
@@ -28,6 +28,7 @@#include <asm/setup.h> #include <asm/tee/tee.h> #include <asm/pci.h> +#include <asm/firmware/sci.h> #include <asm/platform.h> #include <asm/psci.h> #include <asm/setup.h>
@@ -1640,6 +1641,9 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,return 0 ; } +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.
@@ -1740,6 +1744,10 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,if ( res )return res; + res =sci_dt_finalize (d, kinfo->fdt); +if ( res ) +return res; +/* * Create a second memory node to store the ranges covering * reserved-memory regions.
xen/arch/arm/firmware/Kconfig +8 -0
@@ -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" config SCMI_SMC
xen/arch/arm/firmware/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_ARM_SCI) += sci.o obj-$(CONFIG_SCMI_SMC) += scmi-smc.o
xen/arch/arm/firmware/sci.c new file +154 -0
154 lines not on this page · raw message
xen/arch/arm/include/asm/domain.h +5 -0
@@ -120,6 +120,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 } __cacheline_aligned;
xen/arch/arm/include/asm/firmware/sci.h new file +200 -0
200 lines not on this page · raw message
xen/arch/arm/vsmc.c +3 -0
@@ -12,6 +12,7 @@#include <public/arch-arm/smccc.h> #include <asm/cpuerrata.h> #include <asm/cpufeature.h> +#include <asm/firmware/sci.h> #include <asm/monitor.h> #include <asm/regs.h> #include <asm/smccc.h>
@@ -300,6 +301,8 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)break ;case ARM_SMCCC_OWNER_SIP : handled =handle_sip (regs); +if ( !handled ) + handled =sci_handle_call (regs);break ; case ARM_SMCCC_OWNER_TRUSTED_APP ... ARM_SMCCC_OWNER_TRUSTED_APP_END: case ARM_SMCCC_OWNER_TRUSTED_OS ... ARM_SMCCC_OWNER_TRUSTED_OS_END:
xen/common/device-tree/dom0less-build.c +4 -0
@@ -228,6 +228,10 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo,if ( res <0 )return res; + res =arch_handle_passthrough_prop (kinfo, node); +if ( res ) +return res; +/* If xen_force, we allow assignment of devices without IOMMU protection. */ if ( xen_force && !dt_device_is_protected (node) )return 0 ;
xen/include/asm-generic/device.h +1 -0
@@ -18,6 +18,7 @@ enum device_classDEVICE_IOMMU ,DEVICE_INTERRUPT_CONTROLLER ,DEVICE_PCI_HOSTBRIDGE , +DEVICE_FIRMWARE ,/* Use for error */ DEVICE_UNKNOWN, };
xen/include/public/arch-arm.h +4 -0
@@ -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 +#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__ */
xen/include/xen/dom0less-build.h +9 -0
@@ -62,6 +62,9 @@ void set_domain_type(struct domain *d, struct kernel_info *kinfo);int init_intc_phandle (struct kernel_info *kinfo,const char *name,const int node_next,const void *pfdt); +int arch_handle_passthrough_prop (struct kernel_info *kinfo, +struct dt_device_node *node); +#else /* !CONFIG_DOM0LESS_BOOT */ static inline void create_domUs (void ) {}
@@ -71,6 +74,12 @@ static inline bool is_dom0less_mode(void) }static inline void set_xs_domain (struct domain *d) {} +static inline int arch_handle_passthrough_prop (struct kernel_info *kinfo, +struct dt_device_node *node) +{ +return 0 ; +} +#endif /* CONFIG_DOM0LESS_BOOT */ #endif /* __ASM_GENERIC_DOM0LESS_BUILD_H__ */
Signature · 1 line
2.34.1
Re: [PATCH v6 1/4] xen/arm: add generic SCI subsystem
Quoted 27 lines · Oleksii Moisieiev
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_FIRMWAREdevice 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 withsci_register(). Only one SCI driver can be supported.At run-time, the following SCI API calls are introduced:
-
sci_domain_sanitise_config()called fromarch_sanitise_domain_config()
-sci_domain_init()called fromarch_domain_create()
-sci_relinquish_resources()called fromdomain_relinquish_resources()
-sci_domain_destroy()called fromarch_domain_destroy()
-sci_handle_call()called fromvsmccc_handle_call()
-sci_dt_handle_node()
-sci_dt_finalize()called fromhandle_node()(Dom0 DT)
Quoted 3 lines
Signed-off-by Oleksii Moisieiev <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
I just want to say that R-b from me is OK
Re: [PATCH v6 1/4] xen/arm: add generic SCI subsystem
Quoted 28 lines · Stefano Stabellini
Quoted 27 lines · Oleksii Moisieiev
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_FIRMWAREdevice 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 withsci_register(). Only one SCI driver can be supported.At run-time, the following SCI API calls are introduced:
-
sci_domain_sanitise_config()called fromarch_sanitise_domain_config()
-sci_domain_init()called fromarch_domain_create()
-sci_relinquish_resources()called fromdomain_relinquish_resources()
-sci_domain_destroy()called fromarch_domain_destroy()
-sci_handle_call()called fromvsmccc_handle_call()
-sci_dt_handle_node()
-sci_dt_finalize()called fromhandle_node()(Dom0 DT)
Quoted 4 lines
Quoted 3 lines
Signed-off-by Oleksii Moisieiev <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>I just want to say that R-b from me is OK
Oh sorry. My bad.
Re: [PATCH v6 1/4] xen/arm: add generic SCI subsystem
In reply to Oleksii MoisieievOn 28.08.25 19:40, Oleksii Moisieiev wrote:
Hello Oleksii
Quoted 65 lines
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_FIRMWAREdevice 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 withsci_register(). Only one SCI driver can be supported.At run-time, the following SCI API calls are introduced:
-
sci_domain_sanitise_config()called fromarch_sanitise_domain_config()
-sci_domain_init()called fromarch_domain_create()
-sci_relinquish_resources()called fromdomain_relinquish_resources()
-sci_domain_destroy()called fromarch_domain_destroy()
-sci_handle_call()called fromvsmccc_handle_call()
-sci_dt_handle_node()
-sci_dt_finalize()called fromhandle_node()(Dom0 DT)Signed-off-by Oleksii Moisieiev <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changes in v6:
- rebase on top of the latest master
- fix return value ofsci_dt_finalize()callChanges in v5:
- update Maintainers file. Set role as a Reviewer
- rebased on the latest master branch
- Introducearch_handle_passthrough_propcall to handle arm specific nodesChanges in v4:
- fix SPDX-License
- renameDEVICE_ARM_SCIDT device class toFIRMWARE_DEVICE
- moveXEN_DOMCTL_assign_devicecode in separate patch
- Add documentation for SCI SCMI driversMAINTAINERS | 6 + xen/arch/arm/device.c | 5 + xen/arch/arm/dom0less-build.c | 8 + 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/common/device-tree/dom0less-build.c | 4 + xen/include/asm-generic/device.h | 1 + xen/include/public/arch-arm.h | 4 + xen/include/xen/dom0less-build.h | 9 ++ 15 files changed, 427 insertions(+), 1 deletion(-)create mode 100644
xen/arch/arm/firmware/sci.ccreate mode 100644xen/arch/arm/include/asm/firmware/sci.h
[snip]
Quoted 12 lines
xen/arch/arm/include/asm/firmware/sci.h new file +6
-0@@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Generic ARM SCI (System Control Interface) subsystem. +* +* Oleksii Moisieiev <[email protected]> +* Copyright (c) 2025 EPAM Systems
xen/arch/arm/include/asm/firmware/sci.h line 16
Quoted 10 lines
xen/arch/arm/include/asm/firmware/sci.h new file +10
-0+*/ + +#ifndef __ASM_ARM_SCI_H +#define __ASM_ARM_SCI_H + +#include <xen/lib.h> +#include <xen/types.h> +#include <xen/device_tree.h> +#include <xen/errno.h> +#include <xen/sched.h>
NIT: Looks like the headers are not alphabetically sorted
[snip]
Quoted 18 lines
xen/include/xen/dom0less-build.h +3
-0@@ -62,6 +62,9 @@ void set_domain_type(struct domain *d, struct kernel_info *kinfo);int init_intc_phandle (struct kernel_info *kinfo,const char *name,const int node_next,const void *pfdt); +int arch_handle_passthrough_prop (struct kernel_info *kinfo, +struct dt_device_node *node); +#else /* !CONFIG_DOM0LESS_BOOT */ static inline void create_domUs (void ) {}@@ -71,6 +74,12 @@ static inline bool is_dom0less_mode(void) }static inline void set_xs_domain (struct domain *d) {}
xen/include/xen/dom0less-build.h static inline bool is_dom0less_mode(void) · line 85
Quoted 10 lines
xen/include/xen/dom0less-build.h +6
-0+static inline int arch_handle_passthrough_prop (struct kernel_info *kinfo, +struct dt_device_node *node) +{ +return 0 ; +} +#endif /* CONFIG_DOM0LESS_BOOT */ #endif /* __ASM_GENERIC_DOM0LESS_BUILD_H__ */
If I build current patch with # CONFIG_DOM0LESS_BOOT is not set I got the following error:
CC arch/arm/domain_build.o
CC arch/arm/guestcopy.o
In file included from arch/arm/domain_build.c:5:./include/xen/dom0less-build.h:78:55: error: 'struct dt_device_node' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
78 | structdt_device_node *node)
|
^~~~~~~~~~~~~~./include/xen/dom0less-build.h:77:55: error: 'struct kernel_info' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
77 | static inline int arch_handle_passthrough_prop(structkernel_info *kinfo,
| ^~~~~~~~~~~
Re: [PATCH v6 1/4] xen/arm: add generic SCI subsystem
Quoted 141 lines · Oleksandr Tyshchenko
On 28.08.25 19:40, Oleksii Moisieiev wrote:
Hello Oleksii
Quoted 71 lines
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_FIRMWAREdevice 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 withsci_register(). Only one SCI driver can be supported.At run-time, the following SCI API calls are introduced:
-
sci_domain_sanitise_config()called fromarch_sanitise_domain_config()
-sci_domain_init()called fromarch_domain_create()
-sci_relinquish_resources()called fromdomain_relinquish_resources()
-sci_domain_destroy()called fromarch_domain_destroy()
-sci_handle_call()called fromvsmccc_handle_call()
-sci_dt_handle_node()
-sci_dt_finalize()called fromhandle_node()(Dom0 DT)Signed-off-by Oleksii Moisieiev <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changes in v6:
- rebase on top of the latest master
- fix return value ofsci_dt_finalize()callChanges in v5:
- update Maintainers file. Set role as a Reviewer
- rebased on the latest master branch
- Introducearch_handle_passthrough_propcall to handle arm specific nodesChanges in v4:
- fix SPDX-License
- renameDEVICE_ARM_SCIDT device class toFIRMWARE_DEVICE
- moveXEN_DOMCTL_assign_devicecode in separate patch
- Add documentation for SCI SCMI driversMAINTAINERS | 6 + xen/arch/arm/device.c | 5 + xen/arch/arm/dom0less-build.c | 8 + 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/common/device-tree/dom0less-build.c| 4 + xen/include/asm-generic/device.h | 1 + xen/include/public/arch-arm.h | 4 + xen/include/xen/dom0less-build.h | 9 ++15 files changed, 427 insertions(+), 1 deletion(-)create mode 100644
xen/arch/arm/firmware/sci.ccreate mode 100644xen/arch/arm/include/asm/firmware/sci.h[snip]
Quoted 13 lines
xen/arch/arm/include/asm/firmware/sci.h new file +6
-0@@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Generic ARM SCI (System Control Interface) subsystem. +* +* Oleksii Moisieiev <[email protected]> +* Copyright (c) 2025 EPAM Systems xen/arch/arm/include/asm/firmware/sci.h line 16
Quoted 10 lines
xen/arch/arm/include/asm/firmware/sci.h new file +10
-0+*/ + +#ifndef __ASM_ARM_SCI_H +#define __ASM_ARM_SCI_H + +#include <xen/lib.h> +#include <xen/types.h> +#include <xen/device_tree.h> +#include <xen/errno.h> +#include <xen/sched.h> NIT: Looks like the headers are not alphabetically sorted
[snip]
Quoted 25 lines
diff --git
a/xen/include/xen/dom0less-build.hb/xen/include/xen/dom0less-build.h
index408859e325..6fdd0552e0100644xen/include/xen/dom0less-build.h +2
-0@@ -62,6 +62,9 @@ void set_domain_type(struct domain *d, struct kernel_info *kinfo); int init_intc_phandle(struct kernel_info *kinfo, const char *name, const int node_next, const void *pfdt); +int arch_handle_passthrough_prop(struct kernel_info *kinfo, + struct dt_device_node *node); + #else /* !CONFIG_DOM0LESS_BOOT */ static inline void create_domUs(void) {}@@ -71,6 +74,12 @@ static inline bool is_dom0less_mode(void) } static inline void set_xs_domain(struct domain *d) {}+static inline int arch_handle_passthrough_prop(struct
kernel_info*kinfo,
+ structdt_device_node*node)xen/include/xen/dom0less-build.h +4
-0+{ + return 0; +} +Quoted 2 lines
#endif /*
CONFIG_DOM0LESS_BOOT*/
#endif /*__ASM_GENERIC_DOM0LESS_BUILD_H__*/If I build current patch with #
CONFIG_DOM0LESS_BOOTis not set I got the following error:
Quoted 16 lines
CC
arch/arm/domain_build.o
CCarch/arm/guestcopy.o
In file included fromarch/arm/domain_build.c:5:./include/xen/dom0less-build.h:78:55: error: 'structdt_device_node' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
78 | structdt_device_node*node)
| ^~~~~~~~~~~~~~./include/xen/dom0less-build.h:77:55: error: 'structkernel_info' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
77 | static inline int arch_handle_passthrough_prop(structkernel_info*kinfo,
| ^~~~~~~~~~~
Good finding. Thanks. Will be fixed.
PATCH v6 2/4 xen/arm: scmi-smc: update to be used under sci subsystem
In reply to Oleksii MoisieievFrom: Grygorii Strashko <[email protected]>
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.
---
Changes in v6:
- add R-b tag
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
xen/arch/arm/firmware/Kconfig +12 -1
@@ -8,9 +8,18 @@ config ARM_SCI menu "Firmware Drivers" +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. +endchoice + endmenu
xen/arch/arm/firmware/scmi-smc.c +50 -43
153 lines not on this page · raw message
xen/arch/arm/include/asm/firmware/scmi-smc.h deleted +0 -41
41 lines not on this page · raw message
xen/arch/arm/vsmc.c +1 -4
@@ -21,7 +21,6 @@#include <asm/traps.h> #include <asm/vpsci.h> #include <asm/platform.h> -#include <asm/firmware/scmi-smc.h> /* 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; -return scmi_handle_smc (regs); +return sci_handle_call (regs); }/*
@@ -301,8 +300,6 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)break ;case ARM_SMCCC_OWNER_SIP : handled =handle_sip (regs); -if ( !handled ) - handled =sci_handle_call (regs);break ; case ARM_SMCCC_OWNER_TRUSTED_APP ... ARM_SMCCC_OWNER_TRUSTED_APP_END: case ARM_SMCCC_OWNER_TRUSTED_OS ... ARM_SMCCC_OWNER_TRUSTED_OS_END:
xen/include/public/arch-arm.h +1 -0
@@ -328,6 +328,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);#define XEN_DOMCTL_CONFIG_TEE_FFA 2#define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 +#define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC 1struct xen_arch_domainconfig {/* IN/OUT */
Signature · 1 line
2.34.1
Re: [PATCH v6 2/4] xen/arm: scmi-smc: update to be used under sci subsystem
Quoted 15 lines · Oleksii Moisieiev
From: Grygorii Strashko <[email protected]>
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.
Quoted 5 lines
There are no functional changes in general, the driver is just adopted to the SCI interface.
Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Also I wanted to write down that the R-b is OK from me
Re: [PATCH v6 2/4] xen/arm: scmi-smc: update to be used under sci subsystem
In reply to Oleksii MoisieievOn 28.08.25 19:40, Oleksii Moisieiev wrote:
Hello Oleksii
the patch lgtm, just some comments
Quoted 69 lines
From: Grygorii Strashko <[email protected]>
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 <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changes in v6:
- add R-b tagxen/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.hxen/arch/arm/firmware/Kconfig +12
-1@@ -8,9 +8,18 @@ config ARM_SCI menu "Firmware Drivers" +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. +endchoice + endmenuxen/arch/arm/firmware/scmi-smc.c +0
-0
xen/arch/arm/firmware/scmi-smc.c line 12
Quoted 4 lines
xen/arch/arm/firmware/scmi-smc.c +1
-0@@ -9,6 +9,7 @@* Copyright 2024 NXP */ +#include <asm/device.h>
NIT: Should be included after "xen" headers
(could probably be updated on commit)
Quoted 111 lines
xen/arch/arm/firmware/scmi-smc.c +26
-34#include <xen/acpi.h> #include <xen/device_tree.h> #include <xen/errno.h> @@ -16,12 +17,11 @@#include <xen/sched.h> #include <xen/types.h> +#include <asm/firmware/sci.h> #include <asm/smccc.h> -#include <asm/firmware/scmi-smc.h> #define SCMI_SMC_ID_PROP "arm,smc-id" -static bool __ro_after_init scmi_enabled;static uint32_t __ro_after_init scmi_smc_id;/* @@ -41,14 +41,11 @@ static bool scmi_is_valid_smc_id(uint32_t fid)* * Returns true if SMC was handled (regardless of response), false otherwise. */ -bool scmi_handle_smc (struct cpu_user_regs *regs) +static bool scmi_handle_smc (struct cpu_user_regs *regs) {uint32_t fid = (uint32_t )get_user_reg (regs,0 );struct arm_smccc_res res; -if ( !scmi_enabled ) -return false; -if ( !scmi_is_valid_smc_id (fid) )return false;@@ -78,49 +75,45 @@ bool scmi_handle_smc(struct cpu_user_regs *regs)return true; } -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 ; + d->arch.sci_enabled = true; +printk (XENLOG_DEBUG "SCMI: %pd init\n" , d);return 0 ; } -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 = - { -/* 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 ; -/* 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 ; +printk (XENLOG_DEBUG "SCMI: %pd destroy\n" , d); +} - ret =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 node\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 ; } - scmi_enabled = true; -return 0 ; } +static const struct sci_mediator_ops scmi_smc_ops = { + .handle_call = scmi_handle_smc, + .domain_init = scmi_smc_domain_init, + .domain_destroy = 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 *data) {int ret;@@ -134,22 +127,36 @@ static int __init scmi_init(void)if ( ret )return ret;
xen/arch/arm/firmware/scmi-smc.c static int __init scmi_init(void) · line 136
Quoted 10 lines
xen/arch/arm/firmware/scmi-smc.c +7
-3- ret =scmi_dt_init_smccc (); -if ( ret == -EOPNOTSUPP ) -return ret; + ret =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 node\n" , +SCMI_SMC_ID_PROP ,dt_node_full_name (dev)); +return -ENOENT ; + }
I know that you are just moving the code, but I wonder whether it makes sense to validate that retrieved value at least corresponds to SiP Service Calls (for the future hardening)?
Quoted 101 lines
xen/arch/arm/firmware/scmi-smc.c +16
-6+ + ret =sci_register (&scmi_smc_ops);if ( ret ) - goto err; + { +printk (XENLOG_ERR "SCMI: mediator already registered (ret = %d)\n" , + ret); +return ret; + }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; } -__initcall (scmi_init); +static const struct dt_device_match scmi_smc_match[]__initconst = { +DT_MATCH_COMPATIBLE ("arm,scmi-smc" ), + {/* sentinel */ }, +}; + +DT_DEVICE_START (scmi_smc,"SCMI SMC DOM0" ,DEVICE_FIRMWARE ) + .dt_match = scmi_smc_match, + .init = scmi_dom0_init, +DT_DEVICE_END /* * Local variables: xen/arch/arm/include/asm/firmware/scmi-smc.h deleted +0
-41@@ -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 <[email protected]> -* Copyright 2024 NXP -*/ - -#ifndef __ASM_SCMI_SMC_H__ -#define __ASM_SCMI_SMC_H__ - -#include <xen/types.h> - -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: -*/ xen/arch/arm/vsmc.c +1
-2@@ -21,7 +21,6 @@#include <asm/traps.h> #include <asm/vpsci.h> #include <asm/platform.h> -#include <asm/firmware/scmi-smc.h> /* 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; -return scmi_handle_smc (regs); +return sci_handle_call (regs); }/*
xen/arch/arm/vsmc.c static bool vsmccc_handle_call(struct cpu_user_regs *regs) · line 305
Quoted 5 lines
xen/arch/arm/vsmc.c +0
-2@@ -301,8 +300,6 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)break ;case ARM_SMCCC_OWNER_SIP : handled =handle_sip (regs); -if ( !handled ) - handled =sci_handle_call (regs);
These two lines where added by [PATCH v6 1/4] xen/arm: add generic SCI subsystem, but here they are removed. This is not a request for an extra work right now, but ideally the series should be splitted without an extra temporarily changes.
Quoted 15 lines
xen/arch/arm/vsmc.c +0
-0break ; case ARM_SMCCC_OWNER_TRUSTED_APP ... ARM_SMCCC_OWNER_TRUSTED_APP_END: case ARM_SMCCC_OWNER_TRUSTED_OS ... ARM_SMCCC_OWNER_TRUSTED_OS_END:xen/include/public/arch-arm.h +1
-0@@ -328,6 +328,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);#define XEN_DOMCTL_CONFIG_TEE_FFA 2#define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 +#define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC 1struct xen_arch_domainconfig {/* IN/OUT */
Re: [PATCH v6 2/4] xen/arm: scmi-smc: update to be used under sci subsystem
Quoted 87 lines · Oleksandr Tyshchenko
On 28.08.25 19:40, Oleksii Moisieiev wrote:
Hello Oleksii
the patch lgtm, just some comments
Quoted 78 lines
From: Grygorii Strashko <[email protected]>
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 <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changes in v6:
- add R-b tagxen/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.hxen/arch/arm/firmware/Kconfig +0
-0@@ -8,9 +8,18 @@ config ARM_SCImenu "Firmware Drivers"
+choice
+ prompt "ARM SCI driver type"
+ defaultSCMI_SMC
+ help
+ Choose which ARM SCI driver to enable.xen/arch/arm/firmware/Kconfig +4
-0+ +config ARM_SCI_NONE + bool "none" +config
SCMI_SMC
bool "Forward SCMI over SMC calls from hwdom to EL3 firmware" - default y
+ selectARM_SCI
help
This option enables basic awareness for SCMI calls using SMC as doorbell mechanism and Shared Memory for transport ("arm,scmi-smc"xen/arch/arm/firmware/Kconfig +0
-0@@ -18,4 +27,6 @@ config SCMI_SMCfirmware node is used to trap and forward corresponding SCMI SMCs
to firmware running at EL3, for calls coming from the hardware domain.
+endchoice
+
endmenuxen/arch/arm/firmware/scmi-smc.c +0
-0@@ -9,6 +9,7 @@* Copyright 2024 NXP */ +#include <
asm/device.h>
[snip]
Quoted 17 lines
Quoted 17 lines
+
/* Initialize the SCMI layer based on SMCs and Device-tree */xen/arch/arm/firmware/scmi-smc.c +1
-1-static int __init scmi_init (void ) +static int __init scmi_dom0_init(struct dt_device_node *dev, constvoid *data)
{
int ret;
@@ -134,22 +127,36 @@ static int__initscmi_init(void)if ( ret )
return ret;
- ret =scmi_dt_init_smccc();
- if ( ret ==-EOPNOTSUPP)
- return ret;
+ ret =dt_property_read_u32(dev, SCMI_SMC_ID_PROP, &scmi_smc_id); + if ( !ret )
+ {
+ printk(XENLOG_ERR "SCMI: No valid \"%s\" property in \"%s\"
Quoted 10 lines
Quoted 4 lines
DT node\n",
+SCMI_SMC_ID_PROP,dt_node_full_name(dev)); + return-ENOENT;
+ }I know that you are just moving the code, but I wonder whether it makes sense to validate that retrieved value at least corresponds to SiP Service Calls (for the future hardening)?
I don't see any reason for that. I couldn't find any requirement about SiP call in [1]
Also, according to DEN0028D [0] 0x05000000 mask can be used as long as 0x02000000
[0] DEN0028D
https://documentation-service.arm.com/static/6013e5faeee5236980d08619?token=
[1] DEN0056 https://developer.arm.com/documentation/den0056/latest/
Quoted 126 lines
Quoted 99 lines
+
+ ret =sci_register(&scmi_smc_ops);
if ( ret )
- goto err;
+ {
+ printk(XENLOG_ERR "SCMI: mediator already registered (ret = %d)\n",
+ ret);
+ return ret;
+ }
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;
}
-__initcall(scmi_init);xen/arch/arm/firmware/scmi-smc.c +9
-0+static const struct dt_device_match scmi_smc_match[]__initconst = { + DT_MATCH_COMPATIBLE("arm,scmi-smc"), + { /* sentinel */ }, +}; + +DT_DEVICE_START (scmi_smc,"SCMI SMC DOM0" ,DEVICE_FIRMWARE ) + .dt_match = scmi_smc_match, + .init = scmi_dom0_init, +DT_DEVICE_END /*
* Local variables:xen/arch/arm/include/asm/firmware/scmi-smc.h deleted +0
-41@@ -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 <[email protected]> -* Copyright 2024 NXP -*/ - -#ifndef __ASM_SCMI_SMC_H__ -#define __ASM_SCMI_SMC_H__ - -#include <xen/types.h> - -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: -*/ xen/arch/arm/vsmc.c +1
-1@@ -21,7 +21,6 @@ #include <asm/traps.h> #include <asm/vpsci.h> #include <asm/platform.h> -#include <asm/firmware/scmi-smc.h> /* 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; - return scmi_handle_smc(regs); + return sci_handle_call(regs); } /*@@ -301,8 +300,6 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs) break;Quoted 4 lines
case
ARM_SMCCC_OWNER_SIP:
handled =handle_sip(regs);
- if ( !handled )
- handled =sci_handle_call(regs);These two lines where added by [PATCH v6 1/4] xen/arm: add generic SCI subsystem, but here they are removed. This is not a request for an extra work right now, but ideally the series should be splitted without an extra temporarily changes.
Quoted 16 lines
break;
caseARM_SMCCC_OWNER_TRUSTED_APP...ARM_SMCCC_OWNER_TRUSTED_APP_END:
caseARM_SMCCC_OWNER_TRUSTED_OS...ARM_SMCCC_OWNER_TRUSTED_OS_END:xen/include/public/arch-arm.h +1
-0@@ -328,6 +328,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_TEE_FFA 2 #define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 +#define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC 1 struct xen_arch_domainconfig { /* IN/OUT */
PATCH v6 3/4 xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent
In reply to Oleksii MoisieievFrom: Grygorii Strashko <[email protected]>
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 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 = "type=scmi_smc"
- domD: xl.cfg enable access to the "arm,scmi-shmem"
iomem = [
"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 = "arm,scmi-shmem";
reg = <0x0 0x22001000 0x0 0x1000>;};
firmware {
compatible = "simple-bus";
scmi: scmi {
compatible = "arm,scmi-smc";
shmem = <&scmi_shm_0>;
...
}
}
}dom0less case configuration:
- add "xen,sci_type" property for required DomU ("xen,domain") node
xen,sci_type="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 = "arm,scmi-shmem";
reg = <0x00 0x22001000 0x00 0x1000>;-> xen,reg = <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
---
Changes in v6:
- added generated helpers and types go files
- rename cmdline parameter to scmi-smc-passthrough
- fix goto tag in parse_arm_sci_config
Changes in v5:
- rename dom0_scmi_smc_passthrough to scmi_smc_passthrough
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/golang/xenlight/helpers.gen.go | 41 ++++++++++ tools/golang/xenlight/types.gen.go | 12 +++ 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 | 34 +++++++- xen/arch/arm/firmware/Kconfig | 4 +- xen/arch/arm/firmware/scmi-smc.c | 112 +++++++++++++++++++++++++- 12 files changed, 321 insertions(+), 5 deletions(-)
docs/man/xl.cfg.5.pod.in +34 -0
@@ -3123,6 +3123,40 @@ writes will be ignored. This option is only implemented for Arm where the default is enabled. +=item B<arm_sci="ARM_SCI_STRING"> + +Set ARM_SCI specific options for the guest. ARM SCI is System +Control Protocol allows domain to manage various functions that are provided +by HW platform firmware. + +B<ARM_SCI_STRING> is a comma separated list of C<KEY=VALUE> settings, +from the following list: + +=over 4 + +=item B<type=STRING> + +Specifies an ARM SCI type for the guest. + +=over 4 + +=item B<none> + +Don't allow guest to use ARM SCI if present on the platform. This is the +default value. + +=item B<scmi_smc> + +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<scmi-smc-passthrough> Xen command line +option. + +=back + +=back + =back =head3 x86
docs/misc/arm/device-tree/booting.txt +15 -0
@@ -307,6 +307,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 domain. +- 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 the + default value. + + - "scmi_smc" + 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 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.
docs/misc/xen-command-line.pandoc +9 -0
@@ -1097,6 +1097,15 @@ affinities to prefer but be not limited to the specified node(s). Pin dom0 vcpus to their respective pcpus +### scmi-smc-passthrough (ARM) +> `= <boolean>` + +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) > `= path [:options]`
tools/golang/xenlight/helpers.gen.go +41 -0
71 lines not on this page · raw message
tools/golang/xenlight/types.gen.go +12 -0
@@ -520,6 +520,16 @@ SveType1920 SveType = 1920 SveType2048 SveType = 2048 ) +type ArmSciType int +const( +ArmSciTypeNone ArmSciType = 0 +ArmSciTypeScmiSmc ArmSciType = 1 +) + +type ArmSci struct { +Type ArmSciType +} + type RdmReserve struct { Strategy RdmReserveStrategy Policy RdmReservePolicy
@@ -582,6 +592,7 @@ Kernel string Cmdline string Ramdisk string DeviceTree string +DtPassthroughNodes StringList Acpi Defbool Bootloader string BootloaderArgs StringList
@@ -599,6 +610,7 @@ GicVersion GicVersion Vuart VuartType SveVl SveType NrSpis uint32 +ArmSci ArmSci } ArchX86 struct { MsrRelaxed Defbool
tools/include/libxl.h +5 -0
@@ -313,6 +313,11 @@*/ #define LIBXL_HAVE_BUILDINFO_ARCH_NR_SPIS 1 +/* +* 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
tools/libs/light/libxl_arm.c +14 -0
@@ -233,6 +233,20 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, config->arch.sve_vl = d_config->b_info.arch_arm.sve_vl /128U ; } +switch (d_config->b_info.arch_arm.arm_sci.type) { +case LIBXL_ARM_SCI_TYPE_NONE : + config->arch.arm_sci_type =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ; +break ; +case LIBXL_ARM_SCI_TYPE_SCMI_SMC : + config->arch.arm_sci_type =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=%u" , config->arch.arm_sci_type); +return 0 ; }
tools/libs/light/libxl_types.idl +10 -0
@@ -551,6 +551,15 @@ libxl_sve_type = Enumeration("sve_type", [ (2048, "2048") ], init_val = "LIBXL_SVE_TYPE_DISABLED") +libxl_arm_sci_type = Enumeration("arm_sci_type", [ + (0, "none"), + (1, "scmi_smc") + ], init_val = "LIBXL_ARM_SCI_TYPE_NONE") + +libxl_arm_sci = Struct("arm_sci", [ + ("type", libxl_arm_sci_type), + ]) + libxl_rdm_reserve = Struct("rdm_reserve", [ ("strategy", libxl_rdm_reserve_strategy), ("policy", libxl_rdm_reserve_policy),
@@ -726,6 +735,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), ("nr_spis", uint32, {'init_val': 'LIBXL_NR_SPIS_DEFAULT'}), + ("arm_sci", libxl_arm_sci), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),
tools/xl/xl_parse.c +36 -0
@@ -1284,6 +1284,36 @@ out:if (rc)exit (EXIT_FAILURE ); } +static int parse_arm_sci_config (XLU_Config *cfg,libxl_arm_sci *arm_sci, +const char *str) +{ +int ret =0 ; +char *buf2, *ptr; +char *oparg; + +if (NULL == (buf2 = ptr =strdup (str))) +return ERROR_NOMEM ; + + ptr =strtok (buf2,"," ); +while (ptr !=NULL ) + { +if (MATCH_OPTION ("type" , ptr, oparg)) { + ret =libxl_arm_sci_type_from_string (oparg, &arm_sci->type); +if (ret) { +fprintf (stderr,"Unknown ARM_SCI type: %s\n" , oparg); + ret =ERROR_INVAL ; + goto out; + } + } + + ptr =strtok (NULL ,"," ); + } + +out: +free (buf2); +return ret; +} + void parse_config_data(const char *config_source, const char *config_data, int config_len,
@@ -2996,6 +3026,12 @@ skip_usbdev:xlu_cfg_get_defbool (config,"trap_unmapped_accesses" , &b_info->trap_unmapped_accesses,0 ); +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); d_config->virtios =NULL ;
xen/arch/arm/dom0less-build.c +33 -1
@@ -279,6 +279,36 @@ int __init arch_handle_passthrough_prop(struct kernel_info *kinfo,return sci_assign_dt_device (kinfo->bd.d, node); } +int __init domu_dt_sci_parse (struct dt_device_node *node, +struct xen_domctl_createdomain *d_cfg) +{ +const char *sci_type =NULL ; +int ret; + + d_cfg->arch.arm_sci_type =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ; + +if ( !IS_ENABLED (CONFIG_ARM_SCI ) || + !dt_property_read_bool (node,"xen,sci_type" ) ) +return 0 ; + + ret =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 =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ; +else if ( !strcmp (sci_type,"scmi_smc" ) ) + d_cfg->arch.arm_sci_type =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 ; +} +int __init arch_parse_dom0less_node (struct dt_device_node *node,struct boot_domain *bd) {
@@ -288,7 +318,9 @@ int __init arch_parse_dom0less_node(struct dt_device_node *node, d_cfg->arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE ; d_cfg->flags |= XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap; - d_cfg->arch.arm_sci_type =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ; + +if (domu_dt_sci_parse (node, d_cfg) ) +panic ("Error getting SCI configuration\n" );if ( !dt_property_read_u32 (node,"nr_spis" , &d_cfg->arch.nr_spis) ) {
xen/arch/arm/firmware/Kconfig +3 -1
@@ -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. endchoice
xen/arch/arm/firmware/scmi-smc.c +109 -3
161 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v6 3/4] xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent
Quoted 72 lines · Oleksii Moisieiev
From: Grygorii Strashko <[email protected]>
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 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= "type=scmi_smc"- domD: xl.cfg enable access to the "arm,scmi-shmem"
iomem = [
"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 = "arm,scmi-shmem"; reg = <0x0 0x22001000 0x0 0x1000>; }; firmware { compatible = "simple-bus"; scmi: scmi { compatible = "arm,scmi-smc"; shmem = <&scmi_shm_0>; ... } } }dom0less case configuration:
- add "xen,sci_type" property for required DomU ("xen,domain") node
xen,sci_type="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 = "arm,scmi-shmem"; reg = <0x00 0x22001000 0x00 0x1000>;-> xen,reg = <
0x00x47ff00000x00x10000x00x22001000>;
-> 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.
Quoted 6 lines
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 <[email protected]>Signed-off-by Oleksii Moisieiev <[email protected]>
Re: [PATCH v6 3/4] xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent
In reply to Oleksii MoisieievQuoted 7 lines · Oleksii Moisieiev
docs/misc/xen-command-line.pandoc +1
-0@@ -1097,6 +1097,15 @@ affinities to prefer but be not limited to the specified node(s). Pin dom0 vcpus to their respective pcpus +### scmi-smc-passthrough (ARM)
docs/misc/xen-command-line.pandoc affinities to prefer but be not limited to the specified node(s). · line 1110
Quoted 10 lines
docs/misc/xen-command-line.pandoc +8
-0+> `= <boolean>` + +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) > `= path [:options]`
On what basis did you pick where to put the new option? It clearly doesn't fit between dom0_vcpus_pin and dtuart, but wants to go far further down.
Jan
Re: [PATCH v6 3/4] xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent
Quoted 21 lines · Jan Beulich
Quoted 7 lines · Oleksii Moisieiev
docs/misc/xen-command-line.pandoc +1
-0@@ -1097,6 +1097,15 @@ affinities to prefer but be not limited to the specified node(s). Pin dom0 vcpus to their respective pcpus +### scmi-smc-passthrough (ARM)docs/misc/xen-command-line.pandoc affinities to prefer but be not limited to the specified node(s). · line 1110
Quoted 10 lines
docs/misc/xen-command-line.pandoc +8
-0+> `= <boolean>` + +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) > `= path [:options]`On what basis did you pick where to put the new option? It clearly doesn't fit between
dom0_vcpus_pinand dtuart, but wants to go far further down.
Quoted 1 line
Jan
Agreed... will place it above
### scrub-domheap
option.
Re: [PATCH v6 3/4] xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent
In reply to Oleksii MoisieievOn 28.08.25 19:40, Oleksii Moisieiev wrote:
Hello Oleksii
the patch lgtm, just some comments
Quoted 68 lines
From: Grygorii Strashko <[email protected]>
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 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= "type=scmi_smc"- domD: xl.cfg enable access to the "arm,scmi-shmem"
iomem = [
"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 = "arm,scmi-shmem"; reg = <0x0 0x22001000 0x0 0x1000>; }; firmware { compatible = "simple-bus"; scmi: scmi { compatible = "arm,scmi-smc"; shmem = <&scmi_shm_0>; ... } } }dom0less case configuration:
- add "xen,sci_type" property for required DomU ("xen,domain") node
xen,sci_type="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 = "arm,scmi-shmem"; reg = <0x00 0x22001000 0x00 0x1000>; -> xen,reg = <0x0 0x47ff0000 0x0 0x1000 0x0 0x22001000>; -> xen,force-assign-without-iommu; };
Quoted 6 lines
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
?
Quoted 36 lines
Signed-off-by Grygorii Strashko <[email protected]>Signed-off-by Oleksii Moisieiev <[email protected]>---
Changes in v6:
- added generated helpers and types go files
- rename cmdline parameter to scmi-smc-passthrough
- fix goto tag inparse_arm_sci_configChanges in v5:
- renamedom0_scmi_smc_passthroughtoscmi_smc_passthroughChanges in v4:
- xl.cfg doc
- fix comments from Stefano Stabellini
- fix toolstack code as sugested by Anthony PERARD
- useMATCH_OPTION()
- movearm_scistruct and cfg params in "arch_arm"
- add SCMI passthrough for dom0less casedocs/man/xl.cfg.5.pod.in | 34 ++++++++ docs/misc/arm/device-tree/booting.txt | 15 ++++ docs/misc/xen-command-line.pandoc | 9 +++ tools/golang/xenlight/helpers.gen.go | 41 ++++++++++ tools/golang/xenlight/types.gen.go | 12 +++ 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 | 34 +++++++- xen/arch/arm/firmware/Kconfig | 4 +- xen/arch/arm/firmware/scmi-smc.c | 112 +++++++++++++++++++++++++- 12 files changed, 321 insertions(+), 5 deletions(-)
[snip]
xen/arch/arm/dom0less-build.c int __init arch_handle_passthrough_prop(struct kernel_info *kinfo, · line 285
Quoted 12 lines
xen/arch/arm/dom0less-build.c +4
-0@@ -279,6 +279,36 @@ int __init arch_handle_passthrough_prop(struct kernel_info *kinfo,return sci_assign_dt_device (kinfo->bd.d, node); } +int __init domu_dt_sci_parse (struct dt_device_node *node, +struct xen_domctl_createdomain *d_cfg) +{ +const char *sci_type =NULL ;
NIT: I think "= NULL" can be omitted.
Quoted 69 lines
xen/arch/arm/dom0less-build.c +29
-1+int ret; + + d_cfg->arch.arm_sci_type =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ; + +if ( !IS_ENABLED (CONFIG_ARM_SCI ) || + !dt_property_read_bool (node,"xen,sci_type" ) ) +return 0 ; + + ret =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 =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ; +else if ( !strcmp (sci_type,"scmi_smc" ) ) + d_cfg->arch.arm_sci_type =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 ; +} +int __init arch_parse_dom0less_node (struct dt_device_node *node,struct boot_domain *bd) {@@ -288,7 +318,9 @@ int __init arch_parse_dom0less_node(struct dt_device_node *node, d_cfg->arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE ; d_cfg->flags |= XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap; - d_cfg->arch.arm_sci_type =XEN_DOMCTL_CONFIG_ARM_SCI_NONE ; + +if (domu_dt_sci_parse (node, d_cfg) ) +panic ("Error getting SCI configuration\n" );if ( !dt_property_read_u32 (node,"nr_spis" , &d_cfg->arch.nr_spis) ) {xen/arch/arm/firmware/Kconfig +3
-1@@ -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. endchoicexen/arch/arm/firmware/scmi-smc.c +2
-0@@ -14,6 +14,8 @@#include <xen/device_tree.h> #include <xen/errno.h> #include <xen/init.h> +#include <xen/iocap.h> +#include <xen/param.h> #include <xen/sched.h> #include <xen/types.h>
xen/arch/arm/firmware/scmi-smc.c line 27
Quoted 4 lines
xen/arch/arm/firmware/scmi-smc.c +1
-0@@ -22,7 +24,11 @@#define SCMI_SMC_ID_PROP "arm,smc-id" +static bool __ro_after_init opt_scmi_smc_passthrough = false;
NIT: I think "= false" can be omitted.
Quoted 104 lines
xen/arch/arm/firmware/scmi-smc.c +69
-3+boolean_param ("scmi-smc-passthrough" , opt_scmi_smc_passthrough); +static uint32_t __ro_after_init scmi_smc_id; +static struct domain __read_mostly *scmi_dom;/* * 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;/* Only the hardware domain should use SCMI calls */ -if ( !is_hardware_domain (current->domain) ) +if ( scmi_dom != 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; } +static int +scmi_smc_domain_sanitise_config (struct xen_domctl_createdomain *config) +{ +if ( config->arch.arm_sci_type !=XEN_DOMCTL_CONFIG_ARM_SCI_NONE && + config->arch.arm_sci_type !=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_scmi_smc_passthrough && !is_hardware_domain (d) ) + { +if ( config->arch.arm_sci_type ==XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC ) +return -EINVAL ; +else +return 0 ; + } +/* +* scmi_passthrough is enabled: +* - ignore hw_domain +* - proceed only for domain with SCMI enabled. +*/ +if ( opt_scmi_smc_passthrough && + (config->arch.arm_sci_type ==XEN_DOMCTL_CONFIG_ARM_SCI_NONE || +is_hardware_domain (d)) )return 0 ; +if ( scmi_dom ) +return -EEXIST ; + + scmi_dom = d; d->arch.sci_enabled = true;printk (XENLOG_DEBUG "SCMI: %pd init\n" , d);return 0 ;@@ -88,12 +127,77 @@ static int scmi_smc_domain_init(struct domain *d,static void scmi_smc_domain_destroy (struct domain *d) { -if ( !is_hardware_domain (d) ) +if ( scmi_dom && scmi_dom != d )return ; + scmi_dom =NULL ; + d->arch.sci_enabled = false;printk (XENLOG_DEBUG "SCMI: %pd destroy\n" , d); } +/* +* Handle Dom0 SCMI SMC specific DT nodes +* +* if scmi_smc_passthrough=false: +* - Copy SCMI nodes into Dom0 device tree. +* if scmi_smc_passthrough=true: +* - 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 = { +DT_MATCH_COMPATIBLE ("arm,scmi-shmem" ), + {/* sentinel */ }, + }; +static const struct dt_device_match scmi_matches[]__initconst = { +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; + }
xen/arch/arm/firmware/scmi-smc.c static int scmi_smc_domain_init(struct domain *d, · line 175
Quoted 10 lines
xen/arch/arm/firmware/scmi-smc.c +10
-0+ +/* +* 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;
NIT: uint64_t please for the new code
Quoted 7 lines
xen/arch/arm/firmware/scmi-smc.c +7
-0+int ret; + +/* give dom0 control access to SCMI shmem */ + prop =dt_get_property (node,"shmem" ,NULL ); +if ( !prop ) +return true; +
xen/arch/arm/firmware/scmi-smc.c static int scmi_smc_domain_init(struct domain *d, · line 192
Quoted 10 lines
xen/arch/arm/firmware/scmi-smc.c +10
-0+ shmem_node =dt_find_node_by_phandle (be32_to_cpu (*prop)); +if ( !shmem_node ) +return true; + + ret =dt_device_get_address (shmem_node,0 , &paddr, &size); +if ( ret ) +return true; + + ret =iomem_permit_access (d,paddr_to_pfn (paddr), +paddr_to_pfn (paddr + size -1 ));
Shouldn't we at least warn if the access to SCMI shmem is not permitted for Dom0? Or this is not going to be an issue at all?
Quoted 22 lines
xen/arch/arm/firmware/scmi-smc.c +10
-0+ +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)static const struct sci_mediator_ops scmi_smc_ops = { .handle_call = scmi_handle_smc, + .domain_sanitise_config = scmi_smc_domain_sanitise_config, .domain_init = scmi_smc_domain_init, .domain_destroy = scmi_smc_domain_destroy, + .dom0_dt_handle_node = scmi_smc_dt_handle_node, };/* Initialize the SCMI layer based on SMCs and Device-tree */
PATCH v6 4/4 docs: arm: add docs for SCMI over SMC calls forwarding driver
In reply to Oleksii MoisieievFrom: Grygorii Strashko <[email protected]>
Add documentation section for Simple Arm SCMI over SMC calls forwarding driver (EL3).
---
Changes in v6:
- add link to the scmi bindings used in the doc
- remove mentions about HVC calls from doc
- rename cmdline parameter to scmi-smc-passthrough
Changes in v5:
- rename dom0_scmi_smc_passthrough in documentation
.../arm/firmware/arm-scmi.rst | 180 ++++++++++++++++++ docs/hypervisor-guide/arm/index.rst | 9 + docs/hypervisor-guide/index.rst | 1 + 3 files changed, 190 insertions(+) create mode 100644 docs/hypervisor-guide/arm/firmware/arm-scmi.rst create mode 100644 docs/hypervisor-guide/arm/index.rst
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +180 -0
@@ -0,0 +1,180 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +ARM System Control and Management Interface (SCMI) +================================================== + +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 shared-memory transport; +- on dedicated System Control Processor (SCP) with HW mailbox shared-memory transport + +The major purpose of enabling SCMI support in Xen is to enable guest domains access to the SCMI +interfaces for performing management actions on passed-through devices (such as clocks/resets etc) +without accessing directly to the System control HW (like clock controllers) 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 <https://developer.arm.com/documentation/den0056/latest/>`_ +| [2] `System Control and Management Interface (SCMI) bindings <https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/firmware/arm,scmi.yaml>`_ + +Simple SCMI over SMC calls forwarding driver (EL3) +------------------------------------------------------ + +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 with SCMI support. Such EL3 SCMI firmware supports only +single SCMI OSPM transport (agent) with Shared memory based transport and SMC calls as doorbell. + +The SCMI over SMC calls forwarding driver solves major problem for this case by allowing +SMC calls to be forwarded form guest to the EL3 SCMI firmware. + +By default, the SCMI over SMC calls forwarding is enabled for Dom0/hwdom. + +:: + + +--------------------------+ + | | + | 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-copy) and driver only +forwards SMC calls. + +Compiling +^^^^^^^^^ + +To build with the SCMI over SMC calls forwarding enabled support, enable 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 calls forwarding 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 (without 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 +**"scmi-smc-passthrough"** option. This will disable SCMI for Dom0/hwdom 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 = "type=scmi_smc" + +* In domain's xl.cfg file enable access to the "arm,scmi-shmem" + +:: + + iomem = [ + "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 = "arm,scmi-shmem"; + reg = <0x0 0x22001000 0x0 0x1000>; + }; + + firmware { + compatible = "simple-bus"; + scmi: scmi { + compatible = "arm,scmi-smc"; + shmem = <&scmi_shm_0>; + ... + } + } + } + +Please refer to [2] for details of SCMI DT bindings. + +In general, the configuration is similar to any other HW pass-through, except 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="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: + +.. code:: + + scmi_shm_0: sram@22001000 { + compatible = "arm,scmi-shmem"; + reg = <0x00 0x22001000 0x00 0x1000>; + -> xen,reg = <0x0 0x47ff0000 0x0 0x1000 0x0 0x22001000>; + -> xen,force-assign-without-iommu; + };
docs/hypervisor-guide/arm/index.rst new file +9 -0
@@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +ARM +=== + +.. toctree:: + :maxdepth: 2 + + firmware/arm-scmi
docs/hypervisor-guide/index.rst +1 -0
@@ -9,3 +9,4 @@ Hypervisor documentation code-coverage x86/index + arm/index
Signature · 1 line
2.34.1
Re: [PATCH v6 4/4] docs: arm: add docs for SCMI over SMC calls forwarding driver
Quoted 7 lines · Oleksii Moisieiev
From: Grygorii Strashko <[email protected]>
Add documentation section for Simple Arm SCMI over SMC calls forwarding driver (EL3).
Signed-off-by Grygorii Strashko <[email protected]>Signed-off-by Oleksii Moisieiev <[email protected]>
We typically wrap lines at 80. It can be done on commit.
Quoted 231 lines
---
Changes in v6:
- add link to the scmi bindings used in the doc
- remove mentions about HVC calls from doc
- rename cmdline parameter to scmi-smc-passthroughChanges in v5:
- renamedom0_scmi_smc_passthroughin documentation.../arm/firmware/arm-scmi.rst | 180 ++++++++++++++++++ docs/hypervisor-guide/arm/index.rst | 9 + docs/hypervisor-guide/index.rst | 1 + 3 files changed, 190 insertions(+) create mode 100644 docs/hypervisor-guide/arm/firmware/arm-scmi.rst create mode 100644 docs/hypervisor-guide/arm/index.rstdocs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +180
-0@@ -0,0 +1,180 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +ARM System Control and Management Interface (SCMI) +================================================== + +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 shared-memory transport; +- on dedicated System Control Processor (SCP) with HW mailbox shared-memory transport + +The major purpose of enabling SCMI support in Xen is to enable guest domains access to the SCMI +interfaces for performing management actions on passed-through devices (such as clocks/resets etc) +without accessing directly to the System control HW (like clock controllers) 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 <https://developer.arm.com/documentation/den0056/latest/>`_ +| [2] `System Control and Management Interface (SCMI) bindings <https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/firmware/arm,scmi.yaml>`_ + +Simple SCMI over SMC calls forwarding driver (EL3) +------------------------------------------------------ + +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 with SCMI support. Such EL3 SCMI firmware supports only +single SCMI OSPM transport (agent) with Shared memory based transport and SMC calls as doorbell. + +The SCMI over SMC calls forwarding driver solves major problem for this case by allowing +SMC calls to be forwarded form guest to the EL3 SCMI firmware. + +By default, the SCMI over SMC calls forwarding is enabled for Dom0/hwdom. + +:: + + +--------------------------+ + | | + | 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-copy) and driver only +forwards SMC calls. + +Compiling +^^^^^^^^^ + +To build with the SCMI over SMC calls forwarding enabled support, enable 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 calls forwarding 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 (without 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 +**"scmi-smc-passthrough"** option. This will disable SCMI for Dom0/hwdom 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 = "type=scmi_smc" + +* In domain's xl.cfg file enable access to the "arm,scmi-shmem" + +:: + + iomem = [ + "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 = "arm,scmi-shmem"; + reg = <0x0 0x22001000 0x0 0x1000>; + }; + + firmware { + compatible = "simple-bus"; + scmi: scmi { + compatible = "arm,scmi-smc"; + shmem = <&scmi_shm_0>; + ... + } + } + } + +Please refer to [2] for details of SCMI DT bindings. + +In general, the configuration is similar to any other HW pass-through, except 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="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: + +.. code:: + + scmi_shm_0: sram@22001000 { + compatible = "arm,scmi-shmem"; + reg = <0x00 0x22001000 0x00 0x1000>; + -> xen,reg = <0x0 0x47ff0000 0x0 0x1000 0x0 0x22001000>; + -> xen,force-assign-without-iommu; + };docs/hypervisor-guide/arm/index.rst new file +9
-0@@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +ARM +=== + +.. toctree:: + :maxdepth: 2 + + firmware/arm-scmidocs/hypervisor-guide/index.rst +1
-0@@ -9,3 +9,4 @@ Hypervisor documentation code-coverage x86/index + arm/indexSignature · 1 line
2.34.1
Re: [PATCH v6 4/4] docs: arm: add docs for SCMI over SMC calls forwarding driver
In reply to Oleksii MoisieievOn 28.08.25 19:40, Oleksii Moisieiev wrote:
Hello Oleksii
the patch lgtm, just some NITs
Quoted 49 lines
From: Grygorii Strashko <[email protected]>
Add documentation section for Simple Arm SCMI over SMC calls forwarding driver (EL3).
Signed-off-by Grygorii Strashko <[email protected]>Signed-off-by Oleksii Moisieiev <[email protected]>---
Changes in v6:
- add link to the scmi bindings used in the doc
- remove mentions about HVC calls from doc
- rename cmdline parameter to scmi-smc-passthroughChanges in v5:
- renamedom0_scmi_smc_passthroughin documentation.../arm/firmware/arm-scmi.rst | 180 ++++++++++++++++++ docs/hypervisor-guide/arm/index.rst | 9 + docs/hypervisor-guide/index.rst | 1 + 3 files changed, 190 insertions(+)create mode 100644
docs/hypervisor-guide/arm/firmware/arm-scmi.rstcreate mode 100644docs/hypervisor-guide/arm/index.rstdocs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +19
-0@@ -0,0 +1,180 @@ +.. SPDX-License-Identifier: CC-BY-4.0 + +ARM System Control and Management Interface (SCMI) +================================================== + +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. +
docs/hypervisor-guide/arm/firmware/arm-scmi.rst line 29
Quoted 10 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +10
-0+The SCMI compliant firmware could run: + +- as part of EL3 secure world software (like Trusted Firmware-A) with + ARM SMC shared-memory transport; +- on dedicated System Control Processor (SCP) with HW mailbox shared-memory transport + +The major purpose of enabling SCMI support in Xen is to enable guest domains access to the SCMI +interfaces for performing management actions on passed-through devices (such as clocks/resets etc) +without accessing directly to the System control HW (like clock controllers) which in most cases +can't shared/split between domains. Or, at minimum, allow SCMI access for dom0/hwdom (or guest
NIT: can't be shared
Quoted 6 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +6
-0+domain serving as Driver domain). + +The below sections describe SCMI support options available for Xen. + +| [1] `Arm SCMI <https://developer.arm.com/documentation/den0056/latest/>`_ +| [2] `System Control and Management Interface (SCMI) bindings <https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/firmware/arm,scmi.yaml>`_
docs/hypervisor-guide/arm/firmware/arm-scmi.rst line 45
Quoted 10 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +10
-0+ +Simple SCMI over SMC calls forwarding driver (EL3) +------------------------------------------------------ + +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 with SCMI support. Such EL3 SCMI firmware supports only +single SCMI OSPM transport (agent) with Shared memory based transport and SMC calls as doorbell. + +The SCMI over SMC calls forwarding driver solves major problem for this case by allowing +SMC calls to be forwarded form guest to the EL3 SCMI firmware.
NIT: s/form/from
Quoted 26 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +26
-0+ +By default, the SCMI over SMC calls forwarding is enabled for Dom0/hwdom. + +:: + + +--------------------------+ + | | + | 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-copy) and driver only
docs/hypervisor-guide/arm/firmware/arm-scmi.rst line 81
Quoted 10 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +10
-0+forwards SMC calls. + +Compiling +^^^^^^^^^ + +To build with the SCMI over SMC calls forwarding enabled support, enable Kconfig option + +:: + + CONFIG_SCMI_SMC
NIT: I think, if we mention Kconfig option, then s/CONFIG_SCMI_SMC/SCMI_SMC
Quoted 24 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +24
-0+ +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 calls forwarding 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 (without 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 | |
docs/hypervisor-guide/arm/firmware/arm-scmi.rst line 115
Quoted 10 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +10
-0+ +-----------+ +--+-----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
NIT: First,
Quoted 65 lines
docs/hypervisor-guide/arm/firmware/arm-scmi.rst new file +65
-0+**"scmi-smc-passthrough"** option. This will disable SCMI for Dom0/hwdom 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 = "type=scmi_smc" + +* In domain's xl.cfg file enable access to the "arm,scmi-shmem" + +:: + + iomem = [ + "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 = "arm,scmi-shmem"; + reg = <0x0 0x22001000 0x0 0x1000>; + }; + + firmware { + compatible = "simple-bus"; + scmi: scmi { + compatible = "arm,scmi-smc"; + shmem = <&scmi_shm_0>; + ... + } + } + } + +Please refer to [2] for details of SCMI DT bindings. + +In general, the configuration is similar to any other HW pass-through, except 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="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: + +.. code:: + + scmi_shm_0: sram@22001000 { + compatible = "arm,scmi-shmem"; + reg = <0x00 0x22001000 0x00 0x1000>; + -> xen,reg = <0x0 0x47ff0000 0x0 0x1000 0x0 0x22001000>; + -> xen,force-assign-without-iommu; + };
[snip]