5 if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
7 $win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
9 $0 =~ m/(.*[\/\\])[^\
/\\]+$/; $dir=$1;
10 ( $xlate="${dir}x86_64-xlate.pl" and -f
$xlate ) or
11 ( $xlate="${dir}perlasm/x86_64-xlate.pl" and -f
$xlate) or
12 die "can't locate x86_64-xlate.pl";
14 open OUT
,"| \"$^X\" $xlate $flavour $output";
17 ($arg1,$arg2,$arg3,$arg4)=$win64?
("%rcx","%rdx","%r8", "%r9") : # Win64 order
18 ("%rdi","%rsi","%rdx","%rcx"); # Unix order
21 .extern OPENSSL_cpuid_setup
22 .hidden OPENSSL_cpuid_setup
24 call OPENSSL_cpuid_setup
26 .hidden OPENSSL_ia32cap_P
27 .comm OPENSSL_ia32cap_P
,8,4
31 .globl OPENSSL_atomic_add
32 .type OPENSSL_atomic_add
,\
@abi-omnipotent
36 .Lspin
: leaq
($arg2,%rax),%r8
41 .byte
0x48,0x98 # cltq/cdqe
43 .size OPENSSL_atomic_add
,.-OPENSSL_atomic_add
46 .type OPENSSL_rdtsc
,\
@abi-omnipotent
53 .size OPENSSL_rdtsc
,.-OPENSSL_rdtsc
55 .globl OPENSSL_ia32_cpuid
56 .type OPENSSL_ia32_cpuid
,\
@abi-omnipotent
59 mov
%rbx,%r8 # save %rbx
63 mov
%eax,%r11d # max value for standard query level
66 cmp \
$0x756e6547,%ebx # "Genu"
69 cmp \
$0x49656e69,%edx # "ineI"
72 cmp \
$0x6c65746e,%ecx # "ntel"
74 or %eax,%r9d # 0 indicates Intel CPU
77 cmp \
$0x68747541,%ebx # "Auth"
80 cmp \
$0x69746E65,%edx # "enti"
83 cmp \
$0x444D4163,%ecx # "cAMD"
85 or %eax,%r10d # 0 indicates AMD CPU
97 and \
$0x00000801,%r9d # isolate AMD XOP bit, 1<<11
99 cmp \
$0x80000008,%r10d
102 mov \
$0x80000008,%eax
104 movzb
%cl,%r10 # number of cores - 1
105 inc
%r10 # number of cores
109 bt \
$28,%edx # test hyper-threading bit
111 shr \
$16,%ebx # number of logical processors
114 and \
$0xefffffff,%edx # ~(1<<28)
123 mov \
$0,%ecx # query L1D
127 and \
$0xfff,%r10d # number of cores -1 per L1D
132 and \
$0xbfefffff,%edx # force reserved bits to 0
135 or \
$0x40000000,%edx # set reserved bit#30 on Intel CPUs
137 cmp \
$15,%ah # examine Family ID
139 or \
$0x00100000,%edx # set reserved bit#20 to engage RC4_CHAR
141 bt \
$28,%edx # test hyper-threading bit
143 and \
$0xefffffff,%edx # ~(1<<28)
147 or \
$0x10000000,%edx # 1<<28
149 cmp \
$1,%bl # see if cache is shared
151 and \
$0xefffffff,%edx # ~(1<<28)
153 and \
$0x00000800,%r9d # isolate AMD XOP flag
154 and \
$0xfffff7ff,%ecx
155 or %ecx,%r9d # merge AMD XOP flag
157 mov
%edx,%r10d # %r9d:%r10d is copy of %ecx:%edx
158 bt \
$27,%r9d # check OSXSAVE bit
161 .byte
0x0f,0x01,0xd0 # xgetbv
162 and \
$6,%eax # isolate XMM and YMM state support
166 mov \
$0xefffe7ff,%eax # ~(1<<28|1<<12|1<<11)
167 and %eax,%r9d # clear AVX, FMA and AMD XOP bits
171 mov
%r8,%rbx # restore %rbx
174 .size OPENSSL_ia32_cpuid
,.-OPENSSL_ia32_cpuid
176 .globl OPENSSL_cleanse
177 .type OPENSSL_cleanse
,\
@abi-omnipotent
209 .size OPENSSL_cleanse
,.-OPENSSL_cleanse
212 print<<___
if (!$win64);
213 .globl OPENSSL_wipe_cpu
214 .type OPENSSL_wipe_cpu
,\
@abi-omnipotent
243 .size OPENSSL_wipe_cpu
,.-OPENSSL_wipe_cpu
245 print<<___
if ($win64);
246 .globl OPENSSL_wipe_cpu
247 .type OPENSSL_wipe_cpu
,\
@abi-omnipotent
264 .size OPENSSL_wipe_cpu
,.-OPENSSL_wipe_cpu
268 .globl OPENSSL_ia32_rdrand
269 .type OPENSSL_ia32_rdrand
,\
@abi-omnipotent
281 .size OPENSSL_ia32_rdrand
,.-OPENSSL_ia32_rdrand
284 close STDOUT
; # flush