1
0
mirror of https://github.com/google/cpu_features.git synced 2025-04-28 07:23:37 +02:00

Merge pull request #25 from xqp/feature/detect_sgx_smx

detect intel sgx and smx cpu features for the x86 arch
This commit is contained in:
Guillaume Chatelet 2018-02-13 11:52:28 +01:00 committed by GitHub
commit f7e0a6d066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -52,6 +52,9 @@ typedef struct {
int avx512_4vnniw : 1;
int avx512_4vbmi2 : 1;
int smx : 1;
int sgx : 1;
// Make sure to update X86FeaturesEnum below if you add a field here.
} X86Features;
@ -133,6 +136,8 @@ typedef enum {
X86_AVX512VPOPCNTDQ,
X86_AVX512_4VNNIW,
X86_AVX512_4VBMI2,
X86_SMX,
X86_SGX,
X86_LAST_,
} X86FeaturesEnum;

View File

@ -95,11 +95,13 @@ static void ParseCpuId(const uint32_t max_cpuid_leaf, X86Info* info) {
info->model = (extended_model << 4) + model;
info->stepping = ExtractBitRange(leaf_1.eax, 3, 0);
features->smx = IsBitSet(leaf_1.ecx, 6);
features->aes = IsBitSet(leaf_1.ecx, 25);
features->erms = IsBitSet(leaf_7.ebx, 9);
features->f16c = IsBitSet(leaf_1.ecx, 29);
features->sgx = IsBitSet(leaf_7.ebx, 2);
features->bmi1 = IsBitSet(leaf_7.ebx, 3);
features->bmi2 = IsBitSet(leaf_7.ebx, 8);
features->erms = IsBitSet(leaf_7.ebx, 9);
features->vpclmulqdq = IsBitSet(leaf_7.ecx, 10);
if (have_sse_os_support) {
@ -313,6 +315,10 @@ int GetX86FeaturesEnumValue(const X86Features* features,
return features->avx512_4vnniw;
case X86_AVX512_4VBMI2:
return features->avx512_4vbmi2;
case X86_SMX:
return features->smx;
case X86_SGX:
return features->sgx;
case X86_LAST_:
break;
}
@ -375,6 +381,10 @@ const char* GetX86FeaturesEnumName(X86FeaturesEnum value) {
return "avx512_4vnniw";
case X86_AVX512_4VBMI2:
return "avx512_4vbmi2";
case X86_SMX:
return "smx";
case X86_SGX:
return "sgx";
case X86_LAST_:
break;
}