Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 11 Jun 2012 13:31:52 +0000 (16:31 +0300)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 11 Jun 2012 13:31:52 +0000 (16:31 +0300)
Pull crypto fixes from Herbert Xu:
 "This push fixes an unaligned fault on x86-32 with aesni-intel and an
  RNG failure with atmel-rng (repeated bits)."

* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: aesni-intel - fix unaligned cbc decrypt for x86-32
  hwrng: atmel-rng - fix race condition leading to repeated bits

arch/x86/crypto/aesni-intel_asm.S
drivers/char/hw_random/atmel-rng.c

index be6d9e365a800a8569fb4915fccbfc50b0793a09..3470624d7835fa646b7c9f8dafa6acd3d9ed5f2f 100644 (file)
@@ -2460,10 +2460,12 @@ ENTRY(aesni_cbc_dec)
        pxor IN3, STATE4
        movaps IN4, IV
 #else
-       pxor (INP), STATE2
-       pxor 0x10(INP), STATE3
        pxor IN1, STATE4
        movaps IN2, IV
+       movups (INP), IN1
+       pxor IN1, STATE2
+       movups 0x10(INP), IN2
+       pxor IN2, STATE3
 #endif
        movups STATE1, (OUTP)
        movups STATE2, 0x10(OUTP)
index f518b99f53f5b995a3c8f9cd5d8ff616a62d3855..6289f0eee24c9721413a44665e4d93db6e48ad55 100644 (file)
@@ -36,6 +36,13 @@ static int atmel_trng_read(struct hwrng *rng, void *buf, size_t max,
        /* data ready? */
        if (readl(trng->base + TRNG_ODATA) & 1) {
                *data = readl(trng->base + TRNG_ODATA);
+               /*
+                 ensure data ready is only set again AFTER the next data
+                 word is ready in case it got set between checking ISR
+                 and reading ODATA, so we don't risk re-reading the
+                 same word
+               */
+               readl(trng->base + TRNG_ISR);
                return 4;
        } else
                return 0;