Skip to contentSkip to conversation

common/gnttab: Introduce command line feature controls

PATCH In review Andrew Cooper 3 participants 7 messages Feb 1, 2018 – Feb 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/gnttab: Introduce command line feature controls

This patch was originally released as part of XSA-226. It retains the same command line syntax (as various downstreams are mitigating XSA-226 using this mechanism) but the defaults have been updated due to the revised XSA-226 patched, after which transitive grants are believed to functioning properly.

---
CC: Jan Beulich <[email protected]>
CC: George Dunlap <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>

v2:
* Rebase over command-line parsing changes.

---
 docs/misc/xen-command-line.markdown | 13 ++++++++++++
 xen/common/grant_table.c            | 42 +++++++++++++++++++++++++++++++++++--
 2 files changed, 53 insertions(+), 2 deletions(-)
docs/misc/xen-command-line.markdown +13 -0
index 9c10d3a..2bf2a8f 100644
@@ -916,6 +916,19 @@ Controls EPT related features.
 
 Specify which console gdbstub should use. See **console**.
 
+### gnttab
+> `= List of [ max_ver:<integer>, transitive=<bool> ]`
+
+> Default: `gnttab=max_ver:2,transitive`
+
+Control various aspects of the grant table behaviour available to guests.
+
+* `max_ver` Select the maximum grant table version to offer to guests.  Valid
+version are 1 and 2.
+* `transitive` Permit or disallow the use of transitive grants.  Note that the
+use of grant table v2 without transitive grants is an ABI breakage from the
+guests point of view.
+
 ### gnttab\_max\_frames
 > `= <integer>`
 
xen/common/grant_table.c +40 -2

60 lines not on this page · raw message

Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

docs/misc/xen-command-line.markdown Controls EPT related features. · line 920

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 01.02.18 at 15:38, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +2 -0
@@ -916,6 +916,19 @@ Controls EPT related features.
 
 Specify which console gdbstub should use. See **console**.
 
+### gnttab
+> `= List of [ max_ver:<integer>, transitive=<bool> ]`

I realize you don't want to change this as people already use it, but I'd still like to give my usual comment: I'd prefer if we could avoid introducing further underscore-containing (sub)options. I really don't understand why everyone does this: Dashes are easier to type on all keyboards I'm aware of, and there's no need to mimic C identifier names for command line options.

Quoted 12 lines
xen/common/grant_table.c +6 -0
@@ -97,6 +97,40 @@ static unsigned int __read_mostly max_maptrack_frames =
                                                DEFAULT_MAX_MAPTRACK_FRAMES;
 integer_runtime_param("gnttab_max_maptrack_frames", max_maptrack_frames);
 
