Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292240
b: refs/heads/master
c: 4c58464
h: refs/heads/master
v: v3
  • Loading branch information
Jussi Kivilinna authored and Herbert Xu committed Jan 13, 2012
1 parent b095b2f commit 23dd721
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a522ee85ba979e7897a75b1c97db1b0304b68b5c
refs/heads/master: 4c58464b8034cef4317593bf4ccbfc19d5bb3a77
30 changes: 30 additions & 0 deletions trunk/arch/x86/crypto/blowfish_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*
*/

#include <asm/processor.h>
#include <crypto/blowfish.h>
#include <linux/crypto.h>
#include <linux/init.h>
Expand Down Expand Up @@ -446,10 +447,39 @@ static struct crypto_alg blk_ctr_alg = {
},
};

static bool is_blacklisted_cpu(void)
{
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
return false;

if (boot_cpu_data.x86 == 0x0f) {
/*
* On Pentium 4, blowfish-x86_64 is slower than generic C
* implementation because use of 64bit rotates (which are really
* slow on P4). Therefore blacklist P4s.
*/
return true;
}

return false;
}

static int force;
module_param(force, int, 0);
MODULE_PARM_DESC(force, "Force module load, ignore CPU blacklist");

static int __init init(void)
{
int err;

if (!force && is_blacklisted_cpu()) {
printk(KERN_INFO
"blowfish-x86_64: performance on this CPU "
"would be suboptimal: disabling "
"blowfish-x86_64.\n");
return -ENODEV;
}

err = crypto_register_alg(&bf_alg);
if (err)
goto bf_err;
Expand Down

0 comments on commit 23dd721

Please sign in to comment.