diff options
author | Rafaël Carré <funman@videolan.org> | 2012-04-20 13:52:01 -0400 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2012-06-21 10:36:05 +0200 |
commit | baf0dc7e9c26167ab43ba2adebcf2f1abc9d9b3b (patch) | |
tree | e431af69640ffa9808127347bfc717ffb48dae2b /random | |
parent | 39c123b729a472ace039f8536d07f8b9a5f4675a (diff) | |
download | libgcrypt-baf0dc7e9c26167ab43ba2adebcf2f1abc9d9b3b.tar.gz |
Enable VIA Padlock on x86_64 platforms
* cipher/rijndael.c: Duplicate x86 assembly and convert to x86_64.
* random/rndhw.c: Likewise.
* src/hwfeatures.c: Likewise.
--
Changes made to the x86 assembly:
- *l -> *q (long -> quad)
- e** registers -> r** registers (use widest registers available)
- don't mess with ebx GOT register
Tested with make check on VIA Nano X2 L4350
Signed-off-by: Rafaël Carré <funman@videolan.org>
Diffstat (limited to 'random')
-rw-r--r-- | random/rndhw.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/random/rndhw.c b/random/rndhw.c index 82faab45..c933cf90 100644 --- a/random/rndhw.c +++ b/random/rndhw.c @@ -27,7 +27,7 @@ #undef USE_PADLOCK #ifdef ENABLE_PADLOCK_SUPPORT -# if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && defined (__GNUC__) +# if ( (defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4) || defined(__x86_64__) ) && defined (__GNUC__) # define USE_PADLOCK # endif #endif /*ENABLE_PADLOCK_SUPPORT*/ @@ -55,6 +55,16 @@ poll_padlock (void (*add)(const void*, size_t, enum random_origins), nbytes = 0; while (nbytes < 64) { +#ifdef __x86_64__ + asm volatile + ("movq %1, %%rdi\n\t" /* Set buffer. */ + "xorq %%rdx, %%rdx\n\t" /* Request up to 8 bytes. */ + ".byte 0x0f, 0xa7, 0xc0\n\t" /* XSTORE RNG. */ + : "=a" (status) + : "g" (p) + : "%rdx", "%rdi", "cc" + ); +#else asm volatile ("movl %1, %%edi\n\t" /* Set buffer. */ "xorl %%edx, %%edx\n\t" /* Request up to 8 bytes. */ @@ -63,6 +73,7 @@ poll_padlock (void (*add)(const void*, size_t, enum random_origins), : "g" (p) : "%edx", "%edi", "cc" ); +#endif if ((status & (1<<6)) /* RNG still enabled. */ && !(status & (1<<13)) /* von Neumann corrector is enabled. */ && !(status & (1<<14)) /* String filter is disabled. */ |