Skip to contentSkip to conversation

x86/cpuid: Drop a guests cached x86 family and model information

PATCH In review Andrew Cooper 4 participants 6 messages Jan 13, 2017 – Jan 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 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().

---
CC: Jan Beulich <[email protected]>
CC: Paul Durrant <[email protected]>

v2: Broken out from previous v1

---
 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(-)
xen/arch/x86/cpu/common.c +0 -19
index 7d6d024..56a2331 100644
@@ -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;
xen/arch/x86/domain.c +0 -2
index 369a83a..f966da7 100644
@@ -607,8 +607,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);
xen/arch/x86/domctl.c +0 -2
index 772c5d2..0458d8f 100644
@@ -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;
xen/arch/x86/hvm/ioreq.c +4 -2
index 2830f6c..8ad8465 100644
@@ -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;
 
xen/include/asm-x86/cpuid.h +1 -1
index b359b38..c56190b 100644
@@ -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); };
xen/include/asm-x86/domain.h +0 -2
index eb6227d..82296c8 100644
@@ -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
xen/include/asm-x86/processor.h +22 -1
index b130f47..3b859a5 100644
@@ -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__ */
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH v2 2/2 x86/cpuid: Move x86_vendor from arch_domain to cpuid_policy

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: George Dunlap <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

v2: Break out family/model logic

---
 xen/arch/x86/cpuid.c            | 9 +++++----
 xen/arch/x86/domain.c           | 2 --
 xen/arch/x86/domctl.c           | 9 ++++-----
 xen/arch/x86/hvm/emulate.c      | 2 +-
 xen/arch/x86/hvm/hvm.c          | 2 +-
 xen/arch/x86/hvm/ioreq.c        | 2 +-
 xen/arch/x86/hvm/svm/svm.c      | 2 +-
 xen/arch/x86/hvm/vmx/vmx.c      | 2 +-
 xen/arch/x86/mm.c               | 4 ++--
 xen/arch/x86/mm/shadow/common.c | 2 +-
 xen/arch/x86/traps.c            | 2 +-
 xen/include/asm-x86/cpuid.h     | 3 +++
 xen/include/asm-x86/domain.h    | 3 ---
 13 files changed, 21 insertions(+), 23 deletions(-)
xen/arch/x86/cpuid.c +5 -4
index 95040f9..bcdac03 100644
@@ -130,6 +130,8 @@ static void __init calculate_raw_policy(void)
     for ( i = 1; i < min(ARRAY_SIZE(p->extd.raw),
                          p->extd.max_leaf + 1 - 0x80000000ul); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
+
+    p->x86_vendor = boot_cpu_data.x86_vendor;
 }
 
 static void __init calculate_host_policy(void)
@@ -592,7 +594,7 @@ static void pv_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
         res->d = p->extd.e1d;
 
         /* If not emulating AMD, clear the duplicated features in e1d. */
-        if ( currd->arch.x86_vendor != X86_VENDOR_AMD )
+        if ( p->x86_vendor != X86_VENDOR_AMD )
             res->d &= ~CPUID_COMMON_1D_FEATURES;
 
         /*
@@ -805,7 +807,7 @@ static void hvm_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
         res->d = p->extd.e1d;
 
         /* If not emulating AMD, clear the duplicated features in e1d. */
-        if ( d->arch.x86_vendor != X86_VENDOR_AMD )
+        if ( p->x86_vendor != X86_VENDOR_AMD )
             res->d &= ~CPUID_COMMON_1D_FEATURES;
         /* fast-forward MSR_APIC_BASE.EN if it hasn't already been clobbered. */
         else if ( vlapic_hw_disabled(vcpu_vlapic(v)) )
@@ -829,8 +831,7 @@ static void hvm_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
             res->d &= ~cpufeat_mask(X86_FEATURE_PSE36);
 
         /* SYSCALL is hidden outside of long mode on Intel. */
-        if ( d->arch.x86_vendor == X86_VENDOR_INTEL &&
-             !hvm_long_mode_enabled(v))
+        if ( p->x86_vendor == X86_VENDOR_INTEL && !hvm_long_mode_enabled(v) )
             res->d &= ~cpufeat_mask(X86_FEATURE_SYSCALL);
 
         break;
xen/arch/x86/domain.c +0 -2
index f966da7..de4a3d6 100644
@@ -606,8 +606,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
         if ( (rc = init_domain_cpuid_policy(d)) )
             goto fail;
 
-        d->arch.x86_vendor = boot_cpu_data.x86_vendor;
-
         d->arch.ioport_caps = 
             rangeset_new(d, "I/O Ports", RANGESETF_prettyprint_hex);
         rc = -ENOMEM;
xen/arch/x86/domctl.c +4 -5
index 0458d8f..969df12e 100644
@@ -154,12 +154,11 @@ static int update_domain_cpuid_info(struct domain *d,
     switch ( ctl->input[0] )
     {
     case 0: {
-        int old_vendor = d->arch.x86_vendor;
+        int old_vendor = p->x86_vendor;
 
-        d->arch.x86_vendor = get_cpu_vendor(
-            ctl->ebx, ctl->ecx, ctl->edx, gcv_guest);
+        p->x86_vendor = get_cpu_vendor(ctl->ebx, ctl->ecx, ctl->edx, gcv_guest);
 
-        if ( is_hvm_domain(d) && (d->arch.x86_vendor != old_vendor) )
+        if ( is_hvm_domain(d) && (p->x86_vendor != old_vendor) )
         {
             struct vcpu *v;
 
@@ -290,7 +289,7 @@ static int update_domain_cpuid_info(struct domain *d,
                 ecx |= cpufeat_mask(X86_FEATURE_CMP_LEGACY);
 
             /* If not emulating AMD, clear the duplicated features in e1d. */
-            if ( d->arch.x86_vendor != X86_VENDOR_AMD )
+            if ( p->x86_vendor != X86_VENDOR_AMD )
                 edx &= ~CPUID_COMMON_1D_FEATURES;
 
             switch ( boot_cpu_data.x86_vendor )
xen/arch/x86/hvm/emulate.c +1 -1
index e22740f..0d21fe1 100644
@@ -1910,7 +1910,7 @@ void hvm_emulate_init_once(
 
     hvmemul_ctxt->validate = validate;
     hvmemul_ctxt->ctxt.regs = regs;
-    hvmemul_ctxt->ctxt.vendor = curr->domain->arch.x86_vendor;
+    hvmemul_ctxt->ctxt.vendor = curr->domain->arch.cpuid->x86_vendor;
     hvmemul_ctxt->ctxt.force_writeback = true;
 
     if ( cpu_has_vmx )
xen/arch/x86/hvm/hvm.c +1 -1
index 2ec0800..63748dc 100644
@@ -3619,7 +3619,7 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
 {
     struct vcpu *cur = current;
     bool should_emulate =
-        cur->domain->arch.x86_vendor != boot_cpu_data.x86_vendor;
+        cur->domain->arch.cpuid->x86_vendor != boot_cpu_data.x86_vendor;
     struct hvm_emulate_ctxt ctxt;
 
     hvm_emulate_init_once(&ctxt, opt_hvm_fep ? NULL : is_cross_vendor, regs);
xen/arch/x86/hvm/ioreq.c +1 -1
index 8ad8465..26a0cb8 100644
@@ -1140,7 +1140,7 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d,
                (p->addr & 3);
         /* AMD extended configuration space access? */
         if ( CF8_ADDR_HI(cf8) &&
-             d->arch.x86_vendor == X86_VENDOR_AMD &&
+             d->arch.cpuid->x86_vendor == X86_VENDOR_AMD &&
              (x86_fam = get_cpu_family(
                  d->arch.cpuid->basic.raw_fms, NULL, NULL)) > 0x10 &&
              x86_fam <= 0x17 )
xen/arch/x86/hvm/svm/svm.c +1 -1
index ae8e2c4..e8ef88d 100644
@@ -591,7 +591,7 @@ static void svm_update_guest_vendor(struct vcpu *v)
     u32 bitmap = vmcb_get_exception_intercepts(vmcb);
 
     if ( opt_hvm_fep ||
-         (v->domain->arch.x86_vendor != boot_cpu_data.x86_vendor) )
+         (v->domain->arch.cpuid->x86_vendor != boot_cpu_data.x86_vendor) )
         bitmap |= (1U << TRAP_invalid_op);
     else
         bitmap &= ~(1U << TRAP_invalid_op);
xen/arch/x86/hvm/vmx/vmx.c +1 -1
index 61925cf..a5e5ffd 100644
@@ -544,7 +544,7 @@ void vmx_update_exception_bitmap(struct vcpu *v)
 static void vmx_update_guest_vendor(struct vcpu *v)
 {
     if ( opt_hvm_fep ||
-         (v->domain->arch.x86_vendor != boot_cpu_data.x86_vendor) )
+         (v->domain->arch.cpuid->x86_vendor != boot_cpu_data.x86_vendor) )
         v->arch.hvm_vmx.exception_bitmap |= (1U << TRAP_invalid_op);
     else
         v->arch.hvm_vmx.exception_bitmap &= ~(1U << TRAP_invalid_op);
xen/arch/x86/mm.c +2 -2
index d707d1c..a5521f1 100644
@@ -5358,7 +5358,7 @@ int ptwr_do_page_fault(struct vcpu *v, unsigned long addr,
     struct ptwr_emulate_ctxt ptwr_ctxt = {
         .ctxt = {
             .regs = regs,
-            .vendor = d->arch.x86_vendor,
+            .vendor = d->arch.cpuid->x86_vendor,
             .addr_size = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
             .sp_size   = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
             .swint_emulate = x86_swint_emulate_none,
@@ -5514,7 +5514,7 @@ int mmio_ro_do_page_fault(struct vcpu *v, unsigned long addr,
     struct mmio_ro_emulate_ctxt mmio_ro_ctxt = { .cr2 = addr };
     struct x86_emulate_ctxt ctxt = {
         .regs = regs,
-        .vendor = v->domain->arch.x86_vendor,
+        .vendor = v->domain->arch.cpuid->x86_vendor,
         .addr_size = addr_size,
         .sp_size = addr_size,
         .swint_emulate = x86_swint_emulate_none,
xen/arch/x86/mm/shadow/common.c +1 -1
index 4113351..e4ccf92 100644
@@ -330,7 +330,7 @@ const struct x86_emulate_ops *shadow_init_emulation(
     memset(sh_ctxt, 0, sizeof(*sh_ctxt));
 
     sh_ctxt->ctxt.regs = regs;
-    sh_ctxt->ctxt.vendor = v->domain->arch.x86_vendor;
+    sh_ctxt->ctxt.vendor = v->domain->arch.cpuid->x86_vendor;
     sh_ctxt->ctxt.swint_emulate = x86_swint_emulate_none;
 
     /* Segment cache initialisation. Primed with CS. */
xen/arch/x86/traps.c +1 -1
index 4f29c3a..bc95604 100644
@@ -2981,7 +2981,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
     struct domain *currd = curr->domain;
     struct priv_op_ctxt ctxt = {
         .ctxt.regs = regs,
-        .ctxt.vendor = currd->arch.x86_vendor,
+        .ctxt.vendor = currd->arch.cpuid->x86_vendor,
     };
     int rc;
     unsigned int eflags, ar;
xen/include/asm-x86/cpuid.h +3 -0
index c56190b..24ad3e0 100644
@@ -204,6 +204,9 @@ struct cpuid_policy
     /* Toolstack selected Hypervisor max_leaf (if non-zero). */
     uint8_t hv_limit, hv2_limit;
 
+    /* Value calculated from raw data above. */
+    uint8_t x86_vendor;
+
     /* Temporary: Legacy data array. */
 #define MAX_CPUID_INPUT 40
     xen_domctl_cpuid_t legacy[MAX_CPUID_INPUT];
xen/include/asm-x86/domain.h +0 -3
index 82296c8..e6c7e13 100644
@@ -337,9 +337,6 @@ struct arch_domain
     /* Is PHYSDEVOP_eoi to automatically unmask the event channel? */
     bool_t auto_unmask;
 
-    /* Values snooped from updates to cpuids[] (below). */
-    u8 x86_vendor;           /* CPU vendor */
-
     /*
      * The width of the FIP/FDP register in the FPU that needs to be
      * saved/restored during a context switch.  This is needed because
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] x86/cpuid: Move x86_vendor from arch_domain to cpuid_policy

In reply to Andrew Cooper
Quoted 6 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Friday, January 13, 2017 9:56 PM

No functional change.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] x86/cpuid: Move x86_vendor from arch_domain to cpuid_policy

In reply to Andrew Cooper
Quoted 192 lines · Andrew Cooper

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: George Dunlap <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

v2: Break out family/model logic

---
 xen/arch/x86/cpuid.c            | 9 +++++----
 xen/arch/x86/domain.c           | 2 --
 xen/arch/x86/domctl.c           | 9 ++++-----
 xen/arch/x86/hvm/emulate.c      | 2 +-
 xen/arch/x86/hvm/hvm.c          | 2 +-
 xen/arch/x86/hvm/ioreq.c        | 2 +-
 xen/arch/x86/hvm/svm/svm.c      | 2 +-
 xen/arch/x86/hvm/vmx/vmx.c      | 2 +-
 xen/arch/x86/mm.c               | 4 ++--
 xen/arch/x86/mm/shadow/common.c | 2 +-
 xen/arch/x86/traps.c            | 2 +-
 xen/include/asm-x86/cpuid.h     | 3 +++
 xen/include/asm-x86/domain.h    | 3 ---
 13 files changed, 21 insertions(+), 23 deletions(-)
xen/arch/x86/cpuid.c +5 -4
index 95040f9..bcdac03 100644
@@ -130,6 +130,8 @@ static void __init calculate_raw_policy(void)
     for ( i = 1; i < min(ARRAY_SIZE(p->extd.raw),
                          p->extd.max_leaf + 1 - 0x80000000ul); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
+
+    p->x86_vendor = boot_cpu_data.x86_vendor;
 }
 
 static void __init calculate_host_policy(void)
@@ -592,7 +594,7 @@ static void pv_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
         res->d = p->extd.e1d;
 
         /* If not emulating AMD, clear the duplicated features in e1d. */
-        if ( currd->arch.x86_vendor != X86_VENDOR_AMD )
+        if ( p->x86_vendor != X86_VENDOR_AMD )
             res->d &= ~CPUID_COMMON_1D_FEATURES;
 
         /*
@@ -805,7 +807,7 @@ static void hvm_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
         res->d = p->extd.e1d;
 
         /* If not emulating AMD, clear the duplicated features in e1d. */
-        if ( d->arch.x86_vendor != X86_VENDOR_AMD )
+        if ( p->x86_vendor != X86_VENDOR_AMD )
             res->d &= ~CPUID_COMMON_1D_FEATURES;
         /* fast-forward MSR_APIC_BASE.EN if it hasn't already been clobbered. */
         else if ( vlapic_hw_disabled(vcpu_vlapic(v)) )
@@ -829,8 +831,7 @@ static void hvm_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
             res->d &= ~cpufeat_mask(X86_FEATURE_PSE36);
 
         /* SYSCALL is hidden outside of long mode on Intel. */
-        if ( d->arch.x86_vendor == X86_VENDOR_INTEL &&
-             !hvm_long_mode_enabled(v))
+        if ( p->x86_vendor == X86_VENDOR_INTEL && !hvm_long_mode_enabled(v) )
             res->d &= ~cpufeat_mask(X86_FEATURE_SYSCALL);
 
         break;
xen/arch/x86/domain.c +0 -2
index f966da7..de4a3d6 100644
@@ -606,8 +606,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
         if ( (rc = init_domain_cpuid_policy(d)) )
             goto fail;
 
-        d->arch.x86_vendor = boot_cpu_data.x86_vendor;
-
         d->arch.ioport_caps = 
             rangeset_new(d, "I/O Ports", RANGESETF_prettyprint_hex);
         rc = -ENOMEM;
xen/arch/x86/domctl.c +4 -5
index 0458d8f..969df12e 100644
@@ -154,12 +154,11 @@ static int update_domain_cpuid_info(struct domain *d,
     switch ( ctl->input[0] )
     {
     case 0: {
-        int old_vendor = d->arch.x86_vendor;
+        int old_vendor = p->x86_vendor;
 
-        d->arch.x86_vendor = get_cpu_vendor(
-            ctl->ebx, ctl->ecx, ctl->edx, gcv_guest);
+        p->x86_vendor = get_cpu_vendor(ctl->ebx, ctl->ecx, ctl->edx, gcv_guest);
 
-        if ( is_hvm_domain(d) && (d->arch.x86_vendor != old_vendor) )
+        if ( is_hvm_domain(d) && (p->x86_vendor != old_vendor) )
         {
             struct vcpu *v;
 
@@ -290,7 +289,7 @@ static int update_domain_cpuid_info(struct domain *d,
                 ecx |= cpufeat_mask(X86_FEATURE_CMP_LEGACY);
 
             /* If not emulating AMD, clear the duplicated features in e1d. */
-            if ( d->arch.x86_vendor != X86_VENDOR_AMD )
+            if ( p->x86_vendor != X86_VENDOR_AMD )
                 edx &= ~CPUID_COMMON_1D_FEATURES;
 
             switch ( boot_cpu_data.x86_vendor )
xen/arch/x86/hvm/emulate.c +1 -1
index e22740f..0d21fe1 100644
@@ -1910,7 +1910,7 @@ void hvm_emulate_init_once(
 
     hvmemul_ctxt->validate = validate;
     hvmemul_ctxt->ctxt.regs = regs;
-    hvmemul_ctxt->ctxt.vendor = curr->domain->arch.x86_vendor;
+    hvmemul_ctxt->ctxt.vendor = curr->domain->arch.cpuid->x86_vendor;
     hvmemul_ctxt->ctxt.force_writeback = true;
 
     if ( cpu_has_vmx )
xen/arch/x86/hvm/hvm.c +1 -1
index 2ec0800..63748dc 100644
@@ -3619,7 +3619,7 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
 {
     struct vcpu *cur = current;
     bool should_emulate =
-        cur->domain->arch.x86_vendor != boot_cpu_data.x86_vendor;
+        cur->domain->arch.cpuid->x86_vendor != boot_cpu_data.x86_vendor;
     struct hvm_emulate_ctxt ctxt;
 
     hvm_emulate_init_once(&ctxt, opt_hvm_fep ? NULL : is_cross_vendor, regs);
xen/arch/x86/hvm/ioreq.c +1 -1
index 8ad8465..26a0cb8 100644
@@ -1140,7 +1140,7 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d,
                (p->addr & 3);
         /* AMD extended configuration space access? */
         if ( CF8_ADDR_HI(cf8) &&
-             d->arch.x86_vendor == X86_VENDOR_AMD &&
+             d->arch.cpuid->x86_vendor == X86_VENDOR_AMD &&
              (x86_fam = get_cpu_family(
                  d->arch.cpuid->basic.raw_fms, NULL, NULL)) > 0x10 &&
              x86_fam <= 0x17 )
xen/arch/x86/hvm/svm/svm.c +1 -1
index ae8e2c4..e8ef88d 100644
@@ -591,7 +591,7 @@ static void svm_update_guest_vendor(struct vcpu *v)
     u32 bitmap = vmcb_get_exception_intercepts(vmcb);
 
     if ( opt_hvm_fep ||
-         (v->domain->arch.x86_vendor != boot_cpu_data.x86_vendor) )
+         (v->domain->arch.cpuid->x86_vendor != boot_cpu_data.x86_vendor) )
         bitmap |= (1U << TRAP_invalid_op);
     else
         bitmap &= ~(1U << TRAP_invalid_op);
xen/arch/x86/hvm/vmx/vmx.c +1 -1
index 61925cf..a5e5ffd 100644
@@ -544,7 +544,7 @@ void vmx_update_exception_bitmap(struct vcpu *v)
 static void vmx_update_guest_vendor(struct vcpu *v)
 {
     if ( opt_hvm_fep ||
-         (v->domain->arch.x86_vendor != boot_cpu_data.x86_vendor) )
+         (v->domain->arch.cpuid->x86_vendor != boot_cpu_data.x86_vendor) )
         v->arch.hvm_vmx.exception_bitmap |= (1U << TRAP_invalid_op);
     else
         v->arch.hvm_vmx.exception_bitmap &= ~(1U << TRAP_invalid_op);
xen/arch/x86/mm.c +1 -1
index d707d1c..a5521f1 100644
@@ -5358,7 +5358,7 @@ int ptwr_do_page_fault(struct vcpu *v, unsigned long addr,
     struct ptwr_emulate_ctxt ptwr_ctxt = {
         .ctxt = {
             .regs = regs,
-            .vendor = d->arch.x86_vendor,
+            .vendor = d->arch.cpuid->x86_vendor,
             .addr_size = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
             .sp_size   = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
             .swint_emulate = x86_swint_emulate_none,

xen/arch/x86/mm.c int mmio_ro_do_page_fault(struct vcpu *v, unsigned long addr, · line 5520

Quoted 8 lines
xen/arch/x86/mm.c +1 -1
@@ -5514,7 +5514,7 @@ int mmio_ro_do_page_fault(struct vcpu *v, unsigned long addr,
     struct mmio_ro_emulate_ctxt mmio_ro_ctxt = { .cr2 = addr };
     struct x86_emulate_ctxt ctxt = {
         .regs = regs,
-        .vendor = v->domain->arch.x86_vendor,
+        .vendor = v->domain->arch.cpuid->x86_vendor,
         .addr_size = addr_size,
         .sp_size = addr_size,
         .swint_emulate = x86_swint_emulate_none,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v2 1/2
#5 lore raw
In reply to Andrew Cooper
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.01.17 at 14:56, <[email protected]> wrote:

The model information isn't used at all, and the family information is only used once.

Quoted 8 lines

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().

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel