~andersk/ubuntu/oneiric/openssl/spurious-reboot

« back to all changes in this revision

Viewing changes to crypto/x86_64cpuid.pl

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-05-01 23:51:53 UTC
  • mfrom: (11.1.20 sid)
  • Revision ID: james.westby@ubuntu.com-20110501235153-bjcxitndquaezb68
Tags: 1.0.0d-2ubuntu1
* Resynchronise with Debian (LP: #675566).  Remaining changes:
  - debian/libssl1.0.0.postinst:
    + Display a system restart required notification bubble on libssl1.0.0
      upgrade.
    + Use a different priority for libssl1.0.0/restart-services depending
      on whether a desktop, or server dist-upgrade is being performed.
  - debian/{libssl1.0.0-udeb.dirs, control, rules}: Create
    libssl1.0.0-udeb, for the benefit of wget-udeb (no wget-udeb package
    in Debian).
  - debian/{libcrypto1.0.0-udeb.dirs, libssl1.0.0.dirs, libssl1.0.0.files,
    rules}: Move runtime libraries to /lib, for the benefit of
    wpasupplicant.
  - debian/patches/aesni.patch: Backport Intel AES-NI support, now from
    http://rt.openssl.org/Ticket/Display.html?id=2065 rather than the
    0.9.8 variant.
  - debian/patches/Bsymbolic-functions.patch: Link using
    -Bsymbolic-functions.
  - debian/patches/perlpath-quilt.patch: Don't change perl #! paths under
    .pc.
  - debian/rules:
    + Don't run 'make test' when cross-building.
    + Use host compiler when cross-building.  Patch from Neil Williams.
    + Don't build for processors no longer supported: i486, i586 (on
      i386), v8 (on sparc).
    + Fix Makefile to properly clean up libs/ dirs in clean target.
    + Replace duplicate files in the doc directory with symlinks.
* Update architectures affected by Bsymbolic-functions.patch.
* Drop debian/patches/no-sslv2.patch; Debian now adds the 'no-ssl2'
  configure option, which compiles out SSLv2 support entirely, so this is
  no longer needed.
* Drop openssl-doc in favour of the libssl-doc package introduced by
  Debian.  Add Conflicts/Replaces until the next LTS release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
$output=shift;
4
 
$masm=1 if ($output =~ /\.asm/);
5
 
open STDOUT,">$output" || die "can't open $output: $!";
6
 
 
7
 
print<<___ if(defined($masm));
8
 
_TEXT   SEGMENT
9
 
PUBLIC  OPENSSL_rdtsc
10
 
 
11
 
PUBLIC  OPENSSL_atomic_add
12
 
ALIGN   16
13
 
OPENSSL_atomic_add      PROC
14
 
        mov     eax,DWORD PTR[rcx]
15
 
\$Lspin:        lea     r8,DWORD PTR[rdx+rax]
16
 
lock    cmpxchg DWORD PTR[rcx],r8d
17
 
        jne     \$Lspin
18
 
        mov     eax,r8d
19
 
        cdqe    
20
 
        ret
21
 
OPENSSL_atomic_add      ENDP
22
 
 
23
 
PUBLIC  OPENSSL_wipe_cpu
24
 
ALIGN   16
25
 
OPENSSL_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
40
 
OPENSSL_wipe_cpu        ENDP
41
 
_TEXT   ENDS
42
 
 
43
 
CRT\$XIU        SEGMENT
44
 
EXTRN   OPENSSL_cpuid_setup:PROC
45
 
DQ      OPENSSL_cpuid_setup
46
 
CRT\$XIU        ENDS
47
 
 
48
 
___
49
 
print<<___ if(!defined($masm));
50
 
.text
51
 
 
52
 
.globl  OPENSSL_atomic_add
53
 
.type   OPENSSL_atomic_add,\@function
54
 
.align  16
55
 
OPENSSL_atomic_add:
56
 
        movl    (%rdi),%eax
57
 
.Lspin: leaq    (%rsi,%rax),%r8
58
 
lock;   cmpxchgl        %r8d,(%rdi)
59
 
        jne     .Lspin
60
 
        movl    %r8d,%eax
61
 
        .byte   0x48,0x98
62
 
        ret
63
 
.size   OPENSSL_atomic_add,.-OPENSSL_atomic_add
64
 
 
65
 
.globl  OPENSSL_wipe_cpu
66
 
.type   OPENSSL_wipe_cpu,\@function
67
 
.align  16
68
 
OPENSSL_wipe_cpu:
69
 
        pxor    %xmm0,%xmm0
70
 
        pxor    %xmm1,%xmm1
71
 
        pxor    %xmm2,%xmm2
72
 
        pxor    %xmm3,%xmm3
73
 
        pxor    %xmm4,%xmm4
74
 
        pxor    %xmm5,%xmm5
75
 
        pxor    %xmm6,%xmm6
76
 
        pxor    %xmm7,%xmm7
77
 
        pxor    %xmm8,%xmm8
