Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: blowfish-x86_64 - blacklist Pentium 4

Implementation in blowfish-x86_64 uses 64bit rotations which are slow on P4,
making blowfish-x86_64 slower than generic C implementation. Therefore
blacklist P4.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Jussi Kivilinna and committed by
Herbert Xu
4c58464b a522ee85

+30
+30
arch/x86/crypto/blowfish_glue.c
··· 25 25 * 26 26 */ 27 27 28 + #include <asm/processor.h> 28 29 #include <crypto/blowfish.h> 29 30 #include <linux/crypto.h> 30 31 #include <linux/init.h> ··· 447 446 }, 448 447 }; 449 448 449 + static bool is_blacklisted_cpu(void) 450 + { 451 + if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) 452 + return false; 453 + 454 + if (boot_cpu_data.x86 == 0x0f) { 455 + /* 456 + * On Pentium 4, blowfish-x86_64 is slower than generic C 457 + * implementation because use of 64bit rotates (which are really 458 + * slow on P4). Therefore blacklist P4s. 459 + */ 460 + return true; 461 + } 462 + 463 + return false; 464 + } 465 + 466 + static int force; 467 + module_param(force, int, 0); 468 + MODULE_PARM_DESC(force, "Force module load, ignore CPU blacklist"); 469 + 450 470 static int __init init(void) 451 471 { 452 472 int err; 473 + 474 + if (!force && is_blacklisted_cpu()) { 475 + printk(KERN_INFO 476 + "blowfish-x86_64: performance on this CPU " 477 + "would be suboptimal: disabling " 478 + "blowfish-x86_64.\n"); 479 + return -ENODEV; 480 + } 453 481 454 482 err = crypto_register_alg(&bf_alg); 455 483 if (err)