Skip to content

Commit

Permalink
generated asm should properly exclude when using old assembler
Browse files Browse the repository at this point in the history
  • Loading branch information
pittma committed Sep 9, 2024
1 parent 56d8fd6 commit f925e7c
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 24 deletions.
16 changes: 12 additions & 4 deletions crypto/fipsmodule/bn/asm/rsaz-2k-avx512.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@

###############################################################################
# void rsaz_amm52x20_x1_ifma256(BN_ULONG *res,
# const BN_ULONG *a,
# const BN_ULONG *b,
# const BN_ULONG *m,
# BN_ULONG k0);
# const BN_ULONG *a,
# const BN_ULONG *b,
# const BN_ULONG *m,
# BN_ULONG k0);
###############################################################################
{
# input parameters
Expand Down Expand Up @@ -289,6 +289,7 @@ sub amm52x20_x1_norm {
}

$code.=<<___;
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text
.globl rsaz_amm52x20_x1_ifma256
Expand Down Expand Up @@ -675,8 +676,13 @@ sub amm52x20_x1_norm {
.byte 9,0,0,0
.rva rsaz_def_handler
.rva .Lrsaz_amm52x20_x2_ifma256_body,.Lrsaz_amm52x20_x2_ifma256_epilogue
#endif
___
} else {
$code.="#endif";
}

}}} else {{{ # fallback for old assembler
$code.=<<___;
.text
Expand All @@ -690,6 +696,8 @@ sub amm52x20_x1_norm {
.byte 0x0f,0x0b # ud2
ret
.size rsaz_amm52x20_x1_ifma256, .-rsaz_amm52x20_x1_ifma256
#endif
___
}}}

Expand Down
28 changes: 18 additions & 10 deletions crypto/fipsmodule/bn/asm/rsaz-3k-avx512.pl
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@

###############################################################################
# void rsaz_amm52x30_x1_ifma256(BN_ULONG *res,
# const BN_ULONG *a,
# const BN_ULONG *b,
# const BN_ULONG *m,
# BN_ULONG k0);
# const BN_ULONG *a,
# const BN_ULONG *b,
# const BN_ULONG *m,
# BN_ULONG k0);
###############################################################################
{
# input parameters
Expand Down Expand Up @@ -352,6 +352,7 @@ sub amm52x30_x1_norm {
}

$code.=<<___;
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text
.globl rsaz_amm52x30_x1_ifma256
Expand Down Expand Up @@ -484,10 +485,10 @@ sub amm52x30_x1_norm {

###############################################################################
# void rsaz_amm52x30_x2_ifma256(BN_ULONG out[2][32],
# const BN_ULONG a[2][32],
# const BN_ULONG b[2][32],
# const BN_ULONG m[2][32],
# const BN_ULONG k0[2]);
# const BN_ULONG a[2][32],
# const BN_ULONG b[2][32],
# const BN_ULONG m[2][32],
# const BN_ULONG k0[2]);
###############################################################################

$code.=<<___;
Expand Down Expand Up @@ -630,8 +631,8 @@ sub amm52x30_x1_norm {

###############################################################################
# void extract_multiplier_2x30_win5(BN_ULONG *red_Y,
# const BN_ULONG red_table[1 << EXP_WIN_SIZE][2][32],
# int red_table_idx1, int red_table_idx2);
# const BN_ULONG red_table[1 << EXP_WIN_SIZE][2][32],
# int red_table_idx1, int red_table_idx2);
#
###############################################################################
{
Expand Down Expand Up @@ -829,8 +830,13 @@ sub amm52x30_x1_norm {
.byte 9,0,0,0
.rva rsaz_avx_handler
.rva .Lrsaz_amm52x30_x2_ifma256_body,.Lrsaz_amm52x30_x2_ifma256_epilogue
#endif
___
} else {
$code.="#endif";
}

}}} else {{{ # fallback for old assembler
$code.=<<___;
.text
Expand All @@ -845,6 +851,8 @@ sub amm52x30_x1_norm {
.byte 0x0f,0x0b # ud2
ret
.size rsaz_amm52x30_x1_ifma256, .-rsaz_amm52x30_x1_ifma256
#endif
___
}}}

Expand Down
28 changes: 18 additions & 10 deletions crypto/fipsmodule/bn/asm/rsaz-4k-avx512.pl
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@

###############################################################################
# void rsaz_amm52x40_x1_ifma256(BN_ULONG *res,
# const BN_ULONG *a,
# const BN_ULONG *b,
# const BN_ULONG *m,
# BN_ULONG k0);
# const BN_ULONG *a,
# const BN_ULONG *b,
# const BN_ULONG *m,
# BN_ULONG k0);
###############################################################################
{
# input parameters
Expand Down Expand Up @@ -394,6 +394,7 @@ sub amm52x40_x1_norm {
}

$code.=<<___;
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text
.globl rsaz_amm52x40_x1_ifma256
Expand Down Expand Up @@ -528,10 +529,10 @@ sub amm52x40_x1_norm {

###############################################################################
# void rsaz_amm52x40_x2_ifma256(BN_ULONG out[2][40],
# const BN_ULONG a[2][40],
# const BN_ULONG b[2][40],
# const BN_ULONG m[2][40],
# const BN_ULONG k0[2]);
# const BN_ULONG a[2][40],
# const BN_ULONG b[2][40],
# const BN_ULONG m[2][40],
# const BN_ULONG k0[2]);
###############################################################################

$code.=<<___;
Expand Down Expand Up @@ -682,8 +683,8 @@ sub amm52x40_x1_norm {

###############################################################################
# void extract_multiplier_2x40_win5(BN_ULONG *red_Y,
# const BN_ULONG red_table[1 << EXP_WIN_SIZE][2][40],
# int red_table_idx1, int red_table_idx2);
# const BN_ULONG red_table[1 << EXP_WIN_SIZE][2][40],
# int red_table_idx1, int red_table_idx2);
#
###############################################################################
{
Expand Down Expand Up @@ -891,8 +892,13 @@ ()
.byte 9,0,0,0
.rva rsaz_avx_handler
.rva .Lrsaz_amm52x40_x2_ifma256_body,.Lrsaz_amm52x40_x2_ifma256_epilogue
#endif
___
} else {
$code.="#endif";
}

}}} else {{{ # fallback for old assembler
$code.=<<___;
.text
Expand All @@ -907,6 +913,8 @@ ()
.byte 0x0f,0x0b # ud2
ret
.size rsaz_amm52x40_x1_ifma256, .-rsaz_amm52x40_x1_ifma256
#endif
___
}}}

Expand Down
2 changes: 2 additions & 0 deletions generated-src/linux-x86_64/crypto/fipsmodule/rsaz-2k-avx512.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <openssl/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__)
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text

.globl rsaz_amm52x20_x1_ifma256
Expand Down Expand Up @@ -893,3 +894,4 @@ extract_multiplier_2x20_win5:
.quad 0,0,0,0
.text
#endif
#endif
2 changes: 2 additions & 0 deletions generated-src/linux-x86_64/crypto/fipsmodule/rsaz-3k-avx512.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <openssl/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__)
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text

.globl rsaz_amm52x30_x1_ifma256
Expand Down Expand Up @@ -1320,3 +1321,4 @@ extract_multiplier_2x30_win5:
.quad 0,0,0,0
.text
#endif
#endif
2 changes: 2 additions & 0 deletions generated-src/linux-x86_64/crypto/fipsmodule/rsaz-4k-avx512.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <openssl/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__)
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text

