s390xcpuid.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. .text
  2. // Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. //
  4. // Licensed under the OpenSSL license (the "License"). You may not use
  5. // this file except in compliance with the License. You can obtain a copy
  6. // in the file LICENSE in the source distribution or at
  7. // https://www.openssl.org/source/license.html
  8. .globl OPENSSL_s390x_facilities
  9. .type OPENSSL_s390x_facilities,@function
  10. .align 16
  11. OPENSSL_s390x_facilities:
  12. lghi %r0,0
  13. larl %r4,OPENSSL_s390xcap_P
  14. stg %r0,8(%r4) # wipe capability vectors
  15. stg %r0,16(%r4)
  16. stg %r0,24(%r4)
  17. stg %r0,32(%r4)
  18. stg %r0,40(%r4)
  19. stg %r0,48(%r4)
  20. stg %r0,56(%r4)
  21. stg %r0,64(%r4)
  22. stg %r0,72(%r4)
  23. .long 0xb2b04000 # stfle 0(%r4)
  24. brc 8,.Ldone
  25. lghi %r0,1
  26. .long 0xb2b04000 # stfle 0(%r4)
  27. .Ldone:
  28. lmg %r2,%r3,0(%r4)
  29. tmhl %r2,0x4000 # check for message-security-assist
  30. jz .Lret
  31. lghi %r0,0 # query kimd capabilities
  32. la %r1,16(%r4)
  33. .long 0xb93e0002 # kimd %r0,%r2
  34. lghi %r0,0 # query km capability vector
  35. la %r1,32(%r4)
  36. .long 0xb92e0042 # km %r4,%r2
  37. lghi %r0,0 # query kmc capability vector
  38. la %r1,48(%r4)
  39. .long 0xb92f0042 # kmc %r4,%r2
  40. tmhh %r3,0x0004 # check for message-security-assist-4
  41. jz .Lret
  42. lghi %r0,0 # query kmctr capability vector
  43. la %r1,64(%r4)
  44. .long 0xb92d2042 # kmctr %r4,%r2,%r2
  45. .Lret:
  46. br %r14
  47. .size OPENSSL_s390x_facilities,.-OPENSSL_s390x_facilities
  48. .globl OPENSSL_rdtsc
  49. .type OPENSSL_rdtsc,@function
  50. .align 16
  51. OPENSSL_rdtsc:
  52. stck 16(%r15)
  53. lg %r2,16(%r15)
  54. br %r14
  55. .size OPENSSL_rdtsc,.-OPENSSL_rdtsc
  56. .globl OPENSSL_atomic_add
  57. .type OPENSSL_atomic_add,@function
  58. .align 16
  59. OPENSSL_atomic_add:
  60. l %r1,0(%r2)
  61. .Lspin: lr %r0,%r1
  62. ar %r0,%r3
  63. cs %r1,%r0,0(%r2)
  64. brc 4,.Lspin
  65. lgfr %r2,%r0 # OpenSSL expects the new value
  66. br %r14
  67. .size OPENSSL_atomic_add,.-OPENSSL_atomic_add
  68. .globl OPENSSL_wipe_cpu
  69. .type OPENSSL_wipe_cpu,@function
  70. .align 16
  71. OPENSSL_wipe_cpu:
  72. xgr %r0,%r0
  73. xgr %r1,%r1
  74. lgr %r2,%r15
  75. xgr %r3,%r3
  76. xgr %r4,%r4
  77. lzdr %f0
  78. lzdr %f1
  79. lzdr %f2
  80. lzdr %f3
  81. lzdr %f4
  82. lzdr %f5
  83. lzdr %f6
  84. lzdr %f7
  85. br %r14
  86. .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
  87. .globl OPENSSL_cleanse
  88. .type OPENSSL_cleanse,@function
  89. .align 16
  90. OPENSSL_cleanse:
  91. #if !defined(__s390x__) && !defined(__s390x)
  92. llgfr %r3,%r3
  93. #endif
  94. lghi %r4,15
  95. lghi %r0,0
  96. clgr %r3,%r4
  97. jh .Lot
  98. clgr %r3,%r0
  99. bcr 8,%r14
  100. .Little:
  101. stc %r0,0(%r2)
  102. la %r2,1(%r2)
  103. brctg %r3,.Little
  104. br %r14
  105. .align 4
  106. .Lot: tmll %r2,7
  107. jz .Laligned
  108. stc %r0,0(%r2)
  109. la %r2,1(%r2)
  110. brctg %r3,.Lot
  111. .Laligned:
  112. srlg %r4,%r3,3
  113. .Loop: stg %r0,0(%r2)
  114. la %r2,8(%r2)
  115. brctg %r4,.Loop
  116. lghi %r4,7
  117. ngr %r3,%r4
  118. jnz .Little
  119. br %r14
  120. .size OPENSSL_cleanse,.-OPENSSL_cleanse
  121. .globl CRYPTO_memcmp
  122. .type CRYPTO_memcmp,@function
  123. .align 16
  124. CRYPTO_memcmp:
  125. #if !defined(__s390x__) && !defined(__s390x)
  126. llgfr %r4,%r4
  127. #endif
  128. lghi %r5,0
  129. clgr %r4,%r5
  130. je .Lno_data
  131. .Loop_cmp:
  132. llgc %r0,0(%r2)
  133. la %r2,1(%r2)
  134. llgc %r1,0(%r3)
  135. la %r3,1(%r3)
  136. xr %r1,%r0
  137. or %r5,%r1
  138. brctg %r4,.Loop_cmp
  139. lnr %r5,%r5
  140. srl %r5,31
  141. .Lno_data:
  142. lgr %r2,%r5
  143. br %r14
  144. .size CRYPTO_memcmp,.-CRYPTO_memcmp
  145. .globl OPENSSL_instrument_bus
  146. .type OPENSSL_instrument_bus,@function
  147. .align 16
  148. OPENSSL_instrument_bus:
  149. lghi %r2,0
  150. br %r14
  151. .size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus
  152. .globl OPENSSL_instrument_bus2
  153. .type OPENSSL_instrument_bus2,@function
  154. .align 16
  155. OPENSSL_instrument_bus2:
  156. lghi %r2,0
  157. br %r14
  158. .size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2
  159. .section .init
  160. brasl %r14,OPENSSL_cpuid_setup
  161. .comm OPENSSL_s390xcap_P,80,8