+static unsigned int __read_mostly opt_gnttab_max_version = 2;
+static bool __read_mostly opt_transitive_grants = true;
+
+static int __init parse_gnttab(const char *s)
+{
+    const char *ss;

xen/common/grant_table.c static unsigned int __read_mostly max_maptrack_frames = · line 115

Quoted 10 lines
xen/common/grant_table.c +10 -0
+    int val, rc = 0;
+
+    do {
+        ss = strchr(s, ',');
+        if ( !ss )
+            ss = strchr(s, '\0');
+
+        if ( !strncmp(s, "max_ver:", 8) )
+        {
+            long ver = simple_strtol(s + 8, NULL, 10);

In particular with you already having determined the intended end of the number, wouldn't it make sense to refuse non-number input, by checking ss against what simple_strtol() would provide if the middle parameter wasn't NULL?

xen/common/grant_table.c do_grant_table_op( · line 3466

Quoted 10 lines
xen/common/grant_table.c +4 -1
@@ -3424,7 +3459,10 @@ do_grant_table_op(
         break;
 
     case GNTTABOP_set_version:
-        rc = gnttab_set_version(guest_handle_cast(uop, gnttab_set_version_t));
+        if ( opt_gnttab_max_version == 1 )
+            rc = -ENOSYS; /* Behave as before set_version was introduced. */
+        else
+            rc = gnttab_set_version(guest_handle_cast(uop, gnttab_set_version_t));
         break;

I can sort of see why you want it this way, but why do you mean to penalize any guest simply setting the version to 1 regardless of its current setting (like might e.g. be needed in kexec-like situations)? Guests may assume the availability of set_version by looking at the Xen version number (whether that's an entirely valid thing to do is a separate question).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.02.18 at 15:38, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +0 -0
@@ -916,6 +916,19 @@ Controls EPT related features.
 
 Specify which console gdbstub should use. See **console**.
 
Quoted 8 lines

docs/misc/xen-command-line.markdown Controls EPT related features. · line 920

Quoted 2 lines
docs/misc/xen-command-line.markdown +2 -0
+### gnttab
+> `= List of [ max_ver:<integer>, transitive=<bool> ]`

I realize you don't want to change this as people already use it, but I'd still like to give my usual comment: I'd prefer if we could avoid introducing further underscore-containing (sub)options. I really don't understand why everyone does this: Dashes are easier to type on all keyboards I'm aware of, and there's no need to mimic C identifier names for command line options.

I can introduce a max-ver alias if you insist, but dropping max_ver here is going to break users who took this patch for XSA-226.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 05.02.18 at 12:55, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.02.18 at 15:38, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +0 -0
@@ -916,6 +916,19 @@ Controls EPT related features.
 
 Specify which console gdbstub should use. See **console**.
 
Quoted 8 lines

docs/misc/xen-command-line.markdown Controls EPT related features. · line 920

Quoted 2 lines
docs/misc/xen-command-line.markdown +2 -0
+### gnttab
+> `= List of [ max_ver:<integer>, transitive=<bool> ]`

I realize you don't want to change this as people already use it, but I'd still like to give my usual comment: I'd prefer if we could avoid introducing further underscore-containing (sub)options. I really don't understand why everyone does this: Dashes are easier to type on all keyboards I'm aware of, and there's no need to mimic C identifier names for command line options.

Quoted 2 lines

I can introduce a max-ver alias if you insist, but dropping max_ver here is going to break users who took this patch for XSA-226.

Hence the way I've worded my reply - I don't mean to insist on changing what you have, or the introduction of an alias. I merely wanted to give the comment, in the hope that it helps to avoid future underscores in command line option names.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 05.02.18 at 12:55, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich

docs/misc/xen-command-line.markdown Controls EPT related features. · line 920

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 01.02.18 at 15:38, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +2 -0
@@ -916,6 +916,19 @@ Controls EPT related features.
 
 Specify which console gdbstub should use. See **console**.
 
+### gnttab
+> `= List of [ max_ver:<integer>, transitive=<bool> ]`

I realize you don't want to change this as people already use it, but I'd still like to give my usual comment: I'd prefer if we could avoid introducing further underscore-containing (sub)options. I really don't understand why everyone does this: Dashes are easier to type on all keyboards I'm aware of, and there's no need to mimic C identifier names for command line options.

Quoted 7 lines
Quoted 2 lines

I can introduce a max-ver alias if you insist, but dropping max_ver here is going to break users who took this patch for XSA-226.

Hence the way I've worded my reply - I don't mean to insist on changing what you have, or the introduction of an alias. I merely wanted to give the comment, in the hope that it helps to avoid future underscores in command line option names.

FWIW I often end up looking at other options and name things similarly; so making the documentation say "max-ver", but accepting both "max-ver" and "max_ver", would probably make it more likely that future options would start out as having a dash rather than an underscore.

But it's just a suggestion; I wouldn't push for it.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 24 lines · George Dunlap
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 05.02.18 at 12:55, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich

docs/misc/xen-command-line.markdown Controls EPT related features. · line 920

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 01.02.18 at 15:38, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +2 -0
@@ -916,6 +916,19 @@ Controls EPT related features.
 
 Specify which console gdbstub should use. See **console**.
 
+### gnttab
+> `= List of [ max_ver:<integer>, transitive=<bool> ]`

I realize you don't want to change this as people already use it, but I'd still like to give my usual comment: I'd prefer if we could avoid introducing further underscore-containing (sub)options. I really don't understand why everyone does this: Dashes are easier to type on all keyboards I'm aware of, and there's no need to mimic C identifier names for command line options.

Quoted 6 lines
Quoted 2 lines

I can introduce a max-ver alias if you insist, but dropping max_ver here is going to break users who took this patch for XSA-226.

Hence the way I've worded my reply - I don't mean to insist on changing what you have, or the introduction of an alias. I merely wanted to give the comment, in the hope that it helps to avoid future underscores in command line option names.

Quoted 6 lines

FWIW I often end up looking at other options and name things similarly; so making the documentation say "max-ver", but accepting both "max-ver" and "max_ver", would probably make it more likely that future options would start out as having a dash rather than an underscore.

But it's just a suggestion; I wouldn't push for it.

So how to unblock this?  There are no concrete suggestions, and no concrete objections to the patch in its current form.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
Quoted 30 lines · Andrew Cooper
Quoted 29 lines · George Dunlap
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 05.02.18 at 12:55, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich

docs/misc/xen-command-line.markdown Controls EPT related features. · line 920

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 01.02.18 at 15:38, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +2 -0
@@ -916,6 +916,19 @@ Controls EPT related features.
 
 Specify which console gdbstub should use. See **console**.
 
+### gnttab
+> `= List of [ max_ver:<integer>, transitive=<bool> ]`

I realize you don't want to change this as people already use it, but I'd still like to give my usual comment: I'd prefer if we could avoid introducing further underscore-containing (sub)options. I really don't understand why everyone does this: Dashes are easier to type on all keyboards I'm aware of, and there's no need to mimic C identifier names for command line options.

Quoted 6 lines
Quoted 2 lines

I can introduce a max-ver alias if you insist, but dropping max_ver here is going to break users who took this patch for XSA-226.

Hence the way I've worded my reply - I don't mean to insist on changing what you have, or the introduction of an alias. I merely wanted to give the comment, in the hope that it helps to avoid future underscores in command line option names.

FWIW I often end up looking at other options and name things similarly; so making the documentation say "max-ver", but accepting both "max-ver" and "max_ver", would probably make it more likely that future options would start out as having a dash rather than an underscore.

Quoted 4 lines
Quoted 1 line

But it's just a suggestion; I wouldn't push for it.

So how to unblock this?  There are no concrete suggestions, and no concrete objections to the patch in its current form.

From what I understand, both Jan and I are saying, "We won't block the patch if you re-submit with max_ver but Jan's other comments addressed; but we would prefer it if max-ver could be used instead."

Given that you want to keep things compatible with the securty patch, I see two options forward for you:

1. Re-submit it using only max_ver

2. Make it accept both max-ver and max_ver, but only document max-ver.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel