#include <linux/types.h>
 #include <crypto/sha1.h>
 #include <crypto/sha1_base.h>
+#include <asm/cpu_device_id.h>
 #include <asm/simd.h>
 
+static const struct x86_cpu_id module_cpu_ids[] = {
+       X86_MATCH_FEATURE(X86_FEATURE_AVX2, NULL),
+       X86_MATCH_FEATURE(X86_FEATURE_AVX, NULL),
+       X86_MATCH_FEATURE(X86_FEATURE_SSSE3, NULL),
+       {}
+};
+MODULE_DEVICE_TABLE(x86cpu, module_cpu_ids);
+
 static int sha1_update(struct shash_desc *desc, const u8 *data,
                             unsigned int len, sha1_block_fn *sha1_xform)
 {
 
 static int __init sha1_ssse3_mod_init(void)
 {
+       if (!x86_match_cpu(module_cpu_ids))
+               return -ENODEV;
+
        if (register_sha1_ssse3())
                goto fail;
 
 
 #include <crypto/sha2.h>
 #include <crypto/sha256_base.h>
 #include <linux/string.h>
+#include <asm/cpu_device_id.h>
 #include <asm/simd.h>
 
 asmlinkage void sha256_transform_ssse3(struct sha256_state *state,
                                       const u8 *data, int blocks);
 
+static const struct x86_cpu_id module_cpu_ids[] = {
+       X86_MATCH_FEATURE(X86_FEATURE_AVX2, NULL),
+       X86_MATCH_FEATURE(X86_FEATURE_AVX, NULL),
+       X86_MATCH_FEATURE(X86_FEATURE_SSSE3, NULL),
+       {}
+};
+MODULE_DEVICE_TABLE(x86cpu, module_cpu_ids);
+
 static int _sha256_update(struct shash_desc *desc, const u8 *data,
                          unsigned int len, sha256_block_fn *sha256_xform)
 {
 
 static int __init sha256_ssse3_mod_init(void)
 {
+       if (!x86_match_cpu(module_cpu_ids))
+               return -ENODEV;
+
        if (register_sha256_ssse3())
                goto fail;