[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen stable-4.14] x86/cpuid: Split dom0 handling out of init_domain_cpuid_policy()
commit ceea0ecc3ec6fecdf834bcec5bf32acb55a7831e Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Wed Dec 15 15:36:59 2021 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Thu Aug 3 19:14:19 2023 +0100 x86/cpuid: Split dom0 handling out of init_domain_cpuid_policy() To implement dom0-cpuid= support, the special cases would need extending. However there is already a problem with late hwdom where the special cases override toolstack settings, which is unintended and poor behaviour. Introduce a new init_dom0_cpuid_policy() for the purpose, moving the ITSC and ARCH_CAPS logic. The is_hardware_domain() can be dropped, and for now there is no need to rerun recalculate_cpuid_policy(); this is a relatively expensive operation, and will become more-so over time. Rearrange the logic in create_dom0() to make room for a call to init_dom0_cpuid_policy(). The AMX plans for having variable sized XSAVE states require that modifications to the policy happen before vCPUs are created. Additionally, factor out domid into a variable so we can be slightly more correct in the case of a failure, and also print the error from domain_create(). This will at least help distinguish -EINVAL from -ENOMEM. No practical change in behaviour. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> (cherry picked from commit c17072fc164a72583fda8e2b836c71d2e3f8e84d) --- xen/arch/x86/cpuid.c | 24 +++++++++++++++--------- xen/arch/x86/setup.c | 15 +++++++++++---- xen/include/asm-x86/cpuid.h | 3 +++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index 88eae2a09e..01fd016522 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -744,22 +744,28 @@ int init_domain_cpuid_policy(struct domain *d) if ( !p ) return -ENOMEM; - if ( d->disable_migrate ) - p->extd.itsc = cpu_has_itsc; + d->arch.cpuid = p; + + recalculate_cpuid_policy(d); + + return 0; +} + +void __init init_dom0_cpuid_policy(struct domain *d) +{ + struct cpuid_policy *p = d->arch.cpuid; + + /* dom0 can't migrate. Give it ITSC if available. */ + if ( cpu_has_itsc ) + p->extd.itsc = true; /* * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0, * so dom0 can turn off workarounds as appropriate. Temporary, until the * domain policy logic gains a better understanding of MSRs. */ - if ( is_hardware_domain(d) && cpu_has_arch_caps ) + if ( cpu_has_arch_caps ) p->feat.arch_caps = true; - - d->arch.cpuid = p; - - recalculate_cpuid_policy(d); - - return 0; } void guest_cpuid(const struct vcpu *v, uint32_t leaf, diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 29d71087a7..44b09b8be9 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -770,6 +770,7 @@ static struct domain *__init create_dom0(const module_t *image, }; struct domain *d; char *cmdline; + domid_t domid; if ( opt_dom0_pvh ) { @@ -784,10 +785,16 @@ static struct domain *__init create_dom0(const module_t *image, if ( iommu_enabled ) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; - /* Create initial domain 0. */ - d = domain_create(get_initial_domain_id(), &dom0_cfg, !pv_shim); - if ( IS_ERR(d) || (alloc_dom0_vcpu0(d) == NULL) ) - panic("Error creating domain 0\n"); + /* Create initial domain. Not d0 for pvshim. */ + domid = get_initial_domain_id(); + d = domain_create(domid, &dom0_cfg, !pv_shim); + if ( IS_ERR(d) ) + panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + + init_dom0_cpuid_policy(d); + + if ( alloc_dom0_vcpu0(d) == NULL ) + panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ cmdline = image->string ? __va(image->string) : NULL; diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h index 46904061d0..9c3637549a 100644 --- a/xen/include/asm-x86/cpuid.h +++ b/xen/include/asm-x86/cpuid.h @@ -59,6 +59,9 @@ bool recheck_cpu_features(unsigned int cpu); /* Allocate and initialise a CPUID policy suitable for the domain. */ int init_domain_cpuid_policy(struct domain *d); +/* Apply dom0-specific tweaks to the CPUID policy. */ +void init_dom0_cpuid_policy(struct domain *d); + /* Clamp the CPUID policy to reality. */ void recalculate_cpuid_policy(struct domain *d); -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.14
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |