X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=arch%2Farch-x86-common.h;h=cbf66b8d04c18c63566dadff2d06e40a90fd8f69;hb=16dc07107d2abddccf7e42f684c16c3d8657b324;hp=31aa79f1b573841f68575f49788a0cbbee9d1f0c;hpb=68d96e515825185b232bbc8d2e5b5136b90514be;p=fio.git diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h index 31aa79f1..cbf66b8d 100644 --- a/arch/arch-x86-common.h +++ b/arch/arch-x86-common.h @@ -15,8 +15,9 @@ static inline void cpuid(unsigned int op, #define ARCH_HAVE_INIT extern int tsc_reliable; +extern int arch_random; -static inline int arch_init_intel(unsigned int level) +static inline void arch_init_intel(unsigned int level) { unsigned int eax, ebx, ecx = 0, edx; @@ -26,47 +27,51 @@ static inline int arch_init_intel(unsigned int level) eax = 1; do_cpuid(&eax, &ebx, &ecx, &edx); if (!(edx & (1U << 4))) - return 0; + return; /* * Check for constant rate and synced (across cores) TSC */ eax = 0x80000007; do_cpuid(&eax, &ebx, &ecx, &edx); - return edx & (1U << 8); + tsc_reliable = (edx & (1U << 8)) != 0; + + /* + * Check for FDRAND + */ + eax = 0x1; + do_cpuid(&eax, &ebx, &ecx, &edx); + arch_random = (ecx & (1U << 30)) != 0; } -static inline int arch_init_amd(unsigned int level) +static inline void arch_init_amd(unsigned int level) { unsigned int eax, ebx, ecx, edx; cpuid(0x80000000, &eax, &ebx, &ecx, &edx); if (eax < 0x80000007) - return 0; + return; cpuid(0x80000007, &eax, &ebx, &ecx, &edx); - if (edx & (1 << 8)) - return 1; - - return 0; + tsc_reliable = (edx & (1U << 8)) != 0; } -static inline int arch_init(char *envp[]) +static inline void arch_init(char *envp[]) { unsigned int level; char str[13]; + arch_random = tsc_reliable = 0; + cpuid(0, &level, (unsigned int *) &str[0], (unsigned int *) &str[8], (unsigned int *) &str[4]); str[12] = '\0'; if (!strcmp(str, "GenuineIntel")) - tsc_reliable = arch_init_intel(level); + arch_init_intel(level); else if (!strcmp(str, "AuthenticAMD")) - tsc_reliable = arch_init_amd(level); - - return 0; + arch_init_amd(level); } #endif