Last active
April 23, 2026 13:33
-
-
Save mrjk/28a1082d201c7c8c30b788a7b47e820d to your computer and use it in GitHub Desktop.
Report all interestings flags for a given CPU
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
| #!/bin/bash | |
| # This script reports the most common CPU flags to pay attention. | |
| # Usage: | |
| # curl https://gist.githubusercontent.com/mrjk/28a1082d201c7c8c30b788a7b47e820d/raw/54c37076fd8e3f118867d1575efe074724eb1d5b/report-cpu-flags.sh | bash | |
| declare -A flags=( | |
| [vmx]="virt: Intel Virtualisation (VT-x)" | |
| [svm]="virt: AMD Virtualisation (AMD-V)" | |
| [aes]="enc: AES Hardware Encryption" | |
| [avx]="perf: AVX (Advanced Vector Extensions)" | |
| [avx2]="perf: AVX2 (256-bit vector ops)" | |
| [avx512f]="perf: AVX-512 (512-bit vector ops)" | |
| [sse4_2]="perf: SSE 4.2" | |
| [rdrand]="security: Hardware Random Number Generator" | |
| [nx]="security: NX/XD Bit (No-Execute protection)" | |
| [lm]="perf: 64-bit CPU support" | |
| [ht]="perf: Hyper-Threading" | |
| [fma]="perf: Fused Multiply-Add" | |
| [sha_ni]="enc: SHA Hardware Acceleration" | |
| [tsc]="perf: Time Stamp Counter" | |
| [smx]="security: Intel TXT (Trusted Execution)" | |
| [tm2]="perf: Thermal Monitor" | |
| [pdpe1gb]="perf: 1GB Huge Pages support" | |
| ) | |
| report_flags () { | |
| local GREEN='\033[0;32m' | |
| local RED='\033[0;31m' | |
| local NC='\033[0m' | |
| local cpu_flags=$(grep -m1 flags /proc/cpuinfo) | |
| echo "=== CPU Feature Check ===" | |
| for flag in "${!flags[@]}"; do | |
| if echo "$cpu_flags" | grep -qw "$flag"; then | |
| echo -e "${GREEN}[YES]${NC} ${flags[$flag]} ($flag)" | |
| else | |
| echo -e "${RED}[NO] ${NC} ${flags[$flag]} ($flag)" | |
| fi | |
| done | sort -t: -k1,1 -k2,2 | |
| } | |
| report_flags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment