Skip to content

Commit 518dad9

Browse files
committed
JDK-8371864: GaloisCounterMode.implGCMCrypt0 AVX512/AVX2 intrinsics stubs cause AES-GCM encryption failure for certain payload sizes
1 parent 6322aab commit 518dad9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3527,6 +3527,8 @@ void StubGenerator::aesgcm_avx512(Register in, Register len, Register ct, Regist
35273527

35283528
__ bind(MESG_BELOW_32_BLKS);
35293529
__ subl(len, 16 * 16);
3530+
__ cmpl(len, 256);
3531+
__ jcc(Assembler::lessEqual, ENC_DEC_DONE);
35303532
__ addl(pos, 16 * 16);
35313533
gcm_enc_dec_last_avx512(len, in, pos, AAD_HASHx, SHUF_MASK, avx512_subkeyHtbl, ghashin_offset, HashKey_16, true, true);
35323534

@@ -4016,13 +4018,15 @@ void StubGenerator::aesgcm_avx2(Register in, Register len, Register ct, Register
40164018
const Register rounds = r10;
40174019
const XMMRegister ctr_blockx = xmm9;
40184020
const XMMRegister aad_hashx = xmm8;
4019-
Label encrypt_done, encrypt_by_8_new, encrypt_by_8;
4021+
Label encrypt_done, encrypt_by_8_new, encrypt_by_8, exit;
40204022

40214023
//This routine should be called only for message sizes of 128 bytes or more.
40224024
//Macro flow:
40234025
//process 8 16 byte blocks in initial_num_blocks.
40244026
//process 8 16 byte blocks at a time until all are done 'encrypt_by_8_new followed by ghash_last_8'
40254027
__ xorl(pos, pos);
4028+
__ cmpl(len, 128);
4029+
__ jcc(Assembler::less, exit);
40264030

40274031
//Generate 8 constants for htbl
40284032
generateHtbl_8_block_avx2(subkeyHtbl);
@@ -4090,6 +4094,7 @@ void StubGenerator::aesgcm_avx2(Register in, Register len, Register ct, Register
40904094
__ vpxor(xmm0, xmm0, xmm0, Assembler::AVX_128bit);
40914095
__ vpxor(xmm13, xmm13, xmm13, Assembler::AVX_128bit);
40924096

4097+
__ bind(exit);
40934098
}
40944099

40954100
#undef __

0 commit comments

Comments
 (0)