Message ID | 20240726152206.28411-8-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | x86: adventures in Address Space Isolation | expand |
On 26.07.2024 17:21, Roger Pau Monne wrote: > 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>
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index ccadfe0c9e70..3d3c14dbb5ae 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -842,6 +842,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; @@ -908,8 +910,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: diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c index 2a445bb17b99..86b74fb372d5 100644 --- a/xen/arch/x86/pv/domain.c +++ b/xen/arch/x86/pv/domain.c @@ -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) ) { diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index 40f6ae017010..5dc7a17b9354 100644 --- a/xen/arch/x86/spec_ctrl.c +++ b/xen/arch/x86/spec_ctrl.c @@ -1769,6 +1769,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)
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> --- xen/arch/x86/domain.c | 4 ++-- xen/arch/x86/pv/domain.c | 2 -- xen/arch/x86/spec_ctrl.c | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-)