s390xcpuid.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. .text
  2. .globl OPENSSL_s390x_facilities
  3. .type OPENSSL_s390x_facilities,@function
  4. .align 16
  5. OPENSSL_s390x_facilities:
  6. lghi %r0,0
  7. larl %r4,OPENSSL_s390xcap_P
  8. stg %r0,8(%r4) # wipe capability vectors
  9. stg %r0,16(%r4)
  10. stg %r0,24(%r4)
  11. stg %r0,32(%r4)
  12. stg %r0,40(%r4)
  13. stg %r0,48(%r4)
  14. stg %r0,56(%r4)
  15. stg %r0,64(%r4)
  16. stg %r0,72(%r4)
  17. .long 0xb2b04000 # stfle 0(%r4)
  18. brc 8,.Ldone
  19. lghi %r0,1
  20. .long 0xb2b04000 # stfle 0(%r4)
  21. .Ldone:
  22. lmg %r2,%r3,0(%r4)
  23. tmhl %r2,0x4000 # check for message-security-assist
  24. jz .Lret
  25. lghi %r0,0 # query kimd capabilities
  26. la %r1,16(%r4)
  27. .long 0xb93e0002 # kimd %r0,%r2
  28. lghi %r0,0 # query km capability vector
  29. la %r1,32(%r4)
  30. .long 0xb92e0042 # km %r4,%r2
  31. lghi %r0,0 # query kmc capability vector
  32. la %r1,48(%r4)
  33. .long 0xb92f0042 # kmc %r4,%r2
  34. tmhh %r3,0x0004 # check for message-security-assist-4
  35. jz .Lret
  36. lghi %r0,0 # query kmctr capability vector
  37. la %r1,64(%r4)
  38. .long 0xb92d2042 # kmctr %r4,%r2,%r2
  39. .Lret:
  40. br %r14
  41. .size OPENSSL_s390x_facilities,.-OPENSSL_s390x_facilities
  42. .globl OPENSSL_rdtsc
  43. .type OPENSSL_rdtsc,@function
  44. .align 16
  45. OPENSSL_rdtsc:
  46. stck 16(%r15)
  47. lg %r2,16(%r15)
  48. br %r14
  49. .size OPENSSL_rdtsc,.-OPENSSL_rdtsc
  50. .globl OPENSSL_atomic_add
  51. .type OPENSSL_atomic_add,@function
  52. .align 16
  53. OPENSSL_atomic_add:
  54. l %r1,0(%r2)
  55. .Lspin: lr %r0,%r1
  56. ar %r0,%r3
  57. cs %r1,%r0,0(%r2)
  58. brc 4,.Lspin
  59. lgfr %r2,%r0 # OpenSSL expects the new value
  60. br %r14
  61. .size OPENSSL_atomic_add,.-OPENSSL_atomic_add
  62. .globl OPENSSL_wipe_cpu
  63. .type OPENSSL_wipe_cpu,@function
  64. .align 16
  65. OPENSSL_wipe_cpu:
  66. xgr %r0,%r0
  67. xgr %r1,%r1
  68. lgr %r2,%r15
  69. xgr %r3,%r3
  70. xgr %r4,%r4
  71. lzdr %f0
  72. lzdr %f1
  73. lzdr %f2
  74. lzdr %f3
  75. lzdr %f4
  76. lzdr %f5
  77. lzdr %f6
  78. lzdr %f7
  79. br %r14
  80. .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
  81. .globl OPENSSL_cleanse
  82. .type OPENSSL_cleanse,@function
  83. .align 16
  84. OPENSSL_cleanse:
  85. #if !defined(__s390x__) && !defined(__s390x)
  86. llgfr %r3,%r3
  87. #endif
  88. lghi %r4,15
  89. lghi %r0,0
  90. clgr %r3,%r4
  91. jh .Lot
  92. clgr %r3,%r0
  93. bcr 8,%r14
  94. .Little:
  95. stc %r0,0(%r2)
  96. la %r2,1(%r2)
  97. brctg %r3,.Little
  98. br %r14
  99. .align 4
  100. .Lot: tmll %r2,7
  101. jz .Laligned
  102. stc %r0,0(%r2)
  103. la %r2,1(%r2)
  104. brctg %r3,.Lot
  105. .Laligned:
  106. srlg %r4,%r3,3
  107. .Loop: stg %r0,0(%r2)
  108. la %r2,8(%r2)
  109. brctg %r4,.Loop
  110. lghi %r4,7
  111. ngr %r3,%r4
  112. jnz .Little
  113. br %r14
  114. .size OPENSSL_cleanse,.-OPENSSL_cleanse
  115. .section .init
  116. brasl %r14,OPENSSL_cpuid_setup
  117. .comm OPENSSL_s390xcap_P,80,8