x86/cpuid: Move the legacy cpuids array into struct cpuid_policy
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 4 Jan 2017 13:31:53 +0000 (13:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 13 Jan 2017 13:16:57 +0000 (13:16 +0000)
This hides the legacy details inside the cpuid subsystem, where they will
eventually be dropped entirely.

While altering the line containing paging_initialised, change its type to bool
to match its use.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpuid.c
xen/arch/x86/domain.c
xen/arch/x86/domctl.c
xen/include/asm-x86/cpuid.h
xen/include/asm-x86/domain.h

index b7f6e60e26f7df4ca120a688aae01ecd175a331a..95040f9bd46254a22dea234bb176174778339104 100644 (file)
@@ -330,6 +330,8 @@ void recalculate_cpuid_policy(struct domain *d)
 
 int init_domain_cpuid_policy(struct domain *d)
 {
+    unsigned int i;
+
     d->arch.cpuid = xmalloc(struct cpuid_policy);
 
     if ( !d->arch.cpuid )
@@ -339,6 +341,12 @@ int init_domain_cpuid_policy(struct domain *d)
 
     recalculate_cpuid_policy(d);
 
+    for ( i = 0; i < MAX_CPUID_INPUT; i++ )
+    {
+        d->arch.cpuid->legacy[i].input[0] = XEN_CPUID_INPUT_UNUSED;
+        d->arch.cpuid->legacy[i].input[1] = XEN_CPUID_INPUT_UNUSED;
+    }
+
     return 0;
 }
 
@@ -349,7 +357,7 @@ static void domain_cpuid(const struct domain *d, uint32_t leaf,
 
     for ( i = 0; i < MAX_CPUID_INPUT; i++ )
     {
-        cpuid_input_t *cpuid = &d->arch.cpuids[i];
+        xen_domctl_cpuid_t *cpuid = &d->arch.cpuid->legacy[i];
 
         if ( (cpuid->input[0] == leaf) &&
              ((cpuid->input[1] == XEN_CPUID_INPUT_UNUSED) ||
index 6fc12426335fcf898b3058c70ccbd9a00e4dfb06..369a83aebd987a9160d7076f36f1ac681ab0814d 100644 (file)
@@ -503,7 +503,7 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
 int arch_domain_create(struct domain *d, unsigned int domcr_flags,
                        struct xen_arch_domainconfig *config)
 {
-    int i, paging_initialised = 0;
+    bool paging_initialised = false;
     int rc = -ENOMEM;
 
     if ( config == NULL && !is_idle_domain(d) )
@@ -606,16 +606,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
         if ( (rc = init_domain_cpuid_policy(d)) )
             goto fail;
 
-        d->arch.cpuids = xmalloc_array(cpuid_input_t, MAX_CPUID_INPUT);
-        rc = -ENOMEM;
-        if ( d->arch.cpuids == NULL )
-            goto fail;
-        for ( i = 0; i < MAX_CPUID_INPUT; i++ )
-        {
-            d->arch.cpuids[i].input[0] = XEN_CPUID_INPUT_UNUSED;
-            d->arch.cpuids[i].input[1] = XEN_CPUID_INPUT_UNUSED;
-        }
-
         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;
@@ -678,7 +668,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
     iommu_domain_destroy(d);
     cleanup_domain_irq_mapping(d);
     free_xenheap_page(d->shared_info);
-    xfree(d->arch.cpuids);
     xfree(d->arch.cpuid);
     if ( paging_initialised )
         paging_final_teardown(d);
@@ -697,7 +686,6 @@ void arch_domain_destroy(struct domain *d)
         hvm_domain_destroy(d);
 
     xfree(d->arch.e820);
-    xfree(d->arch.cpuids);
     xfree(d->arch.cpuid);
 
     free_domain_pirqs(d);
index 038521a34cced148d460dc443babae51707e6581..772c5d29701aa509c09223a414133425d833da93 100644 (file)
@@ -51,13 +51,13 @@ static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop)
 static int update_legacy_cpuid_array(struct domain *d,
                                      const xen_domctl_cpuid_t *ctl)
 {
-    cpuid_input_t *cpuid, *unused = NULL;
+    xen_domctl_cpuid_t *cpuid, *unused = NULL;
     unsigned int i;
 
     /* Try to insert ctl into d->arch.cpuids[] */
     for ( i = 0; i < MAX_CPUID_INPUT; i++ )
     {
-        cpuid = &d->arch.cpuids[i];
+        cpuid = &d->arch.cpuid->legacy[i];
 
         if ( cpuid->input[0] == XEN_CPUID_INPUT_UNUSED )
         {
index 38e3975a3b344ed2ba5194961899bf740e4fc36c..b359b38a2f2b5e94bc57917c3d858f14b4497b6e 100644 (file)
@@ -203,6 +203,10 @@ struct cpuid_policy
 
     /* Toolstack selected Hypervisor max_leaf (if non-zero). */
     uint8_t hv_limit, hv2_limit;
+
+    /* Temporary: Legacy data array. */
+#define MAX_CPUID_INPUT 40
+    xen_domctl_cpuid_t legacy[MAX_CPUID_INPUT];
 };
 
 /* Fill in a featureset bitmap from a CPUID policy. */
index 9e3a07b070a30ce19f0b6aa5fb66b8c16b102e5a..eb6227d0ad2bba4d4d7df372936a63bd3f04c284 100644 (file)
@@ -234,9 +234,6 @@ struct paging_vcpu {
     struct shadow_vcpu shadow;
 };
 
-#define MAX_CPUID_INPUT 40
-typedef xen_domctl_cpuid_t cpuid_input_t;
-
 #define MAX_NESTEDP2M 10
 
 #define MAX_ALTP2M      10 /* arbitrary */
@@ -360,8 +357,6 @@ struct arch_domain
      */
     uint8_t x87_fip_width;
 
-    cpuid_input_t *cpuids;
-
     /* CPUID Policy. */
     struct cpuid_policy *cpuid;