.globl rsaz_amm52x40_x1_ifma256
Expand Down Expand Up @@ -1363,3 +1364,4 @@ extract_multiplier_2x40_win5:
.quad 0,0,0,0
.text
#endif
#endif
2 changes: 2 additions & 0 deletions generated-src/mac-x86_64/crypto/fipsmodule/rsaz-2k-avx512.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <openssl/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__)
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text

.globl _rsaz_amm52x20_x1_ifma256
Expand Down Expand Up @@ -881,3 +882,4 @@ L$zeros:
.quad 0,0,0,0
.text
#endif
#endif
2 changes: 2 additions & 0 deletions generated-src/mac-x86_64/crypto/fipsmodule/rsaz-3k-avx512.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <openssl/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__)
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text

.globl _rsaz_amm52x30_x1_ifma256
Expand Down Expand Up @@ -1308,3 +1309,4 @@ L$zeros:
.quad 0,0,0,0
.text
#endif
#endif
2 changes: 2 additions & 0 deletions generated-src/mac-x86_64/crypto/fipsmodule/rsaz-4k-avx512.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <openssl/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__)
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text

.globl _rsaz_amm52x40_x1_ifma256
Expand Down Expand Up @@ -1351,3 +1352,4 @@ L$zeros:
.quad 0,0,0,0
.text
#endif
#endif
3 changes: 3 additions & 0 deletions generated-src/win-x86_64/crypto/fipsmodule/rsaz-2k-avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ default rel
%define _CET_ENDBR

%include "openssl/boringssl_prefix_symbols_nasm.inc"
%ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
section .text code align=64


Expand Down Expand Up @@ -1021,6 +1022,8 @@ $L$SEH_info_rsaz_amm52x20_x2_ifma256:
DB 9,0,0,0
DD rsaz_def_handler wrt ..imagebase
DD $L$rsaz_amm52x20_x2_ifma256_body wrt ..imagebase,$L$rsaz_amm52x20_x2_ifma256_epilogue wrt ..imagebase

%endif
%else
; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738
ret
Expand Down
3 changes: 3 additions & 0 deletions generated-src/win-x86_64/crypto/fipsmodule/rsaz-3k-avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ default rel
%define _CET_ENDBR

%include "openssl/boringssl_prefix_symbols_nasm.inc"
%ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
section .text code align=64


Expand Down Expand Up @@ -1499,6 +1500,8 @@ $L$SEH_info_rsaz_amm52x30_x2_ifma256:
DB 9,0,0,0
DD rsaz_avx_handler wrt ..imagebase
DD $L$rsaz_amm52x30_x2_ifma256_body wrt ..imagebase,$L$rsaz_amm52x30_x2_ifma256_epilogue wrt ..imagebase

%endif
%else
; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738
ret
Expand Down
3 changes: 3 additions & 0 deletions generated-src/win-x86_64/crypto/fipsmodule/rsaz-4k-avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ default rel
%define _CET_ENDBR

%include "openssl/boringssl_prefix_symbols_nasm.inc"
%ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
section .text code align=64


Expand Down Expand Up @@ -1542,6 +1543,8 @@ $L$SEH_info_rsaz_amm52x40_x2_ifma256:
DB 9,0,0,0
DD rsaz_avx_handler wrt ..imagebase
DD $L$rsaz_amm52x40_x2_ifma256_body wrt ..imagebase,$L$rsaz_amm52x40_x2_ifma256_epilogue wrt ..imagebase

%endif
%else
; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738
ret
Expand Down

0 comments on commit f925e7c

Please sign in to comment.