All of lore.kernel.org
 help / color / mirror / Atom feed
* #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
@ 2015-06-23  9:17 ` Geert Uytterhoeven
  0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-06-23  9:17 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Stephan Mueller, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 9, 2015 at 6:31 AM, Guenter Roeck <linux@roeck-us.net> wrote:
> On 06/08/2015 07:08 PM, Stephan Mueller wrote:
>> ---8<---
>> Replace the global -O0 compiler flag from the Makefile with GCC
>> pragmas to mark only the functions required to be compiled without
>> optimizations.
>>
>> This patch also adds a comment describing the rationale for the
>> functions chosen to be compiled without optimizations.
>>
>> Signed-off-by: Stephan Mueller <smueller@chronox.de>
>
> With openrisc, I get:
>
>   CC [M]  crypto/jitterentropy.o
> crypto/jitterentropy.c:266:9: warning: #pragma GCC target is not supported
> for this machine
>
> which may not be perfect, but is better than a compile error ;-).

I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.

With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
to the good unused warning reporting, I get:

crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options

If you want to reproduce with a simple test case, you need -Wall.

Which gcc versions introduced support for these pragmas?

I tried all my cross-compilers from https://www.kernel.org/pub/tools/crosstool/,
and it seems I get warnings for all of them, except for powerpc and x86_64:

/opt/cross/gcc-4.2.4-nolibc/avr32-linux/bin/avr32-linux-gcc :
        warning: ignoring #pragma GCC push_options
        warning: ignoring #pragma GCC optimize
        warning: ignoring #pragma GCC pop_options
/opt/cross/gcc-4.5.1-nolibc/or32-linux/bin/or32-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
/opt/cross/gcc-4.6.2-nolibc/tilegx-linux/bin/tilegx-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/alpha-linux/bin/alpha-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/am33_2.0-linux/bin/am33_2.0-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc
:
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/bfin-uclinux/bin/bfin-uclinux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/crisv32-linux/bin/crisv32-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/frv-linux/bin/frv-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/hppa64-linux/bin/hppa64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/ia64-linux/bin/ia64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/m32r-linux/bin/m32r-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/mips64-linux/bin/mips64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/s390x-linux/bin/s390x-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/sh4-linux/bin/sh4-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/sparc64-linux/bin/sparc64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/xtensa-linux/bin/xtensa-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.8.0-nolibc/microblaze-linux/bin/microblaze-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.8.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/alpha-linux/bin/alpha-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/am33_2.0-linux/bin/am33_2.0-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc
:
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/frv-linux/bin/frv-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/h8300-elf/bin/h8300-elf-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/hppa64-linux/bin/hppa64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/ia64-linux/bin/ia64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/m32r-linux/bin/m32r-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/m68k-linux/bin/m68k-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/microblaze-linux/bin/microblaze-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/mips64-linux/bin/mips64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/ppc64le-linux/bin/ppc64le-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/s390x-linux/bin/s390x-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/sparc64-linux/bin/sparc64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/x86_64-linux/bin/x86_64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/x86_64-linux/bin/x86_64-linux-x86_64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/xtensa-linux/bin/xtensa-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 26+ messages in thread

* #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
@ 2015-06-23  9:17 ` Geert Uytterhoeven
  0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-06-23  9:17 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Stephan Mueller, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 9, 2015 at 6:31 AM, Guenter Roeck <linux@roeck-us.net> wrote:
> On 06/08/2015 07:08 PM, Stephan Mueller wrote:
>> ---8<---
>> Replace the global -O0 compiler flag from the Makefile with GCC
>> pragmas to mark only the functions required to be compiled without
>> optimizations.
>>
>> This patch also adds a comment describing the rationale for the
>> functions chosen to be compiled without optimizations.
>>
>> Signed-off-by: Stephan Mueller <smueller@chronox.de>
>
> With openrisc, I get:
>
>   CC [M]  crypto/jitterentropy.o
> crypto/jitterentropy.c:266:9: warning: #pragma GCC target is not supported
> for this machine
>
> which may not be perfect, but is better than a compile error ;-).

I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.

With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
to the good unused warning reporting, I get:

crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options

If you want to reproduce with a simple test case, you need -Wall.

Which gcc versions introduced support for these pragmas?

I tried all my cross-compilers from https://www.kernel.org/pub/tools/crosstool/,
and it seems I get warnings for all of them, except for powerpc and x86_64:

/opt/cross/gcc-4.2.4-nolibc/avr32-linux/bin/avr32-linux-gcc :
        warning: ignoring #pragma GCC push_options
        warning: ignoring #pragma GCC optimize
        warning: ignoring #pragma GCC pop_options
/opt/cross/gcc-4.5.1-nolibc/or32-linux/bin/or32-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
/opt/cross/gcc-4.6.2-nolibc/tilegx-linux/bin/tilegx-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/alpha-linux/bin/alpha-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/am33_2.0-linux/bin/am33_2.0-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc
:
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/bfin-uclinux/bin/bfin-uclinux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/crisv32-linux/bin/crisv32-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/frv-linux/bin/frv-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/hppa64-linux/bin/hppa64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/ia64-linux/bin/ia64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/m32r-linux/bin/m32r-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/mips64-linux/bin/mips64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/s390x-linux/bin/s390x-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/sh4-linux/bin/sh4-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/sparc64-linux/bin/sparc64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.6.3-nolibc/xtensa-linux/bin/xtensa-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
/opt/cross/gcc-4.8.0-nolibc/microblaze-linux/bin/microblaze-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.8.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/alpha-linux/bin/alpha-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/am33_2.0-linux/bin/am33_2.0-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc
:
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/frv-linux/bin/frv-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/h8300-elf/bin/h8300-elf-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/hppa64-linux/bin/hppa64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/ia64-linux/bin/ia64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/m32r-linux/bin/m32r-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/m68k-linux/bin/m68k-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/microblaze-linux/bin/microblaze-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/mips64-linux/bin/mips64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/ppc64le-linux/bin/ppc64le-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/s390x-linux/bin/s390x-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/sparc64-linux/bin/sparc64-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^
/opt/cross/gcc-4.9.0-nolibc/x86_64-linux/bin/x86_64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/x86_64-linux/bin/x86_64-linux-x86_64-linux-gcc :
/opt/cross/gcc-4.9.0-nolibc/xtensa-linux/bin/xtensa-linux-gcc :
        warning: #pragma GCC target is not supported for this machine
[-Wpragmas]
         #pragma GCC pop_options
                 ^

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
  2015-06-23  9:17 ` Geert Uytterhoeven
@ 2015-06-23  9:21   ` Herbert Xu
  -1 siblings, 0 replies; 26+ messages in thread
From: Herbert Xu @ 2015-06-23  9:21 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Guenter Roeck, Stephan Mueller, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
> 
> I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
> 
> With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
> to the good unused warning reporting, I get:
> 
> crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
> crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
> crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
> crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options

Stephan, could you look into moving the relevant functions into
its own file which can then be compiled with -O0? Obviously any
dependency on kernel header files would have to be hidden using
functions outside of this file.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
@ 2015-06-23  9:21   ` Herbert Xu
  0 siblings, 0 replies; 26+ messages in thread
From: Herbert Xu @ 2015-06-23  9:21 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Guenter Roeck, Stephan Mueller, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
> 
> I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
> 
> With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
> to the good unused warning reporting, I get:
> 
> crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
> crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
> crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
> crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
> crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
> crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options

Stephan, could you look into moving the relevant functions into
its own file which can then be compiled with -O0? Obviously any
dependency on kernel header files would have to be hidden using
functions outside of this file.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
  2015-06-23  9:21   ` Herbert Xu
@ 2015-06-23  9:45     ` Stephan Mueller
  -1 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23  9:45 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Geert Uytterhoeven, Guenter Roeck, Peter Zijlstra,
	Andy Shevchenko, Jim Davis, Stephen Rothwell, Linux-Next,
	linux-kernel, David S. Miller, linux-crypto, Waiman Long,
	Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 17:21:06 schrieb Herbert Xu:

Hi Herbert,

>On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
>> I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
>> 
>> With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
>> to the good unused warning reporting, I get:
>> 
>> crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
>> crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
>> crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
>> crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options
>
>Stephan, could you look into moving the relevant functions into
>its own file which can then be compiled with -O0? Obviously any
>dependency on kernel header files would have to be hidden using
>functions outside of this file.

I will look into it.

Thanks

Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
@ 2015-06-23  9:45     ` Stephan Mueller
  0 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23  9:45 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Geert Uytterhoeven, Guenter Roeck, Peter Zijlstra,
	Andy Shevchenko, Jim Davis, Stephen Rothwell, Linux-Next,
	linux-kernel, David S. Miller, linux-crypto, Waiman Long,
	Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 17:21:06 schrieb Herbert Xu:

Hi Herbert,

>On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
>> I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
>> 
>> With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
>> to the good unused warning reporting, I get:
>> 
>> crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
>> crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
>> crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
>> crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
>> crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
>> crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options
>
>Stephan, could you look into moving the relevant functions into
>its own file which can then be compiled with -O0? Obviously any
>dependency on kernel header files would have to be hidden using
>functions outside of this file.

I will look into it.

Thanks

Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
  2015-06-23  9:21   ` Herbert Xu
@ 2015-06-23 13:01     ` Stephan Mueller
  -1 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 13:01 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Geert Uytterhoeven, Guenter Roeck, Peter Zijlstra,
	Andy Shevchenko, Jim Davis, Stephen Rothwell, Linux-Next,
	linux-kernel, David S. Miller, linux-crypto, Waiman Long,
	Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 17:21:06 schrieb Herbert Xu:

Hi Herbert,

> On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
> > I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
> > 
> > With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
> > to the good unused warning reporting, I get:
> > 
> > crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
> > crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
> > crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
> > crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options
> 
> Stephan, could you look into moving the relevant functions into
> its own file which can then be compiled with -O0? Obviously any
> dependency on kernel header files would have to be hidden using
> functions outside of this file.

I have separated all so far. However, there are two items left where I am not 
sure about:

- asm/types.h: I need __u64

- linux/bitops.h: I need rol64

Can I safely include both header files or do I have to hide them too. If yes, 
how would I do that in a way that is satisfactory?

Thanks.

-- 
Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
@ 2015-06-23 13:01     ` Stephan Mueller
  0 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 13:01 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Geert Uytterhoeven, Guenter Roeck, Peter Zijlstra,
	Andy Shevchenko, Jim Davis, Stephen Rothwell, Linux-Next,
	linux-kernel, David S. Miller, linux-crypto, Waiman Long,
	Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 17:21:06 schrieb Herbert Xu:

Hi Herbert,

> On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
> > I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
> > 
> > With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
> > to the good unused warning reporting, I get:
> > 
> > crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
> > crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
> > crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
> > crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
> > crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
> > crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options
> 
> Stephan, could you look into moving the relevant functions into
> its own file which can then be compiled with -O0? Obviously any
> dependency on kernel header files would have to be hidden using
> functions outside of this file.

I have separated all so far. However, there are two items left where I am not 
sure about:

- asm/types.h: I need __u64

- linux/bitops.h: I need rol64

Can I safely include both header files or do I have to hide them too. If yes, 
how would I do that in a way that is satisfactory?

Thanks.

-- 
Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
  2015-06-23 13:01     ` Stephan Mueller
@ 2015-06-23 13:17       ` Geert Uytterhoeven
  -1 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-06-23 13:17 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Herbert Xu, Guenter Roeck, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

Hi Stephan,

On Tue, Jun 23, 2015 at 3:01 PM, Stephan Mueller <smueller@chronox.de> wrote:
>> On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
>> > I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
>> >
>> > With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
>> > to the good unused warning reporting, I get:
>> >
>> > crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
>> > crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
>> > crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
>> > crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options
>>
>> Stephan, could you look into moving the relevant functions into
>> its own file which can then be compiled with -O0? Obviously any
>> dependency on kernel header files would have to be hidden using
>> functions outside of this file.
>
> I have separated all so far. However, there are two items left where I am not
> sure about:
>
> - asm/types.h: I need __u64

I don't expect any reliance on optimization in <asm/types.h>, as it should
just add definitions. However, "__u64" is "unsigned long long" everywhere,
so you can just use that.

> - linux/bitops.h: I need rol64
>
> Can I safely include both header files or do I have to hide them too. If yes,
> how would I do that in a way that is satisfactory?

Either open-code rol64() (it's not that complicated), or add a source file that
contains only

        #include <linux/types.h>
        #include <linux/bitops.h>

        __u64 outofline_rol64(__u64 word, unsigned int shift)
        {
                return rol64(word, shift);
        }

and call outofline_rol64() from your code.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization)
@ 2015-06-23 13:17       ` Geert Uytterhoeven
  0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-06-23 13:17 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Herbert Xu, Guenter Roeck, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

Hi Stephan,

On Tue, Jun 23, 2015 at 3:01 PM, Stephan Mueller <smueller@chronox.de> wrote:
>> On Tue, Jun 23, 2015 at 11:17:23AM +0200, Geert Uytterhoeven wrote:
>> > I get that too with m68k-linux-gcc-4.6.3 and m68k-linux-gcc-4.9.0.
>> >
>> > With m68k-linux-gnu-gcc-4.1, which is still my default cross-compiler due
>> > to the good unused warning reporting, I get:
>> >
>> > crypto/jitterentropy.c:235: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:236: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:266: warning: ignoring #pragma GCC pop_options
>> > crypto/jitterentropy.c:295: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:296: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:336: warning: ignoring #pragma GCC pop_options
>> > crypto/jitterentropy.c:385: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:386: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:416: warning: ignoring #pragma GCC pop_options
>> > crypto/jitterentropy.c:517: warning: ignoring #pragma GCC push_options
>> > crypto/jitterentropy.c:518: warning: ignoring #pragma GCC optimize
>> > crypto/jitterentropy.c:580: warning: ignoring #pragma GCC pop_options
>>
>> Stephan, could you look into moving the relevant functions into
>> its own file which can then be compiled with -O0? Obviously any
>> dependency on kernel header files would have to be hidden using
>> functions outside of this file.
>
> I have separated all so far. However, there are two items left where I am not
> sure about:
>
> - asm/types.h: I need __u64

I don't expect any reliance on optimization in <asm/types.h>, as it should
just add definitions. However, "__u64" is "unsigned long long" everywhere,
so you can just use that.

> - linux/bitops.h: I need rol64
>
> Can I safely include both header files or do I have to hide them too. If yes,
> how would I do that in a way that is satisfactory?

