[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/cpuid: Drop a guests cached x86 family and model information
commit 9841eb71ea8740195775cc8a91101831938626f1 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Thu Jan 12 11:45:10 2017 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Wed Jan 18 12:45:52 2017 +0000 x86/cpuid: Drop a guests cached x86 family and model information The model information isn't used at all, and the family information is only used once. Make get_cpu_family() a static inline (as it is just basic calculation, and the function call is probably more expensive than the function itself) and rearange the logic to avoid calculating model entirely if the caller doesn't want it. Calculate a guests family only when necessary in hvm_select_ioreq_server(). Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/cpu/common.c | 19 ------------------- xen/arch/x86/domain.c | 2 -- xen/arch/x86/domctl.c | 2 -- xen/arch/x86/hvm/ioreq.c | 6 ++++-- xen/include/asm-x86/cpuid.h | 2 +- xen/include/asm-x86/domain.h | 2 -- xen/include/asm-x86/processor.h | 23 ++++++++++++++++++++++- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 7d6d024..56a2331 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -186,25 +186,6 @@ int get_cpu_vendor(uint32_t b, uint32_t c, uint32_t d, enum get_cpu_vendor mode) return X86_VENDOR_UNKNOWN; } -uint8_t get_cpu_family(uint32_t raw, uint8_t *model, uint8_t *stepping) -{ - uint8_t fam, mod; - - fam = (raw >> 8) & 0xf; - if (fam == 0xf) - fam += (raw >> 20) & 0xff; - - mod = (raw >> 4) & 0xf; - if (fam >= 0x6) - mod |= (raw >> 12) & 0xf0; - - if (model) - *model = mod; - if (stepping) - *stepping = raw & 0xf; - return fam; -} - static inline u32 _phys_pkg_id(u32 cpuid_apic, int index_msb) { return cpuid_apic >> index_msb; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 56669fc..354f386 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -609,8 +609,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, goto fail; d->arch.x86_vendor = boot_cpu_data.x86_vendor; - d->arch.x86 = boot_cpu_data.x86; - d->arch.x86_model = boot_cpu_data.x86_model; d->arch.ioport_caps = rangeset_new(d, "I/O Ports", RANGESETF_prettyprint_hex); diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 772c5d2..0458d8f 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -171,8 +171,6 @@ static int update_domain_cpuid_info(struct domain *d, } case 1: - d->arch.x86 = get_cpu_family(ctl->eax, &d->arch.x86_model, NULL); - if ( is_pv_domain(d) && ((levelling_caps & LCAP_1cd) == LCAP_1cd) ) { uint64_t mask = cpuidmask_defaults._1cd; diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index 2830f6c..8ad8465 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -1125,7 +1125,7 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d, (p->addr & ~3) == 0xcfc && CF8_ENABLED(cf8) ) { - uint32_t sbdf; + uint32_t sbdf, x86_fam; /* PCI config data cycle */ @@ -1141,7 +1141,9 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d, /* AMD extended configuration space access? */ if ( CF8_ADDR_HI(cf8) && d->arch.x86_vendor == X86_VENDOR_AMD && - d->arch.x86 >= 0x10 && d->arch.x86 <= 0x17 ) + (x86_fam = get_cpu_family( + d->arch.cpuid->basic.raw_fms, NULL, NULL)) > 0x10 && + x86_fam <= 0x17 ) { uint64_t msr_val; diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h index b359b38..c56190b 100644 --- a/xen/include/asm-x86/cpuid.h +++ b/xen/include/asm-x86/cpuid.h @@ -107,7 +107,7 @@ struct cpuid_policy uint32_t max_leaf, /* b */:32, /* c */:32, /* d */:32; /* Leaf 0x1 - Family/model/stepping and features. */ - uint32_t /* a */:32, /* b */:32; + uint32_t raw_fms, /* b */:32; union { uint32_t _1c; struct { DECL_BITFIELD(1c); }; diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index eb6227d..82296c8 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -338,9 +338,7 @@ struct arch_domain bool_t auto_unmask; /* Values snooped from updates to cpuids[] (below). */ - u8 x86; /* CPU family */ u8 x86_vendor; /* CPU vendor */ - u8 x86_model; /* CPU model */ /* * The width of the FIP/FDP register in the FPU that needs to be diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index b130f47..3b859a5 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -625,7 +625,28 @@ enum get_cpu_vendor { }; int get_cpu_vendor(uint32_t b, uint32_t c, uint32_t d, enum get_cpu_vendor mode); -uint8_t get_cpu_family(uint32_t raw, uint8_t *model, uint8_t *stepping); + +static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model, + uint8_t *stepping) +{ + uint8_t fam = (raw >> 8) & 0xf; + + if ( fam == 0xf ) + fam += (raw >> 20) & 0xff; + + if ( model ) + { + uint8_t mod = (raw >> 4) & 0xf; + + if ( fam >= 0x6 ) + mod |= (raw >> 12) & 0xf0; + + *model = mod; + } + if ( stepping ) + *stepping = raw & 0xf; + return fam; +} #endif /* !__ASSEMBLY__ */ -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |