summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x86_64cpuid.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/x86_64cpuid.pl')
-rw-r--r--src/lib/libcrypto/x86_64cpuid.pl161
1 files changed, 0 insertions, 161 deletions
diff --git a/src/lib/libcrypto/x86_64cpuid.pl b/src/lib/libcrypto/x86_64cpuid.pl
deleted file mode 100644
index 8946b464a8..0000000000
--- a/src/lib/libcrypto/x86_64cpuid.pl
+++ /dev/null
@@ -1,161 +0,0 @@
1#!/usr/bin/env perl
2
3$output=shift;
4$masm=1 if ($output =~ /\.asm/);
5open STDOUT,">$output" || die "can't open $output: $!";
6
7print<<___ if(defined($masm));
8_TEXT SEGMENT
9PUBLIC OPENSSL_rdtsc
10
11PUBLIC OPENSSL_atomic_add
12ALIGN 16
13OPENSSL_atomic_add PROC
14 mov eax,DWORD PTR[rcx]
15\$Lspin: lea r8,DWORD PTR[rdx+rax]
16lock cmpxchg DWORD PTR[rcx],r8d
17 jne \$Lspin
18 mov eax,r8d
19 cdqe
20 ret
21OPENSSL_atomic_add ENDP
22
23PUBLIC OPENSSL_wipe_cpu
24ALIGN 16
25OPENSSL_wipe_cpu PROC
26 pxor xmm0,xmm0
27 pxor xmm1,xmm1
28 pxor xmm2,xmm2
29 pxor xmm3,xmm3
30 pxor xmm4,xmm4
31 pxor xmm5,xmm5
32 xor rcx,rcx
33 xor rdx,rdx
34 xor r8,r8
35 xor r9,r9
36 xor r10,r10
37 xor r11,r11
38 lea rax,QWORD PTR[rsp+8]
39 ret
40OPENSSL_wipe_cpu ENDP
41_TEXT ENDS
42
43CRT\$XIU SEGMENT
44EXTRN OPENSSL_cpuid_setup:PROC
45DQ OPENSSL_cpuid_setup
46CRT\$XIU ENDS
47
48___
49print<<___ if(!defined($masm));
50#include <machine/asm.h>
51
52.text
53
54.globl OPENSSL_atomic_add
55.type OPENSSL_atomic_add,\@function
56.align 16
57OPENSSL_atomic_add:
58 movl (%rdi),%eax
59.Lspin: leaq (%rsi,%rax),%r8
60lock; cmpxchgl %r8d,(%rdi)
61 jne .Lspin
62 movl %r8d,%eax
63 .byte 0x48,0x98
64 ret
65.size OPENSSL_atomic_add,.-OPENSSL_atomic_add
66
67.globl OPENSSL_wipe_cpu
68.type OPENSSL_wipe_cpu,\@function
69.align 16
70OPENSSL_wipe_cpu:
71 pxor %xmm0,%xmm0
72 pxor %xmm1,%xmm1
73 pxor %xmm2,%xmm2
74 pxor %xmm3,%xmm3
75 pxor %xmm4,%xmm4
76 pxor %xmm5,%xmm5
77 pxor %xmm6,%xmm6
78 pxor %xmm7,%xmm7
79 pxor %xmm8,%xmm8
80 pxor %xmm9,%xmm9
81 pxor %xmm10,%xmm10
82 pxor %xmm11,%xmm11
83 pxor %xmm12,%xmm12
84 pxor %xmm13,%xmm13
85 pxor %xmm14,%xmm14
86 pxor %xmm15,%xmm15
87 xorq %rcx,%rcx
88 xorq %rdx,%rdx
89 xorq %rsi,%rsi
90 xorq %rdi,%rdi
91 xorq %r8,%r8
92 xorq %r9,%r9
93 xorq %r10,%r10
94 xorq %r11,%r11
95 leaq 8(%rsp),%rax
96 ret
97.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
98
99.section .init
100 call PIC_PLT(OPENSSL_cpuid_setup)
101
102___
103
104open STDOUT,"| $^X perlasm/x86_64-xlate.pl $output";
105print<<___;
106.text
107
108.globl OPENSSL_rdtsc
109.type OPENSSL_rdtsc,\@abi-omnipotent
110.align 16
111OPENSSL_rdtsc:
112 rdtsc
113 shl \$32,%rdx
114 or %rdx,%rax
115 ret
116.size OPENSSL_rdtsc,.-OPENSSL_rdtsc
117
118.globl OPENSSL_ia32_cpuid
119.type OPENSSL_ia32_cpuid,\@abi-omnipotent
120.align 16
121OPENSSL_ia32_cpuid:
122 mov %rbx,%r8
123
124 xor %eax,%eax
125 cpuid
126 xor %eax,%eax
127 cmp \$0x756e6547,%ebx # "Genu"
128 setne %al
129 mov %eax,%r9d
130 cmp \$0x49656e69,%edx # "ineI"
131 setne %al
132 or %eax,%r9d
133 cmp \$0x6c65746e,%ecx # "ntel"
134 setne %al
135 or %eax,%r9d
136
137 mov \$1,%eax
138 cpuid
139 cmp \$0,%r9d
140 jne .Lnotintel
141 or \$0x00100000,%edx # use reserved 20th bit to engage RC4_CHAR
142 and \$15,%ah
143 cmp \$15,%ah # examine Family ID
144 je .Lnotintel
145 or \$0x40000000,%edx # use reserved bit to skip unrolled loop
146.Lnotintel:
147 bt \$28,%edx # test hyper-threading bit
148 jnc .Ldone
149 shr \$16,%ebx
150 cmp \$1,%bl # see if cache is shared
151 ja .Ldone
152 and \$0xefffffff,%edx # ~(1<<28)
153.Ldone:
154 shl \$32,%rcx
155 mov %edx,%eax
156 mov %r8,%rbx
157 or %rcx,%rax
158 ret
159.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
160___
161close STDOUT; # flush