diff mbox series

[Xen-devel,for-4.12,v2] xen/arm: domain_build: Require the property "cpus" when building a domU

Message ID 20190218101436.31127-1-julien.grall@arm.com
State New
Headers show
Series [Xen-devel,for-4.12,v2] xen/arm: domain_build: Require the property "cpus" when building a domU | expand

Commit Message

Julien Grall Feb. 18, 2019, 10:14 a.m. UTC
The 3rd argument of function dt_property_read_u32() is only valid when
the call succeeded. So we cannot assume the value will not be modifed
in case of failure.

The documentation of Dom0less does not give a default value when the
property "cpus" is not set. So require the property in the configuration.

Coverity-ID: 1476825
Signed-off-by: Julien Grall <julien.grall@arm.com>

---
    Changes in v2
        - Add missing newline in panic
---
 xen/arch/arm/domain_build.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Juergen Gross Feb. 18, 2019, 11:34 a.m. UTC | #1
On 18/02/2019 11:14, Julien Grall wrote:
> The 3rd argument of function dt_property_read_u32() is only valid when
> the call succeeded. So we cannot assume the value will not be modifed
> in case of failure.
> 
> The documentation of Dom0less does not give a default value when the
> property "cpus" is not set. So require the property in the configuration.
> 
> Coverity-ID: 1476825
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen
Stefano Stabellini Feb. 25, 2019, 10:26 p.m. UTC | #2
On Mon, 18 Feb 2019, Julien Grall wrote:
> The 3rd argument of function dt_property_read_u32() is only valid when
> the call succeeded. So we cannot assume the value will not be modifed
> in case of failure.
> 
> The documentation of Dom0less does not give a default value when the
> property "cpus" is not set. So require the property in the configuration.
> 
> Coverity-ID: 1476825
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>     Changes in v2
>         - Add missing newline in panic
> ---
>  xen/arch/arm/domain_build.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 31af989e63..c92f8c6be1 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -2069,7 +2069,6 @@ void __init create_domUs(void)
>              .arch.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE,
>              .arch.nr_spis = 0,
>              .flags = XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap,
> -            .max_vcpus = 1,
>              .max_evtchn_port = -1,
>              .max_grant_frames = 64,
>              .max_maptrack_frames = 1024,
> @@ -2080,7 +2079,10 @@ void __init create_domUs(void)
>  
>          if ( dt_property_read_bool(node, "vpl011") )
>              d_cfg.arch.nr_spis = GUEST_VPL011_SPI - 32 + 1;
> -        dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus);
> +
> +        if ( !dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus) )
> +            panic("Missing property 'cpus' for domain %s\n",
> +                  dt_node_name(node));
>  
>          d = domain_create(++max_init_domid, &d_cfg, false);
>          if ( IS_ERR(d) )
> -- 
> 2.11.0
>
diff mbox series

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 31af989e63..c92f8c6be1 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2069,7 +2069,6 @@  void __init create_domUs(void)
             .arch.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE,
             .arch.nr_spis = 0,
             .flags = XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap,
-            .max_vcpus = 1,
             .max_evtchn_port = -1,
             .max_grant_frames = 64,
             .max_maptrack_frames = 1024,
@@ -2080,7 +2079,10 @@  void __init create_domUs(void)
 
         if ( dt_property_read_bool(node, "vpl011") )
             d_cfg.arch.nr_spis = GUEST_VPL011_SPI - 32 + 1;
-        dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus);
+
+        if ( !dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus) )
+            panic("Missing property 'cpus' for domain %s\n",
+                  dt_node_name(node));
 
         d = domain_create(++max_init_domid, &d_cfg, false);
         if ( IS_ERR(d) )