3976 __ sha512_AVX2(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4, |
3976 __ sha512_AVX2(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4, |
3977 buf, state, ofs, limit, rsp, multi_block, shuf_mask); |
3977 buf, state, ofs, limit, rsp, multi_block, shuf_mask); |
3978 |
3978 |
3979 __ vzeroupper(); |
3979 __ vzeroupper(); |
3980 __ leave(); |
3980 __ leave(); |
|
3981 __ ret(0); |
|
3982 return start; |
|
3983 } |
|
3984 |
|
3985 // This mask is used for incrementing counter value(linc0, linc4, etc.) |
|
3986 address counter_mask_addr() { |
|
3987 __ align(64); |
|
3988 StubCodeMark mark(this, "StubRoutines", "counter_mask_addr"); |
|
3989 address start = __ pc(); |
|
3990 __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);//lbswapmask |
|
3991 __ emit_data64(0x0001020304050607, relocInfo::none); |
|
3992 __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none); |
|
3993 __ emit_data64(0x0001020304050607, relocInfo::none); |
|
3994 __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none); |
|
3995 __ emit_data64(0x0001020304050607, relocInfo::none); |
|
3996 __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none); |
|
3997 __ emit_data64(0x0001020304050607, relocInfo::none); |
|
3998 __ emit_data64(0x0000000000000000, relocInfo::none);//linc0 = counter_mask_addr+64 |
|
3999 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4000 __ emit_data64(0x0000000000000001, relocInfo::none);//counter_mask_addr() + 80 |
|
4001 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4002 __ emit_data64(0x0000000000000002, relocInfo::none); |
|
4003 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4004 __ emit_data64(0x0000000000000003, relocInfo::none); |
|
4005 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4006 __ emit_data64(0x0000000000000004, relocInfo::none);//linc4 = counter_mask_addr() + 128 |
|
4007 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4008 __ emit_data64(0x0000000000000004, relocInfo::none); |
|
4009 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4010 __ emit_data64(0x0000000000000004, relocInfo::none); |
|
4011 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4012 __ emit_data64(0x0000000000000004, relocInfo::none); |
|
4013 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4014 __ emit_data64(0x0000000000000008, relocInfo::none);//linc8 = counter_mask_addr() + 192 |
|
4015 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4016 __ emit_data64(0x0000000000000008, relocInfo::none); |
|
4017 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4018 __ emit_data64(0x0000000000000008, relocInfo::none); |
|
4019 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4020 __ emit_data64(0x0000000000000008, relocInfo::none); |
|
4021 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4022 __ emit_data64(0x0000000000000020, relocInfo::none);//linc32 = counter_mask_addr() + 256 |
|
4023 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4024 __ emit_data64(0x0000000000000020, relocInfo::none); |
|
4025 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4026 __ emit_data64(0x0000000000000020, relocInfo::none); |
|
4027 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4028 __ emit_data64(0x0000000000000020, relocInfo::none); |
|
4029 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4030 __ emit_data64(0x0000000000000010, relocInfo::none);//linc16 = counter_mask_addr() + 320 |
|
4031 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4032 __ emit_data64(0x0000000000000010, relocInfo::none); |
|
4033 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4034 __ emit_data64(0x0000000000000010, relocInfo::none); |
|
4035 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4036 __ emit_data64(0x0000000000000010, relocInfo::none); |
|
4037 __ emit_data64(0x0000000000000000, relocInfo::none); |
|
4038 return start; |
|
4039 } |
|
4040 |
|
4041 // Vector AES Counter implementation |
|
4042 address generate_counterMode_VectorAESCrypt() { |
|
4043 __ align(CodeEntryAlignment); |
|
4044 StubCodeMark mark(this, "StubRoutines", "counterMode_AESCrypt"); |
|
4045 address start = __ pc(); |
|
4046 const Register from = c_rarg0; // source array address |
|
4047 const Register to = c_rarg1; // destination array address |
|
4048 const Register key = c_rarg2; // key array address r8 |
|
4049 const Register counter = c_rarg3; // counter byte array initialized from counter array address |
|
4050 // and updated with the incremented counter in the end |
|
4051 #ifndef _WIN64 |
|
4052 const Register len_reg = c_rarg4; |
|
4053 const Register saved_encCounter_start = c_rarg5; |
|
4054 const Register used_addr = r10; |
|
4055 const Address used_mem(rbp, 2 * wordSize); |
|
4056 const Register used = r11; |
|
4057 #else |
|
4058 const Address len_mem(rbp, 6 * wordSize); // length is on stack on Win64 |
|
4059 const Address saved_encCounter_mem(rbp, 7 * wordSize); // saved encrypted counter is on stack on Win64 |
|
4060 const Address used_mem(rbp, 8 * wordSize); // used length is on stack on Win64 |
|
4061 const Register len_reg = r10; // pick the first volatile windows register |
|
4062 const Register saved_encCounter_start = r11; |
|
4063 const Register used_addr = r13; |
|
4064 const Register used = r14; |
|
4065 #endif |
|
4066 __ enter(); |
|
4067 // Save state before entering routine |
|
4068 __ push(r12); |
|
4069 __ push(r13); |
|
4070 __ push(r14); |
|
4071 __ push(r15); |
|
4072 #ifdef _WIN64 |
|
4073 // on win64, fill len_reg from stack position |
|
4074 __ movl(len_reg, len_mem); |
|
4075 __ movptr(saved_encCounter_start, saved_encCounter_mem); |
|
4076 __ movptr(used_addr, used_mem); |
|
4077 __ movl(used, Address(used_addr, 0)); |
|
4078 #else |
|
4079 __ push(len_reg); // Save |
|
4080 __ movptr(used_addr, used_mem); |
|
4081 __ movl(used, Address(used_addr, 0)); |
|
4082 #endif |
|
4083 __ push(rbx); |
|
4084 __ aesctr_encrypt(from, to, key, counter, len_reg, used, used_addr, saved_encCounter_start); |
|
4085 // Restore state before leaving routine |
|
4086 __ pop(rbx); |
|
4087 #ifdef _WIN64 |
|
4088 __ movl(rax, len_mem); // return length |
|
4089 #else |
|
4090 __ pop(rax); // return length |
|
4091 #endif |
|
4092 __ pop(r15); |
|
4093 __ pop(r14); |
|
4094 __ pop(r13); |
|
4095 __ pop(r12); |
|
4096 |
|
4097 __ leave(); // required for proper stackwalking of RuntimeStub frame |
3981 __ ret(0); |
4098 __ ret(0); |
3982 return start; |
4099 return start; |
3983 } |
4100 } |
3984 |
4101 |
3985 // This is a version of CTR/AES crypt which does 6 blocks in a loop at a time |
4102 // This is a version of CTR/AES crypt which does 6 blocks in a loop at a time |