]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
arch: use __get_cpuid instead of do_cpuid 14857/head
authorJos Collin <jcollin@redhat.com>
Fri, 28 Apr 2017 01:57:16 +0000 (07:27 +0530)
committerJos Collin <jcollin@redhat.com>
Fri, 28 Apr 2017 04:02:46 +0000 (09:32 +0530)
Use __get_cpuid() instead of implementing do_cpuid(). Fixed the review comments too.

Fixes: http://tracker.ceph.com/issues/7869
Signed-off-by: Jos Collin <jcollin@redhat.com>
src/arch/intel.c

index a45bc1debbe20db4febab7d2f8d12a5f3820302e..5c483dccbdd21671bb538252c1bf56a55d61904c 100644 (file)
@@ -25,24 +25,7 @@ int ceph_arch_intel_sse2 = 0;
 int ceph_arch_intel_aesni = 0;
 
 #ifdef __x86_64__
-
-/* Note: valgrind redefines cpuid : it is different from the native processor. */
-/* intel cpu? */
-static void do_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
-                     unsigned int *edx)
-{
-        int id = *eax;
-
-        asm("movl %4, %%eax;"
-            "cpuid;"
-            "movl %%eax, %0;"
-            "movl %%ebx, %1;"
-            "movl %%ecx, %2;"
-            "movl %%edx, %3;"
-                : "=r" (*eax), "=r" (*ebx), "=r" (*ecx), "=r" (*edx)
-                : "r" (id)
-                : "eax", "ebx", "ecx", "edx");
-}
+#include <cpuid.h>
 
 /* http://en.wikipedia.org/wiki/CPUID#EAX.3D1:_Processor_Info_and_Feature_Bits */
 
@@ -57,8 +40,10 @@ static void do_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
 int ceph_arch_intel_probe(void)
 {
        /* i know how to check this on x86_64... */
-       unsigned int eax = 1, ebx, ecx, edx;
-       do_cpuid(&eax, &ebx, &ecx, &edx);
+       unsigned int eax, ebx, ecx = 0, edx = 0;
+       if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) {
+         return 1;
+       }
        if ((ecx & CPUID_PCLMUL) != 0) {
                ceph_arch_intel_pclmul = 1;
        }