Either open-code rol64() (it's not that complicated), or add a source file that
contains only

        #include <linux/types.h>
        #include <linux/bitops.h>

        __u64 outofline_rol64(__u64 word, unsigned int shift)
        {
                return rol64(word, shift);
        }

and call outofline_rol64() from your code.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 13:17       ` Geert Uytterhoeven
@ 2015-06-23 14:18         ` Stephan Mueller
  -1 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 14:18 UTC (permalink / raw)
  To: Geert Uytterhoeven, Guenter Roeck
  Cc: Herbert Xu, Peter Zijlstra, Andy Shevchenko, Jim Davis,
	Stephen Rothwell, Linux-Next, linux-kernel, David S. Miller,
	linux-crypto, Waiman Long, Ingo Molnar, x86

Hi Geert, Guenter,

may I ask that you check that the following patch compiles without errors or warnings on your systems?

Though, when I test that patch with the AVR32 cross compiler, I get a warning about the code being not relaxable.

Thank you very much.

---8<---
The core of the Jitter RNG is intended to be compiled with -O0. To
ensure that the Jitter RNG can be compiled on all architectures,
separate out the RNG core into a stand-alone C file that can be compiled
with -O0 which does not depend on any kernel include file.

As no kernel includes can be used in the C file implementing the core
RNG, any dependencies on kernel code must be extracted.

A second file provides the link to the kernel and the kernel crypto API
that can be compiled with the regular compile options of the kernel.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 crypto/Makefile              |   4 +-
 crypto/jitterentropy-kcapi.c | 208 ++++++++++++++++++++++++++++++++++++++++++
 crypto/jitterentropy.c       | 213 ++++++++-----------------------------------
 3 files changed, 248 insertions(+), 177 deletions(-)
 create mode 100644 crypto/jitterentropy-kcapi.c

diff --git a/crypto/Makefile b/crypto/Makefile
index 0077476..a16a7e7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -106,7 +106,9 @@ obj-$(CONFIG_CRYPTO_842) += 842.o
 obj-$(CONFIG_CRYPTO_RNG2) += rng.o
 obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
 obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
-obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy.o
+obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
+CFLAGS_jitterentropy.o = -O0
+jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
 obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
 obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 obj-$(CONFIG_CRYPTO_USER_API) += af_alg.o
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
new file mode 100644
index 0000000..b32d834
--- /dev/null
+++ b/crypto/jitterentropy-kcapi.c
@@ -0,0 +1,208 @@
+/*
+ * Non-physical true random number generator based on timing jitter --
+ * Linux Kernel Crypto API specific code
+ *
+ * Copyright Stephan Mueller <smueller@chronox.de>, 2015
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU General Public License, in which case the provisions of the GPL2 are
+ * required INSTEAD OF the above restrictions.  (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/fips.h>
+#include <linux/time.h>
+#include <linux/crypto.h>
+#include <crypto/internal/rng.h>
+
+struct rand_data;
+int jent_read_entropy(struct rand_data *ec, unsigned char *data,
+		      unsigned int len);
+int jent_entropy_init(void);
+struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
+					       unsigned int flags);
+void jent_entropy_collector_free(struct rand_data *entropy_collector);
+
+/***************************************************************************
+ * Helper function
+ ***************************************************************************/
+
+__u64 jent_rol64(__u64 word, unsigned int shift)
+{
+	return rol64(word, shift);
+}
+
+void *jent_zalloc(unsigned int len)
+{
+	return kzalloc(len, GFP_KERNEL);
+}
+
+void jent_zfree(void *ptr)
+{
+	kzfree(ptr);
+}
+
+int jent_fips_enabled(void)
+{
+	return fips_enabled;
+}
+
+void jent_panic(char *s)
+{
+	panic(s);
+}
+
+void jent_memcpy(void *dest, const void *src, unsigned int n)
+{
+	memcpy(dest, src, n);
+}
+
+void jent_get_nstime(__u64 *out)
+{
+	struct timespec ts;
+	__u64 tmp = 0;
+
+	tmp = random_get_entropy();
+
+	/*
+	 * If random_get_entropy does not return a value (which is possible on,
+	 * for example, MIPS), invoke __getnstimeofday
+	 * hoping that there are timers we can work with.
+	 *
+	 * The list of available timers can be obtained from
+	 * /sys/devices/system/clocksource/clocksource0/available_clocksource
+	 * and are registered with clocksource_register()
+	 */
+	if ((0 == tmp) &&
+	   (0 == __getnstimeofday(&ts))) {
+		tmp = ts.tv_sec;
+		tmp = tmp << 32;
+		tmp = tmp | ts.tv_nsec;
+	}
+
+	*out = tmp;
+}
+
+/***************************************************************************
+ * Kernel crypto API interface
+ ***************************************************************************/
+
+struct jitterentropy {
+	spinlock_t jent_lock;
+	struct rand_data *entropy_collector;
+};
+
+static int jent_kcapi_init(struct crypto_tfm *tfm)
+{
+	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
+	int ret = 0;
+
+	rng->entropy_collector = jent_entropy_collector_alloc(1, 0);
+	if (!rng->entropy_collector)
+		ret = -ENOMEM;
+
+	spin_lock_init(&rng->jent_lock);
+	return ret;
+}
+
+static void jent_kcapi_cleanup(struct crypto_tfm *tfm)
+{
+	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
+
+	spin_lock(&rng->jent_lock);
+	if (rng->entropy_collector)
+		jent_entropy_collector_free(rng->entropy_collector);
+	rng->entropy_collector = NULL;
+	spin_unlock(&rng->jent_lock);
+}
+
+static int jent_kcapi_random(struct crypto_rng *tfm,
+			     const u8 *src, unsigned int slen,
+			     u8 *rdata, unsigned int dlen)
+{
+	struct jitterentropy *rng = crypto_rng_ctx(tfm);
+	int ret = 0;
+
+	spin_lock(&rng->jent_lock);
+	ret = jent_read_entropy(rng->entropy_collector, rdata, dlen);
+	spin_unlock(&rng->jent_lock);
+
+	return ret;
+}
+
+static int jent_kcapi_reset(struct crypto_rng *tfm,
+			    const u8 *seed, unsigned int slen)
+{
+	return 0;
+}
+
+static struct rng_alg jent_alg = {
+	.generate		= jent_kcapi_random,
+	.seed			= jent_kcapi_reset,
+	.seedsize		= 0,
+	.base			= {
+		.cra_name               = "jitterentropy_rng",
+		.cra_driver_name        = "jitterentropy_rng",
+		.cra_priority           = 100,
+		.cra_ctxsize            = sizeof(struct jitterentropy),
+		.cra_module             = THIS_MODULE,
+		.cra_init               = jent_kcapi_init,
+		.cra_exit               = jent_kcapi_cleanup,
+
+	}
+};
+
+static int __init jent_mod_init(void)
+{
+	int ret = 0;
+
+	ret = jent_entropy_init();
+	if (ret) {
+		pr_info("jitterentropy: Initialization failed with host not compliant with requirements: %d\n", ret);
+		return -EFAULT;
+	}
+	return crypto_register_rng(&jent_alg);
+}
+
+static void __exit jent_mod_exit(void)
+{
+	crypto_unregister_rng(&jent_alg);
+}
+
+module_init(jent_mod_init);
+module_exit(jent_mod_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
+MODULE_DESCRIPTION("Non-physical True Random Number Generator based on CPU Jitter");
+MODULE_ALIAS_CRYPTO("jitterentropy_rng");
diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c
index d3c3045..6dfb220 100644
--- a/crypto/jitterentropy.c
+++ b/crypto/jitterentropy.c
@@ -1,7 +1,8 @@
 /*
- * Non-physical true random number generator based on timing jitter.
+ * Non-physical true random number generator based on timing jitter --
+ * Jitter RNG standalone code.
  *
- * Copyright Stephan Mueller <smueller@chronox.de>, 2014
+ * Copyright Stephan Mueller <smueller@chronox.de>, 2015
  *
  * Design
  * ======
@@ -49,13 +50,14 @@
  * version 1.1.0 provided at http://www.chronox.de/jent.html
  */
 
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/fips.h>
-#include <linux/time.h>
-#include <linux/crypto.h>
-#include <crypto/internal/rng.h>
+#ifdef __OPTIMIZE__
+ #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."
+#endif
+
+typedef	unsigned long long	__u64;
+typedef	long long		__s64;
+typedef	unsigned int		__u32;
+#define NULL    ((void *) 0)
 
 /* The entropy pool */
 struct rand_data {
@@ -93,8 +95,6 @@ struct rand_data {
 					   * entropy, saves MEMORY_SIZE RAM for
 					   * entropy collector */
 
-#define DRIVER_NAME     "jitterentropy"
-
 /* -- error codes for init function -- */
 #define JENT_ENOTIME		1 /* Timer service not available */
 #define JENT_ECOARSETIME	2 /* Timer too coarse for RNG */
@@ -110,32 +110,13 @@ struct rand_data {
  * Helper functions
  ***************************************************************************/
 
-static inline void jent_get_nstime(__u64 *out)
-{
-	struct timespec ts;
-	__u64 tmp = 0;
-
-	tmp = random_get_entropy();
-
-	/*
-	 * If random_get_entropy does not return a value (which is possible on,
-	 * for example, MIPS), invoke __getnstimeofday
-	 * hoping that there are timers we can work with.
-	 *
-	 * The list of available timers can be obtained from
-	 * /sys/devices/system/clocksource/clocksource0/available_clocksource
-	 * and are registered with clocksource_register()
-	 */
-	if ((0 == tmp) &&
-	   (0 == __getnstimeofday(&ts))) {
-		tmp = ts.tv_sec;
-		tmp = tmp << 32;
-		tmp = tmp | ts.tv_nsec;
-	}
-
-	*out = tmp;
-}
-
+void jent_get_nstime(__u64 *out);
+__u64 jent_rol64(__u64 word, unsigned int shift);
+void *jent_zalloc(unsigned int len);
+void jent_zfree(void *ptr);
+int jent_fips_enabled(void);
+void jent_panic(char *s);
+void jent_memcpy(void *dest, const void *src, unsigned int n);
 
 /**
  * Update of the loop count used for the next round of
@@ -184,20 +165,6 @@ static __u64 jent_loop_shuffle(struct rand_data *ec,
  * Noise sources
  ***************************************************************************/
 
-/*
- * The disabling of the optimizations is performed as documented and assessed
- * thoroughly in http://www.chronox.de/jent.html. However, instead of disabling
- * the optimization of the entire C file, only the main functions the jitter is
- * measured for are not optimized. These functions include the noise sources as
- * well as the main functions triggering the noise sources. As the time
- * measurement is done from one invocation of the jitter noise source to the
- * next, even the execution jitter of the code invoking the noise sources
- * contribute to the overall randomness as well. The behavior of the RNG and the
- * statistical characteristics when only the mentioned functions are not
- * optimized is almost equal to the a completely non-optimized RNG compilation
- * as tested with the test tools provided at the initially mentioned web site.
- */
-
 /**
  * CPU Jitter noise source -- this is the noise source based on the CPU
  *			      execution time jitter
@@ -232,8 +199,6 @@ static __u64 jent_loop_shuffle(struct rand_data *ec,
  *
  * @return Number of loops the folding operation is performed
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static __u64 jent_fold_time(struct rand_data *ec, __u64 time,
 			    __u64 *folded, __u64 loop_cnt)
 {
@@ -263,7 +228,6 @@ static __u64 jent_fold_time(struct rand_data *ec, __u64 time,
 	*folded = new;
 	return fold_loop_cnt;
 }
-#pragma GCC pop_options
 
 /**
  * Memory Access noise source -- this is a noise source based on variations in
@@ -292,8 +256,6 @@ static __u64 jent_fold_time(struct rand_data *ec, __u64 time,
  *
  * @return Number of memory access operations
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static unsigned int jent_memaccess(struct rand_data *ec, __u64 loop_cnt)
 {
 	unsigned char *tmpval = NULL;
@@ -333,7 +295,6 @@ static unsigned int jent_memaccess(struct rand_data *ec, __u64 loop_cnt)
 	}
 	return i;
 }
-#pragma GCC pop_options
 
 /***************************************************************************
  * Start of entropy processing logic
@@ -382,8 +343,6 @@ static void jent_stuck(struct rand_data *ec, __u64 current_delta)
  *
  * @return One random bit
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static __u64 jent_measure_jitter(struct rand_data *ec)
 {
 	__u64 time = 0;
@@ -413,7 +372,6 @@ static __u64 jent_measure_jitter(struct rand_data *ec)
 
 	return data;
 }
-#pragma GCC pop_options
 
 /**
  * Von Neuman unbias as explained in RFC 4086 section 4.2. As shown in the
@@ -502,7 +460,7 @@ static void jent_stir_pool(struct rand_data *entropy_collector)
 		 */
 		if ((entropy_collector->data >> i) & 1)
 			mixer.u64 ^= constant.u64;
-		mixer.u64 = rol64(mixer.u64, 1);
+		mixer.u64 = jent_rol64(mixer.u64, 1);
 	}
 	entropy_collector->data ^= mixer.u64;
 }
@@ -514,8 +472,6 @@ static void jent_stir_pool(struct rand_data *entropy_collector)
  * Input:
  * @ec Reference to entropy collector
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static void jent_gen_entropy(struct rand_data *ec)
 {
 	unsigned int k = 0;
@@ -565,7 +521,7 @@ static void jent_gen_entropy(struct rand_data *ec)
 		ec->data ^= ((ec->data >> 30) & 1);
 		ec->data ^= ((ec->data >> 27) & 1);
 		ec->data ^= ((ec->data >> 22) & 1);
-		ec->data = rol64(ec->data, 1);
+		ec->data = jent_rol64(ec->data, 1);
 
 		/*
 		 * We multiply the loop value with ->osr to obtain the
@@ -577,7 +533,6 @@ static void jent_gen_entropy(struct rand_data *ec)
 	if (ec->stir)
 		jent_stir_pool(ec);
 }
-#pragma GCC pop_options
 
 /**
  * The continuous test required by FIPS 140-2 -- the function automatically
@@ -589,7 +544,7 @@ static void jent_gen_entropy(struct rand_data *ec)
  */
 static void jent_fips_test(struct rand_data *ec)
 {
-	if (!fips_enabled)
+	if (!jent_fips_enabled())
 		return;
 
 	/* prime the FIPS test */
@@ -599,12 +554,11 @@ static void jent_fips_test(struct rand_data *ec)
 	}
 
 	if (ec->data == ec->old_data)
-		panic(DRIVER_NAME ": Duplicate output detected\n");
+		jent_panic("jitterentropy: Duplicate output detected\n");
 
 	ec->old_data = ec->data;
 }
 
-
 /**
  * Entry function: Obtain entropy for the caller.
  *
@@ -627,15 +581,16 @@ static void jent_fips_test(struct rand_data *ec)
  * The following error codes can occur:
  *	-1	entropy_collector is NULL
  */
-static ssize_t jent_read_entropy(struct rand_data *ec, u8 *data, size_t len)
+int jent_read_entropy(struct rand_data *ec, unsigned char *data,
+		      unsigned int len)
 {
-	u8 *p = data;
+	unsigned char *p = data;
 
 	if (!ec)
-		return -EINVAL;
+		return -1;
 
 	while (0 < len) {
-		size_t tocopy;
+		unsigned int tocopy;
 
 		jent_gen_entropy(ec);
 		jent_fips_test(ec);
@@ -643,7 +598,7 @@ static ssize_t jent_read_entropy(struct rand_data *ec, u8 *data, size_t len)
 			tocopy = (DATA_SIZE_BITS / 8);
 		else
 			tocopy = len;
-		memcpy(p, &ec->data, tocopy);
+		jent_memcpy(p, &ec->data, tocopy);
 
 		len -= tocopy;
 		p += tocopy;
@@ -656,12 +611,12 @@ static ssize_t jent_read_entropy(struct rand_data *ec, u8 *data, size_t len)
  * Initialization logic
  ***************************************************************************/
 
-static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
-						      unsigned int flags)
+struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
+					       unsigned int flags)
 {
 	struct rand_data *entropy_collector;
 
-	entropy_collector = kzalloc(sizeof(struct rand_data), GFP_KERNEL);
+	entropy_collector = jent_zalloc(sizeof(struct rand_data));
 	if (!entropy_collector)
 		return NULL;
 
@@ -669,9 +624,9 @@ static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
 		/* Allocate memory for adding variations based on memory
 		 * access
 		 */
-		entropy_collector->mem = kzalloc(JENT_MEMORY_SIZE, GFP_KERNEL);
+		entropy_collector->mem = jent_zalloc(JENT_MEMORY_SIZE);
 		if (!entropy_collector->mem) {
-			kfree(entropy_collector);
+			jent_zfree(entropy_collector);
 			return NULL;
 		}
 		entropy_collector->memblocksize = JENT_MEMORY_BLOCKSIZE;
@@ -696,17 +651,17 @@ static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
 	return entropy_collector;
 }
 
-static void jent_entropy_collector_free(struct rand_data *entropy_collector)
+void jent_entropy_collector_free(struct rand_data *entropy_collector)
 {
 	if (entropy_collector->mem)
-		kzfree(entropy_collector->mem);
+		jent_zfree(entropy_collector->mem);
 	entropy_collector->mem = NULL;
 	if (entropy_collector)
-		kzfree(entropy_collector);
+		jent_zfree(entropy_collector);
 	entropy_collector = NULL;
 }
 
-static int jent_entropy_init(void)
+int jent_entropy_init(void)
 {
 	int i;
 	__u64 delta_sum = 0;
@@ -832,97 +787,3 @@ static int jent_entropy_init(void)
 
 	return 0;
 }
-
-/***************************************************************************
- * Kernel crypto API interface
- ***************************************************************************/
-
-struct jitterentropy {
-	spinlock_t jent_lock;
-	struct rand_data *entropy_collector;
-};
-
-static int jent_kcapi_init(struct crypto_tfm *tfm)
-{
-	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
-	int ret = 0;
-
-	rng->entropy_collector = jent_entropy_collector_alloc(1, 0);
-	if (!rng->entropy_collector)
-		ret = -ENOMEM;
-
-	spin_lock_init(&rng->jent_lock);
-	return ret;
-}
-
-static void jent_kcapi_cleanup(struct crypto_tfm *tfm)
-{
-	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
-
-	spin_lock(&rng->jent_lock);
-	if (rng->entropy_collector)
-		jent_entropy_collector_free(rng->entropy_collector);
-	rng->entropy_collector = NULL;
-	spin_unlock(&rng->jent_lock);
-}
-
-static int jent_kcapi_random(struct crypto_rng *tfm,
-			     const u8 *src, unsigned int slen,
-			     u8 *rdata, unsigned int dlen)
-{
-	struct jitterentropy *rng = crypto_rng_ctx(tfm);
-	int ret = 0;
-
-	spin_lock(&rng->jent_lock);
-	ret = jent_read_entropy(rng->entropy_collector, rdata, dlen);
-	spin_unlock(&rng->jent_lock);
-
-	return ret;
-}
-
-static int jent_kcapi_reset(struct crypto_rng *tfm,
-			    const u8 *seed, unsigned int slen)
-{
-	return 0;
-}
-
-static struct rng_alg jent_alg = {
-	.generate		= jent_kcapi_random,
-	.seed			= jent_kcapi_reset,
-	.seedsize		= 0,
-	.base			= {
-		.cra_name               = "jitterentropy_rng",
-		.cra_driver_name        = "jitterentropy_rng",
-		.cra_priority           = 100,
-		.cra_ctxsize            = sizeof(struct jitterentropy),
-		.cra_module             = THIS_MODULE,
-		.cra_init               = jent_kcapi_init,
-		.cra_exit               = jent_kcapi_cleanup,
-
-	}
-};
-
-static int __init jent_mod_init(void)
-{
-	int ret = 0;
-
-	ret = jent_entropy_init();
-	if (ret) {
-		pr_info(DRIVER_NAME ": Initialization failed with host not compliant with requirements: %d\n", ret);
-		return -EFAULT;
-	}
-	return crypto_register_rng(&jent_alg);
-}
-
-static void __exit jent_mod_exit(void)
-{
-	crypto_unregister_rng(&jent_alg);
-}
-
-module_init(jent_mod_init);
-module_exit(jent_mod_exit);
-
-MODULE_LICENSE("Dual BSD/GPL");
-MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
-MODULE_DESCRIPTION("Non-physical True Random Number Generator based on CPU Jitter");
-MODULE_ALIAS_CRYPTO("jitterentropy_rng");
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-23 14:18         ` Stephan Mueller
  0 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 14:18 UTC (permalink / raw)
  To: Geert Uytterhoeven, Guenter Roeck
  Cc: Herbert Xu, Peter Zijlstra, Andy Shevchenko, Jim Davis,
	Stephen Rothwell, Linux-Next, linux-kernel, David S. Miller,
	linux-crypto, Waiman Long, Ingo Molnar, x86

Hi Geert, Guenter,

may I ask that you check that the following patch compiles without errors or warnings on your systems?

Though, when I test that patch with the AVR32 cross compiler, I get a warning about the code being not relaxable.

Thank you very much.

---8<---
The core of the Jitter RNG is intended to be compiled with -O0. To
ensure that the Jitter RNG can be compiled on all architectures,
separate out the RNG core into a stand-alone C file that can be compiled
with -O0 which does not depend on any kernel include file.

As no kernel includes can be used in the C file implementing the core
RNG, any dependencies on kernel code must be extracted.

A second file provides the link to the kernel and the kernel crypto API
that can be compiled with the regular compile options of the kernel.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 crypto/Makefile              |   4 +-
 crypto/jitterentropy-kcapi.c | 208 ++++++++++++++++++++++++++++++++++++++++++
 crypto/jitterentropy.c       | 213 ++++++++-----------------------------------
 3 files changed, 248 insertions(+), 177 deletions(-)
 create mode 100644 crypto/jitterentropy-kcapi.c

diff --git a/crypto/Makefile b/crypto/Makefile
index 0077476..a16a7e7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -106,7 +106,9 @@ obj-$(CONFIG_CRYPTO_842) += 842.o
 obj-$(CONFIG_CRYPTO_RNG2) += rng.o
 obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
 obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
-obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy.o
+obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
+CFLAGS_jitterentropy.o = -O0
+jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
 obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
 obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 obj-$(CONFIG_CRYPTO_USER_API) += af_alg.o
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
new file mode 100644
index 0000000..b32d834
--- /dev/null
+++ b/crypto/jitterentropy-kcapi.c
@@ -0,0 +1,208 @@
+/*
+ * Non-physical true random number generator based on timing jitter --
+ * Linux Kernel Crypto API specific code
+ *
+ * Copyright Stephan Mueller <smueller@chronox.de>, 2015
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU General Public License, in which case the provisions of the GPL2 are
+ * required INSTEAD OF the above restrictions.  (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/fips.h>
+#include <linux/time.h>
+#include <linux/crypto.h>
+#include <crypto/internal/rng.h>
+
+struct rand_data;
+int jent_read_entropy(struct rand_data *ec, unsigned char *data,
+		      unsigned int len);
+int jent_entropy_init(void);
+struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
+					       unsigned int flags);
+void jent_entropy_collector_free(struct rand_data *entropy_collector);
+
+/***************************************************************************
+ * Helper function
+ ***************************************************************************/
+
+__u64 jent_rol64(__u64 word, unsigned int shift)
+{
+	return rol64(word, shift);
+}
+
+void *jent_zalloc(unsigned int len)
+{
+	return kzalloc(len, GFP_KERNEL);
+}
+
+void jent_zfree(void *ptr)
+{
+	kzfree(ptr);
+}
+
+int jent_fips_enabled(void)
+{
+	return fips_enabled;
+}
+
+void jent_panic(char *s)
+{
+	panic(s);
+}
+
+void jent_memcpy(void *dest, const void *src, unsigned int n)
+{
+	memcpy(dest, src, n);
+}
+
+void jent_get_nstime(__u64 *out)
+{
+	struct timespec ts;
+	__u64 tmp = 0;
+
+	tmp = random_get_entropy();
+
+	/*
+	 * If random_get_entropy does not return a value (which is possible on,
+	 * for example, MIPS), invoke __getnstimeofday
+	 * hoping that there are timers we can work with.
+	 *
+	 * The list of available timers can be obtained from
+	 * /sys/devices/system/clocksource/clocksource0/available_clocksource
+	 * and are registered with clocksource_register()
+	 */
+	if ((0 == tmp) &&
+	   (0 == __getnstimeofday(&ts))) {
+		tmp = ts.tv_sec;
+		tmp = tmp << 32;
+		tmp = tmp | ts.tv_nsec;
+	}
+
+	*out = tmp;
+}
+
+/***************************************************************************
+ * Kernel crypto API interface
+ ***************************************************************************/
+
+struct jitterentropy {
+	spinlock_t jent_lock;
+	struct rand_data *entropy_collector;
+};
+
+static int jent_kcapi_init(struct crypto_tfm *tfm)
+{
+	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
+	int ret = 0;
+
+	rng->entropy_collector = jent_entropy_collector_alloc(1, 0);
+	if (!rng->entropy_collector)
+		ret = -ENOMEM;
+
+	spin_lock_init(&rng->jent_lock);
+	return ret;
+}
+
+static void jent_kcapi_cleanup(struct crypto_tfm *tfm)
+{
+	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
+
+	spin_lock(&rng->jent_lock);
+	if (rng->entropy_collector)
+		jent_entropy_collector_free(rng->entropy_collector);
+	rng->entropy_collector = NULL;
+	spin_unlock(&rng->jent_lock);
+}
+
+static int jent_kcapi_random(struct crypto_rng *tfm,
+			     const u8 *src, unsigned int slen,
+			     u8 *rdata, unsigned int dlen)
+{
+	struct jitterentropy *rng = crypto_rng_ctx(tfm);
+	int ret = 0;
+
+	spin_lock(&rng->jent_lock);
+	ret = jent_read_entropy(rng->entropy_collector, rdata, dlen);
+	spin_unlock(&rng->jent_lock);
+
+	return ret;
+}
+
+static int jent_kcapi_reset(struct crypto_rng *tfm,
+			    const u8 *seed, unsigned int slen)
+{
+	return 0;
+}
+
+static struct rng_alg jent_alg = {
+	.generate		= jent_kcapi_random,
+	.seed			= jent_kcapi_reset,
+	.seedsize		= 0,
+	.base			= {
+		.cra_name               = "jitterentropy_rng",
+		.cra_driver_name        = "jitterentropy_rng",
+		.cra_priority           = 100,
+		.cra_ctxsize            = sizeof(struct jitterentropy),
+		.cra_module             = THIS_MODULE,
+		.cra_init               = jent_kcapi_init,
+		.cra_exit               = jent_kcapi_cleanup,
+
+	}
+};
+
+static int __init jent_mod_init(void)
+{
+	int ret = 0;
+
+	ret = jent_entropy_init();
+	if (ret) {
+		pr_info("jitterentropy: Initialization failed with host not compliant with requirements: %d\n", ret);
+		return -EFAULT;
+	}
+	return crypto_register_rng(&jent_alg);
+}
+
+static void __exit jent_mod_exit(void)
+{
+	crypto_unregister_rng(&jent_alg);
+}
+
+module_init(jent_mod_init);
+module_exit(jent_mod_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
+MODULE_DESCRIPTION("Non-physical True Random Number Generator based on CPU Jitter");
+MODULE_ALIAS_CRYPTO("jitterentropy_rng");
diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c
index d3c3045..6dfb220 100644
--- a/crypto/jitterentropy.c
+++ b/crypto/jitterentropy.c
@@ -1,7 +1,8 @@
 /*
- * Non-physical true random number generator based on timing jitter.
+ * Non-physical true random number generator based on timing jitter --
+ * Jitter RNG standalone code.
  *
- * Copyright Stephan Mueller <smueller@chronox.de>, 2014
+ * Copyright Stephan Mueller <smueller@chronox.de>, 2015
  *
  * Design
  * ======
@@ -49,13 +50,14 @@
  * version 1.1.0 provided at http://www.chronox.de/jent.html
  */
 
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/fips.h>
-#include <linux/time.h>
-#include <linux/crypto.h>
-#include <crypto/internal/rng.h>
+#ifdef __OPTIMIZE__
+ #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."
+#endif
+
+typedef	unsigned long long	__u64;
+typedef	long long		__s64;
+typedef	unsigned int		__u32;
+#define NULL    ((void *) 0)
 
 /* The entropy pool */
 struct rand_data {
@@ -93,8 +95,6 @@ struct rand_data {
 					   * entropy, saves MEMORY_SIZE RAM for
 					   * entropy collector */
 
-#define DRIVER_NAME     "jitterentropy"
-
 /* -- error codes for init function -- */
 #define JENT_ENOTIME		1 /* Timer service not available */
 #define JENT_ECOARSETIME	2 /* Timer too coarse for RNG */
@@ -110,32 +110,13 @@ struct rand_data {
  * Helper functions
  ***************************************************************************/
 
-static inline void jent_get_nstime(__u64 *out)
-{
-	struct timespec ts;
-	__u64 tmp = 0;
-
-	tmp = random_get_entropy();
-
-	/*
-	 * If random_get_entropy does not return a value (which is possible on,
-	 * for example, MIPS), invoke __getnstimeofday
-	 * hoping that there are timers we can work with.
-	 *
-	 * The list of available timers can be obtained from
-	 * /sys/devices/system/clocksource/clocksource0/available_clocksource
-	 * and are registered with clocksource_register()
-	 */
-	if ((0 == tmp) &&
-	   (0 == __getnstimeofday(&ts))) {
-		tmp = ts.tv_sec;
-		tmp = tmp << 32;
-		tmp = tmp | ts.tv_nsec;
-	}
-
-	*out = tmp;
-}
-
+void jent_get_nstime(__u64 *out);
+__u64 jent_rol64(__u64 word, unsigned int shift);
+void *jent_zalloc(unsigned int len);
+void jent_zfree(void *ptr);
+int jent_fips_enabled(void);
+void jent_panic(char *s);
+void jent_memcpy(void *dest, const void *src, unsigned int n);
 
 /**
  * Update of the loop count used for the next round of
@@ -184,20 +165,6 @@ static __u64 jent_loop_shuffle(struct rand_data *ec,
  * Noise sources
  ***************************************************************************/
 
-/*
- * The disabling of the optimizations is performed as documented and assessed
- * thoroughly in http://www.chronox.de/jent.html. However, instead of disabling
- * the optimization of the entire C file, only the main functions the jitter is
- * measured for are not optimized. These functions include the noise sources as
- * well as the main functions triggering the noise sources. As the time
- * measurement is done from one invocation of the jitter noise source to the
- * next, even the execution jitter of the code invoking the noise sources
- * contribute to the overall randomness as well. The behavior of the RNG and the
- * statistical characteristics when only the mentioned functions are not
- * optimized is almost equal to the a completely non-optimized RNG compilation
- * as tested with the test tools provided at the initially mentioned web site.
- */
-
 /**
  * CPU Jitter noise source -- this is the noise source based on the CPU
  *			      execution time jitter
@@ -232,8 +199,6 @@ static __u64 jent_loop_shuffle(struct rand_data *ec,
  *
  * @return Number of loops the folding operation is performed
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static __u64 jent_fold_time(struct rand_data *ec, __u64 time,
 			    __u64 *folded, __u64 loop_cnt)
 {
@@ -263,7 +228,6 @@ static __u64 jent_fold_time(struct rand_data *ec, __u64 time,
 	*folded = new;
 	return fold_loop_cnt;
 }
-#pragma GCC pop_options
 
 /**
  * Memory Access noise source -- this is a noise source based on variations in
@@ -292,8 +256,6 @@ static __u64 jent_fold_time(struct rand_data *ec, __u64 time,
  *
  * @return Number of memory access operations
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static unsigned int jent_memaccess(struct rand_data *ec, __u64 loop_cnt)
 {
 	unsigned char *tmpval = NULL;
@@ -333,7 +295,6 @@ static unsigned int jent_memaccess(struct rand_data *ec, __u64 loop_cnt)
 	}
 	return i;
 }
-#pragma GCC pop_options
 
 /***************************************************************************
  * Start of entropy processing logic
@@ -382,8 +343,6 @@ static void jent_stuck(struct rand_data *ec, __u64 current_delta)
  *
  * @return One random bit
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static __u64 jent_measure_jitter(struct rand_data *ec)
 {
 	__u64 time = 0;
@@ -413,7 +372,6 @@ static __u64 jent_measure_jitter(struct rand_data *ec)
 
 	return data;
 }
-#pragma GCC pop_options
 
 /**
  * Von Neuman unbias as explained in RFC 4086 section 4.2. As shown in the
@@ -502,7 +460,7 @@ static void jent_stir_pool(struct rand_data *entropy_collector)
 		 */
 		if ((entropy_collector->data >> i) & 1)
 			mixer.u64 ^= constant.u64;
-		mixer.u64 = rol64(mixer.u64, 1);
+		mixer.u64 = jent_rol64(mixer.u64, 1);
 	}
 	entropy_collector->data ^= mixer.u64;
 }
@@ -514,8 +472,6 @@ static void jent_stir_pool(struct rand_data *entropy_collector)
  * Input:
  * @ec Reference to entropy collector
  */
-#pragma GCC push_options
-#pragma GCC optimize ("-O0")
 static void jent_gen_entropy(struct rand_data *ec)
 {
 	unsigned int k = 0;
@@ -565,7 +521,7 @@ static void jent_gen_entropy(struct rand_data *ec)
 		ec->data ^= ((ec->data >> 30) & 1);
 		ec->data ^= ((ec->data >> 27) & 1);
 		ec->data ^= ((ec->data >> 22) & 1);
-		ec->data = rol64(ec->data, 1);
+		ec->data = jent_rol64(ec->data, 1);
 
 		/*
 		 * We multiply the loop value with ->osr to obtain the
@@ -577,7 +533,6 @@ static void jent_gen_entropy(struct rand_data *ec)
 	if (ec->stir)
 		jent_stir_pool(ec);
 }
-#pragma GCC pop_options
 
 /**
  * The continuous test required by FIPS 140-2 -- the function automatically
@@ -589,7 +544,7 @@ static void jent_gen_entropy(struct rand_data *ec)
  */
 static void jent_fips_test(struct rand_data *ec)
 {
-	if (!fips_enabled)
+	if (!jent_fips_enabled())
 		return;
 
 	/* prime the FIPS test */
@@ -599,12 +554,11 @@ static void jent_fips_test(struct rand_data *ec)
 	}
 
 	if (ec->data == ec->old_data)
-		panic(DRIVER_NAME ": Duplicate output detected\n");
+		jent_panic("jitterentropy: Duplicate output detected\n");
 
 	ec->old_data = ec->data;
 }
 
-
 /**
  * Entry function: Obtain entropy for the caller.
  *
@@ -627,15 +581,16 @@ static void jent_fips_test(struct rand_data *ec)
  * The following error codes can occur:
  *	-1	entropy_collector is NULL
  */
-static ssize_t jent_read_entropy(struct rand_data *ec, u8 *data, size_t len)
+int jent_read_entropy(struct rand_data *ec, unsigned char *data,
+		      unsigned int len)
 {
-	u8 *p = data;
+	unsigned char *p = data;
 
 	if (!ec)
-		return -EINVAL;
+		return -1;
 
 	while (0 < len) {
-		size_t tocopy;
+		unsigned int tocopy;
 
 		jent_gen_entropy(ec);
 		jent_fips_test(ec);
@@ -643,7 +598,7 @@ static ssize_t jent_read_entropy(struct rand_data *ec, u8 *data, size_t len)
 			tocopy = (DATA_SIZE_BITS / 8);
 		else
 			tocopy = len;
-		memcpy(p, &ec->data, tocopy);
+		jent_memcpy(p, &ec->data, tocopy);
 
 		len -= tocopy;
 		p += tocopy;
@@ -656,12 +611,12 @@ static ssize_t jent_read_entropy(struct rand_data *ec, u8 *data, size_t len)
  * Initialization logic
  ***************************************************************************/
 
-static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
-						      unsigned int flags)
+struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
+					       unsigned int flags)
 {
 	struct rand_data *entropy_collector;
 
-	entropy_collector = kzalloc(sizeof(struct rand_data), GFP_KERNEL);
+	entropy_collector = jent_zalloc(sizeof(struct rand_data));
 	if (!entropy_collector)
 		return NULL;
 
@@ -669,9 +624,9 @@ static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
 		/* Allocate memory for adding variations based on memory
 		 * access
 		 */
-		entropy_collector->mem = kzalloc(JENT_MEMORY_SIZE, GFP_KERNEL);
+		entropy_collector->mem = jent_zalloc(JENT_MEMORY_SIZE);
 		if (!entropy_collector->mem) {
-			kfree(entropy_collector);
+			jent_zfree(entropy_collector);
 			return NULL;
 		}
 		entropy_collector->memblocksize = JENT_MEMORY_BLOCKSIZE;
@@ -696,17 +651,17 @@ static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
 	return entropy_collector;
 }
 
-static void jent_entropy_collector_free(struct rand_data *entropy_collector)
+void jent_entropy_collector_free(struct rand_data *entropy_collector)
 {
 	if (entropy_collector->mem)
-		kzfree(entropy_collector->mem);
+		jent_zfree(entropy_collector->mem);
 	entropy_collector->mem = NULL;
 	if (entropy_collector)
-		kzfree(entropy_collector);
+		jent_zfree(entropy_collector);
 	entropy_collector = NULL;
 }
 
-static int jent_entropy_init(void)
+int jent_entropy_init(void)
 {
 	int i;
 	__u64 delta_sum = 0;
@@ -832,97 +787,3 @@ static int jent_entropy_init(void)
 
 	return 0;
 }
-
-/***************************************************************************
- * Kernel crypto API interface
- ***************************************************************************/
-
-struct jitterentropy {
-	spinlock_t jent_lock;
-	struct rand_data *entropy_collector;
-};
-
-static int jent_kcapi_init(struct crypto_tfm *tfm)
-{
-	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
-	int ret = 0;
-
-	rng->entropy_collector = jent_entropy_collector_alloc(1, 0);
-	if (!rng->entropy_collector)
-		ret = -ENOMEM;
-
-	spin_lock_init(&rng->jent_lock);
-	return ret;
-}
-
-static void jent_kcapi_cleanup(struct crypto_tfm *tfm)
-{
-	struct jitterentropy *rng = crypto_tfm_ctx(tfm);
-
-	spin_lock(&rng->jent_lock);
-	if (rng->entropy_collector)
-		jent_entropy_collector_free(rng->entropy_collector);
-	rng->entropy_collector = NULL;
-	spin_unlock(&rng->jent_lock);
-}
-
-static int jent_kcapi_random(struct crypto_rng *tfm,
-			     const u8 *src, unsigned int slen,
-			     u8 *rdata, unsigned int dlen)
-{
-	struct jitterentropy *rng = crypto_rng_ctx(tfm);
-	int ret = 0;
-
-	spin_lock(&rng->jent_lock);
-	ret = jent_read_entropy(rng->entropy_collector, rdata, dlen);
-	spin_unlock(&rng->jent_lock);
-
-	return ret;
-}
-
-static int jent_kcapi_reset(struct crypto_rng *tfm,
-			    const u8 *seed, unsigned int slen)
-{
-	return 0;
-}
-
-static struct rng_alg jent_alg = {
-	.generate		= jent_kcapi_random,
-	.seed			= jent_kcapi_reset,
-	.seedsize		= 0,
-	.base			= {
-		.cra_name               = "jitterentropy_rng",
-		.cra_driver_name        = "jitterentropy_rng",
-		.cra_priority           = 100,
-		.cra_ctxsize            = sizeof(struct jitterentropy),
-		.cra_module             = THIS_MODULE,
-		.cra_init               = jent_kcapi_init,
-		.cra_exit               = jent_kcapi_cleanup,
-
-	}
-};
-
-static int __init jent_mod_init(void)
-{
-	int ret = 0;
-
-	ret = jent_entropy_init();
-	if (ret) {
-		pr_info(DRIVER_NAME ": Initialization failed with host not compliant with requirements: %d\n", ret);
-		return -EFAULT;
-	}
-	return crypto_register_rng(&jent_alg);
-}
-
-static void __exit jent_mod_exit(void)
-{
-	crypto_unregister_rng(&jent_alg);
-}
-
-module_init(jent_mod_init);
-module_exit(jent_mod_exit);
-
-MODULE_LICENSE("Dual BSD/GPL");
-MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
-MODULE_DESCRIPTION("Non-physical True Random Number Generator based on CPU Jitter");
-MODULE_ALIAS_CRYPTO("jitterentropy_rng");
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 14:18         ` Stephan Mueller
@ 2015-06-23 15:31           ` Guenter Roeck
  -1 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2015-06-23 15:31 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Geert Uytterhoeven, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
> Hi Geert, Guenter,
> 
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
> 
Stephan,

I applied your patch on top of the current mainline (which includes
the crypto updates for 4.2) and pushed it into my 'testing' branch.
You should be able to see the results in a couple of hours at
http://server.roeck-us.net:8010/builders, in the 'testing' column.

The build system doesn't log warnings, but this should give us an idea
if the build passes for all architectures.

I'll have a look myself later and let you know as well.

Guenter

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-23 15:31           ` Guenter Roeck
  0 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2015-06-23 15:31 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Geert Uytterhoeven, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
> Hi Geert, Guenter,
> 
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
> 
Stephan,

I applied your patch on top of the current mainline (which includes
the crypto updates for 4.2) and pushed it into my 'testing' branch.
You should be able to see the results in a couple of hours at
http://server.roeck-us.net:8010/builders, in the 'testing' column.

The build system doesn't log warnings, but this should give us an idea
if the build passes for all architectures.

I'll have a look myself later and let you know as well.

Guenter

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 15:31           ` Guenter Roeck
@ 2015-06-23 15:36             ` Stephan Mueller
  -1 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 15:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Geert Uytterhoeven, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 08:31:10 schrieb Guenter Roeck:

Hi Guenter,

>On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
>> Hi Geert, Guenter,
>> 
>> may I ask that you check that the following patch compiles without errors
>> or warnings on your systems?
>Stephan,
>
>I applied your patch on top of the current mainline (which includes
>the crypto updates for 4.2) and pushed it into my 'testing' branch.
>You should be able to see the results in a couple of hours at
>http://server.roeck-us.net:8010/builders, in the 'testing' column.
>
>The build system doesn't log warnings, but this should give us an idea
>if the build passes for all architectures.
>
>I'll have a look myself later and let you know as well.

Thank you very much!


Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-23 15:36             ` Stephan Mueller
  0 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 15:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Geert Uytterhoeven, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 08:31:10 schrieb Guenter Roeck:

Hi Guenter,

>On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
>> Hi Geert, Guenter,
>> 
>> may I ask that you check that the following patch compiles without errors
>> or warnings on your systems?
>Stephan,
>
>I applied your patch on top of the current mainline (which includes
>the crypto updates for 4.2) and pushed it into my 'testing' branch.
>You should be able to see the results in a couple of hours at
>http://server.roeck-us.net:8010/builders, in the 'testing' column.
>
>The build system doesn't log warnings, but this should give us an idea
>if the build passes for all architectures.
>
>I'll have a look myself later and let you know as well.

Thank you very much!


Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 14:18         ` Stephan Mueller
@ 2015-06-23 17:41           ` Guenter Roeck
  -1 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2015-06-23 17:41 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Geert Uytterhoeven, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
> Hi Geert, Guenter,
> 
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
> 
No build failures for all architectures.

Guenter

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-23 17:41           ` Guenter Roeck
  0 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2015-06-23 17:41 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Geert Uytterhoeven, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
> Hi Geert, Guenter,
> 
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
> 
No build failures for all architectures.

Guenter

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 17:41           ` Guenter Roeck
@ 2015-06-23 17:55             ` Stephan Mueller
  -1 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 17:55 UTC (permalink / raw)
  To: Guenter Roeck, Geert Uytterhoeven
  Cc: Herbert Xu, Peter Zijlstra, Andy Shevchenko, Jim Davis,
	Stephen Rothwell, Linux-Next, linux-kernel, David S. Miller,
	linux-crypto, Waiman Long, Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 10:41:03 schrieb Guenter Roeck:

Hi Guenter, Geert,

>On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
>> Hi Geert, Guenter,
>> 
>> may I ask that you check that the following patch compiles without errors
>> or warnings on your systems?
>No build failures for all architectures.

Thank you very much for your help.

Now, if Geert would be so kind and have a check on his OpenRISC to ensure that 
there are no compiler warnings, I would be happy.

Though, does anybody have any idea what the AVR32 compiler warning about 
crypto/builtin.o not being relaxable mean and whether that is an issue? Note, 
when I was compiling AVR32, I saw some of these warnings for other builtin.o 
too.

Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-23 17:55             ` Stephan Mueller
  0 siblings, 0 replies; 26+ messages in thread
From: Stephan Mueller @ 2015-06-23 17:55 UTC (permalink / raw)
  To: Guenter Roeck, Geert Uytterhoeven
  Cc: Herbert Xu, Peter Zijlstra, Andy Shevchenko, Jim Davis,
	Stephen Rothwell, Linux-Next, linux-kernel, David S. Miller,
	linux-crypto, Waiman Long, Ingo Molnar, x86

Am Dienstag, 23. Juni 2015, 10:41:03 schrieb Guenter Roeck:

Hi Guenter, Geert,

>On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
>> Hi Geert, Guenter,
>> 
>> may I ask that you check that the following patch compiles without errors
>> or warnings on your systems?
>No build failures for all architectures.

Thank you very much for your help.

Now, if Geert would be so kind and have a check on his OpenRISC to ensure that 
there are no compiler warnings, I would be happy.

Though, does anybody have any idea what the AVR32 compiler warning about 
crypto/builtin.o not being relaxable mean and whether that is an issue? Note, 
when I was compiling AVR32, I saw some of these warnings for other builtin.o 
too.

Ciao
Stephan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 14:18         ` Stephan Mueller
@ 2015-06-23 18:15           ` Geert Uytterhoeven
  -1 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-06-23 18:15 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Guenter Roeck, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

Hi Stephan,

On Tue, Jun 23, 2015 at 4:18 PM, Stephan Mueller <smueller@chronox.de> wrote:
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
>
> Though, when I test that patch with the AVR32 cross compiler, I get a warning about the code being not relaxable.
>
> Thank you very much.
>
> ---8<---
> The core of the Jitter RNG is intended to be compiled with -O0. To
> ensure that the Jitter RNG can be compiled on all architectures,
> separate out the RNG core into a stand-alone C file that can be compiled
> with -O0 which does not depend on any kernel include file.
>
> As no kernel includes can be used in the C file implementing the core
> RNG, any dependencies on kernel code must be extracted.
>
> A second file provides the link to the kernel and the kernel crypto API
> that can be compiled with the regular compile options of the kernel.
>
> Signed-off-by: Stephan Mueller <smueller@chronox.de>

Thanks, the warnings I saw before with m68k-linux-gnu-gcc-4.1.2
are gone.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-23 18:15           ` Geert Uytterhoeven
  0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-06-23 18:15 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Guenter Roeck, Herbert Xu, Peter Zijlstra, Andy Shevchenko,
	Jim Davis, Stephen Rothwell, Linux-Next, linux-kernel,
	David S. Miller, linux-crypto, Waiman Long, Ingo Molnar, x86

Hi Stephan,

On Tue, Jun 23, 2015 at 4:18 PM, Stephan Mueller <smueller@chronox.de> wrote:
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
>
> Though, when I test that patch with the AVR32 cross compiler, I get a warning about the code being not relaxable.
>
> Thank you very much.
>
> ---8<---
> The core of the Jitter RNG is intended to be compiled with -O0. To
> ensure that the Jitter RNG can be compiled on all architectures,
> separate out the RNG core into a stand-alone C file that can be compiled
> with -O0 which does not depend on any kernel include file.
>
> As no kernel includes can be used in the C file implementing the core
> RNG, any dependencies on kernel code must be extracted.
>
> A second file provides the link to the kernel and the kernel crypto API
> that can be compiled with the regular compile options of the kernel.
>
> Signed-off-by: Stephan Mueller <smueller@chronox.de>

Thanks, the warnings I saw before with m68k-linux-gnu-gcc-4.1.2
are gone.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 17:55             ` Stephan Mueller
@ 2015-06-23 23:18               ` Guenter Roeck
  -1 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2015-06-23 23:18 UTC (permalink / raw)
  To: Stephan Mueller, Geert Uytterhoeven
  Cc: Herbert Xu, Peter Zijlstra, Andy Shevchenko, Jim Davis,
	Stephen Rothwell, Linux-Next, linux-kernel, David S. Miller,
	linux-crypto, Waiman Long, Ingo Molnar, x86

On 06/23/2015 10:55 AM, Stephan Mueller wrote:
> Am Dienstag, 23. Juni 2015, 10:41:03 schrieb Guenter Roeck:
>
> Hi Guenter, Geert,
>
>> On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
>>> Hi Geert, Guenter,
>>>
>>> may I ask that you check that the following patch compiles without errors
>>> or warnings on your systems?
>> No build failures for all architectures.
>
> Thank you very much for your help.
>
> Now, if Geert would be so kind and have a check on his OpenRISC to ensure that
> there are no compiler warnings, I would be happy.
>
> Though, does anybody have any idea what the AVR32 compiler warning about
> crypto/builtin.o not being relaxable mean and whether that is an issue? Note,
> when I was compiling AVR32, I saw some of these warnings for other builtin.o
> too.
>

At least it compiles ;-). I don't think there is anything else we can do.

Guenter

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-23 23:18               ` Guenter Roeck
  0 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2015-06-23 23:18 UTC (permalink / raw)
  To: Stephan Mueller, Geert Uytterhoeven
  Cc: Herbert Xu, Peter Zijlstra, Andy Shevchenko, Jim Davis,
	Stephen Rothwell, Linux-Next, linux-kernel, David S. Miller,
	linux-crypto, Waiman Long, Ingo Molnar, x86

On 06/23/2015 10:55 AM, Stephan Mueller wrote:
> Am Dienstag, 23. Juni 2015, 10:41:03 schrieb Guenter Roeck:
>
> Hi Guenter, Geert,
>
>> On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
>>> Hi Geert, Guenter,
>>>
>>> may I ask that you check that the following patch compiles without errors
>>> or warnings on your systems?
>> No build failures for all architectures.
>
> Thank you very much for your help.
>
> Now, if Geert would be so kind and have a check on his OpenRISC to ensure that
> there are no compiler warnings, I would be happy.
>
> Though, does anybody have any idea what the AVR32 compiler warning about
> crypto/builtin.o not being relaxable mean and whether that is an issue? Note,
> when I was compiling AVR32, I saw some of these warnings for other builtin.o
> too.
>

At least it compiles ;-). I don't think there is anything else we can do.

Guenter


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
  2015-06-23 14:18         ` Stephan Mueller
@ 2015-06-25 15:37           ` Herbert Xu
  -1 siblings, 0 replies; 26+ messages in thread
From: Herbert Xu @ 2015-06-25 15:37 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Geert Uytterhoeven, Guenter Roeck, Peter Zijlstra,
	Andy Shevchenko, Jim Davis, Stephen Rothwell, Linux-Next,
	linux-kernel, David S. Miller, linux-crypto, Waiman Long,
	Ingo Molnar, x86

On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
> Hi Geert, Guenter,
> 
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
> 
> Though, when I test that patch with the AVR32 cross compiler, I get a warning about the code being not relaxable.
> 
> Thank you very much.
> 
> ---8<---
> The core of the Jitter RNG is intended to be compiled with -O0. To
> ensure that the Jitter RNG can be compiled on all architectures,
> separate out the RNG core into a stand-alone C file that can be compiled
> with -O0 which does not depend on any kernel include file.
> 
> As no kernel includes can be used in the C file implementing the core
> RNG, any dependencies on kernel code must be extracted.
> 
> A second file provides the link to the kernel and the kernel crypto API
> that can be compiled with the regular compile options of the kernel.
> 
> Signed-off-by: Stephan Mueller <smueller@chronox.de>

Applied.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] crypto: jitterentropy - avoid compiler warnings
@ 2015-06-25 15:37           ` Herbert Xu
  0 siblings, 0 replies; 26+ messages in thread
From: Herbert Xu @ 2015-06-25 15:37 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Geert Uytterhoeven, Guenter Roeck, Peter Zijlstra,
	Andy Shevchenko, Jim Davis, Stephen Rothwell, Linux-Next,
	linux-kernel, David S. Miller, linux-crypto, Waiman Long,
	Ingo Molnar, x86

On Tue, Jun 23, 2015 at 04:18:54PM +0200, Stephan Mueller wrote:
> Hi Geert, Guenter,
> 
> may I ask that you check that the following patch compiles without errors or warnings on your systems?
> 
> Though, when I test that patch with the AVR32 cross compiler, I get a warning about the code being not relaxable.
> 
> Thank you very much.
> 
> ---8<---
> The core of the Jitter RNG is intended to be compiled with -O0. To
> ensure that the Jitter RNG can be compiled on all architectures,
> separate out the RNG core into a stand-alone C file that can be compiled
> with -O0 which does not depend on any kernel include file.
> 
> As no kernel includes can be used in the C file implementing the core
> RNG, any dependencies on kernel code must be extracted.
> 
> A second file provides the link to the kernel and the kernel crypto API
> that can be compiled with the regular compile options of the kernel.
> 
> Signed-off-by: Stephan Mueller <smueller@chronox.de>

Applied.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2015-06-25 15:38 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-23  9:17 #pragma GCC warnings (was: Re: [PATCH] crypto: drbg - use pragmas for disabling optimization) Geert Uytterhoeven
2015-06-23  9:17 ` Geert Uytterhoeven
2015-06-23  9:21 ` Herbert Xu
2015-06-23  9:21   ` Herbert Xu
2015-06-23  9:45   ` Stephan Mueller
2015-06-23  9:45     ` Stephan Mueller
2015-06-23 13:01   ` Stephan Mueller
2015-06-23 13:01     ` Stephan Mueller
2015-06-23 13:17     ` Geert Uytterhoeven
2015-06-23 13:17       ` Geert Uytterhoeven
2015-06-23 14:18       ` [PATCH] crypto: jitterentropy - avoid compiler warnings Stephan Mueller
2015-06-23 14:18         ` Stephan Mueller
2015-06-23 15:31         ` Guenter Roeck
2015-06-23 15:31           ` Guenter Roeck
2015-06-23 15:36           ` Stephan Mueller
2015-06-23 15:36             ` Stephan Mueller
2015-06-23 17:41         ` Guenter Roeck
2015-06-23 17:41           ` Guenter Roeck
2015-06-23 17:55           ` Stephan Mueller
2015-06-23 17:55             ` Stephan Mueller
2015-06-23 23:18             ` Guenter Roeck
2015-06-23 23:18               ` Guenter Roeck
2015-06-23 18:15         ` Geert Uytterhoeven
2015-06-23 18:15           ` Geert Uytterhoeven
2015-06-25 15:37         ` Herbert Xu
2015-06-25 15:37           ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.