From: Andy Polyakov Date: Fri, 14 Feb 2014 16:24:12 +0000 (+0100) Subject: x86[_64]cpuid.pl: add low-level RDSEED. X-Git-Tag: OpenSSL_1_0_2-beta1~27 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=104c032b7bed893f87d08ef3178848715e7035b3;p=oweals%2Fopenssl.git x86[_64]cpuid.pl: add low-level RDSEED. (cherry picked from commit f4d456408d9d7bca31f34765d1a05fbd9fa55826) --- diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl index ead4a7d3b5..f51184aedd 100755 --- a/crypto/perlasm/x86_64-xlate.pl +++ b/crypto/perlasm/x86_64-xlate.pl @@ -778,6 +778,19 @@ my $rdrand = sub { } }; +my $rdseed = sub { + if (shift =~ /%[er](\w+)/) { + my @opcode=(); + my $dst=$1; + if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; } + rex(\@opcode,0,$1,8); + push @opcode,0x0f,0xc7,0xf8|($dst&7); + @opcode; + } else { + (); + } +}; + sub rxb { local *opcode=shift; my ($dst,$src1,$src2,$rxb)=@_; diff --git a/crypto/perlasm/x86asm.pl b/crypto/perlasm/x86asm.pl index 17abf92297..dcbc738516 100644 --- a/crypto/perlasm/x86asm.pl +++ b/crypto/perlasm/x86asm.pl @@ -131,6 +131,14 @@ sub ::rdrand { &::generic("rdrand",@_); } } +sub ::rdseed +{ my ($dst)=@_; + if ($dst =~ /(e[a-dsd][ixp])/) + { &::data_byte(0x0f,0xc7,0xf8|$regrm{$dst}); } + else + { &::generic("rdrand",@_); } +} + sub rxb { local *opcode=shift; my ($dst,$src1,$src2,$rxb)=@_; diff --git a/crypto/x86_64cpuid.pl b/crypto/x86_64cpuid.pl index 34118c30ec..d208d02392 100644 --- a/crypto/x86_64cpuid.pl +++ b/crypto/x86_64cpuid.pl @@ -289,6 +289,21 @@ OPENSSL_ia32_rdrand: cmove %rcx,%rax ret .size OPENSSL_ia32_rdrand,.-OPENSSL_ia32_rdrand + +.globl OPENSSL_ia32_rdseed +.type OPENSSL_ia32_rdseed,\@abi-omnipotent +.align 16 +OPENSSL_ia32_rdseed: + mov \$8,%ecx +.Loop_rdseed: + rdseed %rax + jc .Lbreak_rdseed + loop .Loop_rdseed +.Lbreak_rdseed: + cmp \$0,%rax + cmove %rcx,%rax + ret +.size OPENSSL_ia32_rdseed,.-OPENSSL_ia32_rdseed ___ close STDOUT; # flush diff --git a/crypto/x86cpuid.pl b/crypto/x86cpuid.pl index 390c883d2b..e95f6274f5 100644 --- a/crypto/x86cpuid.pl +++ b/crypto/x86cpuid.pl @@ -367,6 +367,18 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } &ret (); &function_end_B("OPENSSL_ia32_rdrand"); +&function_begin_B("OPENSSL_ia32_rdseed"); + &mov ("ecx",8); +&set_label("loop"); + &rdseed ("eax"); + &jc (&label("break")); + &loop (&label("loop")); +&set_label("break"); + &cmp ("eax",0); + &cmove ("eax","ecx"); + &ret (); +&function_end_B("OPENSSL_ia32_rdseed"); + &initseg("OPENSSL_cpuid_setup"); &hidden("OPENSSL_cpuid_setup");