78
 
        pxor    %xmm9,%xmm9
79
 
        pxor    %xmm10,%xmm10
80
 
        pxor    %xmm11,%xmm11
81
 
        pxor    %xmm12,%xmm12
82
 
        pxor    %xmm13,%xmm13
83
 
        pxor    %xmm14,%xmm14
84
 
        pxor    %xmm15,%xmm15
85
 
        xorq    %rcx,%rcx
86
 
        xorq    %rdx,%rdx
87
 
        xorq    %rsi,%rsi
88
 
        xorq    %rdi,%rdi
89
 
        xorq    %r8,%r8
90
 
        xorq    %r9,%r9
91
 
        xorq    %r10,%r10
92
 
        xorq    %r11,%r11
93
 
        leaq    8(%rsp),%rax
94
 
        ret
95
 
.size   OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
96
 
 
 
1
#!/usr/bin/env perl
 
2
 
 
3
$flavour = shift;
 
4
$output  = shift;
 
5
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
 
6
 
 
7
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
 
8
 
 
9
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 
10
open STDOUT,"| $^X ${dir}perlasm/x86_64-xlate.pl $flavour $output";
 
11
 
 
12
if ($win64)     { $arg1="%rcx"; $arg2="%rdx"; }
 
13
else            { $arg1="%rdi"; $arg2="%rsi"; }
 
14
print<<___;
 
15
.extern         OPENSSL_cpuid_setup
97
16
.section        .init
98
17
#ifdef OPENSSL_PIC
99
18
        call    OPENSSL_cpuid_setup\@PLT
101
20
        call    OPENSSL_cpuid_setup
102
21
#endif
103
22
 
104
 
___
105
 
 
106
 
open STDOUT,"| $^X perlasm/x86_64-xlate.pl $output";
107
 
print<<___;
108
23
.text
109
24
 
 
25
.globl  OPENSSL_atomic_add
 
26
.type   OPENSSL_atomic_add,\@abi-omnipotent
 
27
.align  16
 
28
OPENSSL_atomic_add:
 
29
        movl    ($arg1),%eax
 
30
.Lspin: leaq    ($arg2,%rax),%r8
 
31
        .byte   0xf0            # lock
 
32
        cmpxchgl        %r8d,($arg1)
 
33
        jne     .Lspin
 
34
        movl    %r8d,%eax
 
35
        .byte   0x48,0x98       # cltq/cdqe
 
36
        ret
 
37
.size   OPENSSL_atomic_add,.-OPENSSL_atomic_add
 
38
 
110
39
.globl  OPENSSL_rdtsc
111
40
.type   OPENSSL_rdtsc,\@abi-omnipotent
112
41
.align  16
125
54
 
126
55
        xor     %eax,%eax
127
56
        cpuid
 
57
        mov     %eax,%r11d              # max value for standard query level
 
58
 
128
59
        xor     %eax,%eax
129
60
        cmp     \$0x756e6547,%ebx       # "Genu"
130
61
        setne   %al
134
65
        or      %eax,%r9d
135
66
        cmp     \$0x6c65746e,%ecx       # "ntel"
136
67
        setne   %al
137
 
        or      %eax,%r9d
138
 
 
 
68
        or      %eax,%r9d               # 0 indicates Intel CPU
 
69
        jz      .Lintel
 
70
 
 
71
        cmp     \$0x68747541,%ebx       # "Auth"
 
72
        setne   %al
 
73
        mov     %eax,%r10d
 
74
        cmp     \$0x69746E65,%edx       # "enti"
 
75
        setne   %al
 
76
        or      %eax,%r10d
 
77
        cmp     \$0x444D4163,%ecx       # "cAMD"
 
78
        setne   %al
 
79
        or      %eax,%r10d              # 0 indicates AMD CPU
 
80
        jnz     .Lintel
 
81
 
 
82
        # AMD specific
 
83
        mov     \$0x80000000,%eax
 
84
        cpuid
 
85
        cmp     \$0x80000008,%eax
 
86
        jb      .Lintel
 
87
 
 
88
        mov     \$0x80000008,%eax
 
89
        cpuid
 
90
        movzb   %cl,%r10                # number of cores - 1
 
91
        inc     %r10                    # number of cores
 
92
 
 
93
        mov     \$1,%eax
 
94
        cpuid
 
95
        bt      \$28,%edx               # test hyper-threading bit
 
96
        jnc     .Ldone
 
97
        shr     \$16,%ebx               # number of logical processors
 
98
        cmp     %r10b,%bl
 
99
        ja      .Ldone
 
100
        and     \$0xefffffff,%edx       # ~(1<<28)
 
101
        jmp     .Ldone
 
102
 
 
103
.Lintel:
 
104
        cmp     \$4,%r11d
 
105
        mov     \$-1,%r10d
 
106
        jb      .Lnocacheinfo
 
107
 
 
108
        mov     \$4,%eax
 
109
        mov     \$0,%ecx                # query L1D
 
