diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2018-07-05 14:27:53 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2018-07-05 14:27:53 +0000 |
commit | a11213dc4a5db7b7eed540233cb66cca483d1ea5 (patch) | |
tree | 54302e9f9e5ce4f10df36b36de22bed100d66c1c /sys | |
parent | 692741b43bfda1f9eab023a9a3b0284cc7b16325 (diff) |
backout r1.11 "Add retguard macros for kernel asm", ok deraadt
after starting iked kernel enters ddb with:
Stopped at aesni_ctr_enc+0xd8: int $3
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/aes_intel.S | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/sys/arch/amd64/amd64/aes_intel.S b/sys/arch/amd64/amd64/aes_intel.S index c463d679cf4..e90d2c00af6 100644 --- a/sys/arch/amd64/amd64/aes_intel.S +++ b/sys/arch/amd64/amd64/aes_intel.S @@ -1,4 +1,4 @@ -/* $OpenBSD: aes_intel.S,v 1.11 2018/07/03 23:21:15 mortimer Exp $ */ +/* $OpenBSD: aes_intel.S,v 1.12 2018/07/05 14:27:52 sthen Exp $ */ /* * Implement AES algorithm in Intel AES-NI instructions. @@ -106,7 +106,6 @@ _key_expansion_128: _key_expansion_256a: - RETGUARD_SETUP(_key_expansion_128, rax) pshufd $0b11111111,%xmm1,%xmm1 shufps $0b00010000,%xmm0,%xmm4 pxor %xmm4,%xmm0 @@ -115,11 +114,9 @@ _key_expansion_256a: pxor %xmm1,%xmm0 movaps %xmm0,(%rcx) add $0x10,%rcx - RETGUARD_CHECK(_key_expansion_128, rax) ret _key_expansion_192a: - RETGUARD_SETUP(_key_expansion_192a, rax) pshufd $0b01010101,%xmm1,%xmm1 shufps $0b00010000,%xmm0,%xmm4 pxor %xmm4,%xmm0 @@ -140,11 +137,9 @@ _key_expansion_192a: shufps $0b01001110,%xmm2,%xmm1 movaps %xmm1,16(%rcx) add $0x20,%rcx - RETGUARD_CHECK(_key_expansion_192a, rax) ret _key_expansion_192b: - RETGUARD_SETUP(_key_expansion_192b, rax) pshufd $0b01010101,%xmm1,%xmm1 shufps $0b00010000,%xmm0,%xmm4 pxor %xmm4,%xmm0 @@ -160,11 +155,9 @@ _key_expansion_192b: movaps %xmm0,(%rcx) add $0x10,%rcx - RETGUARD_CHECK(_key_expansion_192b, rax) ret _key_expansion_256b: - RETGUARD_SETUP(_key_expansion_256b, rax) pshufd $0b10101010,%xmm1,%xmm1 shufps $0b00010000,%xmm2,%xmm4 pxor %xmm4,%xmm2 @@ -173,14 +166,12 @@ _key_expansion_256b: pxor %xmm1,%xmm2 movaps %xmm2,(%rcx) add $0x10,%rcx - RETGUARD_CHECK(_key_expansion_256b, rax) ret /* * void aesni_set_key(struct aesni_session *ses, uint8_t *key, size_t len) */ ENTRY(aesni_set_key) - RETGUARD_SETUP(aesni_set_key, r11) movups (%rsi),%xmm0 # user key (first 16 bytes) movaps %xmm0,(%rdi) lea 0x10(%rdi),%rcx # key addr @@ -276,19 +267,16 @@ ENTRY(aesni_set_key) sub $0x10,%rsi cmp %rcx,%rdi jb 4b - RETGUARD_CHECK(aesni_set_key, r11) ret /* * void aesni_enc(struct aesni_session *ses, uint8_t *dst, uint8_t *src) */ ENTRY(aesni_enc) - RETGUARD_SETUP(aesni_enc, r11) movl 480(KEYP),KLEN # key length movups (INP),STATE # input call _aesni_enc1 movups STATE,(OUTP) # output - RETGUARD_CHECK(aesni_enc, r11) ret /* @@ -304,7 +292,6 @@ ENTRY(aesni_enc) * TKEYP (T1) */ _aesni_enc1: - RETGUARD_SETUP(_aesni_enc1, rax) movaps (KEYP),KEY # key mov KEYP,TKEYP pxor KEY,STATE # round 0 @@ -346,7 +333,6 @@ _aesni_enc1: aesenc KEY,STATE movaps 0x70(TKEYP),KEY aesenclast KEY,STATE - RETGUARD_CHECK(_aesni_enc1, rax) ret /* @@ -368,7 +354,6 @@ _aesni_enc1: * TKEYP (T1) */ _aesni_enc4: - RETGUARD_SETUP(_aesni_enc4, rax) movaps (KEYP),KEY # key mov KEYP,TKEYP pxor KEY,STATE1 # round 0 @@ -455,20 +440,17 @@ _aesni_enc4: aesenclast KEY,STATE2 aesenclast KEY,STATE3 aesenclast KEY,STATE4 - RETGUARD_CHECK(_aesni_enc4, rax) ret /* * void aesni_dec(struct aesni_session *ses, uint8_t *dst, uint8_t *src) */ ENTRY(aesni_dec) - RETGUARD_SETUP(aesni_dec, r11) mov 480(KEYP),KLEN # key length add $240,KEYP movups (INP),STATE # input call _aesni_dec1 movups STATE,(OUTP) # output - RETGUARD_CHECK(aesni_dec, r11) ret /* @@ -484,7 +466,6 @@ ENTRY(aesni_dec) * TKEYP (T1) */ _aesni_dec1: - RETGUARD_SETUP(_aesni_dec1, rax) movaps (KEYP),KEY # key mov KEYP,TKEYP pxor KEY,STATE # round 0 @@ -526,7 +507,6 @@ _aesni_dec1: aesdec KEY,STATE movaps 0x70(TKEYP),KEY aesdeclast KEY,STATE - RETGUARD_CHECK(_aesni_dec1, rax) ret /* @@ -548,7 +528,6 @@ _aesni_dec1: * TKEYP (T1) */ _aesni_dec4: - RETGUARD_SETUP(_aesni_dec4, rax) movaps (KEYP),KEY # key mov KEYP,TKEYP pxor KEY,STATE1 # round 0 @@ -635,7 +614,6 @@ _aesni_dec4: aesdeclast KEY,STATE2 aesdeclast KEY,STATE3 aesdeclast KEY,STATE4 - RETGUARD_CHECK(_aesni_dec4, rax) ret #if 0 @@ -644,7 +622,6 @@ _aesni_dec4: * size_t len) */ ENTRY(aesni_ecb_enc) - RETGUARD_SETUP(aesni_ecb_enc, r11) test LEN,LEN # check length jz 3f mov 480(KEYP),KLEN @@ -681,7 +658,6 @@ ENTRY(aesni_ecb_enc) cmp $16,LEN jge 2b 3: - RETGUARD_CHECK(aesni_ecb_enc, r11) ret /* @@ -689,7 +665,6 @@ ENTRY(aesni_ecb_enc) * size_t len); */ ENTRY(aesni_ecb_dec) - RETGUARD_SETUP(aesni_ecb_dec, r11) test LEN,LEN jz 3f mov 480(KEYP),KLEN @@ -727,7 +702,6 @@ ENTRY(aesni_ecb_dec) cmp $16,LEN jge 2b 3: - RETGUARD_CHECK(aesni_ecb_dec, r11) ret #endif @@ -736,7 +710,6 @@ ENTRY(aesni_ecb_dec) * size_t len, uint8_t *iv) */ ENTRY(aesni_cbc_enc) - RETGUARD_SETUP(aesni_cbc_enc, r11) cmp $16,LEN jb 2f mov 480(KEYP),KLEN @@ -754,7 +727,6 @@ ENTRY(aesni_cbc_enc) jge 1b movups STATE,(IVP) 2: - RETGUARD_CHECK(aesni_cbc_enc, r11) ret /* @@ -762,7 +734,6 @@ ENTRY(aesni_cbc_enc) * size_t len, uint8_t *iv) */ ENTRY(aesni_cbc_dec) - RETGUARD_SETUP(aesni_cbc_dec, r11) cmp $16,LEN jb 4f mov 480(KEYP),KLEN @@ -813,7 +784,6 @@ ENTRY(aesni_cbc_dec) 3: movups IV,(IVP) 4: - RETGUARD_CHECK(aesni_cbc_dec, r11) ret /* @@ -829,7 +799,6 @@ ENTRY(aesni_cbc_dec) * BSWAP_MASK == endian swapping mask */ _aesni_inc_init: - RETGUARD_SETUP(_aesni_inc_init, rax) movdqa CTR,IV pslldq $8,IV movdqu .Lbswap_mask,BSWAP_MASK @@ -837,7 +806,6 @@ _aesni_inc_init: mov $1,TCTR_LOW movd TCTR_LOW,INC movd CTR,TCTR_LOW - RETGUARD_CHECK(_aesni_inc_init, rax) ret /* @@ -856,7 +824,6 @@ _aesni_inc_init: * TCTR_LOW: == lower dword of CTR */ _aesni_inc: - RETGUARD_SETUP(_aesni_inc, rax) paddq INC,CTR add $1,TCTR_LOW jnc 1f @@ -866,7 +833,6 @@ _aesni_inc: 1: movaps CTR,IV pshufb BSWAP_MASK,IV - RETGUARD_CHECK(_aesni_inc, rax) ret /* @@ -874,7 +840,6 @@ _aesni_inc: * size_t len, uint8_t *icb) */ ENTRY(aesni_ctr_enc) - RETGUARD_SETUP(aesni_ctr_enc, r10) cmp $16,LEN jb 4f mov 480(KEYP),KLEN @@ -928,11 +893,9 @@ ENTRY(aesni_ctr_enc) 3: movq IV,(IVP) 4: - RETGUARD_CHECK(aesni_ctr_enc, r10) ret _aesni_gmac_gfmul: - RETGUARD_SETUP(_aesni_gmac_gfmul, rax) movdqa %xmm0,%xmm3 pclmulqdq $0x00,%xmm1,%xmm3 # xmm3 holds a0*b0 movdqa %xmm0,%xmm4 @@ -996,14 +959,12 @@ _aesni_gmac_gfmul: pxor %xmm8,%xmm2 pxor %xmm2,%xmm3 pxor %xmm3,%xmm6 # the result is in xmm6 - RETGUARD_CHECK(_aesni_gmac_gfmul, rax) ret /* * void aesni_gmac_update(GHASH_CTX *ghash, uint8_t *src, size_t len) */ ENTRY(aesni_gmac_update) - RETGUARD_SETUP(aesni_gmac_update, r11) cmp $16,%rdx jb 2f @@ -1029,7 +990,6 @@ ENTRY(aesni_gmac_update) movdqu %xmm6,16(%rdi) movdqu %xmm6,32(%rdi) 2: - RETGUARD_CHECK(aesni_gmac_update, r11) ret /* @@ -1037,14 +997,12 @@ ENTRY(aesni_gmac_update) * uint8_t *icb, uint8_t *hashstate) */ ENTRY(aesni_gmac_final) - RETGUARD_SETUP(aesni_gmac_final, r11) movl 480(KEYP),KLEN # key length movdqu (INP),STATE # icb call _aesni_enc1 movdqu (HSTATE),IN pxor IN,STATE movdqu STATE,(OUTP) # output - RETGUARD_CHECK(aesni_gmac_final, r11) ret /* @@ -1052,8 +1010,6 @@ ENTRY(aesni_gmac_final) * size_t len, uint8_t *iv) */ ENTRY(aesni_xts_enc) - RETGUARD_SETUP(aesni_xts_enc, r11) - RETGUARD_PUSH(r11) cmp $16,%rcx jb 2f @@ -1075,8 +1031,6 @@ ENTRY(aesni_xts_enc) cmp $16,%rcx jge 1b 2: - RETGUARD_POP(r11) - RETGUARD_CHECK(aesni_xts_enc, r11) ret /* @@ -1084,8 +1038,6 @@ ENTRY(aesni_xts_enc) * size_t len, uint8_t *iv) */ ENTRY(aesni_xts_dec) - RETGUARD_SETUP(aesni_xts_dec, r11) - RETGUARD_PUSH(r11) cmp $16,%rcx jb 2f @@ -1108,8 +1060,6 @@ ENTRY(aesni_xts_dec) cmp $16,%rcx jge 1b 2: - RETGUARD_POP(r11) - RETGUARD_CHECK(aesni_xts_dec, r11) ret /* @@ -1120,8 +1070,6 @@ ENTRY(aesni_xts_dec) * xts is in %rdi, iv is in %r8 and we return the tweak in %xmm3. */ _aesni_xts_tweak: - RETGUARD_SETUP(_aesni_xts_tweak, rax) - RETGUARD_PUSH(rax) mov (%r8),%r10 movd %r10,%xmm0 # Last 64-bits of IV are always zero. mov KEYP,%r11 @@ -1130,15 +1078,12 @@ _aesni_xts_tweak: call _aesni_enc1 movdqa %xmm0,%xmm3 mov %r11,KEYP - RETGUARD_POP(rax) - RETGUARD_CHECK(_aesni_xts_tweak, rax) ret /* * Exponentiate AES XTS tweak (in %xmm3). */ _aesni_xts_tweak_exp: - RETGUARD_SETUP(_aesni_xts_tweak_exp, rax) pextrw $7,%xmm3,%r10 pextrw $3,%xmm3,%r11 psllq $1,%xmm3 # Left shift. @@ -1156,5 +1101,4 @@ _aesni_xts_tweak_exp: xor $0x87,%r11 # AES XTS alpha - GF(2^128). pinsrw $0,%r11,%xmm3 2: - RETGUARD_CHECK(_aesni_xts_tweak_exp, rax) ret |