Skip to contentSkip to conversation

xen/argo: Command line handling improvements

PATCH In review Andrew Cooper 5 participants 7 messages May 20, 2025 – May 29, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/argo: Command line handling improvements

Treat "argo" on the command line as a positive boolean, rather than requiring the user to pass "argo=1/on/enable/true".

Move both opt_argo* variables into __ro_after_init. They're set during command line parsing and never modified thereafter.

---
CC: Christopher Clark <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Denis Mukhin <[email protected]>

Found while

---
 xen/common/argo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
xen/common/argo.c +6 -3
index cbe8911a4364..027b37b18a6c 100644
@@ -79,8 +79,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_argo_unregister_ring_t);
 DEFINE_COMPAT_HANDLE(compat_argo_iov_t);
 #endif
 
-static bool __read_mostly opt_argo;
-static bool __read_mostly opt_argo_mac_permissive;
+static bool __ro_after_init opt_argo;
+static bool __ro_after_init opt_argo_mac_permissive;
 
 static int __init cf_check parse_argo(const char *s)
 {
@@ -92,7 +92,10 @@ static int __init cf_check parse_argo(const char *s)
         if ( !ss )
             ss = strchr(s, '\0');
 
-        if ( (val = parse_bool(s, ss)) >= 0 )
+        /* Intepret "argo" as a positive boolean. */
+        if ( *s == '\0' )
+            opt_argo = true;
+        else if ( (val = parse_bool(s, ss)) >= 0 )
             opt_argo = val;
         else if ( (val = parse_boolean("mac-permissive", s, ss)) >= 0 )
             opt_argo_mac_permissive = val;

base-commit: 293abb9e0c5e8df96cc5dfe457c62dfcb7542b19

Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines · Andrew Cooper

Treat "argo" on the command line as a positive boolean, rather than requiring the user to pass "argo=1/on/enable/true".

Move both opt_argo* variables into __ro_after_init. They're set during command line parsing and never modified thereafter.

---
CC: Christopher Clark <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Denis Mukhin <[email protected]>

Found while

---
  xen/common/argo.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
xen/common/argo.c +6 -3
index cbe8911a4364..027b37b18a6c 100644
@@ -79,8 +79,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_argo_unregister_ring_t);
  DEFINE_COMPAT_HANDLE(compat_argo_iov_t);
  #endif
 
-static bool __read_mostly opt_argo;
-static bool __read_mostly opt_argo_mac_permissive;
+static bool __ro_after_init opt_argo;
+static bool __ro_after_init opt_argo_mac_permissive;
 
  static int __init cf_check parse_argo(const char *s)
  {
@@ -92,7 +92,10 @@ static int __init cf_check parse_argo(const char *s)
          if ( !ss )
              ss = strchr(s, '\0');
 
-        if ( (val = parse_bool(s, ss)) >= 0 )
+        /* Intepret "argo" as a positive boolean. */
+        if ( *s == '\0' )
+            opt_argo = true;
+        else if ( (val = parse_bool(s, ss)) >= 0 )
              opt_argo = val;
          else if ( (val = parse_boolean("mac-permissive", s, ss)) >= 0 )
              opt_argo_mac_permissive = val;
Quoted 1 line

base-commit: 293abb9e0c5e8df96cc5dfe457c62dfcb7542b19

While it is logical, this does technically change the behavior of the command line flag. Should there be an update to xen-command-line.pandoc to clarify that the list is optional?

Other than the doc concern,

#2 lore raw
Quoted 46 lines · Daniel P. Smith
Quoted 45 lines · Andrew Cooper

Treat "argo" on the command line as a positive boolean, rather than requiring the user to pass "argo=1/on/enable/true".

Move both opt_argo* variables into __ro_after_init. They're set during command line parsing and never modified thereafter.

---
CC: Christopher Clark <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Denis Mukhin <[email protected]>

Found while

---
  xen/common/argo.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
xen/common/argo.c +6 -3
index cbe8911a4364..027b37b18a6c 100644
@@ -79,8 +79,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_argo_unregister_ring_t);
  DEFINE_COMPAT_HANDLE(compat_argo_iov_t);
  #endif
 
