VirtualBox

Changeset 31413 in vbox for trunk/include


Ignore:
Timestamp:
Aug 5, 2010 3:24:55 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64478
Message:

iprt: ASMCpuId() and ASMGetApicId() return different data on different CPU cores so use volatile in the asm statement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm-amd64-x86.h

    r30803 r31413  
    470470#  ifdef RT_ARCH_AMD64
    471471    RTCCUINTREG uRAX, uRBX, uRCX, uRDX;
    472     __asm__ ("cpuid\n\t"
    473              : "=a" (uRAX),
    474                "=b" (uRBX),
    475                "=c" (uRCX),
    476                "=d" (uRDX)
     472    __asm__ __volatile__ ("cpuid\n\t"
     473                          : "=a" (uRAX),
     474                            "=b" (uRBX),
     475                            "=c" (uRCX),
     476                            "=d" (uRDX)
    477477             : "0" (uOperator));
    478478    *(uint32_t *)pvEAX = (uint32_t)uRAX;
     
    481481    *(uint32_t *)pvEDX = (uint32_t)uRDX;
    482482#  else
    483     __asm__ ("xchgl %%ebx, %1\n\t"
    484              "cpuid\n\t"
    485              "xchgl %%ebx, %1\n\t"
    486              : "=a" (*(uint32_t *)pvEAX),
    487                "=r" (*(uint32_t *)pvEBX),
    488                "=c" (*(uint32_t *)pvECX),
    489                "=d" (*(uint32_t *)pvEDX)
    490              : "0" (uOperator));
     483    __asm__ __volatile__ ("xchgl %%ebx, %1\n\t"
     484                          "cpuid\n\t"
     485                          "xchgl %%ebx, %1\n\t"
     486                         : "=a" (*(uint32_t *)pvEAX),
     487                           "=r" (*(uint32_t *)pvEBX),
     488                           "=c" (*(uint32_t *)pvECX),
     489                           "=d" (*(uint32_t *)pvEDX)
     490                         : "0" (uOperator));
    491491#  endif
    492492
     
    906906#  ifdef RT_ARCH_AMD64
    907907    RTCCUINTREG uSpill;
    908     __asm__ ("cpuid"
    909              : "=a" (uSpill),
    910                "=b" (xBX)
    911              : "0" (1)
    912              : "rcx", "rdx");
     908    __asm__ __volatile__ ("cpuid"
     909                          : "=a" (uSpill),
     910                            "=b" (xBX)
     911                          : "0" (1)
     912                          : "rcx", "rdx");
    913913#  elif (defined(PIC) || defined(__PIC__)) && defined(__i386__)
    914914    RTCCUINTREG uSpill;
    915     __asm__ ("mov   %%ebx,%1\n\t"
    916              "cpuid\n\t"
    917              "xchgl %%ebx,%1\n\t"
    918              : "=a" (uSpill),
    919                "=r" (xBX)
    920              : "0" (1)
    921              : "ecx", "edx");
     915    __asm__ __volatile__ ("mov   %%ebx,%1\n\t"
     916                          "cpuid\n\t"
     917                          "xchgl %%ebx,%1\n\t"
     918                          : "=a" (uSpill),
     919                            "=r" (xBX)
     920                          : "0" (1)
     921                          : "ecx", "edx");
    922922#  else
    923923    RTCCUINTREG uSpill;
    924     __asm__ ("cpuid"
    925              : "=a" (uSpill),
    926                "=b" (xBX)
    927              : "0" (1)
    928              : "ecx", "edx");
     924    __asm__ __volatile__ ("cpuid"
     925                          : "=a" (uSpill),
     926                            "=b" (xBX)
     927                          : "0" (1)
     928                          : "ecx", "edx");
    929929#  endif
    930930
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette