Skip to contentSkip to conversation

x86/spec-ctrl: Yet more fixes for xpti= parsing

PATCH In review Andrew Cooper 2 participants 2 messages Aug 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/spec-ctrl: Yet more fixes for xpti= parsing

As it currently stands, 'xpti=dom0' is indistinguishable from the default value, which means it will be overridden by ARCH_CAPABILITIES_RDCL_NO on fixed hardware.

Switch opt_xpti to use -1 as a default like all our other related options, and clobber it as soon as we have a string to parse.

In addition, 'xpti' alone should be interpreted in its positive boolean form, rather than resulting in a parse error.

(XEN) parameter "xpti" has invalid value "", rc=-22!

---
CC: Jan Beulich <[email protected]>
CC: Juergen Gross <[email protected]>

v2:
* Don't intepret "xpti=dom0," as "xpti"

---
 xen/arch/x86/spec_ctrl.c        | 15 +++++++++++----
 xen/include/asm-x86/spec_ctrl.h |  2 +-
 2 files changed, 12 insertions(+), 5 deletions(-)
xen/arch/x86/spec_ctrl.c +11 -4
index 32a4ea6..32213ac 100644
@@ -420,8 +420,7 @@ static bool __init should_use_eager_fpu(void)
     }
 }
 
-#define OPT_XPTI_DEFAULT  0xff
-uint8_t __read_mostly opt_xpti = OPT_XPTI_DEFAULT;
+int8_t __read_mostly opt_xpti = -1;
 
 static __init void xpti_init_default(uint64_t caps)
 {
@@ -439,6 +438,14 @@ static __init int parse_xpti(const char *s)
     const char *ss;
     int val, rc = 0;
 
+    /* Inhibit the defaults as an explicit choice has been given. */
+    if ( opt_xpti == -1 )
+        opt_xpti = 0;
+
+    /* Interpret 'xpti' alone in its positive boolean form. */
+    if ( *s == '\0' )
+        opt_xpti = OPT_XPTI_DOM0 | OPT_XPTI_DOMU;
+
     do {
         ss = strchr(s, ',');
         if ( !ss )
@@ -456,7 +463,7 @@ static __init int parse_xpti(const char *s)
 
         default:
             if ( !strcmp(s, "default") )
-                opt_xpti = OPT_XPTI_DEFAULT;
+                opt_xpti = -1;
             else if ( (val = parse_boolean("dom0", s, ss)) >= 0 )
                 opt_xpti = (opt_xpti & ~OPT_XPTI_DOM0) |
                            (val ? OPT_XPTI_DOM0 : 0);
@@ -618,7 +625,7 @@ void __init init_speculation_mitigations(void)
     if ( default_xen_spec_ctrl )
         setup_force_cpu_cap(X86_FEATURE_SC_MSR_IDLE);
 
-    if ( opt_xpti == OPT_XPTI_DEFAULT )
+    if ( opt_xpti == -1 )
         xpti_init_default(caps);
 
     if ( opt_xpti == 0 )
xen/include/asm-x86/spec_ctrl.h +1 -1
index 5b40afb..fea8260 100644
@@ -34,7 +34,7 @@ extern bool bsp_delay_spec_ctrl;
 extern uint8_t default_xen_spec_ctrl;
 extern uint8_t default_spec_ctrl_flags;
 
-extern uint8_t opt_xpti;
+extern int8_t opt_xpti;
 #define OPT_XPTI_DOM0  0x01
 #define OPT_XPTI_DOMU  0x02
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 10.08.18 at 14:42, <[email protected]> wrote:

As it currently stands, 'xpti=dom0' is indistinguishable from the default value, which means it will be overridden by ARCH_CAPABILITIES_RDCL_NO on fixed hardware.

Switch opt_xpti to use -1 as a default like all our other related options, and clobber it as soon as we have a string to parse.

Quoted 6 lines

In addition, 'xpti' alone should be interpreted in its positive boolean form, rather than resulting in a parse error.

(XEN) parameter "xpti" has invalid value "", rc=-22!

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