xen/grants: repurpose command line max options
PATCH 1/1 xen/grants: repurpose command line max options
Slightly change the meaning of the command line gnttab_max_{maptrack_,}frames: do not use them as upper bounds for the passed values at domain creation, instead just use them as defaults in the absence of any provided value.
It's not very useful for the options to be used both as defaults and as capping values for domain creation inputs. The defaults passed on the command line are used by dom0 which has a very different grant requirements than a regular domU. dom0 usually needs a bigger maptrack array, while domU usually require a bigger number of grant frames.
--- docs/misc/xen-command-line.pandoc | 12 ++++++------ xen/common/grant_table.c | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-)
docs/misc/xen-command-line.pandoc +6 -6
@@ -1232,9 +1232,8 @@ The usage of gnttab v2 is not security supported on ARM platforms. > Can be modified at runtime -Specify the maximum number of frames which any domain may use as part -of its grant table. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames which any domain may use as part +of its grant table unless a different value is specified at domain creation. Dom0 is using this value for sizing its grant table.
@@ -1245,9 +1244,10 @@ Dom0 is using this value for sizing its grant table. > Can be modified at runtime -Specify the maximum number of frames to use as part of a domains -maptrack array. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames to use as part of a domains +maptrack array unless a different value is specified at domain creation. + +Dom0 is using this value for sizing its maptrack array. ### global-pages = <boolean>
xen/common/grant_table.c +3 -6
@@ -1956,18 +1956,15 @@ int grant_table_init(struct domain *d, int max_grant_frames,return -EINVAL ; } -/* Default to maximum value if no value was specified */ +/* Apply defaults if no value was specified */ if ( max_grant_frames <0 ) max_grant_frames = opt_max_grant_frames;if ( max_maptrack_frames <0 ) max_maptrack_frames = opt_max_maptrack_frames; -if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES || - max_grant_frames > opt_max_grant_frames || - max_maptrack_frames > opt_max_maptrack_frames ) +if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES ) { -dprintk (XENLOG_INFO ,"Bad grant table sizes: grant %u, maptrack %u\n" , - max_grant_frames, max_maptrack_frames); +dprintk (XENLOG_INFO ,"Bad grant table size %u\n" , max_grant_frames);return -EINVAL ; }
Signature · 1 line
2.39.0
docs/misc/xen-command-line.pandoc The usage of gnttab v2 is not security supported on ARM platforms. · line 1238
Quoted 13 lines · Roger Pau Monne
docs/misc/xen-command-line.pandoc +2
-3@@ -1232,9 +1232,8 @@ The usage of gnttab v2 is not security supported on ARM platforms. > Can be modified at runtime -Specify the maximum number of frames which any domain may use as part -of its grant table. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames which any domain may use as part +of its grant table unless a different value is specified at domain creation. Dom0 is using this value for sizing its grant table.
dom0less DomU-s do as well, at the very least, also ...
docs/misc/xen-command-line.pandoc Dom0 is using this value for sizing its grant table. · line 1250
Quoted 11 lines
docs/misc/xen-command-line.pandoc +4
-3@@ -1245,9 +1244,10 @@ Dom0 is using this value for sizing its grant table. > Can be modified at runtime -Specify the maximum number of frames to use as part of a domains -maptrack array. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames to use as part of a domains +maptrack array unless a different value is specified at domain creation. + +Dom0 is using this value for sizing its maptrack array.
... here. And even ordinary DomU-s appear to default to that in the absence of a specific value in the guest config. IOW at the very least the info you add should not be misleading. Better would be if the pre- existing info was adjusted at the same time.
I also wonder about the specific wording down here: While the max grant table size can indeed be queried, this isn't the case for the maptrack array. A domain also doesn't need to know its size, so maybe "This value is used to size all domains' maptrack arrays, unless overridden by their guest config"?
Quoted 13 lines
xen/common/grant_table.c +1
-1@@ -1956,18 +1956,15 @@ int grant_table_init(struct domain *d, int max_grant_frames,return -EINVAL ; } -/* Default to maximum value if no value was specified */ +/* Apply defaults if no value was specified */ if ( max_grant_frames <0 ) max_grant_frames = opt_max_grant_frames;if ( max_maptrack_frames <0 ) max_maptrack_frames = opt_max_maptrack_frames;
xen/common/grant_table.c int grant_table_init(struct domain *d, int max_grant_frames, · line 1969
Quoted 10 lines
xen/common/grant_table.c +2
-5-if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES || - max_grant_frames > opt_max_grant_frames || - max_maptrack_frames > opt_max_maptrack_frames ) +if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES ) { -dprintk (XENLOG_INFO ,"Bad grant table sizes: grant %u, maptrack %u\n" , - max_grant_frames, max_maptrack_frames); +dprintk (XENLOG_INFO ,"Bad grant table size %u\n" , max_grant_frames);return -EINVAL ; }
I think I agree with the relaxation done here, but I also think this not introducing security concerns wants spelling out in the description: My understanding is that even in disaggregated environments we assume only fully privileged entities can create domains.
Jan
Quoted 21 lines · Jan Beulich
docs/misc/xen-command-line.pandoc The usage of gnttab v2 is not security supported on ARM platforms. · line 1238
Quoted 13 lines · Roger Pau Monne
docs/misc/xen-command-line.pandoc +2
-3@@ -1232,9 +1232,8 @@ The usage of gnttab v2 is not security supported on ARM platforms. > Can be modified at runtime -Specify the maximum number of frames which any domain may use as part -of its grant table. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames which any domain may use as part +of its grant table unless a different value is specified at domain creation. Dom0 is using this value for sizing its grant table.dom0less DomU-s do as well, at the very least, also ...
Quoted 4 lines
docs/misc/xen-command-line.pandoc +0
-0@@ -1245,9 +1244,10 @@ Dom0 is using this value for sizing its grant table. > Can be modified at runtime
Quoted 12 lines
docs/misc/xen-command-line.pandoc Dom0 is using this value for sizing its grant table. · line 1250
Quoted 7 lines
docs/misc/xen-command-line.pandoc +4
-3-Specify the maximum number of frames to use as part of a domains -maptrack array. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames to use as part of a domains +maptrack array unless a different value is specified at domain creation. + +Dom0 is using this value for sizing its maptrack array.... here. And even ordinary DomU-s appear to default to that in the absence of a specific value in the guest config. IOW at the very least the info you add should not be misleading. Better would be if the pre- existing info was adjusted at the same time.
Aren't domUs already clearly covered by the sentence:
"Specify the default maximum number of frames to use as part of a domains..."
IMO dom0 needs to be explicitly mentioned because in that case the value provided is not the one used by default, but rather the one that gets used.
Quoted 5 lines
I also wonder about the specific wording down here: While the max grant table size can indeed be queried, this isn't the case for the maptrack array. A domain also doesn't need to know its size, so maybe "This value is used to size all domains' maptrack arrays, unless overridden by their guest config"?
I think the wording I've added already conveys this meaning:
"Specify the default maximum number of frames to use as part of a domains maptrack array unless a different value is specified at domain creation."
Quoted 13 lines
Quoted 13 lines
xen/common/grant_table.c +1
-1@@ -1956,18 +1956,15 @@ int grant_table_init(struct domain *d, int max_grant_frames,return -EINVAL ; } -/* Default to maximum value if no value was specified */ +/* Apply defaults if no value was specified */ if ( max_grant_frames <0 ) max_grant_frames = opt_max_grant_frames;if ( max_maptrack_frames <0 ) max_maptrack_frames = opt_max_maptrack_frames;
Quoted 15 lines
xen/common/grant_table.c int grant_table_init(struct domain *d, int max_grant_frames, · line 1969
Quoted 10 lines
xen/common/grant_table.c +2
-5-if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES || - max_grant_frames > opt_max_grant_frames || - max_maptrack_frames > opt_max_maptrack_frames ) +if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES ) { -dprintk (XENLOG_INFO ,"Bad grant table sizes: grant %u, maptrack %u\n" , - max_grant_frames, max_maptrack_frames); +dprintk (XENLOG_INFO ,"Bad grant table size %u\n" , max_grant_frames);return -EINVAL ; }I think I agree with the relaxation done here, but I also think this not introducing security concerns wants spelling out in the description: My understanding is that even in disaggregated environments we assume only fully privileged entities can create domains.
Yes, that's my understanding, as domain creation can only be done by privileged domains. Of course when using a custom XSM policy the permissions can be changed, but it's then the job of the user to asses the security implications in that case, and there are existing paths to cause resource exhausting when having access to the domain create hypercall. I can add:
"The relaxation in the logic for the maximum size of the grant and maptrack table sizes doesn't change the fact that domain creation hypercall can cause resource exhausting, so disaggregated setups should take it into account."
But domain creation for example also allows creating a domain that has MSR relaxed, at which point it could also be vulnerable to other issues.
Thanks, Roger.
Quoted 35 lines · Roger Pau Monné
Quoted 21 lines · Jan Beulich
docs/misc/xen-command-line.pandoc The usage of gnttab v2 is not security supported on ARM platforms. · line 1238
Quoted 13 lines · Roger Pau Monne
docs/misc/xen-command-line.pandoc +2
-3@@ -1232,9 +1232,8 @@ The usage of gnttab v2 is not security supported on ARM platforms. > Can be modified at runtime -Specify the maximum number of frames which any domain may use as part -of its grant table. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames which any domain may use as part +of its grant table unless a different value is specified at domain creation. Dom0 is using this value for sizing its grant table.dom0less DomU-s do as well, at the very least, also ...
Quoted 4 lines
docs/misc/xen-command-line.pandoc +0
-0@@ -1245,9 +1244,10 @@ Dom0 is using this value for sizing its grant table. > Can be modified at runtimeQuoted 12 lines
docs/misc/xen-command-line.pandoc Dom0 is using this value for sizing its grant table. · line 1250
Quoted 7 lines
docs/misc/xen-command-line.pandoc +4
-3-Specify the maximum number of frames to use as part of a domains -maptrack array. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames to use as part of a domains +maptrack array unless a different value is specified at domain creation. + +Dom0 is using this value for sizing its maptrack array.... here. And even ordinary DomU-s appear to default to that in the absence of a specific value in the guest config. IOW at the very least the info you add should not be misleading. Better would be if the pre- existing info was adjusted at the same time.
Quoted 3 lines
Aren't domUs already clearly covered by the sentence:
"Specify the default maximum number of frames to use as part of a domains..."
Hmm, yes, my attention was caught too much by the Dom0 statement. While ...
Quoted 3 lines
IMO dom0 needs to be explicitly mentioned because in that case the value provided is not the one used by default, but rather the one that gets used.
... explicitly mentioning Dom0 is fine, I still think this needs wording differently here, because Dom0 doesn't actively do anything with this value (and, as said, it can't even obtain it other than by probing how many mappings it can create).
Quoted 10 lines
Quoted 5 lines
I also wonder about the specific wording down here: While the max grant table size can indeed be queried, this isn't the case for the maptrack array. A domain also doesn't need to know its size, so maybe "This value is used to size all domains' maptrack arrays, unless overridden by their guest config"?
I think the wording I've added already conveys this meaning:
"Specify the default maximum number of frames to use as part of a domains maptrack array unless a different value is specified at domain creation."
Well, I mean specifically the Dom0 related statement.
Also to me "default maximum" reads odd (and slightly ambiguous). Would "default upper bound on the number of ..." perhaps be a little better?
Quoted 36 lines
Quoted 13 lines
Quoted 13 lines
xen/common/grant_table.c +1
-1@@ -1956,18 +1956,15 @@ int grant_table_init(struct domain *d, int max_grant_frames,return -EINVAL ; } -/* Default to maximum value if no value was specified */ +/* Apply defaults if no value was specified */ if ( max_grant_frames <0 ) max_grant_frames = opt_max_grant_frames;if ( max_maptrack_frames <0 ) max_maptrack_frames = opt_max_maptrack_frames;Quoted 15 lines
xen/common/grant_table.c int grant_table_init(struct domain *d, int max_grant_frames, · line 1969
Quoted 10 lines
xen/common/grant_table.c +2
-5-if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES || - max_grant_frames > opt_max_grant_frames || - max_maptrack_frames > opt_max_maptrack_frames ) +if ( max_grant_frames <INITIAL_NR_GRANT_FRAMES ) { -dprintk (XENLOG_INFO ,"Bad grant table sizes: grant %u, maptrack %u\n" , - max_grant_frames, max_maptrack_frames); +dprintk (XENLOG_INFO ,"Bad grant table size %u\n" , max_grant_frames);return -EINVAL ; }I think I agree with the relaxation done here, but I also think this not introducing security concerns wants spelling out in the description: My understanding is that even in disaggregated environments we assume only fully privileged entities can create domains.
Yes, that's my understanding, as domain creation can only be done by privileged domains. Of course when using a custom XSM policy the permissions can be changed, but it's then the job of the user to asses the security implications in that case, and there are existing paths to cause resource exhausting when having access to the domain create hypercall. I can add:
Quoted 4 lines
"The relaxation in the logic for the maximum size of the grant and maptrack table sizes doesn't change the fact that domain creation hypercall can cause resource exhausting, so disaggregated setups should take it into account."
SGTM, and ...
Quoted 3 lines
But domain creation for example also allows creating a domain that has MSR relaxed, at which point it could also be vulnerable to other issues.
... I think while what you say is true, it still is relevant to point out for every change which may cause yet another way of running out of resources.
Jan
Quoted 59 lines · Jan Beulich
Quoted 35 lines · Roger Pau Monné
Quoted 21 lines · Jan Beulich
docs/misc/xen-command-line.pandoc The usage of gnttab v2 is not security supported on ARM platforms. · line 1238
Quoted 13 lines · Roger Pau Monne
docs/misc/xen-command-line.pandoc +2
-3@@ -1232,9 +1232,8 @@ The usage of gnttab v2 is not security supported on ARM platforms. > Can be modified at runtime -Specify the maximum number of frames which any domain may use as part -of its grant table. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames which any domain may use as part +of its grant table unless a different value is specified at domain creation. Dom0 is using this value for sizing its grant table.dom0less DomU-s do as well, at the very least, also ...
Quoted 4 lines
docs/misc/xen-command-line.pandoc +0
-0@@ -1245,9 +1244,10 @@ Dom0 is using this value for sizing its grant table. > Can be modified at runtimeQuoted 12 lines
docs/misc/xen-command-line.pandoc Dom0 is using this value for sizing its grant table. · line 1250
Quoted 7 lines
docs/misc/xen-command-line.pandoc +4
-3-Specify the maximum number of frames to use as part of a domains -maptrack array. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames to use as part of a domains +maptrack array unless a different value is specified at domain creation. + +Dom0 is using this value for sizing its maptrack array.... here. And even ordinary DomU-s appear to default to that in the absence of a specific value in the guest config. IOW at the very least the info you add should not be misleading. Better would be if the pre- existing info was adjusted at the same time.
Quoted 3 lines
Aren't domUs already clearly covered by the sentence:
"Specify the default maximum number of frames to use as part of a domains..."
Hmm, yes, my attention was caught too much by the Dom0 statement. While ...
Quoted 3 lines
IMO dom0 needs to be explicitly mentioned because in that case the value provided is not the one used by default, but rather the one that gets used.
... explicitly mentioning Dom0 is fine, I still think this needs wording differently here, because Dom0 doesn't actively do anything with this value (and, as said, it can't even obtain it other than by probing how many mappings it can create).
Quoted 8 lines
Quoted 5 lines
I also wonder about the specific wording down here: While the max grant table size can indeed be queried, this isn't the case for the maptrack array. A domain also doesn't need to know its size, so maybe "This value is used to size all domains' maptrack arrays, unless overridden by their guest config"?
I think the wording I've added already conveys this meaning:
Quoted 7 lines
Quoted 2 lines
"Specify the default maximum number of frames to use as part of a domains maptrack array unless a different value is specified at domain creation."
Well, I mean specifically the Dom0 related statement.
Also to me "default maximum" reads odd (and slightly ambiguous). Would "default upper bound on the number of ..." perhaps be a little better?
So what about using:
"Specify the default upper bound on the number of frames which any domain may use as part of its grant table unless a different value is specified at domain creation.
Note this value is the enforced upper bound for dom0."
And similar for the maptrack option.
Thanks, Roger.
Quoted 70 lines · Roger Pau Monné
Quoted 59 lines · Jan Beulich
Quoted 35 lines · Roger Pau Monné
Quoted 21 lines · Jan Beulich
docs/misc/xen-command-line.pandoc The usage of gnttab v2 is not security supported on ARM platforms. · line 1238
Quoted 13 lines · Roger Pau Monne
docs/misc/xen-command-line.pandoc +2
-3@@ -1232,9 +1232,8 @@ The usage of gnttab v2 is not security supported on ARM platforms. > Can be modified at runtime -Specify the maximum number of frames which any domain may use as part -of its grant table. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames which any domain may use as part +of its grant table unless a different value is specified at domain creation. Dom0 is using this value for sizing its grant table.dom0less DomU-s do as well, at the very least, also ...
Quoted 4 lines
docs/misc/xen-command-line.pandoc +0
-0@@ -1245,9 +1244,10 @@ Dom0 is using this value for sizing its grant table. > Can be modified at runtimeQuoted 12 lines
docs/misc/xen-command-line.pandoc Dom0 is using this value for sizing its grant table. · line 1250
Quoted 7 lines
docs/misc/xen-command-line.pandoc +4
-3-Specify the maximum number of frames to use as part of a domains -maptrack array. This value is an upper boundary of the per-domain -value settable via Xen tools. +Specify the default maximum number of frames to use as part of a domains +maptrack array unless a different value is specified at domain creation. + +Dom0 is using this value for sizing its maptrack array.... here. And even ordinary DomU-s appear to default to that in the absence of a specific value in the guest config. IOW at the very least the info you add should not be misleading. Better would be if the pre- existing info was adjusted at the same time.
Quoted 3 lines
Aren't domUs already clearly covered by the sentence:
"Specify the default maximum number of frames to use as part of a domains..."
Hmm, yes, my attention was caught too much by the Dom0 statement. While ...
Quoted 3 lines
IMO dom0 needs to be explicitly mentioned because in that case the value provided is not the one used by default, but rather the one that gets used.
... explicitly mentioning Dom0 is fine, I still think this needs wording differently here, because Dom0 doesn't actively do anything with this value (and, as said, it can't even obtain it other than by probing how many mappings it can create).
Quoted 8 lines
Quoted 5 lines
I also wonder about the specific wording down here: While the max grant table size can indeed be queried, this isn't the case for the maptrack array. A domain also doesn't need to know its size, so maybe "This value is used to size all domains' maptrack arrays, unless overridden by their guest config"?
I think the wording I've added already conveys this meaning:
Quoted 7 lines
Quoted 2 lines
"Specify the default maximum number of frames to use as part of a domains maptrack array unless a different value is specified at domain creation."
Well, I mean specifically the Dom0 related statement.
Also to me "default maximum" reads odd (and slightly ambiguous). Would "default upper bound on the number of ..." perhaps be a little better?
So what about using:
Quoted 7 lines
"Specify the default upper bound on the number of frames which any domain may use as part of its grant table unless a different value is specified at domain creation.
Note this value is the enforced upper bound for dom0."
And similar for the maptrack option.
SGTM. (Maybe soften a little by using "effective" instead of "enforced", but only if you don't mean to emphasize the "enforce" aspect.)
Jan