]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
x86/spec-ctrl: initialize per-domain XPTI in spec_ctrl_init_domain()
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 14 Aug 2024 13:39:26 +0000 (15:39 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 14 Aug 2024 13:39:26 +0000 (15:39 +0200)
XPTI being a speculation mitigation feels better to be initialized in
spec_ctrl_init_domain().

No functional change intended, although the call to spec_ctrl_init_domain() in
arch_domain_create() needs to be moved ahead of pv_domain_initialise() for
d->->arch.pv.xpti to be correctly set.

Move it ahead of most of the initialization functions, since
spec_ctrl_init_domain() doesn't depend on any member in the struct domain being
set.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domain.c
xen/arch/x86/pv/domain.c
xen/arch/x86/spec_ctrl.c

index d977ec71ca2085b1f716ab6363df3d13380b0f8f..89aad7e8978fcef93b549cbf5a6b30d098b7186d 100644 (file)
@@ -830,6 +830,8 @@ int arch_domain_create(struct domain *d,
         is_pv_domain(d) ? __HYPERVISOR_COMPAT_VIRT_START : ~0u;
 #endif
 
+    spec_ctrl_init_domain(d);
+
     if ( (rc = paging_domain_init(d)) != 0 )
         goto fail;
     paging_initialised = true;
@@ -896,8 +898,6 @@ int arch_domain_create(struct domain *d,
 
     d->arch.msr_relaxed = config->arch.misc_flags & XEN_X86_MSR_RELAXED;
 
-    spec_ctrl_init_domain(d);
-
     return 0;
 
  fail:
index 2a445bb17b99ea4c3bad5f9ea544e313ac56015f..86b74fb372d54c047c98c7696b495a0ff780ceee 100644 (file)
@@ -383,8 +383,6 @@ int pv_domain_initialise(struct domain *d)
 
     d->arch.ctxt_switch = &pv_csw;
 
-    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 ( ACCESS_ONCE(opt_pcid) )
         {
index 92405b8be713972b7a19e0ca78a7a7891086fca0..75a4177a75d2094eff0a33de6db50cd801f97e5e 100644 (file)
@@ -1748,6 +1748,10 @@ void spec_ctrl_init_domain(struct domain *d)
         (ibpb   ? SCF_entry_ibpb   : 0) |
         (bhb    ? SCF_entry_bhb    : 0) |
         0;
+
+    if ( pv )
+        d->arch.pv.xpti = is_hardware_domain(d) ? opt_xpti_hwdom
+                                                : opt_xpti_domu;
 }
 
 void __init init_speculation_mitigations(void)