xen/arm: Allow to set grant table related limits for dom0less domUs
PATCH 1/1 xen/arm: Allow to set grant table related limits for dom0less domUs
At the moment, for dom0less domUs, we do not have a way to specify per domain grant table related limits (unlike when using xl), namely max version, max number of grant frames, max number of maptrack frames. This means that such domains always use the values specified by the Xen command line parameters or their default values if unspecified.
In order to have more control over dom0less domUs, introduce the following device-tree properties that can be set under domUs nodes:
- max_grant_version to set the maximum grant table version the domain is allowed to use,
- max_grant_frames to set the maximum number of grant frames the domain is allowed to have,
- max_maptrack_frames to set the maximum number of grant maptrack frames the domain is allowed to have.
Update documentation accordingly.
Note that the sanity checks regarding the passed values are already there in grant_table_init() resulting in panic in case of errors, therefore no need to repeat them in create_domUs().
--- docs/misc/arm/device-tree/booting.txt | 21 +++++++++++++++++++++ xen/arch/arm/domain_build.c | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)
docs/misc/arm/device-tree/booting.txt +21 -0
@@ -223,6 +223,27 @@ with the following properties: the default size of domain P2M pool, i.e. 1MB per guest vCPU plus 4KB per MB of guest RAM plus 512KB for guest extended regions. +- max_grant_version + + Optional. A 32-bit integer specifying the maximum grant table version + the domain is allowed to use (valid values are 1 or 2). If this property + is missing, the value specified by Xen command line parameter gnttab=max-ver + (or its default value if unspecified, i.e. 1) is used. + +- max_grant_frames + + Optional. A 32-bit integer specifying the maximum number of grant frames + the domain is allowed to have. If this property is missing, the value + specified by Xen command line parameter gnttab_max_frames (or its default + value if unspecified, i.e. 64) is used. + +- max_maptrack_frames + + Optional. A 32-bit integer specifying the maximum number of grant maptrack + frames the domain is allowed to have. If this property is missing, the + value specified by Xen command line parameter gnttab_max_maptrack_frames + (or its default value if unspecified, i.e. 1024) is used. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk.
xen/arch/arm/domain_build.c +10 -1
@@ -3871,7 +3871,7 @@ void __init create_domUs(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; -unsigned int flags =0U ; +unsigned int flags =0U , val;if ( !dt_device_is_compatible (node,"xen,domain" ) )continue ;
@@ -3940,6 +3940,15 @@ void __init create_domUs(void) d_cfg.cpupool_id = pool_id; } +if (dt_property_read_u32 (node,"max_grant_version" , &val) ) + d_cfg.grant_opts =XEN_DOMCTL_GRANT_version (val); + +if (dt_property_read_u32 (node,"max_grant_frames" , &val) ) + d_cfg.max_grant_frames = val; + +if (dt_property_read_u32 (node,"max_maptrack_frames" , &val) ) + d_cfg.max_maptrack_frames = val; +/* * The variable max_init_domid is initialized with zero, so here it's * very important to use the pre-increment operator to call
Signature · 1 line
2.25.1
Quoted 19 lines · Michal Orzel
At the moment, for dom0less domUs, we do not have a way to specify per domain grant table related limits (unlike when using xl), namely max version, max number of grant frames, max number of maptrack frames. This means that such domains always use the values specified by the Xen command line parameters or their default values if unspecified.
In order to have more control over dom0less domUs, introduce the following device-tree properties that can be set under domUs nodes:
-max_grant_versionto set the maximum grant table version the domain is allowed to use,
-max_grant_framesto set the maximum number of grant frames the domain is allowed to have,
-max_maptrack_framesto set the maximum number of grant maptrack frames the domain is allowed to have.
Quoted 7 lines
Update documentation accordingly.
Note that the sanity checks regarding the passed values are already there in
grant_table_init()resulting in panic in case of errors, therefore no need to repeat them increate_domUs().Signed-off-by Michal Orzel <[email protected]>
The patch looks good to me.
Quoted 70 lines
---
docs/misc/arm/device-tree/booting.txt| 21 +++++++++++++++++++++xen/arch/arm/domain_build.c| 11 ++++++++++-2 files changed, 31 insertions(+), 1 deletion(-)docs/misc/arm/device-tree/booting.txt +21
-0@@ -223,6 +223,27 @@ with the following properties: the default size of domain P2M pool, i.e. 1MB per guest vCPU plus 4KB per MB of guest RAM plus 512KB for guest extended regions. +- max_grant_version + + Optional. A 32-bit integer specifying the maximum grant table version + the domain is allowed to use (valid values are 1 or 2). If this property + is missing, the value specified by Xen command line parameter gnttab=max-ver + (or its default value if unspecified, i.e. 1) is used. + +- max_grant_frames + + Optional. A 32-bit integer specifying the maximum number of grant frames + the domain is allowed to have. If this property is missing, the value + specified by Xen command line parameter gnttab_max_frames (or its default + value if unspecified, i.e. 64) is used. + +- max_maptrack_frames + + Optional. A 32-bit integer specifying the maximum number of grant maptrack + frames the domain is allowed to have. If this property is missing, the + value specified by Xen command line parameter gnttab_max_maptrack_frames + (or its default value if unspecified, i.e. 1024) is used. +Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk.
xen/arch/arm/domain_build.c +10
-1@@ -3871,7 +3871,7 @@ void __init create_domUs(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; -unsigned int flags =0U ; +unsigned int flags =0U , val;if ( !dt_device_is_compatible (node,"xen,domain" ) )continue ;@@ -3940,6 +3940,15 @@ void __init create_domUs(void) d_cfg.cpupool_id = pool_id; } +if (dt_property_read_u32 (node,"max_grant_version" , &val) ) + d_cfg.grant_opts =XEN_DOMCTL_GRANT_version (val); + +if (dt_property_read_u32 (node,"max_grant_frames" , &val) ) + d_cfg.max_grant_frames = val; + +if (dt_property_read_u32 (node,"max_maptrack_frames" , &val) ) + d_cfg.max_maptrack_frames = val; +/* * The variable max_init_domid is initialized with zero, so here it's * very important to use the pre-increment operator to call Signature · 1 line
2.25.1
Quoted 64 lines · Michal Orzel
At the moment, for dom0less domUs, we do not have a way to specify per domain grant table related limits (unlike when using xl), namely max version, max number of grant frames, max number of maptrack frames. This means that such domains always use the values specified by the Xen command line parameters or their default values if unspecified.
In order to have more control over dom0less domUs, introduce the following device-tree properties that can be set under domUs nodes:
-max_grant_versionto set the maximum grant table version the domain is allowed to use,
-max_grant_framesto set the maximum number of grant frames the domain is allowed to have,
-max_maptrack_framesto set the maximum number of grant maptrack frames the domain is allowed to have.Update documentation accordingly.
Note that the sanity checks regarding the passed values are already there in
grant_table_init()resulting in panic in case of errors, therefore no need to repeat them increate_domUs().Signed-off-by Michal Orzel <[email protected]>--- docs/misc/arm/device-tree/booting.txt | 21 +++++++++++++++++++++ xen/arch/arm/domain_build.c | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)docs/misc/arm/device-tree/booting.txt +21
-0@@ -223,6 +223,27 @@ with the following properties: the default size of domain P2M pool, i.e. 1MB per guest vCPU plus 4KB per MB of guest RAM plus 512KB for guest extended regions. +- max_grant_version + + Optional. A 32-bit integer specifying the maximum grant table version + the domain is allowed to use (valid values are 1 or 2). If this property + is missing, the value specified by Xen command line parameter gnttab=max-ver + (or its default value if unspecified, i.e. 1) is used. + +- max_grant_frames + + Optional. A 32-bit integer specifying the maximum number of grant frames + the domain is allowed to have. If this property is missing, the value + specified by Xen command line parameter gnttab_max_frames (or its default + value if unspecified, i.e. 64) is used. + +- max_maptrack_frames + + Optional. A 32-bit integer specifying the maximum number of grant maptrack + frames the domain is allowed to have. If this property is missing, the + value specified by Xen command line parameter gnttab_max_maptrack_frames + (or its default value if unspecified, i.e. 1024) is used. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk.xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3874
Quoted 5 lines
xen/arch/arm/domain_build.c +1
-1@@ -3871,7 +3871,7 @@ void __init create_domUs(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; -unsigned int flags =0U ; +unsigned int flags =0U , val;
val should be uint32_t
Quoted 4 lines
xen/arch/arm/domain_build.c +0
-0if ( !dt_device_is_compatible (node,"xen,domain" ) )continue ;@@ -3940,6 +3940,15 @@ void __init create_domUs(void) d_cfg.cpupool_id = pool_id;
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3950
Quoted 10 lines
xen/arch/arm/domain_build.c +8
-0} +if (dt_property_read_u32 (node,"max_grant_version" , &val) ) + d_cfg.grant_opts =XEN_DOMCTL_GRANT_version (val); + +if (dt_property_read_u32 (node,"max_grant_frames" , &val) ) + d_cfg.max_grant_frames = val; + +if (dt_property_read_u32 (node,"max_maptrack_frames" , &val) ) + d_cfg.max_maptrack_frames = val;
We need to be careful here because max_grant_frames and max_maptrack_frames are defined as int32_t (signed):
int32_t max_grant_frames;
int32_t max_maptrack_frames;I think we should have a check to make sure we don't cause an overflow. For instance:
if ( val >= INT32_MAX ) {
error;
}d_cfg.max_grant_frames = val;
Hi Stefano,
Quoted 62 lines · Stefano Stabellini
Quoted 59 lines · Michal Orzel
At the moment, for dom0less domUs, we do not have a way to specify per domain grant table related limits (unlike when using xl), namely max version, max number of grant frames, max number of maptrack frames. This means that such domains always use the values specified by the Xen command line parameters or their default values if unspecified.
In order to have more control over dom0less domUs, introduce the following device-tree properties that can be set under domUs nodes:
-max_grant_versionto set the maximum grant table version the domain is allowed to use,
-max_grant_framesto set the maximum number of grant frames the domain is allowed to have,
-max_maptrack_framesto set the maximum number of grant maptrack frames the domain is allowed to have.Update documentation accordingly.
Note that the sanity checks regarding the passed values are already there in
grant_table_init()resulting in panic in case of errors, therefore no need to repeat them increate_domUs().Signed-off-by Michal Orzel <[email protected]>--- docs/misc/arm/device-tree/booting.txt | 21 +++++++++++++++++++++ xen/arch/arm/domain_build.c | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)docs/misc/arm/device-tree/booting.txt +21
-0@@ -223,6 +223,27 @@ with the following properties: the default size of domain P2M pool, i.e. 1MB per guest vCPU plus 4KB per MB of guest RAM plus 512KB for guest extended regions. +- max_grant_version + + Optional. A 32-bit integer specifying the maximum grant table version + the domain is allowed to use (valid values are 1 or 2). If this property + is missing, the value specified by Xen command line parameter gnttab=max-ver + (or its default value if unspecified, i.e. 1) is used. + +- max_grant_frames + + Optional. A 32-bit integer specifying the maximum number of grant frames + the domain is allowed to have. If this property is missing, the value + specified by Xen command line parameter gnttab_max_frames (or its default + value if unspecified, i.e. 64) is used. + +- max_maptrack_frames + + Optional. A 32-bit integer specifying the maximum number of grant maptrack + frames the domain is allowed to have. If this property is missing, the + value specified by Xen command line parameter gnttab_max_maptrack_frames + (or its default value if unspecified, i.e. 1024) is used. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk.
Quoted 12 lines
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3874
Quoted 10 lines
xen/arch/arm/domain_build.c +1
-1@@ -3871,7 +3871,7 @@ void __init create_domUs(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; -unsigned int flags =0U ; +unsigned int flags =0U , val;val should be
uint32_t
ok
Quoted 23 lines
Quoted 6 lines
xen/arch/arm/domain_build.c +0
-0if ( !dt_device_is_compatible (node,"xen,domain" ) )continue ;@@ -3940,6 +3940,15 @@ void __init create_domUs(void) d_cfg.cpupool_id = pool_id;xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3950
Quoted 10 lines
xen/arch/arm/domain_build.c +8
-0} +if (dt_property_read_u32 (node,"max_grant_version" , &val) ) + d_cfg.grant_opts =XEN_DOMCTL_GRANT_version (val); + +if (dt_property_read_u32 (node,"max_grant_frames" , &val) ) + d_cfg.max_grant_frames = val; + +if (dt_property_read_u32 (node,"max_maptrack_frames" , &val) ) + d_cfg.max_maptrack_frames = val;We need to be careful here because
max_grant_framesandmax_maptrack_framesare defined asint32_t(signed):int32_t max_grant_frames; int32_t max_maptrack_frames;
Quoted 7 lines
I think we should have a check to make sure we don't cause an overflow. For instance:
if ( val >= INT32_MAX ) { error; }d_cfg.max_grant_frames = val;
Is following ok for you?
if ( dt_property_read_u32(node, "max_grant_frames", &val) )
{
if ( val > INT32_MAX )
panic("max_grant_frames (%"PRIu32") overflow\n", val);
d_cfg.max_grant_frames = val;
}if ( dt_property_read_u32(node, "max_maptrack_frames", &val) )
{
if ( val > INT32_MAX )
panic("max_maptrack_frames (%"PRIu32") overflow\n", val);
d_cfg.max_maptrack_frames = val;
}~Michal
Quoted 115 lines · Michal Orzel
Quoted 60 lines · Stefano Stabellini
Quoted 59 lines · Michal Orzel
At the moment, for dom0less domUs, we do not have a way to specify per domain grant table related limits (unlike when using xl), namely max version, max number of grant frames, max number of maptrack frames. This means that such domains always use the values specified by the Xen command line parameters or their default values if unspecified.
In order to have more control over dom0less domUs, introduce the following device-tree properties that can be set under domUs nodes:
-max_grant_versionto set the maximum grant table version the domain is allowed to use,
-max_grant_framesto set the maximum number of grant frames the domain is allowed to have,
-max_maptrack_framesto set the maximum number of grant maptrack frames the domain is allowed to have.Update documentation accordingly.
Note that the sanity checks regarding the passed values are already there in
grant_table_init()resulting in panic in case of errors, therefore no need to repeat them increate_domUs().Signed-off-by Michal Orzel <[email protected]>--- docs/misc/arm/device-tree/booting.txt | 21 +++++++++++++++++++++ xen/arch/arm/domain_build.c | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)docs/misc/arm/device-tree/booting.txt +21
-0@@ -223,6 +223,27 @@ with the following properties: the default size of domain P2M pool, i.e. 1MB per guest vCPU plus 4KB per MB of guest RAM plus 512KB for guest extended regions. +- max_grant_version + + Optional. A 32-bit integer specifying the maximum grant table version + the domain is allowed to use (valid values are 1 or 2). If this property + is missing, the value specified by Xen command line parameter gnttab=max-ver + (or its default value if unspecified, i.e. 1) is used. + +- max_grant_frames + + Optional. A 32-bit integer specifying the maximum number of grant frames + the domain is allowed to have. If this property is missing, the value + specified by Xen command line parameter gnttab_max_frames (or its default + value if unspecified, i.e. 64) is used. + +- max_maptrack_frames + + Optional. A 32-bit integer specifying the maximum number of grant maptrack + frames the domain is allowed to have. If this property is missing, the + value specified by Xen command line parameter gnttab_max_maptrack_frames + (or its default value if unspecified, i.e. 1024) is used. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk.Quoted 12 lines
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3874
Quoted 10 lines
xen/arch/arm/domain_build.c +1
-1@@ -3871,7 +3871,7 @@ void __init create_domUs(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; -unsigned int flags =0U ; +unsigned int flags =0U , val;val should be
uint32_tok
Quoted 23 lines
Quoted 6 lines
xen/arch/arm/domain_build.c +0
-0if ( !dt_device_is_compatible (node,"xen,domain" ) )continue ;@@ -3940,6 +3940,15 @@ void __init create_domUs(void) d_cfg.cpupool_id = pool_id;xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3950
Quoted 10 lines
xen/arch/arm/domain_build.c +8
-0} +if (dt_property_read_u32 (node,"max_grant_version" , &val) ) + d_cfg.grant_opts =XEN_DOMCTL_GRANT_version (val); + +if (dt_property_read_u32 (node,"max_grant_frames" , &val) ) + d_cfg.max_grant_frames = val; + +if (dt_property_read_u32 (node,"max_maptrack_frames" , &val) ) + d_cfg.max_maptrack_frames = val;We need to be careful here because
max_grant_framesandmax_maptrack_framesare defined asint32_t(signed):int32_t max_grant_frames; int32_t max_maptrack_frames;Quoted 7 lines
I think we should have a check to make sure we don't cause an overflow. For instance:
if ( val >= INT32_MAX ) { error; }d_cfg.max_grant_frames = val;
Is following ok for you?
if (
dt_property_read_u32(node, "max_grant_frames", &val)){ if ( val > INT32_MAX ) panic("max_grant_frames (%"PRIu32") overflow\n", val); d_cfg.max_grant_frames = val; }
Quoted 6 lines
if (
dt_property_read_u32(node, "max_maptrack_frames", &val)){ if ( val > INT32_MAX ) panic("max_maptrack_frames (%"PRIu32") overflow\n", val); d_cfg.max_maptrack_frames = val; }
Yes, looks good