Created
April 19, 2025 20:23
-
-
Save ldmsys/7b1bd0647af6312584be7d0f21b25d83 to your computer and use it in GitHub Desktop.
SMAP Checker
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 <linux/module.h> | |
| #include <linux/kernel.h> | |
| static int __init smap_check_init(void) { | |
| unsigned int eax, ebx, ecx, edx; | |
| eax = 7; | |
| ecx = 0; | |
| asm volatile( | |
| "cpuid" | |
| : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) | |
| : "a"(eax), "c"(ecx) | |
| ); | |
| if (ebx & (1 << 20)) | |
| pr_info("✅ This CPU supports SMAP!\n"); | |
| else | |
| pr_info("❌ This CPU does NOT support SMAP.\n"); | |
| return 0; | |
| } | |
| static void __exit smap_check_exit(void) { | |
| pr_info("SMAP check module unloaded.\n"); | |
| } | |
| module_init(smap_check_init); | |
| module_exit(smap_check_exit); | |
| MODULE_LICENSE("GPL"); | |
| MODULE_DESCRIPTION("Minimal SMAP check kernel module"); |
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
| obj-m += check_smap.o | |
| all: | |
| make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules | |
| clean: | |
| make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment