On 23.12.2008, at 12:01, Amit Shah <[email protected]> wrote:

host_cpuid is now available in target-i386/helper.c. Rename
that function to cpu_x86_host_cpuid and use that one everywhere.

I definitely believe we can get rid of all /most cpuid special handling in qemu-kvm-x86.c, now that the very same functionality it is responsible for is implemented upstream.



Signed-off-by: Amit Shah <[email protected]>
---
qemu/qemu-kvm-x86.c       |   37 ++-----------------------------------
qemu/target-i386/cpu.h    |    3 +++
qemu/target-i386/helper.c |    8 ++++----
3 files changed, 9 insertions(+), 39 deletions(-)

diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
index aa36be8..510692b 100644
--- a/qemu/qemu-kvm-x86.c
+++ b/qemu/qemu-kvm-x86.c
@@ -451,39 +451,6 @@ void kvm_arch_save_regs(CPUState *env)
    }
}

-static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
-               uint32_t *ecx, uint32_t *edx)
-{
-    uint32_t vec[4];
-
-#ifdef __x86_64__
-    asm volatile("cpuid"
-         : "=a"(vec[0]), "=b"(vec[1]),
-           "=c"(vec[2]), "=d"(vec[3])
-         : "0"(function) : "cc");
-#else
-    asm volatile("pusha \n\t"
-         "cpuid \n\t"
-         "mov %%eax, 0(%1) \n\t"
-         "mov %%ebx, 4(%1) \n\t"
-         "mov %%ecx, 8(%1) \n\t"
-         "mov %%edx, 12(%1) \n\t"
-         "popa"
-         : : "a"(function), "S"(vec)
-         : "memory", "cc");
-#endif
-
-    if (eax)
-    *eax = vec[0];
-    if (ebx)
-    *ebx = vec[1];
-    if (ecx)
-    *ecx = vec[2];
-    if (edx)
-    *edx = vec[3];
-}
-
-
static void do_cpuid_ent(struct kvm_cpuid_entry *e, uint32_t function,
            CPUState *env)
{
@@ -497,7 +464,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry *e, uint32_t function,
    if (function == 0x80000001) {
   uint32_t h_eax, h_edx;

-    host_cpuid(function, &h_eax, NULL, NULL, &h_edx);
+    cpu_x86_host_cpuid(function, &h_eax, NULL, NULL, &h_edx);

   // long mode
   if ((h_edx & 0x20000000) == 0 || !lm_capable_kernel)
@@ -519,7 +486,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry *e, uint32_t function,
    if (function == 0) {
   uint32_t bcd[3];

-    host_cpuid(0, NULL, &bcd[0], &bcd[1], &bcd[2]);
+    cpu_x86_host_cpuid(0, NULL, &bcd[0], &bcd[1], &bcd[2]);
   e->ebx = bcd[0];
   e->ecx = bcd[1];
   e->edx = bcd[2];
diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h
index 0f518f8..816832d 100644
--- a/qemu/target-i386/cpu.h
+++ b/qemu/target-i386/cpu.h
@@ -746,6 +746,9 @@ void cpu_x86_set_a20(CPUX86State *env, int a20_state);
void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
                   uint32_t *eax, uint32_t *ebx,
                   uint32_t *ecx, uint32_t *edx);
+void cpu_x86_host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
+                        uint32_t *ecx, uint32_t *edx);
+

static inline int hw_breakpoint_enabled(unsigned long dr7, int index)
{
diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c
index 1c5b85c..6faa521 100644
--- a/qemu/target-i386/helper.c
+++ b/qemu/target-i386/helper.c
@@ -1377,8 +1377,8 @@ static void breakpoint_handler(CPUState *env)
}
#endif /* !CONFIG_USER_ONLY */

-static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
-                       uint32_t *ecx, uint32_t *edx)
+void cpu_x86_host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
+                        uint32_t *ecx, uint32_t *edx)
{
#if defined(CONFIG_KVM) || defined(USE_KVM)
    uint32_t vec[4];
@@ -1436,7 +1436,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, * actuall cpu, and say goodbye to migration between different vendors
         * is you use compatibility mode. */
        if (kvm_enabled())
-            host_cpuid(0, NULL, ebx, ecx, edx);
+            cpu_x86_host_cpuid(0, NULL, ebx, ecx, edx);
        break;
    case 1:
        *eax = env->cpuid_version;
@@ -1528,7 +1528,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
        if (kvm_enabled()) {
            uint32_t h_eax, h_edx;

-            host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);
+ cpu_x86_host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);

            /* disable CPU features that the host does not support */

--
1.5.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to