[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] x86: split opt_xpti



commit 51e0cb45932d80d4eeb59994ee2c3f3c597b0212
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Oct 4 14:48:18 2018 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Oct 4 14:48:18 2018 +0200

    x86: split opt_xpti
    
    Use separate tracking variables for the hardware domain and DomU-s.
    
    No functional change intended.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/flushtlb.c         |  2 +-
 xen/arch/x86/pv/domain.c        |  3 +--
 xen/arch/x86/smpboot.c          |  2 +-
 xen/arch/x86/spec_ctrl.c        | 50 +++++++++++++++++++++++++----------------
 xen/include/asm-x86/spec_ctrl.h |  4 +---
 5 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/flushtlb.c b/xen/arch/x86/flushtlb.c
index 7d79d9048d..ed0504c478 100644
--- a/xen/arch/x86/flushtlb.c
+++ b/xen/arch/x86/flushtlb.c
@@ -182,7 +182,7 @@ unsigned int flush_area_local(const void *va, unsigned int 
flags)
                  */
                 invpcid_flush_one(PCID_PV_PRIV, addr);
                 invpcid_flush_one(PCID_PV_USER, addr);
-                if ( opt_xpti )
+                if ( opt_xpti_hwdom || opt_xpti_domu )
                 {
                     invpcid_flush_one(PCID_PV_PRIV | PCID_PV_XPTI, addr);
                     invpcid_flush_one(PCID_PV_USER | PCID_PV_XPTI, addr);
diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
index 355f320fa3..ac85d11b55 100644
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -253,8 +253,7 @@ int pv_domain_initialise(struct domain *d)
     /* 64-bit PV guest by default. */
     d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0;
 
-    d->arch.pv.xpti = opt_xpti & (is_hardware_domain(d)
-                                  ? OPT_XPTI_DOM0 : OPT_XPTI_DOMU);
+    d->arch.pv.xpti = is_hardware_domain(d) ? opt_xpti_hwdom : opt_xpti_domu;
 
     if ( !is_pv_32bit_domain(d) && use_invpcid && cpu_has_pcid )
         switch ( opt_pcid )
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 9976da302f..35abfc4ea4 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -789,7 +789,7 @@ static int setup_cpu_root_pgt(unsigned int cpu)
     unsigned int off;
     int rc;
 
-    if ( !opt_xpti )
+    if ( !opt_xpti_hwdom && !opt_xpti_domu )
         return 0;
 
     rpt = alloc_xen_pagetable();
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index a67353f766..f300b562ca 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -135,8 +135,10 @@ static int __init parse_spec_ctrl(const char *s)
 
             opt_eager_fpu = 0;
 
-            if ( opt_xpti < 0 )
-                opt_xpti = 0;
+            if ( opt_xpti_hwdom < 0 )
+                opt_xpti_hwdom = 0;
+            if ( opt_xpti_domu < 0 )
+                opt_xpti_domu = 0;
 
             if ( opt_smt < 0 )
                 opt_smt = 1;
@@ -349,8 +351,8 @@ static void __init print_details(enum ind_thunk thunk, 
uint64_t caps)
            opt_eager_fpu                             ? " EAGER_FPU"     : "");
 
     printk("  XPTI (64-bit PV only): Dom0 %s, DomU %s (with%s PCID)\n",
-           opt_xpti & OPT_XPTI_DOM0 ? "enabled" : "disabled",
-           opt_xpti & OPT_XPTI_DOMU ? "enabled" : "disabled",
+           opt_xpti_hwdom ? "enabled" : "disabled",
+           opt_xpti_domu  ? "enabled" : "disabled",
            xpti_pcid_enabled() ? "" : "out");
 
     printk("  PV L1TF shadowing: Dom0 %s, DomU %s\n",
@@ -665,7 +667,8 @@ static __init void l1tf_calculations(uint64_t caps)
                                             : (3ul << (paddr_bits - 2))));
 }
 
