5 if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
7 $0 =~ m/(.*[\/\\])[^\
/\\]+$/; $dir=$1;
8 ( $xlate="${dir}x86_64-xlate.pl" and -f
$xlate ) or
9 ( $xlate="${dir}perlasm/x86_64-xlate.pl" and -f
$xlate) or
10 die "can't locate x86_64-xlate.pl";
12 open OUT
,"| \"$^X\" $xlate $flavour $output";
15 ($arg1,$arg2,$arg3,$arg4)=("%rdi","%rsi","%rdx","%rcx"); # Unix order
18 .extern OPENSSL_cpuid_setup
19 .hidden OPENSSL_cpuid_setup
21 call OPENSSL_cpuid_setup
23 .extern OPENSSL_ia32cap_P
24 .hidden OPENSSL_ia32cap_P
28 .globl OPENSSL_atomic_add
29 .type OPENSSL_atomic_add
,\
@abi-omnipotent
33 .Lspin
: leaq
($arg2,%rax),%r8
38 .byte
0x48,0x98 # cltq/cdqe
40 .size OPENSSL_atomic_add
,.-OPENSSL_atomic_add
42 .globl OPENSSL_ia32_cpuid
43 .type OPENSSL_ia32_cpuid
,\
@abi-omnipotent
46 mov
%rbx,%r8 # save %rbx
50 mov
%eax,%r11d # max value for standard query level
53 cmp \
$0x756e6547,%ebx # "Genu"
56 cmp \
$0x49656e69,%edx # "ineI"
59 cmp \
$0x6c65746e,%ecx # "ntel"
61 or %eax,%r9d # 0 indicates Intel CPU
64 cmp \
$0x68747541,%ebx # "Auth"
67 cmp \
$0x69746E65,%edx # "enti"
70 cmp \
$0x444D4163,%ecx # "cAMD"
72 or %eax,%r10d # 0 indicates AMD CPU
83 and \
$IA32CAP_MASK1_AMD_XOP,%r9d # isolate AMD XOP bit
84 or \
$1,%r9d # make sure %r9d is not zero
86 cmp \
$0x80000008,%r10d
91 movzb
%cl,%r10 # number of cores - 1
92 inc
%r10 # number of cores
96 bt \
$IA32CAP_BIT0_HT,%edx # test hyper-threading bit
98 shr \
$16,%ebx # number of logical processors
101 xor \
$IA32CAP_MASK0_HT,%edx
110 mov \
$0,%ecx # query L1D
114 and \
$0xfff,%r10d # number of cores -1 per L1D
119 # force reserved bits to 0
120 and \
$(~(IA32CAP_MASK0_INTELP4
| IA32CAP_MASK0_INTEL
)),%edx
123 # set reserved bit#30 on Intel CPUs
124 or \
$IA32CAP_MASK0_INTEL,%edx
126 cmp \
$15,%ah # examine Family ID
128 # set reserved bit#20 to engage RC4_CHAR
129 or \
$IA32CAP_MASK0_INTELP4,%edx
131 bt \
$IA32CAP_BIT0_HT,%edx # test hyper-threading bit
133 xor \
$IA32CAP_MASK0_HT,%edx
137 or \
$IA32CAP_MASK0_HT,%edx
139 cmp \
$1,%bl # see if cache is shared
141 xor \
$IA32CAP_MASK0_HT,%edx # clear hyper-threading bit if not
144 and \
$IA32CAP_MASK1_AMD_XOP,%r9d # isolate AMD XOP flag
145 and \
$(~IA32CAP_MASK1_AMD_XOP
),%ecx
146 or %ecx,%r9d # merge AMD XOP flag
148 mov
%edx,%r10d # %r9d:%r10d is copy of %ecx:%edx
149 bt \
$IA32CAP_BIT1_OSXSAVE,%r9d # check OSXSAVE bit
152 .byte
0x0f,0x01,0xd0 # xgetbv
153 and \
$6,%eax # isolate XMM and YMM state support
157 mov \
$(~(IA32CAP_MASK1_AVX
| IA32CAP_MASK1_FMA3
| IA32CAP_MASK1_AMD_XOP
)),%eax
158 and %eax,%r9d # clear AVX, FMA and AMD XOP bits
162 mov
%r8,%rbx # restore %rbx
165 .size OPENSSL_ia32_cpuid
,.-OPENSSL_ia32_cpuid
169 .globl OPENSSL_wipe_cpu
170 .type OPENSSL_wipe_cpu
,\
@abi-omnipotent
199 .size OPENSSL_wipe_cpu
,.-OPENSSL_wipe_cpu
202 close STDOUT
; # flush