Re: [PATCH] crypto: serpent - add x86_64/avx assembler implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Goetzfried
<Johannes.Goetzfried@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
> +
> +static int __init serpent_init(void)
> +{
> +	u64 xcr0;
> +
> +	if (!cpu_has_avx || !cpu_has_osxsave) {
> +		printk(KERN_INFO "AVX instructions are not detected.\n");
> +		return -ENODEV;
> +	}
> +
> +	xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
> +	if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) {
> +		printk(KERN_INFO "AVX detected but unusable.\n");
> +		return -ENODEV;
> +	}
> +
> +	return crypto_register_algs(serpent_algs, ARRAY_SIZE(serpent_algs));
> +}
> +
> +static void __exit serpent_exit(void)
> +{
> +	crypto_unregister_algs(serpent_algs, ARRAY_SIZE(serpent_algs));
> +}
> +
> +module_init(serpent_init);
> +module_exit(serpent_exit);
> +
> +MODULE_DESCRIPTION("Serpent Cipher Algorithm, AVX optimized");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("serpent");

The driver needs CPUID annotations now (since 3.3), so that it can be 
autoloaded.  Something like:

#include <asm/cpu_device_id.h>


static const struct x86_cpu_id avx_cpu_id[] = {
        X86_FEATURE_MATCH(X86_FEATURE_AVX),
        {}
};
MODULE_DEVICE_TABLE(x86cpu, avx_cpu_id);


Replace the manual check in init with

            if (!x86_match_cpu(avx_cpu_id))
                return -ENODEV;

Also drivers should never print anything when they cannot find hardware.
Remove that printk.

-Andi

-- 
ak@xxxxxxxxxxxxxxx -- Speaking for myself only
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux