[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



On 13/01/17 13:56, Andrew Cooper wrote:
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Tim Deegan <tim@xxxxxxx>
> CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
> CC: Paul Durrant <paul.durrant@xxxxxxxxxx>
> CC: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> CC: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> CC: Jun Nakajima <jun.nakajima@xxxxxxxxx>
> CC: Kevin Tian <kevin.tian@xxxxxxxxx>
> 
> 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(-)
> 
> diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
> index 95040f9..bcdac03 100644
> --- a/xen/arch/x86/cpuid.c
> +++ b/xen/arch/x86/cpuid.c
> @@ -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;
> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> index f966da7..de4a3d6 100644
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -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;
> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> index 0458d8f..969df12e 100644
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -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 )
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> index e22740f..0d21fe1 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -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 )
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 2ec0800..63748dc 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -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);
> diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c
> index 8ad8465..26a0cb8 100644
> --- a/xen/arch/x86/hvm/ioreq.c
> +++ b/xen/arch/x86/hvm/ioreq.c
> @@ -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 )
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index ae8e2c4..e8ef88d 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -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);
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 61925cf..a5e5ffd 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -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);
> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
> index d707d1c..a5521f1 100644
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -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,

Acked-by: George Dunlap <george.dunlap@xxxxxxxxxx>


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.