-int8_t __read_mostly opt_xpti = -1;
+int8_t __read_mostly opt_xpti_hwdom = -1;
+int8_t __read_mostly opt_xpti_domu = -1;
 
 static __init void xpti_init_default(uint64_t caps)
 {
@@ -673,9 +676,19 @@ static __init void xpti_init_default(uint64_t caps)
         caps = ARCH_CAPABILITIES_RDCL_NO;
 
     if ( caps & ARCH_CAPABILITIES_RDCL_NO )
-        opt_xpti = 0;
+    {
+        if ( opt_xpti_hwdom < 0 )
+            opt_xpti_hwdom = 0;
+        if ( opt_xpti_domu < 0 )
+            opt_xpti_domu = 0;
+    }
     else
-        opt_xpti = OPT_XPTI_DOM0 | OPT_XPTI_DOMU;
+    {
+        if ( opt_xpti_hwdom < 0 )
+            opt_xpti_hwdom = 1;
+        if ( opt_xpti_domu < 0 )
+            opt_xpti_domu = 1;
+    }
 }
 
 static __init int parse_xpti(const char *s)
@@ -684,12 +697,14 @@ static __init int parse_xpti(const char *s)
     int val, rc = 0;
 
     /* Inhibit the defaults as an explicit choice has been given. */
-    if ( opt_xpti == -1 )
-        opt_xpti = 0;
+    if ( opt_xpti_hwdom == -1 )
+        opt_xpti_hwdom = 0;
+    if ( opt_xpti_domu == -1 )
+        opt_xpti_domu = 0;
 
     /* Interpret 'xpti' alone in its positive boolean form. */
     if ( *s == '\0' )
-        opt_xpti = OPT_XPTI_DOM0 | OPT_XPTI_DOMU;
+        opt_xpti_hwdom = opt_xpti_domu = 1;
 
     do {
         ss = strchr(s, ',');
@@ -699,22 +714,20 @@ static __init int parse_xpti(const char *s)
         switch ( parse_bool(s, ss) )
         {
         case 0:
-            opt_xpti = 0;
+            opt_xpti_hwdom = opt_xpti_domu = 0;
             break;
 
         case 1:
-            opt_xpti = OPT_XPTI_DOM0 | OPT_XPTI_DOMU;
+            opt_xpti_hwdom = opt_xpti_domu = 1;
             break;
 
         default:
             if ( !strcmp(s, "default") )
-                opt_xpti = -1;
+                opt_xpti_hwdom = opt_xpti_domu = -1;
             else if ( (val = parse_boolean("dom0", s, ss)) >= 0 )
-                opt_xpti = (opt_xpti & ~OPT_XPTI_DOM0) |
-                           (val ? OPT_XPTI_DOM0 : 0);
+                opt_xpti_hwdom = val;
             else if ( (val = parse_boolean("domu", s, ss)) >= 0 )
-                opt_xpti = (opt_xpti & ~OPT_XPTI_DOMU) |
-                           (val ? OPT_XPTI_DOMU : 0);
+                opt_xpti_domu = val;
             else if ( *s )
                 rc = -EINVAL;
             break;
@@ -870,8 +883,7 @@ void __init init_speculation_mitigations(void)
     if ( default_xen_spec_ctrl )
         setup_force_cpu_cap(X86_FEATURE_SC_MSR_IDLE);
 
-    if ( opt_xpti == -1 )
-        xpti_init_default(caps);
+    xpti_init_default(caps);
 
     l1tf_calculations(caps);
 
diff --git a/xen/include/asm-x86/spec_ctrl.h b/xen/include/asm-x86/spec_ctrl.h
index e06fa84865..c6c20c1b43 100644
--- a/xen/include/asm-x86/spec_ctrl.h
+++ b/xen/include/asm-x86/spec_ctrl.h
@@ -42,9 +42,7 @@ extern bool bsp_delay_spec_ctrl;
 extern uint8_t default_xen_spec_ctrl;
 extern uint8_t default_spec_ctrl_flags;
 
-extern int8_t opt_xpti;
-#define OPT_XPTI_DOM0  0x01
-#define OPT_XPTI_DOMU  0x02
+extern int8_t opt_xpti_hwdom, opt_xpti_domu;
 
 extern int8_t opt_pv_l1tf;
 #define OPT_PV_L1TF_DOM0  0x01
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.