110
        cpuid
 
111
        mov     %eax,%r10d
 
112
        shr     \$14,%r10d
 
113
        and     \$0xfff,%r10d           # number of cores -1 per L1D
 
114
 
 
115
.Lnocacheinfo:
139
116
        mov     \$1,%eax
140
117
        cpuid
141
118
        cmp     \$0,%r9d
148
125
.Lnotintel:
149
126
        bt      \$28,%edx               # test hyper-threading bit
150
127
        jnc     .Ldone
 
128
        and     \$0xefffffff,%edx       # ~(1<<28)
 
129
        cmp     \$0,%r10d
 
130
        je      .Ldone
 
131
 
 
132
        or      \$0x10000000,%edx       # 1<<28
151
133
        shr     \$16,%ebx
152
134
        cmp     \$1,%bl                 # see if cache is shared
153
135
        ja      .Ldone
159
141
        or      %rcx,%rax
160
142
        ret
161
143
.size   OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
162
 
___
 
144
 
 
145
.globl  OPENSSL_cleanse
 
146
.type   OPENSSL_cleanse,\@abi-omnipotent
 
147
.align  16
 
148
OPENSSL_cleanse:
 
149
        xor     %rax,%rax
 
150
        cmp     \$15,$arg2
 
151
        jae     .Lot
 
152
        cmp     \$0,$arg2
 
153
        je      .Lret
 
154
.Little:
 
155
        mov     %al,($arg1)
 
156
        sub     \$1,$arg2
 
157
        lea     1($arg1),$arg1
 
158
        jnz     .Little
 
159
.Lret:
 
160
        ret
 
161
.align  16
 
162
.Lot:
 
163
        test    \$7,$arg1
 
164
        jz      .Laligned
 
165
        mov     %al,($arg1)
 
166
        lea     -1($arg2),$arg2
 
167
        lea     1($arg1),$arg1
 
168
        jmp     .Lot
 
169
.Laligned:
 
170
        mov     %rax,($arg1)
 
171
        lea     -8($arg2),$arg2
 
172
        test    \$-8,$arg2
 
173
        lea     8($arg1),$arg1
 
174
        jnz     .Laligned
 
175
        cmp     \$0,$arg2
 
176
        jne     .Little
 
177
        ret
 
178
.size   OPENSSL_cleanse,.-OPENSSL_cleanse
 
179
___
 
180
 
 
181
print<<___ if (!$win64);
 
182
.globl  OPENSSL_wipe_cpu
 
183
.type   OPENSSL_wipe_cpu,\@abi-omnipotent
 
184
.align  16
 
185
OPENSSL_wipe_cpu:
 
186
        pxor    %xmm0,%xmm0
 
187
        pxor    %xmm1,%xmm1
 
188
        pxor    %xmm2,%xmm2
 
189
        pxor    %xmm3,%xmm3
 
190
        pxor    %xmm4,%xmm4
 
191
        pxor    %xmm5,%xmm5
 
192
        pxor    %xmm6,%xmm6
 
193
        pxor    %xmm7,%xmm7
 
194
        pxor    %xmm8,%xmm8
 
195
        pxor    %xmm9,%xmm9
 
196
        pxor    %xmm10,%xmm10
 
197
        pxor    %xmm11,%xmm11
 
198
        pxor    %xmm12,%xmm12
 
199
        pxor    %xmm13,%xmm13
 
200
        pxor    %xmm14,%xmm14
 
201
        pxor    %xmm15,%xmm15
 
202
        xorq    %rcx,%rcx
 
203
        xorq    %rdx,%rdx
 
204
        xorq    %rsi,%rsi
 
205
        xorq    %rdi,%rdi
 
206
        xorq    %r8,%r8
 
207
        xorq    %r9,%r9
 
208
        xorq    %r10,%r10
 
209
        xorq    %r11,%r11
 
210
        leaq    8(%rsp),%rax
 
211
        ret
 
212
.size   OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
 
213
___
 
214
print<<___ if ($win64);
 
215
.globl  OPENSSL_wipe_cpu
 
216
.type   OPENSSL_wipe_cpu,\@abi-omnipotent
 
217
.align  16
 
218
OPENSSL_wipe_cpu:
 
219
        pxor    %xmm0,%xmm0
 
220
        pxor    %xmm1,%xmm1
 
221
        pxor    %xmm2,%xmm2
 
222
        pxor    %xmm3,%xmm3
 
223
        pxor    %xmm4,%xmm4
 
224
        pxor    %xmm5,%xmm5
 
225
        xorq    %rcx,%rcx
 
226
        xorq    %rdx,%rdx
 
227
        xorq    %r8,%r8
 
228
        xorq    %r9,%r9
 
229
        xorq    %r10,%r10
 
230
        xorq    %r11,%r11
 
231
        leaq    8(%rsp),%rax
 
232
        ret
 
233
.size   OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
 
234
___
 
235
 
163
236
close STDOUT;   # flush