-
-
Save mbs0221/e8f39f93f4ca5e0caec51c5059ce9150 to your computer and use it in GitHub Desktop.
Checks whether your cpu supports Intel CET or not (Linux).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cpuid.h> | |
#include <stdint.h> | |
int cpu_supports_cet_shadow_stack() { | |
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; | |
__cpuid_count(7, 0, eax, ebx, ecx, edx); | |
return (ecx & (1 << 7)) != 0; | |
} | |
int cpu_supports_cet_ibt() { | |
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; | |
__cpuid_count(7, 0, eax, ebx, ecx, edx); | |
return (edx & (1 << 20)) != 0; | |
} | |
int main() { | |
if (cpu_supports_cet_shadow_stack()) { | |
puts("CET Shadow Stack is supported"); | |
} | |
if (cpu_supports_cet_ibt()) { | |
puts("CET IBT is supported"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment