Skip to contentSkip to conversation

padlock: don't whinge when loaded on a non-VIA cpu

PATCH In review Kyle McMartin 7 participants 7 messages Jul 8, 2008 – Jul 9, 2008 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 padlock: don't whinge when loaded on a non-VIA cpu

I've become seriously tired of seeing these messages on every machine running an i386 Fedora kernel...

padlock: VIA PadLock not detected.
padlock: VIA PadLock Hash Engine not detected.

So let's eliminate them!

---

drivers/crypto/padlock-aes.c +3 -0
index bb30eb9..c11f456 100644
@@ -384,6 +384,9 @@ static int __init padlock_init(void)
 {
 	int ret;
 
+	if (!(boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR))
+		return -ENODEV;
+
 	if (!cpu_has_xcrypt) {
 		printk(KERN_ERR PFX "VIA PadLock not detected.\n");
 		return -ENODEV;
drivers/crypto/padlock-sha.c +3 -0
index c666b4e..9b360fb 100644
@@ -253,6 +253,9 @@ static int __init padlock_init(void)
 {
 	int rc = -ENODEV;
 
+	if (!(boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR))
+		return -ENODEV;
+
 	if (!cpu_has_phe) {
 		printk(KERN_ERR PFX "VIA PadLock Hash Engine not detected.\n");
 		return -ENODEV;
#1 lore raw
Quoted 7 lines · On Tue, 8 Jul 2008 15:04:27 -0400 Kyle McMartin <[email protected]> wrote:

I've become seriously tired of seeing these messages on every machine running an i386 Fedora kernel...

padlock: VIA PadLock not detected.
padlock: VIA PadLock Hash Engine not detected.

So let's eliminate them!

Silly question - but why are they being printed even for older VIA processors. We don't see the following on boot

i386: no CMOV instruction detected
i386: no SSE3 instruction detected

So I think your patch should be a bit more brutal ;)

Alan

#2 lore raw
Quoted 11 lines · Alan Cox
Quoted 7 lines · On Tue, 8 Jul 2008 15:04:27 -0400 Kyle McMartin <[email protected]> wrote:

I've become seriously tired of seeing these messages on every machine running an i386 Fedora kernel...

padlock: VIA PadLock not detected.
padlock: VIA PadLock Hash Engine not detected.

So let's eliminate them!

Quoted 8 lines

Silly question - but why are they being printed even for older VIA processors. We don't see the following on boot

i386: no CMOV instruction detected
i386: no SSE3 instruction detected

So I think your patch should be a bit more brutal ;)

I completely agree, but I don't know anything about Centaur cpuids...

Something like this might suffice:

drivers/crypto/padlock-aes.c +4 -0
index bb30eb9..0192de4 100644
@@ -384,6 +384,10 @@ static int __init padlock_init(void)
 {
 	int ret;
 
+	if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR) &&
+	     (boot_cpu_data.x86 >= 6)))	/* only on VIA C3 and above */
+		return -ENODEV;
+
 	if (!cpu_has_xcrypt) {
 		printk(KERN_ERR PFX "VIA PadLock not detected.\n");
 		return -ENODEV;
drivers/crypto/padlock-sha.c +4 -0
index c666b4e..70ec14b 100644
@@ -253,6 +253,10 @@ static int __init padlock_init(void)
 {
 	int rc = -ENODEV;
 
+	if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR) &&
+	     (boot_cpu_data.x86 >= 6)))	/* only on VIA C3 and above */
+		return -ENODEV;
+
 	if (!cpu_has_phe) {
 		printk(KERN_ERR PFX "VIA PadLock Hash Engine not detected.\n");
 		return -ENODEV;
#6 lore raw
In reply to Kyle McMartin

drivers/crypto/padlock-aes.c static int __init padlock_init(void) · line 389

Quoted 9 lines · Kyle McMartin
drivers/crypto/padlock-aes.c +3 -0
@@ -384,6 +384,9 @@ static int __init padlock_init(void)
 {
 	int ret;
 
+	if (!(boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR))
+		return -ENODEV;
+

BTW C has "!=" operator, may be useful.

Signature · 1 line
Krzysztof Halasa
#3 lore raw
In reply to Kyle McMartin
Quoted 5 lines · Kyle McMartin
drivers/crypto/padlock-sha.c +0 -0
index c666b4e..70ec14b 100644

drivers/crypto/padlock-sha.c static int __init padlock_init(void) · line 262

Quoted 10 lines
drivers/crypto/padlock-sha.c +4 -0
@@ -253,6 +253,10 @@ static int __init padlock_init(void)
 {
 	int rc = -ENODEV;
 
+	if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR) &&
+	     (boot_cpu_data.x86 >= 6)))	/* only on VIA C3 and above */
+		return -ENODEV;
+
 	if (!cpu_has_phe) {
 		printk(KERN_ERR PFX "VIA PadLock Hash Engine not detected.\n");
 		return -ENODEV;

int rc doesn't need to be initialized to -ENODEV either.

drivers/crypto/padlock-sha.c +1 -1
@@ -251,7 +251,7 @@ static struct crypto_alg sha256_alg = {
 
 static int __init padlock_init(void)
 {
-	int rc = -ENODEV;
+	int rc;
 
 	if (!cpu_has_phe) {
 		printk(KERN_ERR PFX "VIA PadLock Hash Engine not detected.\n");
#4 lore raw
In reply to Kyle McMartin

drivers/crypto/padlock-aes.c static int __init padlock_init(void) · line 389

Quoted 3 lines · On Tue, 8 Jul 2008 15:37:41 -0400 Kyle McMartin <[email protected]> wrote:
drivers/crypto/padlock-aes.c +3 -0
+	if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR) &&
+	     (boot_cpu_data.x86 >= 6)))	/* only on VIA C3 and above */
+		return -ENODEV;

Why add this?

drivers/crypto/padlock-aes.c static int __init padlock_init(void) · line 393

Quoted 3 lines
drivers/crypto/padlock-aes.c +0 -0
 	if (!cpu_has_xcrypt) {
 		printk(KERN_ERR PFX "VIA PadLock not detected.\n");
 		return -ENODEV;

When you could simply delete the printk lines?

Signature · 1 line
All rights reversed.
maintainer
#5 lore raw
In reply to Kyle McMartin
Quoted 4 lines · Kyle McMartin

I completely agree, but I don't know anything about Centaur cpuids...

Something like this might suffice:

Please base your patch on top of cryptodev-2.6 which already has a fix on this from Jeremy Katz. Also I suggest you either remove the printk completely or invert it so that it prints something when the hardware is detected.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt