x86/cpuid: Effectively remove domain_cpuid()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 4 Jan 2017 12:46:09 +0000 (12:46 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 13 Jan 2017 13:16:57 +0000 (13:16 +0000)
The only callers of domain_cpuid() are the legacy cpuid path via
{pv,hvm}_cpuid().  Move domain_cpuid() to being private in cpuid.c, with an
adjusted API to use struct cpuid_leaf rather than individual pointers.

The ITSC clobbering logic is dropped.  It is no longer necessary now that the
logic has moved into recalculate_cpuid_policy()

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/include/asm-x86/domain.h

index 1e5013d24749ae4229585125f0297183f3c7decd..b7f6e60e26f7df4ca120a688aae01ecd175a331a 100644 (file)
@@ -342,6 +342,26 @@ int init_domain_cpuid_policy(struct domain *d)
     return 0;
 }
 
+static void domain_cpuid(const struct domain *d, uint32_t leaf,
+                         uint32_t subleaf, struct cpuid_leaf *res)
+{
+    unsigned int i;
+
+    for ( i = 0; i < MAX_CPUID_INPUT; i++ )
+    {
+        cpuid_input_t *cpuid = &d->arch.cpuids[i];
+
+        if ( (cpuid->input[0] == leaf) &&
+             ((cpuid->input[1] == XEN_CPUID_INPUT_UNUSED) ||
+              (cpuid->input[1] == subleaf)) )
+        {
+            *res = (struct cpuid_leaf){ cpuid->eax, cpuid->ebx,
+                                        cpuid->ecx, cpuid->edx };
+            return;
+        }
+    }
+}
+
 static void pv_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
 {
     struct vcpu *curr = current;
@@ -349,7 +369,7 @@ static void pv_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
     const struct cpuid_policy *p = currd->arch.cpuid;
 
     if ( !is_control_domain(currd) && !is_hardware_domain(currd) )
-        domain_cpuid(currd, leaf, subleaf, &res->a, &res->b, &res->c, &res->d);
+        domain_cpuid(currd, leaf, subleaf, res);
     else
         cpuid_count_leaf(leaf, subleaf, res);
 
@@ -612,7 +632,7 @@ static void hvm_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res)
     struct domain *d = v->domain;
     const struct cpuid_policy *p = d->arch.cpuid;
 
-    domain_cpuid(d, leaf, subleaf, &res->a, &res->b, &res->c, &res->d);
+    domain_cpuid(d, leaf, subleaf, res);
 
     switch ( leaf )
     {
index 319cc8ad03846f3f3d6095adfa21209eebc94cfd..6fc12426335fcf898b3058c70ccbd9a00e4dfb06 100644 (file)
@@ -2622,46 +2622,6 @@ void arch_dump_vcpu_info(struct vcpu *v)
     vpmu_dump(v);
 }
 
-void domain_cpuid(
-    const struct domain *d,
-    unsigned int  input,
-    unsigned int  sub_input,
-    unsigned int  *eax,
-    unsigned int  *ebx,
-    unsigned int  *ecx,
-    unsigned int  *edx)
-{
-    cpuid_input_t *cpuid;
-    int i;
-
-    for ( i = 0; i < MAX_CPUID_INPUT; i++ )
-    {
-        cpuid = &d->arch.cpuids[i];
-
-        if ( (cpuid->input[0] == input) &&
-             ((cpuid->input[1] == XEN_CPUID_INPUT_UNUSED) ||
-              (cpuid->input[1] == sub_input)) )
-        {
-            *eax = cpuid->eax;
-            *ebx = cpuid->ebx;
-            *ecx = cpuid->ecx;
-            *edx = cpuid->edx;
-
-            /*
-             * Do not advertise host's invariant TSC unless the TSC is
-             * emulated, or the domain cannot migrate to other hosts.
-             */
-            if ( (input == 0x80000007) && /* Advanced Power Management */
-                 !d->disable_migrate && !d->arch.vtsc )
-                *edx &= ~cpufeat_mask(X86_FEATURE_ITSC);
-
-            return;
-        }
-    }
-
-    *eax = *ebx = *ecx = *edx = 0;
-}
-
 void vcpu_kick(struct vcpu *v)
 {
     /*
index 896e78d9bfa7aa396fefea30bdeec254a3cdb5db..9e3a07b070a30ce19f0b6aa5fb66b8c16b102e5a 100644 (file)
@@ -617,14 +617,6 @@ unsigned long pv_guest_cr4_fixup(const struct vcpu *, unsigned long guest_cr4);
              X86_CR4_OSXSAVE | X86_CR4_SMEP |               \
              X86_CR4_FSGSBASE | X86_CR4_SMAP))
 
-void domain_cpuid(const struct domain *d,
-                  unsigned int  input,
-                  unsigned int  sub_input,
-                  unsigned int  *eax,
-                  unsigned int  *ebx,
-                  unsigned int  *ecx,
-                  unsigned int  *edx);
-
 #define domain_max_vcpus(d) (is_hvm_domain(d) ? HVM_MAX_VCPUS : MAX_VIRT_CPUS)
 
 static inline struct vcpu_guest_context *alloc_vcpu_guest_context(void)