From 9ca418a225bfe86f4f47ba971bc20212295f9032 Mon Sep 17 00:00:00 2001 From: Brian White Date: Sat, 20 Apr 2024 17:54:08 -0400 Subject: [PATCH] Add LM feature for X86 --- include/cpuinfo_x86.h | 3 +++ src/impl_x86__base_implementation.inl | 4 +++- src/impl_x86_linux_or_android.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/cpuinfo_x86.h b/include/cpuinfo_x86.h index 7d1d5d42..6f7f4df0 100644 --- a/include/cpuinfo_x86.h +++ b/include/cpuinfo_x86.h @@ -111,6 +111,8 @@ typedef struct { int lam : 1; // Intel Linear Address Mask int uai : 1; // AMD Upper Address Ignore + + int lm : 1; // Make sure to update X86FeaturesEnum below if you add a field here. } X86Features; @@ -277,6 +279,7 @@ typedef enum { X86_FS_REP_CMPSB_SCASB, X86_LAM, X86_UAI, + X86_LM, X86_LAST_, } X86FeaturesEnum; diff --git a/src/impl_x86__base_implementation.inl b/src/impl_x86__base_implementation.inl index dfff46c6..84fe5d07 100644 --- a/src/impl_x86__base_implementation.inl +++ b/src/impl_x86__base_implementation.inl @@ -393,6 +393,7 @@ static void ParseCpuId(const Leaves* leaves, X86Info* info, features->adx = IsBitSet(leaf_7.ebx, 19); features->lzcnt = IsBitSet(leaf_80000001.ecx, 5); features->lam = IsBitSet(leaf_7_1.eax, 26); + features->lm = IsBitSet(leaf_80000001.edx, 29); ///////////////////////////////////////////////////////////////////////////// // The following section is devoted to Vector Extensions. @@ -1998,7 +1999,8 @@ CacheInfo GetX86CacheInfo(void) { LINE(X86_FS_REP_STOSB, fs_rep_stosb, , , ) \ LINE(X86_FS_REP_CMPSB_SCASB, fs_rep_cmpsb_scasb, , , ) \ LINE(X86_LAM, lam, , , ) \ - LINE(X86_UAI, uai, , , ) + LINE(X86_UAI, uai, , , ) \ + LINE(X86_LM, lm, , , ) #define INTROSPECTION_PREFIX X86 #define INTROSPECTION_ENUM_PREFIX X86 #include "define_introspection.inl" diff --git a/src/impl_x86_linux_or_android.c b/src/impl_x86_linux_or_android.c index a4d07f3e..40bd0bcc 100644 --- a/src/impl_x86_linux_or_android.c +++ b/src/impl_x86_linux_or_android.c @@ -48,6 +48,7 @@ static void DetectFeaturesFromOs(X86Info* info, X86Features* features) { features->ssse3 = CpuFeatures_StringView_HasWord(value, "ssse3", ' '); features->sse4_1 = CpuFeatures_StringView_HasWord(value, "sse4_1", ' '); features->sse4_2 = CpuFeatures_StringView_HasWord(value, "sse4_2", ' '); + features->lm = CpuFeatures_StringView_HasWord(value, "lm", ' '); break; } CpuFeatures_CloseFile(fd);