Skip to contentSkip to conversation

xen/arm: sci: Don't create a domain with unsatisfied user requests

PATCH In review Michal Orzel 3 participants 3 messages May 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: sci: Don't create a domain with unsatisfied user requests

On Arm we stay on the safe side and refuse to create a domain on user requests (e.g. via xl.cfg, DT options) that cannot be satisfied due to the feature not being compiled in. SCI fall through the crack and does not adhere to that i.e. a user request for SCI type other than NONE when CONFIG_SCMI_SMC (and thus CONFIG_ARM_SCI) is not set would be silently ignored. Fix it by not allowing anything else other than NONE if the feature is not enabled.

Fixes 10e7473d6024 ("xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent")
---
 xen/arch/arm/dom0less-build.c           | 11 +++++++++--
 xen/arch/arm/include/asm/firmware/sci.h |  5 +++++
 2 files changed, 14 insertions(+), 2 deletions(-)
xen/arch/arm/dom0less-build.c +9 -2
index 6f73c65e5151..52cf788a45ea 100644
@@ -273,8 +273,7 @@ static int __init domu_dt_sci_parse(struct dt_device_node *node,
 
     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") )
+    if ( !dt_property_read_bool(node, "xen,sci_type") )
         return 0;
 
     ret = dt_property_read_string(node, "xen,sci_type", &sci_type);
@@ -284,7 +283,15 @@ static int __init domu_dt_sci_parse(struct dt_device_node *node,
     if ( !strcmp(sci_type, "none") )
         d_cfg->arch.arm_sci_type = XEN_DOMCTL_CONFIG_ARM_SCI_NONE;
     else if ( !strcmp(sci_type, "scmi_smc") )
+    {
+        if ( !IS_ENABLED(CONFIG_SCMI_SMC) )
+        {
+            printk(XENLOG_ERR "xen,sci_type=scmi_smc requested, but CONFIG_SCMI_SMC not set\n");
+            return -EINVAL;
+        }
+
         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",
xen/arch/arm/include/asm/firmware/sci.h +5 -0
index 3500216bc250..485ce211c995 100644
@@ -148,6 +148,8 @@ int sci_dt_finalize(struct domain *d, void *fdt);
 int sci_assign_dt_device(struct domain *d, struct dt_device_node *dev);
 #else
 
+#include <public/arch-arm.h>
+
 static inline bool sci_domain_is_enabled(struct domain *d)
 {
     return false;
@@ -162,6 +164,9 @@ static inline int sci_domain_init(struct domain *d,
 static inline int
 sci_domain_sanitise_config(struct xen_domctl_createdomain *config)
 {
+    if ( config->arch.arm_sci_type != XEN_DOMCTL_CONFIG_ARM_SCI_NONE )
+        return -EINVAL;
+
     return 0;
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Michal,

Quoted 10 lines · Michal Orzel

On Arm we stay on the safe side and refuse to create a domain on user requests (e.g. via xl.cfg, DT options) that cannot be satisfied due to the feature not being compiled in. SCI fall through the crack and does not adhere to that i.e. a user request for SCI type other than NONE when CONFIG_SCMI_SMC (and thus CONFIG_ARM_SCI) is not set would be silently ignored. Fix it by not allowing anything else other than NONE if the feature is not enabled.

Quoted 6 lines
Fixes 10e7473d6024 ("xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent")

---
xen/arch/arm/dom0less-build.c | 11 +++++++++--
xen/arch/arm/include/asm/firmware/sci.h | 5 +++++

2 files changed, 14 insertions(+), 2 deletions(-)

Looks ok to me

Cheers,
Luca

Reviewed-by on v1 1/1
#2 lore raw
In reply to Michal Orzel

Hi Michal,

Quoted 10 lines · Michal Orzel

On Arm we stay on the safe side and refuse to create a domain on user requests (e.g. via xl.cfg, DT options) that cannot be satisfied due to the feature not being compiled in. SCI fall through the crack and does not adhere to that i.e. a user request for SCI type other than NONE when CONFIG_SCMI_SMC (and thus CONFIG_ARM_SCI) is not set would be silently ignored. Fix it by not allowing anything else other than NONE if the feature is not enabled.

Quoted 2 lines
Fixes 10e7473d6024 ("xen/arm: scmi-smc: passthrough SCMI SMC to domain, single agent")

Looks good to me:

Cheers
Bertrand