-static bool __read_mostly opt_argo;
-static bool __read_mostly opt_argo_mac_permissive;
+static bool __ro_after_init opt_argo;
+static bool __ro_after_init opt_argo_mac_permissive;
 
  static int __init cf_check parse_argo(const char *s)
  {
@@ -92,7 +92,10 @@ static int __init cf_check parse_argo(const char *s)
          if ( !ss )
              ss = strchr(s, '\0');
 
-        if ( (val = parse_bool(s, ss)) >= 0 )
+        /* Intepret "argo" as a positive boolean. */
+        if ( *s == '\0' )
+            opt_argo = true;
+        else if ( (val = parse_bool(s, ss)) >= 0 )
              opt_argo = val;
          else if ( (val = parse_boolean("mac-permissive", s, ss)) >= 0 )
              opt_argo_mac_permissive = val;
Quoted 5 lines
Quoted 1 line

base-commit: 293abb9e0c5e8df96cc5dfe457c62dfcb7542b19

While it is logical, this does technically change the behavior of the command line flag. Should there be an update to xen-command-line.pandoc to clarify that the list is optional?

I'd view it the other way around: If you look at the neighboring doc entries, we uniformly say

Quoted 1 line

= <boolean>

when the options can appear all by themselves. This would therefore be the expected behavior for "argo" alone, too.

Jan

Reviewed-by Denis Mukhin on v1 1/1
#3 lore raw
In reply to Andrew Cooper
Quoted 7 lines · Andrew Cooper

Treat "argo" on the command line as a positive boolean, rather than requiring the user to pass "argo=1/on/enable/true".

Move both opt_argo* variables into __ro_after_init. They're set during command line parsing and never modified thereafter.

Quoted 42 lines

---
CC: Christopher Clark <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Denis Mukhin <[email protected]>

Found while

---
 xen/common/argo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
xen/common/argo.c +6 -3
index cbe8911a4364..027b37b18a6c 100644
@@ -79,8 +79,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_argo_unregister_ring_t);
 DEFINE_COMPAT_HANDLE(compat_argo_iov_t);
 #endif
 
-static bool __read_mostly opt_argo;
-static bool __read_mostly opt_argo_mac_permissive;
+static bool __ro_after_init opt_argo;
+static bool __ro_after_init opt_argo_mac_permissive;
 
 static int __init cf_check parse_argo(const char *s)
 {
@@ -92,7 +92,10 @@ static int __init cf_check parse_argo(const char *s)
         if ( !ss )
             ss = strchr(s, '\0');
 
-        if ( (val = parse_bool(s, ss)) >= 0 )
+        /* Intepret "argo" as a positive boolean. */
+        if ( *s == '\0' )
+            opt_argo = true;
+        else if ( (val = parse_bool(s, ss)) >= 0 )
             opt_argo = val;
         else if ( (val = parse_boolean("mac-permissive", s, ss)) >= 0 )
             opt_argo_mac_permissive = val;

base-commit: 293abb9e0c5e8df96cc5dfe457c62dfcb7542b19 --
2.39.5

#4 lore raw
In reply to Andrew Cooper
Quoted 7 lines · Andrew Cooper

Treat "argo" on the command line as a positive boolean, rather than requiring
the user to pass "argo=1/on/enable/true".

Move both opt_argo* variables into __ro_after_init. They're set during command line parsing and never modified thereafter.

Instead of binding to static values set at boot, would boolean_runtime_param be acceptable? This allows the system administrator to adjust the Argo settings if the hypervisor has been compiled with it enabled and booted with the default settings, and avoid having to reboot and modify the bootloader configuration.

I agree with Daniel's request for a doc update where affected.

thanks,

Christopher

Quoted 45 lines

---
CC: Christopher Clark <[email protected]>
CC: Daniel P. Smith <[email protected]>
CC: Denis Mukhin <[email protected]>

Found while

---
 xen/common/argo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
xen/common/argo.c +6 -3
index cbe8911a4364..027b37b18a6c 100644
@@ -79,8 +79,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_argo_unregister_ring_t);
 DEFINE_COMPAT_HANDLE(compat_argo_iov_t);
 #endif
 
-static bool __read_mostly opt_argo;
-static bool __read_mostly opt_argo_mac_permissive;
+static bool __ro_after_init opt_argo;
+static bool __ro_after_init opt_argo_mac_permissive;
 
 static int __init cf_check parse_argo(const char *s)
 {
@@ -92,7 +92,10 @@ static int __init cf_check parse_argo(const char *s)
         if ( !ss )
             ss = strchr(s, '\0');
 
-        if ( (val = parse_bool(s, ss)) >= 0 )
+        /* Intepret "argo" as a positive boolean. */
+        if ( *s == '\0' )
+            opt_argo = true;
+        else if ( (val = parse_bool(s, ss)) >= 0 )
             opt_argo = val;
         else if ( (val = parse_boolean("mac-permissive", s, ss)) >= 0 )
             opt_argo_mac_permissive = val;

base-commit: 293abb9e0c5e8df96cc5dfe457c62dfcb7542b19 --
2.39.5

#5 lore raw
Quoted 7 lines · Christopher Clark

On Tue, May 20, 2025 at 3:10 PM Andrew Cooper
<[email protected]> wrote:

Treat "argo" on the command line as a positive boolean, rather than requiring
the user to pass "argo=1/on/enable/true".

Quoted 7 lines

Move both opt_argo* variables into __ro_after_init.  They're set during
command line parsing and never modified thereafter.

Instead of binding to static values set at boot, would boolean_runtime_param be acceptable?

No, for several reasons.

Sure, you could dynamically turn it on, but existing domains can't use it because argo_init() wasn't called on them.  Now consider what happens when dynamically turning it off behind the back of a domain which was using it.

All the existing runtime controls are for properties that are not visible to guests.  Adding opt_argo to this list would create a lot of carnage.

(Like almost everything else in Xen), Argo is entirely broken with respect to enumeration and controls.  And while this isn't your fault for having copied the status quo, it is still a problem needing fixing.

Argo's availability needs advertising to the toolstack like all other features, and the toolstack needs to be able to choose the Argo settings on a per-VM basis.  Like everything else about VMs, the Argo-ness must be invariant for the lifetime of the domain.

This means changes to sysctls/domctls, which IMO are prerequisites for Argo to move from Tech Preview to Supported.  In a world where such controls existed, the argo cmdline option would really only be for someone trying to disable Argo globally.

This particular patch comes simply from me trying to experiment with Argo to sort out the XTF test, and deciding that the behaviour was objectionable enough that I'd improve it.

~Andrew

#6 lore raw
Quoted 8 lines · Andrew Cooper
Quoted 6 lines · Christopher Clark

On Tue, May 20, 2025 at 3:10 PM Andrew Cooper
<[email protected]> wrote:

Treat "argo" on the command line as a positive boolean, rather than requiring
the user to pass "argo=1/on/enable/true".

I have tested that this patch does change the command line behaviour as described, and doesn't prevent the existing valid options from parsing and acting as they currently do, to enable and disable the subsystem, so that is positive. I do have significant reservations stated below, however.

Quoted 5 lines
Quoted 4 lines

Move both opt_argo* variables into __ro_after_init. They're set during
command line parsing and never modified thereafter.

I haven't directly tested this aspect of the patch.

Quoted 7 lines
Quoted 4 lines

Instead of binding to static values set at boot, would boolean_runtime_param be acceptable?

No, for several reasons.

Thanks for the reply, your perspective is helpful.

Quoted 11 lines

Sure, you could dynamically turn it on, but existing domains can't use it because argo_init() wasn't called on them. Now consider what happens when dynamically turning it off behind the back of a domain which was using it.

All the existing runtime controls are for properties that are not visible to guests. Adding opt_argo to this list would create a lot of carnage.

OK, your aversion to it is clear and I'm not pushing to make that change.

Quoted 11 lines

(Like almost everything else in Xen), Argo is entirely broken with respect to enumeration and controls. And while this isn't your fault for having copied the status quo, it is still a problem needing fixing.

Argo's availability needs advertising to the toolstack like all other features, and the toolstack needs to be able to choose the Argo settings on a per-VM basis. Like everything else about VMs, the Argo-ness must be invariant for the lifetime of the domain.

Quoted 5 lines

This means changes to sysctls/domctls, which IMO are prerequisites for Argo to move from Tech Preview to Supported. In a world where such controls existed, the argo cmdline option would really only be for someone trying to disable Argo globally.

The above is why I'd prefer not to apply this patch: at the moment, the population of Argo developers and system integrators do not create or use bootloader configuration files with the single "argo" keyword on the Xen command line. (They use "argo=1" or similar instead.)

Once a change such as this is merged, then there is a new behaviour that is made available, and a new expectation created not to change the behaviour of the standalone command line option (ie. "argo").

I'd like to retain using the standalone argo keyword for when the only boot option that is necessary is just a simple on or off. At the moment, that's not the case: the suboption ("mac-permissive=1") is valid to either include or omit, and there is work to do in order to enable retiring it - and hopefully it will enable behaviour similar to the wider connectivity of that option by default, which will not be the case for a system with "argo" on the command line if just this current patch is applied.

Quoted 5 lines

This particular patch comes simply from me trying to experiment with Argo to sort out the XTF test, and deciding that the behaviour was objectionable enough that I'd improve it.

I agree with the end goal; but don't think this is the right next step to get there, and I don't think the existing situation is sufficiently objectionable to make this change this way.

Christopher

Quoted 3 lines

~Andrew