xen/arm: domain_build: Require the property "cpus" when building a domU
PATCH 1/1 xen/arm: domain_build: Require the property "cpus" when building a domU
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
--- xen/arch/arm/domain_build.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
xen/arch/arm/domain_build.c +3 -2
@@ -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,9 @@ 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" ,dt_node_name (node)); d =domain_create (++max_init_domid, &d_cfg, false);if (IS_ERR (d) )
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 26 lines · Julien Grall
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 <[email protected]>--- xen/arch/arm/domain_build.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)xen/arch/arm/domain_build.c +0
-1@@ -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,
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 2084
Quoted 7 lines
xen/arch/arm/domain_build.c +3
-1@@ -2080,7 +2079,9 @@ 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" ,dt_node_name (node));
Panic needs a \n at the end, now that I went and fixed up the 50/50 split we had of styles.
~Andrew
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 2087
Quoted 3 lines
xen/arch/arm/domain_build.c +0
-0d =domain_create (++max_init_domid, &d_cfg, false);if (IS_ERR (d) )
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Andrew,
Quoted 28 lines · Andrew Cooper
Quoted 27 lines · Julien Grall
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 <[email protected]>--- xen/arch/arm/domain_build.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)xen/arch/arm/domain_build.c +0
-1@@ -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,9 @@ void __init create_domUs(void)
Quoted 9 lines
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 2084
Quoted 6 lines
xen/arch/arm/domain_build.c +3
-1if (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" ,dt_node_name (node));Panic needs a \n at the end, now that I went and fixed up the 50/50 split we had of styles.
I was not sure about it. It looks like we introduce new panic without the newline in this function. Hence the confusion.
I will send a patch for it.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel