s390x assembly pack: implement OPENSSL_rdtsc as STCKF
authorPatrick Steuer <patrick.steuer@de.ibm.com>
Wed, 7 Feb 2018 17:49:29 +0000 (18:49 +0100)
committerAndy Polyakov <appro@openssl.org>
Tue, 13 Feb 2018 19:34:38 +0000 (20:34 +0100)
.. if avalable. STCK has an artificial delay to ensure uniqueness
which can result in a performance penalty if used heavily
concurrently.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5284)

crypto/s390xcpuid.pl

index 5f6ffc6..b0ed9e0 100755 (executable)
@@ -129,6 +129,14 @@ OPENSSL_s390x_facilities:
 .type  OPENSSL_rdtsc,\@function
 .align 16
 OPENSSL_rdtsc:
+       larl    %r4,OPENSSL_s390xcap_P
+       tm      S390X_STFLE+3(%r4),0x40 # check for store-clock-fast facility
+       jz      .Lstck
+
+       .long   0xb27cf010      # stckf 16($sp)
+       lg      %r2,16($sp)
+       br      $ra
+.Lstck:
        stck    16($sp)
        lg      %r2,16($sp)
        br      $ra