Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP OpenSSL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP OpenSSL
Commits
932cc129
Commit
932cc129
authored
17 years ago
by
Andy Polyakov
Browse files
Options
Downloads
Patches
Plain Diff
x86_64 assembler updates.
parent
1a42839b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
crypto/perlasm/x86_64-xlate.pl
+16
-3
16 additions, 3 deletions
crypto/perlasm/x86_64-xlate.pl
crypto/x86_64cpuid.pl
+32
-70
32 additions, 70 deletions
crypto/x86_64cpuid.pl
with
48 additions
and
73 deletions
crypto/perlasm/x86_64-xlate.pl
+
16
−
3
View file @
932cc129
...
...
@@ -57,7 +57,13 @@
# lea .Label-.Lpic_point(%rcx),%rbp
my
$output
=
shift
;
open
STDOUT
,"
>
$output
"
||
die
"
can't open
$output
: $!
";
{
my
(
$stddev
,
$stdino
,
@junk
)
=
stat
(
STDOUT
);
my
(
$outdev
,
$outino
,
@junk
)
=
stat
(
$output
);
open
STDOUT
,"
>
$output
"
||
die
"
can't open
$output
: $!
"
if
(
$stddev
!=
$outdev
||
$stdino
!=
$outino
);
}
my
$masm
=
1
if
(
$output
=~
/\.asm/
);
...
...
@@ -70,7 +76,7 @@ my $current_function;
local
*line
=
shift
;
undef
$ret
;
if
(
$line
=~
/^([a-z]
+
)/i
)
{
if
(
$line
=~
/^([a-z]
[a-z0-9]*
)/i
)
{
$self
->
{
op
}
=
$
1
;
$ret
=
$self
;
$line
=
substr
(
$line
,
@
+
[
0
]);
$line
=~
s/^\s+//
;
...
...
@@ -95,8 +101,10 @@ my $current_function;
sub
out
{
my
$self
=
shift
;
if
(
!
$masm
)
{
if
(
$self
->
{
op
}
eq
"
movz
")
{
# movz i
n
pain...
if
(
$self
->
{
op
}
eq
"
movz
")
{
# movz i
s
pain...
sprintf
"
%s%s%s
",
$self
->
{
op
},
$self
->
{
sz
},
shift
;
}
elsif
(
$self
->
{
op
}
=~
/^set/
)
{
"
$self
->{op}
";
}
elsif
(
$self
->
{
op
}
eq
"
ret
")
{
"
.byte 0xf3,0xc3
";
}
else
{
...
...
@@ -198,6 +206,8 @@ my $current_function;
$self
->
{
label
},
$self
->
{
index
},
$self
->
{
scale
},
$self
->
{
base
};
}
elsif
(
$self
->
{
base
}
eq
"
rip
")
{
sprintf
"
%s PTR %s
",
$szmap
{
$sz
},
$self
->
{
label
};
}
else
{
sprintf
"
%s PTR %s[%s]
",
$szmap
{
$sz
},
$self
->
{
label
},
$self
->
{
base
};
...
...
@@ -325,6 +335,8 @@ my $current_function;
$self
->
{
value
}
=
sprintf
"
\t
.long
\t
0x%x,0x90000000
",
$opcode
{
$
1
};
}
elsif
(
$line
=~
/\.asciz\s+"(.*)"$/
)
{
$self
->
{
value
}
=
"
.byte
\t
"
.
join
("
,
",
unpack
("
C*
",
$
1
),
0
);
}
elsif
(
$line
=~
/\.extern/
)
{
$self
->
{
value
}
=
"";
# swallow extern
}
else
{
$self
->
{
value
}
=
$line
;
}
...
...
@@ -346,6 +358,7 @@ my $current_function;
$self
->
{
value
}
=
$v
;
last
;
};
/\.extern/
&&
do
{
$self
->
{
value
}
=
"
EXTRN
\t
"
.
$line
;
last
;
};
/\.globl/
&&
do
{
$self
->
{
value
}
=
"
PUBLIC
\t
"
.
$line
;
last
;
};
/\.type/
&&
do
{
(
$sym
,
$type
,
$narg
)
=
split
('
,
',
$line
);
if
(
$type
eq
"
\@
function
")
{
...
...
This diff is collapsed.
Click to expand it.
crypto/x86_64cpuid.pl
+
32
−
70
View file @
932cc129
#!/usr/bin/env perl
$output
=
shift
;
$
win64a
=
1
if
(
$output
=~
/
win64a\.[s|
asm
]
/
);
$
masm
=
1
if
(
$output
=~
/
\.
asm/
);
open
STDOUT
,"
>
$output
"
||
die
"
can't open
$output
: $!
";
print
<<
___
if
(
defined
(
$
win64a
));
print
<<
___
if
(
defined
(
$
masm
));
_TEXT
SEGMENT
PUBLIC
OPENSSL_rdtsc
ALIGN
16
OPENSSL_rdtsc
PROC
rdtsc
shl
rdx
,
32
or
rax
,
rdx
ret
OPENSSL_rdtsc
ENDP
PUBLIC
OPENSSL_atomic_add
ALIGN
16
...
...
@@ -45,64 +38,16 @@ OPENSSL_wipe_cpu PROC
lea
rax
,
QWORD
PTR
[
rsp
+
8
]
ret
OPENSSL_wipe_cpu
ENDP
OPENSSL_ia32_cpuid
PROC
mov
r8
,
rbx
xor
eax
,
eax
cpuid
xor
eax
,
eax
cmp
ebx
,
0756
e6547h
setne
al
mov
r9d
,
eax
cmp
edx
,
04
9656e69
h
setne
al
or
r9d
,
eax
cmp
ecx
,
06
c65746eh
setne
al
or
r9d
,
eax
mov
eax
,
1
cpuid
bt
edx
,
28
jnc
\
$Ldone
cmp
r9
,
0
jne
\
$Lnotintel
or
edx
,
000100000
h
and
ah
,
15
cmp
ah
,
15
je
\
$Lnotintel
or
edx
,
040000000
h
\
$Lnotintel:
shr
ebx
,
16
cmp
bl
,
1
ja
\
$Ldone
and
edx
,
0
efffffffh
\
$Ldone:
shl
rcx
,
32
mov
eax
,
edx
mov
rbx
,
r8
or
rax
,
rcx
ret
OPENSSL_ia32_cpuid
ENDP
_TEXT
ENDS
CRT
\
$XIU
SEGMENT
EXTRN
OPENSSL_cpuid_setup:PROC
DQ
OPENSSL_cpuid_setup
CRT
\
$XIU
ENDS
END
___
print
<<
___
if
(
!
defined
(
$
win64a
));
print
<<
___
if
(
!
defined
(
$
masm
));
.
text
.
globl
OPENSSL_rdtsc
.
align
16
OPENSSL_rdtsc:
rdtsc
shlq
\
$
32
,
%rdx
orq
%rdx
,
%rax
ret
.
size
OPENSSL_rdtsc
,
.-
OPENSSL_rdtsc
.
globl
OPENSSL_atomic_add
.
type
OPENSSL_atomic_add
,
\
@function
...
...
@@ -149,10 +94,30 @@ OPENSSL_wipe_cpu:
ret
.
size
OPENSSL_wipe_cpu
,
.-
OPENSSL_wipe_cpu
.
section
.
init
call
OPENSSL_cpuid_setup
___
open
STDOUT
,"
| $^X perlasm/x86_64-xlate.pl
$output
";
print
<<___;
.text
.globl OPENSSL_rdtsc
.type OPENSSL_rdtsc,\@abi-omnipotent
.align 16
OPENSSL_rdtsc:
rdtsc
shl \$32,%rdx
or %rdx,%rax
ret
.size OPENSSL_rdtsc,.-OPENSSL_rdtsc
.globl OPENSSL_ia32_cpuid
.type OPENSSL_ia32_cpuid,\@abi-omnipotent
.align 16
OPENSSL_ia32_cpuid:
mov
q
%rbx
,
%r8
mov %rbx,%r8
xor %eax,%eax
cpuid
...
...
@@ -167,11 +132,11 @@ OPENSSL_ia32_cpuid:
setne %al
or %eax,%r9d
mov
l
\
$
1
,
%eax
mov \$1,%eax
cpuid
bt \$28,%edx # test hyper-threading bit
jnc .Ldone
cmp
\
$
0
,
%r9
cmp \$0,%r9
d
jne .Lnotintel
or \$1<<20,%edx # use reserved bit to engage RC4_CHAR
and \$15,%ah
...
...
@@ -182,15 +147,12 @@ OPENSSL_ia32_cpuid:
shr \$16,%ebx
cmp \$1,%bl # see if cache is shared
ja .Ldone
and
\
$~
(
1
<<
28
)
,
%edx
and \$
0xefffffff,%edx #
~(1<<28)
.Ldone:
shl
q
\
$
32
,
%rcx
mov
l
%edx
,
%eax
mov
q
%r8
,
%rbx
or
q
%rcx
,
%rax
shl \$32,%rcx
mov %edx,%eax
mov %r8,%rbx
or %rcx,%rax
ret
.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
.
section
.
init
call
OPENSSL_cpuid_setup
___
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment