Skip to contentSkip to conversation

x86/cmdline: Interpret 'vpmu' as a positive boolean

PATCH In review Andrew Cooper 2 participants 6 messages Mar 2, 2022 – Mar 3, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/cmdline: Interpret 'vpmu' as a positive boolean

This makes it behave slightly more like a regular boolean option.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>

Slightly RFC, because there is no easy way of making the opposite "normal boolean" case work for no-vpmu.

---
 xen/arch/x86/cpu/vpmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/cpu/vpmu.c +3 -1
index 4fedc7c57012..501d4f0af94e 100644
@@ -66,7 +66,9 @@ static int __init cf_check parse_vpmu_params(const char *s)
         if ( !ss )
             ss = strchr(s, '\0');
 
-        if ( (val = parse_bool(s, ss)) >= 0 )
+        if ( s == ss )
+            opt_vpmu_enabled = true;
+        else if ( (val = parse_bool(s, ss)) >= 0 )
         {
             opt_vpmu_enabled = val;
             if ( !val )
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Andrew Cooper

This makes it behave slightly more like a regular boolean option.

Quoted 2 lines

Slightly RFC, because there is no easy way of making the opposite "normal boolean" case work for no-vpmu.

There's nothing to do to make this work afaict: Generic command line handling converts "no-<option>" to "<option>=no" for custom params.

Jan

#2 lore raw
Quoted 10 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper

This makes it behave slightly more like a regular boolean option.

Quoted 2 lines

Slightly RFC, because there is no easy way of making the opposite "normal boolean" case work for no-vpmu.

There's nothing to do to make this work afaict: Generic command line handling converts "no-<option>" to "<option>=no" for custom params.

Oh - I'd forgotten that, in which case this patch actually wants to be simply:

xen/common/kernel.c +0 -0
index adff2d2c77f3..2cea1da781ac 100644
@@ -162,6 +162,11 @@ static int parse_params(const char *cmdline, const

struct kernel_param *start,
                     safe_strcpy(opt, "no");
                     optval = opt;
                 }
+                else if ( !*optval )
+                {
+                    safe_strcpy(opt, "1");
+                    optval = opt;
+                }
                 rctmp = param->par.func(optval);
                 break;
             case OPT_IGNORE:

to turn "option\0" into "option=1", no?

~Andrew

#3 lore raw
Quoted 33 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper

This makes it behave slightly more like a regular boolean option.

Quoted 2 lines

Slightly RFC, because there is no easy way of making the opposite "normal boolean" case work for no-vpmu.

There's nothing to do to make this work afaict: Generic command line handling converts "no-<option>" to "<option>=no" for custom params.

Oh - I'd forgotten that, in which case this patch actually wants to be simply:

xen/common/kernel.c +5 -0
index adff2d2c77f3..2cea1da781ac 100644
@@ -162,6 +162,11 @@ static int parse_params(const char *cmdline, const
 struct kernel_param *start,
                      safe_strcpy(opt, "no");
                      optval = opt;
                  }
+                else if ( !*optval )
+                {
+                    safe_strcpy(opt, "1");
+                    optval = opt;
+                }
                  rctmp = param->par.func(optval);
                  break;

             case OPT_IGNORE:

Quoted 1 line

to turn "option\0" into "option=1", no?

Iirc extending this to the positive case was deliberately not done, for the risk of breaking custom handlers not expecting the standard boolean forms. We could likely go this route, but only after auditing all custom handlers, I'm afraid.

Jan

#4 lore raw
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper

This makes it behave slightly more like a regular boolean option.

Quoted 2 lines

Slightly RFC, because there is no easy way of making the opposite "normal boolean" case work for no-vpmu.

There's nothing to do to make this work afaict: Generic command line handling converts "no-<option>" to "<option>=no" for custom params.

Oh - I'd forgotten that, in which case this patch actually wants to be simply:

xen/common/kernel.c +5 -0
index adff2d2c77f3..2cea1da781ac 100644
@@ -162,6 +162,11 @@ static int parse_params(const char *cmdline, const
 struct kernel_param *start,
                      safe_strcpy(opt, "no");
                      optval = opt;
                  }
+                else if ( !*optval )
+                {
+                    safe_strcpy(opt, "1");
+                    optval = opt;
+                }
                  rctmp = param->par.func(optval);
                  break;

             case OPT_IGNORE:

Quoted 5 lines
Quoted 1 line

to turn "option\0" into "option=1", no?

Iirc extending this to the positive case was deliberately not done, for the risk of breaking custom handlers not expecting the standard boolean forms. We could likely go this route, but only after auditing all custom handlers, I'm afraid.

Well - I've already audited them all once recently.  What's once more...

I'll have a go in due course; I'd definitely prefer to avoid special casing the positive boolean form in individual handlers.

~Andrew

#5 lore raw
Quoted 34 lines · Andrew Cooper
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper

This makes it behave slightly more like a regular boolean option.

Quoted 2 lines

Slightly RFC, because there is no easy way of making the opposite "normal boolean" case work for no-vpmu.

There's nothing to do to make this work afaict: Generic command line handling converts "no-<option>" to "<option>=no" for custom params.

Oh - I'd forgotten that, in which case this patch actually wants to be simply:

xen/common/kernel.c +5 -0
index adff2d2c77f3..2cea1da781ac 100644
@@ -162,6 +162,11 @@ static int parse_params(const char *cmdline, const
 struct kernel_param *start,
                      safe_strcpy(opt, "no");
                      optval = opt;
                  }
+                else if ( !*optval )
+                {
+                    safe_strcpy(opt, "1");
+                    optval = opt;
+                }
                  rctmp = param->par.func(optval);
                  break;

             case OPT_IGNORE:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

to turn "option\0" into "option=1", no?

Iirc extending this to the positive case was deliberately not done, for the risk of breaking custom handlers not expecting the standard boolean forms. We could likely go this route, but only after auditing all custom handlers, I'm afraid.

Well - I've already audited them all once recently.  What's once more...

Of course if you did an audit (for this particular property) recently, that's definitely enough. Feel free to apply my earlier provided R-b also to this alternative change then.

Jan

Quoted 4 lines

I'll have a go in due course; I'd definitely prefer to avoid special casing the positive boolean form in individual handlers.

~Andrew