From b99dc55f21aaf743b5853a775afdda343d719d10 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Thu, 9 Feb 2017 13:56:50 -0800 Subject: [PATCH] chacha/asm/chacha-x86.pl: improve [backward] portability. (Imports upstream's d89773d659129368a341df746476da445d47ad31.) In order to minimize dependency on assembler version a number of post-SSE2 instructions are encoded manually. But in order to simplify the procedure only register operands are considered. Non-register operands are passed down to assembler. Module in question uses pshufb with memory operands, and old [GNU] assembler can't handle it. Fortunately in this case it's possible skip just the problematic segment without skipping SSSE3 support altogether. Change-Id: Ic3ba1eef14170f9922c2cc69e0d57315e99a788b Reviewed-on: https://boringssl-review.googlesource.com/13778 Commit-Queue: Adam Langley Commit-Queue: David Benjamin Reviewed-by: David Benjamin --- crypto/chacha/asm/chacha-x86.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/chacha/asm/chacha-x86.pl b/crypto/chacha/asm/chacha-x86.pl index 1a006628..1bb87d6c 100755 --- a/crypto/chacha/asm/chacha-x86.pl +++ b/crypto/chacha/asm/chacha-x86.pl @@ -40,6 +40,7 @@ open STDOUT,">$output"; &asm_init($ARGV[0],"chacha-x86.pl",$ARGV[$#ARGV] eq "386"); $xmm=$ymm=1; +$gasver=999; # enable everything $a="eax"; ($b,$b_)=("ebx","ebp"); @@ -436,6 +437,12 @@ my ($ap,$bp,$cp,$dp)=map(($_&~3)+(($_-1)&3),($ai,$bi,$ci,$di)); # previous &label("pic_point"),"eax")); &movdqu ("xmm3",&QWP(0,"ebx")); # counter and nonce +if (defined($gasver) && $gasver>=2.17) { # even though we encode + # pshufb manually, we + # handle only register + # operands, while this + # segment uses memory + # operand... &cmp ($len,64*4); &jb (&label("1x")); @@ -617,6 +624,7 @@ my ($ap,$bp,$cp,$dp)=map(($_&~3)+(($_-1)&3),($ai,$bi,$ci,$di)); # previous &paddd ("xmm2",&QWP(16*6,"eax")); # +four &pand ("xmm3",&QWP(16*7,"eax")); &por ("xmm3","xmm2"); # counter value +} { my ($a,$b,$c,$d,$t,$t1,$rot16,$rot24)=map("xmm$_",(0..7));