Merge branches 'bugzilla-13121+', 'bugzilla-13233', 'redhat-bugzilla-500311', 'pci...
[safe/jmp/linux-2.6] / drivers / crypto / padlock-sha.c
index 4e8de16..a2c8e85 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/scatterlist.h>
+#include <asm/i387.h>
 #include "padlock.h"
 
 #define SHA1_DEFAULT_FALLBACK  "sha1-generic"
@@ -55,7 +56,7 @@ static void padlock_sha_bypass(struct crypto_tfm *tfm)
        if (ctx(tfm)->data && ctx(tfm)->used) {
                struct scatterlist sg;
 
-               sg_set_buf(&sg, ctx(tfm)->data, ctx(tfm)->used);
+               sg_init_one(&sg, ctx(tfm)->data, ctx(tfm)->used);
                crypto_hash_update(&ctx(tfm)->fallback, &sg, sg.length);
        }
 
@@ -79,7 +80,7 @@ static void padlock_sha_update(struct crypto_tfm *tfm,
 
        if (unlikely(ctx(tfm)->bypass)) {
                struct scatterlist sg;
-               sg_set_buf(&sg, (uint8_t *)data, length);
+               sg_init_one(&sg, (uint8_t *)data, length);
                crypto_hash_update(&ctx(tfm)->fallback, &sg, length);
                return;
        }
@@ -102,6 +103,7 @@ static void padlock_do_sha1(const char *in, char *out, int count)
         *     PadLock microcode needs it that big. */
        char buf[128+16];
        char *result = NEAREST_ALIGNED(buf);
+       int ts_state;
 
        ((uint32_t *)result)[0] = SHA1_H0;
        ((uint32_t *)result)[1] = SHA1_H1;
@@ -109,9 +111,12 @@ static void padlock_do_sha1(const char *in, char *out, int count)
        ((uint32_t *)result)[3] = SHA1_H3;
        ((uint32_t *)result)[4] = SHA1_H4;
  
+       /* prevent taking the spurious DNA fault with padlock. */
+       ts_state = irq_ts_save();
        asm volatile (".byte 0xf3,0x0f,0xa6,0xc8" /* rep xsha1 */
                      : "+S"(in), "+D"(result)
                      : "c"(count), "a"(0));
+       irq_ts_restore(ts_state);
 
        padlock_output_block((uint32_t *)result, (uint32_t *)out, 5);
 }
@@ -123,6 +128,7 @@ static void padlock_do_sha256(const char *in, char *out, int count)
         *     PadLock microcode needs it that big. */
        char buf[128+16];
        char *result = NEAREST_ALIGNED(buf);
+       int ts_state;
 
        ((uint32_t *)result)[0] = SHA256_H0;
        ((uint32_t *)result)[1] = SHA256_H1;
@@ -133,9 +139,12 @@ static void padlock_do_sha256(const char *in, char *out, int count)
        ((uint32_t *)result)[6] = SHA256_H6;
        ((uint32_t *)result)[7] = SHA256_H7;
 
+       /* prevent taking the spurious DNA fault with padlock. */
+       ts_state = irq_ts_save();
        asm volatile (".byte 0xf3,0x0f,0xa6,0xd0" /* rep xsha256 */
                      : "+S"(in), "+D"(result)
                      : "c"(count), "a"(0));
+       irq_ts_restore(ts_state);
 
        padlock_output_block((uint32_t *)result, (uint32_t *)out, 8);
 }
@@ -254,12 +263,12 @@ static int __init padlock_init(void)
        int rc = -ENODEV;
 
        if (!cpu_has_phe) {
-               printk(KERN_ERR PFX "VIA PadLock Hash Engine not detected.\n");
+               printk(KERN_NOTICE PFX "VIA PadLock Hash Engine not detected.\n");
                return -ENODEV;
        }
 
        if (!cpu_has_phe_enabled) {
-               printk(KERN_ERR PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n");
+               printk(KERN_NOTICE PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n");
                return -ENODEV;
        }
 
@@ -295,7 +304,7 @@ MODULE_DESCRIPTION("VIA PadLock SHA1/SHA256 algorithms support.");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Michal Ludvig");
 
-MODULE_ALIAS("sha1");
-MODULE_ALIAS("sha256");
+MODULE_ALIAS("sha1-all");
+MODULE_ALIAS("sha256-all");
 MODULE_ALIAS("sha1-padlock");
 MODULE_ALIAS("sha256-padlock");