arm64cpuid.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include "arm_arch.h"
  2. .text
  3. .arch armv8-a+crypto
  4. .align 5
  5. .globl _armv7_neon_probe
  6. .type _armv7_neon_probe,%function
  7. _armv7_neon_probe:
  8. orr v15.16b, v15.16b, v15.16b
  9. ret
  10. .size _armv7_neon_probe,.-_armv7_neon_probe
  11. .globl _armv7_tick
  12. .type _armv7_tick,%function
  13. _armv7_tick:
  14. #ifdef __APPLE__
  15. mrs x0, CNTPCT_EL0
  16. #else
  17. mrs x0, CNTVCT_EL0
  18. #endif
  19. ret
  20. .size _armv7_tick,.-_armv7_tick
  21. .globl _armv8_aes_probe
  22. .type _armv8_aes_probe,%function
  23. _armv8_aes_probe:
  24. aese v0.16b, v0.16b
  25. ret
  26. .size _armv8_aes_probe,.-_armv8_aes_probe
  27. .globl _armv8_sha1_probe
  28. .type _armv8_sha1_probe,%function
  29. _armv8_sha1_probe:
  30. sha1h s0, s0
  31. ret
  32. .size _armv8_sha1_probe,.-_armv8_sha1_probe
  33. .globl _armv8_sha256_probe
  34. .type _armv8_sha256_probe,%function
  35. _armv8_sha256_probe:
  36. sha256su0 v0.4s, v0.4s
  37. ret
  38. .size _armv8_sha256_probe,.-_armv8_sha256_probe
  39. .globl _armv8_pmull_probe
  40. .type _armv8_pmull_probe,%function
  41. _armv8_pmull_probe:
  42. pmull v0.1q, v0.1d, v0.1d
  43. ret
  44. .size _armv8_pmull_probe,.-_armv8_pmull_probe
  45. .globl _armv8_sha512_probe
  46. .type _armv8_sha512_probe,%function
  47. _armv8_sha512_probe:
  48. .long 0xcec08000 // sha512su0 v0.2d,v0.2d
  49. ret
  50. .size _armv8_sha512_probe,.-_armv8_sha512_probe
  51. .globl OPENSSL_cleanse
  52. .type OPENSSL_cleanse,%function
  53. .align 5
  54. OPENSSL_cleanse:
  55. cbz x1,.Lret // len==0?
  56. cmp x1,#15
  57. b.hi .Lot // len>15
  58. nop
  59. .Little:
  60. strb wzr,[x0],#1 // store byte-by-byte
  61. subs x1,x1,#1
  62. b.ne .Little
  63. .Lret: ret
  64. .align 4
  65. .Lot: tst x0,#7
  66. b.eq .Laligned // inp is aligned
  67. strb wzr,[x0],#1 // store byte-by-byte
  68. sub x1,x1,#1
  69. b .Lot
  70. .align 4
  71. .Laligned:
  72. str xzr,[x0],#8 // store word-by-word
  73. sub x1,x1,#8
  74. tst x1,#-8
  75. b.ne .Laligned // len>=8
  76. cbnz x1,.Little // len!=0?
  77. ret
  78. .size OPENSSL_cleanse,.-OPENSSL_cleanse
  79. .globl CRYPTO_memcmp
  80. .type CRYPTO_memcmp,%function
  81. .align 4
  82. CRYPTO_memcmp:
  83. eor w3,w3,w3
  84. cbz x2,.Lno_data // len==0?
  85. cmp x2,#16
  86. b.ne .Loop_cmp
  87. ldp x8,x9,[x0]
  88. ldp x10,x11,[x1]
  89. eor x8,x8,x10
  90. eor x9,x9,x11
  91. orr x8,x8,x9
  92. mov x0,#1
  93. cmp x8,#0
  94. csel x0,xzr,x0,eq
  95. ret
  96. .align 4
  97. .Loop_cmp:
  98. ldrb w4,[x0],#1
  99. ldrb w5,[x1],#1
  100. eor w4,w4,w5
  101. orr w3,w3,w4
  102. subs x2,x2,#1
  103. b.ne .Loop_cmp
  104. .Lno_data:
  105. neg w0,w3
  106. lsr w0,w0,#31
  107. ret
  108. .size CRYPTO_memcmp,.-CRYPTO_memcmp