1*0a6a1f1dSLionel Sambuc#include "arm_arch.h" 2*0a6a1f1dSLionel Sambuc#include "arm_asm.h" 3*0a6a1f1dSLionel Sambuc 4*0a6a1f1dSLionel Sambuc.text 5*0a6a1f1dSLionel Sambuc.code 32 6*0a6a1f1dSLionel Sambuc 7*0a6a1f1dSLionel Sambuc.align 5 8*0a6a1f1dSLionel Sambuc.global OPENSSL_atomic_add 9*0a6a1f1dSLionel Sambuc.type OPENSSL_atomic_add,%function 10*0a6a1f1dSLionel SambucOPENSSL_atomic_add: 11*0a6a1f1dSLionel Sambuc#if __ARM_ARCH__>=6 12*0a6a1f1dSLionel Sambuc.Ladd: ldrex r2,[r0] 13*0a6a1f1dSLionel Sambuc add r3,r2,r1 14*0a6a1f1dSLionel Sambuc strex r2,r3,[r0] 15*0a6a1f1dSLionel Sambuc cmp r2,#0 16*0a6a1f1dSLionel Sambuc bne .Ladd 17*0a6a1f1dSLionel Sambuc mov r0,r3 18*0a6a1f1dSLionel Sambuc RET 19*0a6a1f1dSLionel Sambuc#else 20*0a6a1f1dSLionel Sambuc stmdb sp!,{r4-r6,lr} 21*0a6a1f1dSLionel Sambuc ldr r2,.Lspinlock 22*0a6a1f1dSLionel Sambuc adr r3,.Lspinlock 23*0a6a1f1dSLionel Sambuc mov r4,r0 24*0a6a1f1dSLionel Sambuc mov r5,r1 25*0a6a1f1dSLionel Sambuc add r6,r3,r2 @ &spinlock 26*0a6a1f1dSLionel Sambuc b .+8 27*0a6a1f1dSLionel Sambuc.Lspin: bl sched_yield 28*0a6a1f1dSLionel Sambuc mov r0,#-1 29*0a6a1f1dSLionel Sambuc swp r0,r0,[r6] 30*0a6a1f1dSLionel Sambuc cmp r0,#0 31*0a6a1f1dSLionel Sambuc bne .Lspin 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel Sambuc ldr r2,[r4] 34*0a6a1f1dSLionel Sambuc add r2,r2,r5 35*0a6a1f1dSLionel Sambuc str r2,[r4] 36*0a6a1f1dSLionel Sambuc str r0,[r6] @ release spinlock 37*0a6a1f1dSLionel Sambuc ldmia sp!,{r4-r6,lr} 38*0a6a1f1dSLionel Sambuc tst lr,#1 39*0a6a1f1dSLionel Sambuc moveq pc,lr 40*0a6a1f1dSLionel Sambuc .word 0xe12fff1e @ bx lr 41*0a6a1f1dSLionel Sambuc#endif 42*0a6a1f1dSLionel Sambuc.size OPENSSL_atomic_add,.-OPENSSL_atomic_add 43*0a6a1f1dSLionel Sambuc 44*0a6a1f1dSLionel Sambuc.global OPENSSL_cleanse 45*0a6a1f1dSLionel Sambuc.type OPENSSL_cleanse,%function 46*0a6a1f1dSLionel SambucOPENSSL_cleanse: 47*0a6a1f1dSLionel Sambuc eor ip,ip,ip 48*0a6a1f1dSLionel Sambuc cmp r1,#7 49*0a6a1f1dSLionel Sambuc subhs r1,r1,#4 50*0a6a1f1dSLionel Sambuc bhs .Lot 51*0a6a1f1dSLionel Sambuc cmp r1,#0 52*0a6a1f1dSLionel Sambuc beq .Lcleanse_done 53*0a6a1f1dSLionel Sambuc.Little: 54*0a6a1f1dSLionel Sambuc strb ip,[r0],#1 55*0a6a1f1dSLionel Sambuc subs r1,r1,#1 56*0a6a1f1dSLionel Sambuc bhi .Little 57*0a6a1f1dSLionel Sambuc b .Lcleanse_done 58*0a6a1f1dSLionel Sambuc 59*0a6a1f1dSLionel Sambuc.Lot: tst r0,#3 60*0a6a1f1dSLionel Sambuc beq .Laligned 61*0a6a1f1dSLionel Sambuc strb ip,[r0],#1 62*0a6a1f1dSLionel Sambuc sub r1,r1,#1 63*0a6a1f1dSLionel Sambuc b .Lot 64*0a6a1f1dSLionel Sambuc.Laligned: 65*0a6a1f1dSLionel Sambuc str ip,[r0],#4 66*0a6a1f1dSLionel Sambuc subs r1,r1,#4 67*0a6a1f1dSLionel Sambuc bhs .Laligned 68*0a6a1f1dSLionel Sambuc adds r1,r1,#4 69*0a6a1f1dSLionel Sambuc bne .Little 70*0a6a1f1dSLionel Sambuc.Lcleanse_done: 71*0a6a1f1dSLionel Sambuc#if __ARM_ARCH__>=5 72*0a6a1f1dSLionel Sambuc RET 73*0a6a1f1dSLionel Sambuc#else 74*0a6a1f1dSLionel Sambuc tst lr,#1 75*0a6a1f1dSLionel Sambuc moveq pc,lr 76*0a6a1f1dSLionel Sambuc .word 0xe12fff1e @ bx lr 77*0a6a1f1dSLionel Sambuc#endif 78*0a6a1f1dSLionel Sambuc.size OPENSSL_cleanse,.-OPENSSL_cleanse 79*0a6a1f1dSLionel Sambuc 80*0a6a1f1dSLionel Sambuc#if __ARM_MAX_ARCH__>=7 81*0a6a1f1dSLionel Sambuc.arch armv7-a 82*0a6a1f1dSLionel Sambuc.fpu neon 83*0a6a1f1dSLionel Sambuc 84*0a6a1f1dSLionel Sambuc.align 5 85*0a6a1f1dSLionel Sambuc.global _armv7_neon_probe 86*0a6a1f1dSLionel Sambuc.type _armv7_neon_probe,%function 87*0a6a1f1dSLionel Sambuc_armv7_neon_probe: 88*0a6a1f1dSLionel Sambuc vorr q0,q0,q0 89*0a6a1f1dSLionel Sambuc RET 90*0a6a1f1dSLionel Sambuc.size _armv7_neon_probe,.-_armv7_neon_probe 91*0a6a1f1dSLionel Sambuc 92*0a6a1f1dSLionel Sambuc.global _armv7_tick 93*0a6a1f1dSLionel Sambuc.type _armv7_tick,%function 94*0a6a1f1dSLionel Sambuc_armv7_tick: 95*0a6a1f1dSLionel Sambuc mrrc p15,1,r0,r1,c14 @ CNTVCT 96*0a6a1f1dSLionel Sambuc RET 97*0a6a1f1dSLionel Sambuc.size _armv7_tick,.-_armv7_tick 98*0a6a1f1dSLionel Sambuc 99*0a6a1f1dSLionel Sambuc.global _armv8_aes_probe 100*0a6a1f1dSLionel Sambuc.type _armv8_aes_probe,%function 101*0a6a1f1dSLionel Sambuc_armv8_aes_probe: 102*0a6a1f1dSLionel Sambuc .inst 0xf3b00300 @ aese.8 q0,q0 103*0a6a1f1dSLionel Sambuc RET 104*0a6a1f1dSLionel Sambuc.size _armv8_aes_probe,.-_armv8_aes_probe 105*0a6a1f1dSLionel Sambuc 106*0a6a1f1dSLionel Sambuc.global _armv8_sha1_probe 107*0a6a1f1dSLionel Sambuc.type _armv8_sha1_probe,%function 108*0a6a1f1dSLionel Sambuc_armv8_sha1_probe: 109*0a6a1f1dSLionel Sambuc .inst 0xf2000c40 @ sha1c.32 q0,q0,q0 110*0a6a1f1dSLionel Sambuc RET 111*0a6a1f1dSLionel Sambuc.size _armv8_sha1_probe,.-_armv8_sha1_probe 112*0a6a1f1dSLionel Sambuc 113*0a6a1f1dSLionel Sambuc.global _armv8_sha256_probe 114*0a6a1f1dSLionel Sambuc.type _armv8_sha256_probe,%function 115*0a6a1f1dSLionel Sambuc_armv8_sha256_probe: 116*0a6a1f1dSLionel Sambuc .inst 0xf3000c40 @ sha256h.32 q0,q0,q0 117*0a6a1f1dSLionel Sambuc RET 118*0a6a1f1dSLionel Sambuc.size _armv8_sha256_probe,.-_armv8_sha256_probe 119*0a6a1f1dSLionel Sambuc.global _armv8_pmull_probe 120*0a6a1f1dSLionel Sambuc.type _armv8_pmull_probe,%function 121*0a6a1f1dSLionel Sambuc_armv8_pmull_probe: 122*0a6a1f1dSLionel Sambuc .inst 0xf2a00e00 @ vmull.p64 q0,d0,d0 123*0a6a1f1dSLionel Sambuc RET 124*0a6a1f1dSLionel Sambuc.size _armv8_pmull_probe,.-_armv8_pmull_probe 125*0a6a1f1dSLionel Sambuc#endif 126*0a6a1f1dSLionel Sambuc 127*0a6a1f1dSLionel Sambuc.global OPENSSL_wipe_cpu 128*0a6a1f1dSLionel Sambuc.type OPENSSL_wipe_cpu,%function 129*0a6a1f1dSLionel SambucOPENSSL_wipe_cpu: 130*0a6a1f1dSLionel Sambuc#if __ARM_MAX_ARCH__>=7 131*0a6a1f1dSLionel Sambuc ldr r0,.LOPENSSL_armcap 132*0a6a1f1dSLionel Sambuc adr r1,.LOPENSSL_armcap 133*0a6a1f1dSLionel Sambuc ldr r0,[r1,r0] 134*0a6a1f1dSLionel Sambuc#endif 135*0a6a1f1dSLionel Sambuc eor r2,r2,r2 136*0a6a1f1dSLionel Sambuc eor r3,r3,r3 137*0a6a1f1dSLionel Sambuc eor ip,ip,ip 138*0a6a1f1dSLionel Sambuc#if __ARM_MAX_ARCH__>=7 139*0a6a1f1dSLionel Sambuc tst r0,#1 140*0a6a1f1dSLionel Sambuc beq .Lwipe_done 141*0a6a1f1dSLionel Sambuc veor q0, q0, q0 142*0a6a1f1dSLionel Sambuc veor q1, q1, q1 143*0a6a1f1dSLionel Sambuc veor q2, q2, q2 144*0a6a1f1dSLionel Sambuc veor q3, q3, q3 145*0a6a1f1dSLionel Sambuc veor q8, q8, q8 146*0a6a1f1dSLionel Sambuc veor q9, q9, q9 147*0a6a1f1dSLionel Sambuc veor q10, q10, q10 148*0a6a1f1dSLionel Sambuc veor q11, q11, q11 149*0a6a1f1dSLionel Sambuc veor q12, q12, q12 150*0a6a1f1dSLionel Sambuc veor q13, q13, q13 151*0a6a1f1dSLionel Sambuc veor q14, q14, q14 152*0a6a1f1dSLionel Sambuc veor q15, q15, q15 153*0a6a1f1dSLionel Sambuc.Lwipe_done: 154*0a6a1f1dSLionel Sambuc#endif 155*0a6a1f1dSLionel Sambuc mov r0,sp 156*0a6a1f1dSLionel Sambuc#if __ARM_ARCH__>=5 157*0a6a1f1dSLionel Sambuc RET 158*0a6a1f1dSLionel Sambuc#else 159*0a6a1f1dSLionel Sambuc tst lr,#1 160*0a6a1f1dSLionel Sambuc moveq pc,lr 161*0a6a1f1dSLionel Sambuc .word 0xe12fff1e @ bx lr 162*0a6a1f1dSLionel Sambuc#endif 163*0a6a1f1dSLionel Sambuc.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 164*0a6a1f1dSLionel Sambuc 165*0a6a1f1dSLionel Sambuc.global OPENSSL_instrument_bus 166*0a6a1f1dSLionel Sambuc.type OPENSSL_instrument_bus,%function 167*0a6a1f1dSLionel SambucOPENSSL_instrument_bus: 168*0a6a1f1dSLionel Sambuc eor r0,r0,r0 169*0a6a1f1dSLionel Sambuc#if __ARM_ARCH__>=5 170*0a6a1f1dSLionel Sambuc RET 171*0a6a1f1dSLionel Sambuc#else 172*0a6a1f1dSLionel Sambuc tst lr,#1 173*0a6a1f1dSLionel Sambuc moveq pc,lr 174*0a6a1f1dSLionel Sambuc .word 0xe12fff1e @ bx lr 175*0a6a1f1dSLionel Sambuc#endif 176*0a6a1f1dSLionel Sambuc.size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus 177*0a6a1f1dSLionel Sambuc 178*0a6a1f1dSLionel Sambuc.global OPENSSL_instrument_bus2 179*0a6a1f1dSLionel Sambuc.type OPENSSL_instrument_bus2,%function 180*0a6a1f1dSLionel SambucOPENSSL_instrument_bus2: 181*0a6a1f1dSLionel Sambuc eor r0,r0,r0 182*0a6a1f1dSLionel Sambuc#if __ARM_ARCH__>=5 183*0a6a1f1dSLionel Sambuc RET 184*0a6a1f1dSLionel Sambuc#else 185*0a6a1f1dSLionel Sambuc tst lr,#1 186*0a6a1f1dSLionel Sambuc moveq pc,lr 187*0a6a1f1dSLionel Sambuc .word 0xe12fff1e @ bx lr 188*0a6a1f1dSLionel Sambuc#endif 189*0a6a1f1dSLionel Sambuc.size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2 190*0a6a1f1dSLionel Sambuc 191*0a6a1f1dSLionel Sambuc.align 5 192*0a6a1f1dSLionel Sambuc#if __ARM_MAX_ARCH__>=7 193*0a6a1f1dSLionel Sambuc.LOPENSSL_armcap: 194*0a6a1f1dSLionel Sambuc.word OPENSSL_armcap_P-.LOPENSSL_armcap 195*0a6a1f1dSLionel Sambuc#endif 196*0a6a1f1dSLionel Sambuc#if __ARM_ARCH__>=6 197*0a6a1f1dSLionel Sambuc.align 5 198*0a6a1f1dSLionel Sambuc#else 199*0a6a1f1dSLionel Sambuc.Lspinlock: 200*0a6a1f1dSLionel Sambuc.word atomic_add_spinlock-.Lspinlock 201*0a6a1f1dSLionel Sambuc.align 5 202*0a6a1f1dSLionel Sambuc 203*0a6a1f1dSLionel Sambuc.data 204*0a6a1f1dSLionel Sambuc.align 2 205*0a6a1f1dSLionel Sambucatomic_add_spinlock: 206*0a6a1f1dSLionel Sambuc.word 0 207*0a6a1f1dSLionel Sambuc#endif 208*0a6a1f1dSLionel Sambuc 209*0a6a1f1dSLionel Sambuc.comm OPENSSL_armcap_P,4,4 210*0a6a1f1dSLionel Sambuc.hidden OPENSSL_armcap_P 211