Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPUID is failing starting from 12-15 July #974

Closed
9il opened this issue Aug 10, 2016 · 6 comments
Closed

CPUID is failing starting from 12-15 July #974

9il opened this issue Aug 10, 2016 · 6 comments

Comments

@9il
Copy link

9il commented Aug 10, 2016

CPUID library https://github.com/libmir/cpuid
is failing starting from 12-15 July.
Does appveyor use virtual machine without CPUID instruction support?

@FeodorFitsner
Copy link
Member

How do you use CPUID?

@9il
Copy link
Author

9il commented Aug 10, 2016

The exact problem is that for (virtual?) Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz

  1. after CPUID(EAX<-0), registerEAX >= 0xB - this means that 0xB CPUID information leaf can be used.
  2. after CPUID(EAX<-0xB, ECX<-0), register EBX[31..0] == 0 - this means that there are 0 threads per core. So, cores # (cores = threads / threadsPerCore) gives division by 0.
CpuInfo _cpuid(uint eax, uint ecx = 0)
{
    uint a = void;
    uint b = void;
    uint c = void;
    uint d = void;
        asm pure nothrow @nogc
        {
            mov EAX, eax;
            mov ECX, ecx;
            cpuid;
            mov a, EAX;
            mov b, EBX;
            mov c, ECX;
            mov d, EDX;
        }
    return CpuInfo(a, b, c, d);
}

I suppose that problem is in virtualisation. It can be checked on real E5-2680 v3:

dub fetch cpuid
dub test cpuid

where dub is D package manager.

@FeodorFitsner
Copy link
Member

Right, builds are currently running on Hyper-V VMs. You would probably need to adjust your library to support such cases.

@9il
Copy link
Author

9il commented Aug 11, 2016

Right, builds are currently running on Hyper-V VMs. You would probably need to adjust your library to support such cases.

This is not possible because vendor is specified as GenuineIntel. I can tune it if is Microsoft Hv.

Either vendor should be changed to Microsoft Hv or behaviour should be the same like GenuineIntel.

@dnadlinger
Copy link

Maybe this would be interesting for a workaround:

Software determines the presence of a hypervisor through the CPUID instruction. Processors conforming to the Intel® 64 architecture have reserved a feature flag in CPUID Function 0x01 - Feature Information for this purpose. Bit 31 returned in ECX is defined as Not Used, and will always return 0 from the physical CPU. A hypervisor conformant with the Microsoft hypervisor interface will set CPUID.1:ECX [bit 31] = 1 to indicate its presence to software.

@9il
Copy link
Author

9il commented Aug 14, 2016

@klickverbot Thanks!

@9il 9il closed this as completed Oct 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants