xen/arm: scmi: introduce SCI SCMI SMC single-agent support
v7 cover xen/arm: scmi: introduce SCI SCMI SMC single-agent support
Inroducing V7 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 v7:
- fix sci_handl_call to make changes more readable
- fix build error when DOM0LESS_BUILD is disabled (removed arch_handle_passthrough_prop from the header)
- sort headers in alphabetical order in sci.h
- sort headers in scmi-smc.c file
- Fix commit description.
- Move scmi-smc-passthrough definition to match alphaberical order
- remove unneeded initialization with NULL
- changed u64 to uint64_t
- Send warning if iomem permit access was failed
- fixed typos
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 | 194 +++++++++++++---- 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 | 3 + 29 files changed, 989 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 v7 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 v7:
- fix sci_handl_call to make changes more readable
- fix build error when DOM0LESS_BUILD is disabled (removed arch_handle_passthrough_prop from the header)
- sort headers in alphabetical order in sci.h
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 | 3 + 15 files changed, 420 insertions(+), 2 deletions(-) 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 +2 -1
@@ -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>
@@ -232,7 +233,7 @@ static bool handle_sip(struct cpu_user_regs *regs)if (platform_smc (regs) )return true; -return scmi_handle_smc (regs); +return (scmi_handle_smc (regs)) ? true :sci_handle_call (regs); }/*
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 +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 ) {}
Signature · 1 line
2.34.1
PATCH v7 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 v7:
- sort headers in scmi-smc.c file
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 | 3 +- xen/include/public/arch-arm.h | 1 + 5 files changed, 64 insertions(+), 87 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
147 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 -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)) ? true :sci_handle_call (regs); +return sci_handle_call (regs); }/*
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
PATCH v7 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 when "scmi-smc-passthrough" cmdline parameter was provided.
---
Changes in v7:
- Fix commit description.
- Move scmi-smc-passthrough definition to match alphaberical order
- remove unneeded initialization with NULL
- changed u64 to uint64_t
- Send warning if iomem permit access was failed
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 | 115 +++++++++++++++++++++++++- 12 files changed, 324 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
@@ -2382,6 +2382,15 @@ sockets, &c. This will reduce performance somewhat, particularly on systems with hyperthreading enabled, but should reduce power by enabling more sockets and cores to go into deeper sleep states. +### 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). + ### scrub-domheap > `= <boolean>`
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; +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 +112 -3
164 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v7 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 when "scmi-smc-passthrough" cmdline parameter was provided.
Signed-off-by Grygorii Strashko <[email protected]>Signed-off-by Oleksii Moisieiev <[email protected]>
PATCH v7 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 v7:
- fixed typos
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 be 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 from 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 + +:: + + 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
I was going to commit this series but this patch breaks compilation on x86:
https://gitlab.com/xen-project/people/sstabellini/xen/-/jobs/11223159836
Hi Stefano,
Sorry for that. I've regenerated {types,helpers}.gen.go without unneded option and sent in V8.
--
Oleksii
Quoted 5 lines · Stefano Stabellini
I was going to commit this series but this patch breaks compilation on x86:
https://gitlab.com/xen-project/people/sstabellini/xen/-/jobs/11223159836