- Fixed for SPARC64

This commit is contained in:
Paul Bakker 2012-10-30 07:29:57 +00:00
parent df2bb75c28
commit 4f024b7ba9
2 changed files with 71 additions and 20 deletions

View File

@ -61,6 +61,7 @@ Bugfix
* mpi_add_abs() now correctly handles adding short numbers to long numbers * mpi_add_abs() now correctly handles adding short numbers to long numbers
with carry rollover (found by Ruslan Yushchenko) with carry rollover (found by Ruslan Yushchenko)
* Handle existence of OpenSSL Trust Extensions at end of X.509 DER blob * Handle existence of OpenSSL Trust Extensions at end of X.509 DER blob
* Fixed MPI assembly for SPARC64 platform
Security Security
* Fixed potential memory corruption on miscrafted client messages (found by * Fixed potential memory corruption on miscrafted client messages (found by

View File

@ -395,32 +395,82 @@
#endif /* PPC32 */ #endif /* PPC32 */
#endif /* PPC64 */ #endif /* PPC64 */
#if defined(__sparc__) #if defined(__sparc__) && defined(__sparc64__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "ld %0, %%o0 " :: "m" (s)); \ asm( \
asm( "ld %0, %%o1 " :: "m" (d)); \ " \
asm( "ld %0, %%o2 " :: "m" (c)); \ ldx %3, %%o0; \
asm( "ld %0, %%o3 " :: "m" (b)); ldx %4, %%o1; \
ld %5, %%o2; \
ld %6, %%o3; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "ld [%o0], %o4 " ); \ " \
asm( "inc 4, %o0 " ); \ ld [%%o0], %%o4; \
asm( "ld [%o1], %o5 " ); \ inc 4, %%o0; \
asm( "umul %o3, %o4, %o4 " ); \ ld [%%o1], %%o5; \
asm( "addcc %o4, %o2, %o4 " ); \ umul %%o3, %%o4, %%o4; \
asm( "rd %y, %g1 " ); \ addcc %%o4, %%o2, %%o4; \
asm( "addx %g1, 0, %g1 " ); \ rd %%y, %%g1; \
asm( "addcc %o4, %o5, %o4 " ); \ addx %%g1, 0, %%g1; \
asm( "st %o4, [%o1] " ); \ addcc %%o4, %%o5, %%o4; \
asm( "addx %g1, 0, %o2 " ); \ st %%o4, [%%o1]; \
asm( "inc 4, %o1 " ); addx %%g1, 0, %%o2; \
inc 4, %%o1; \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "st %%o2, %0 " : "=m" (c)); \ " \
asm( "st %%o1, %0 " : "=m" (d)); \ st %%o2, %0; \
asm( "st %%o0, %0 " : "=m" (s) :: \ stx %%o1, %1; \
"g1", "o0", "o1", "o2", "o3", "o4", "o5" ); stx %%o0, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "g1", "o0", "o1", "o2", "o3", "o4", \
"o5" \
);
#endif /* SPARCv9 */
#if defined(__sparc__) && !defined(__sparc64__)
#define MULADDC_INIT \
asm( \
" \
ld %3, %%o0; \
ld %4, %%o1; \
ld %5, %%o2; \
ld %6, %%o3; \
"
#define MULADDC_CORE \
" \
ld [%%o0], %%o4; \
inc 4, %%o0; \
ld [%%o1], %%o5; \
umul %%o3, %%o4, %%o4; \
addcc %%o4, %%o2, %%o4; \
rd %%y, %%g1; \
addx %%g1, 0, %%g1; \
addcc %%o4, %%o5, %%o4; \
st %%o4, [%%o1]; \
addx %%g1, 0, %%o2; \
inc 4, %%o1; \
"
#define MULADDC_STOP \
" \
st %%o2, %0; \
st %%o1, %1; \
st %%o0, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "g1", "o0", "o1", "o2", "o3", "o4", \
"o5" \
);
#endif /* SPARCv8 */ #endif /* SPARCv8 */