8274323: compiler/codegen/aes/TestAESMain.java failed with "Error: invalid offset: -1434443640" after 8273297

Reviewed-by: sviswanathan, kvn
This commit is contained in:
Smita Kamath 2021-12-20 20:09:42 +00:00 committed by Sandhya Viswanathan
parent ad1282842c
commit 819f9bd084
12 changed files with 20 additions and 52 deletions

@ -55,9 +55,6 @@
// No support for generic vector operands.
static const bool supports_generic_vector_operands = false;
// No support for 48 extra htbl entries in aes-gcm intrinsic
static const int htbl_entries = 0;
static constexpr bool isSimpleConstant64(jlong value) {
// Will one (StoreL ConL) be cheaper than two (StoreI ConI)?.
// Probably always true, even if a temp register is required.

@ -3094,8 +3094,7 @@ class StubGenerator: public StubCodeGenerator {
// key = c_rarg4
// state = c_rarg5 - GHASH.state
// subkeyHtbl = c_rarg6 - powers of H
// subkeyHtbl_48_entries = c_rarg7 (not used)
// counter = [sp, #0] pointer to 16 bytes of CTR
// counter = c_rarg7 - 16 bytes of CTR
// return - number of processed bytes
address generate_galoisCounterMode_AESCrypt() {
address ghash_polynomial = __ pc();
@ -3121,10 +3120,7 @@ class StubGenerator: public StubCodeGenerator {
const Register subkeyHtbl = c_rarg6;
// Pointer to CTR is passed on the stack before the (fp, lr) pair.
const Address counter_mem(sp, 2 * wordSize);
const Register counter = c_rarg7;
__ ldr(counter, counter_mem);
const Register keylen = r10;
// Save state before entering routine

@ -56,9 +56,6 @@
// No support for generic vector operands.
static const bool supports_generic_vector_operands = false;
// No support for 48 extra htbl entries in aes-gcm intrinsic
static const int htbl_entries = -1;
static constexpr bool isSimpleConstant64(jlong value) {
// Will one (StoreL ConL) be cheaper than two (StoreI ConI)?.
return false;

@ -57,9 +57,6 @@
// No support for generic vector operands.
static const bool supports_generic_vector_operands = false;
// No support for 48 extra htbl entries in aes-gcm intrinsic
static const int htbl_entries = -1;
static constexpr bool isSimpleConstant64(jlong value) {
// Probably always true, even if a temp register is required.
return true;

@ -57,9 +57,6 @@
// No support for generic vector operands.
static const bool supports_generic_vector_operands = false;
// No support for 48 extra htbl entries in aes-gcm intrinsic
static const int htbl_entries = -1;
static constexpr bool isSimpleConstant64(jlong value) {
// Probably always true, even if a temp register is required.
return true;

@ -148,8 +148,6 @@
static const bool int_in_long = false;
#endif
// Number of htbl entries for aes-gcm intrinsic
static const int htbl_entries = 96;
// Does the CPU supports vector variable shift instructions?
static bool supports_vector_variable_shifts(void) {

@ -4414,9 +4414,8 @@ class StubGenerator: public StubCodeGenerator {
const Register state = c_rarg5;
const Address subkeyH_mem(rbp, 2 * wordSize);
const Register subkeyHtbl = r11;
const Address avx512_subkeyH_mem(rbp, 3 * wordSize);
const Register avx512_subkeyHtbl = r13;
const Address counter_mem(rbp, 4 * wordSize);
const Address counter_mem(rbp, 3 * wordSize);
const Register counter = r12;
#else
const Address key_mem(rbp, 6 * wordSize);
@ -4425,9 +4424,8 @@ class StubGenerator: public StubCodeGenerator {
const Register state = r13;
const Address subkeyH_mem(rbp, 8 * wordSize);
const Register subkeyHtbl = r14;
const Address avx512_subkeyH_mem(rbp, 9 * wordSize);
const Register avx512_subkeyHtbl = r12;
const Address counter_mem(rbp, 10 * wordSize);
const Address counter_mem(rbp, 9 * wordSize);
const Register counter = rsi;
#endif
__ enter();
@ -4444,11 +4442,20 @@ class StubGenerator: public StubCodeGenerator {
__ movptr(state, state_mem);
#endif
__ movptr(subkeyHtbl, subkeyH_mem);
__ movptr(avx512_subkeyHtbl, avx512_subkeyH_mem);
__ movptr(counter, counter_mem);
// Save rbp and rsp
__ push(rbp);
__ movq(rbp, rsp);
// Align stack
__ andq(rsp, -64);
__ subptr(rsp, 96 * longSize); // Create space on the stack for htbl entries
__ movptr(avx512_subkeyHtbl, rsp);
__ aesgcm_encrypt(in, len, ct, out, key, state, subkeyHtbl, avx512_subkeyHtbl, counter);
__ movq(rsp, rbp);
__ pop(rbp);
// Restore state before leaving routine
#ifdef _WIN64
__ pop(rsi);

@ -2494,8 +2494,7 @@ Node* GraphKit::make_runtime_call(int flags,
Node* parm0, Node* parm1,
Node* parm2, Node* parm3,
Node* parm4, Node* parm5,
Node* parm6, Node* parm7,
Node* parm8) {
Node* parm6, Node* parm7) {
assert(call_addr != NULL, "must not call NULL targets");
// Slow-path call
@ -2542,8 +2541,7 @@ Node* GraphKit::make_runtime_call(int flags,
if (parm5 != NULL) { call->init_req(TypeFunc::Parms+5, parm5);
if (parm6 != NULL) { call->init_req(TypeFunc::Parms+6, parm6);
if (parm7 != NULL) { call->init_req(TypeFunc::Parms+7, parm7);
if (parm8 != NULL) { call->init_req(TypeFunc::Parms+8, parm8);
/* close each nested if ===> */ } } } } } } } } }
/* close each nested if ===> */ } } } } } } } }
assert(call->in(call->req()-1) != NULL, "must initialize all parms");
if (!is_leaf) {

@ -802,8 +802,7 @@ class GraphKit : public Phase {
Node* parm0 = NULL, Node* parm1 = NULL,
Node* parm2 = NULL, Node* parm3 = NULL,
Node* parm4 = NULL, Node* parm5 = NULL,
Node* parm6 = NULL, Node* parm7 = NULL,
Node* parm8 = NULL);
Node* parm6 = NULL, Node* parm7 = NULL);
Node* sign_extend_byte(Node* in);
Node* sign_extend_short(Node* in);

@ -6795,7 +6795,7 @@ bool LibraryCallKit::inline_galoisCounterMode_AESCrypt() {
Node* state = load_field_from_object(ghash_object, "state", "[J");
if (embeddedCipherObj == NULL || counter == NULL || subkeyHtbl == NULL || state == NULL) {
return false;
return false;
}
// cast it to what we know it will be at runtime
const TypeInstPtr* tinst = _gvn.type(gctr_object)->isa_instptr();
@ -6811,38 +6811,22 @@ bool LibraryCallKit::inline_galoisCounterMode_AESCrypt() {
// we need to get the start of the aescrypt_object's expanded key array
Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object);
if (k_start == NULL) return false;
// similarly, get the start address of the r vector
Node* cnt_start = array_element_address(counter, intcon(0), T_BYTE);
Node* state_start = array_element_address(state, intcon(0), T_LONG);
Node* subkeyHtbl_start = array_element_address(subkeyHtbl, intcon(0), T_LONG);
ciKlass* klass = ciTypeArrayKlass::make(T_LONG);
Node* klass_node = makecon(TypeKlassPtr::make(klass));
// Does this target support this intrinsic?
if (Matcher::htbl_entries == -1) return false;
Node* subkeyHtbl_48_entries_start;
if (Matcher::htbl_entries != 0) {
// new array to hold 48 computed htbl entries
Node* subkeyHtbl_48_entries = new_array(klass_node, intcon(Matcher::htbl_entries), 0);
if (subkeyHtbl_48_entries == NULL) return false;
subkeyHtbl_48_entries_start = array_element_address(subkeyHtbl_48_entries, intcon(0), T_LONG);
} else {
// This target doesn't need the extra-large Htbl.
subkeyHtbl_48_entries_start = ConvL2X(intcon(0));
}
// Call the stub, passing params
Node* gcmCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
OptoRuntime::galoisCounterMode_aescrypt_Type(),
stubAddr, stubName, TypePtr::BOTTOM,
in_start, len, ct_start, out_start, k_start, state_start, subkeyHtbl_start, subkeyHtbl_48_entries_start, cnt_start);
in_start, len, ct_start, out_start, k_start, state_start, subkeyHtbl_start, cnt_start);
// return cipher length (int)
Node* retvalue = _gvn.transform(new ProjNode(gcmCrypt, TypeFunc::Parms));
set_result(retvalue);
return true;
}

@ -958,7 +958,7 @@ const TypeFunc* OptoRuntime::counterMode_aescrypt_Type() {
//for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
const TypeFunc* OptoRuntime::galoisCounterMode_aescrypt_Type() {
// create input type (domain)
int num_args = 9;
int num_args = 8;
int argcnt = num_args;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
@ -969,7 +969,6 @@ const TypeFunc* OptoRuntime::galoisCounterMode_aescrypt_Type() {
fields[argp++] = TypePtr::NOTNULL; // byte[] key from AESCrypt obj
fields[argp++] = TypePtr::NOTNULL; // long[] state from GHASH obj
fields[argp++] = TypePtr::NOTNULL; // long[] subkeyHtbl from GHASH obj
fields[argp++] = TypePtr::NOTNULL; // long[] avx512_subkeyHtbl newly created
fields[argp++] = TypePtr::NOTNULL; // byte[] counter from GCTR obj
assert(argp == TypeFunc::Parms + argcnt, "correct decoding");

@ -37,4 +37,3 @@ vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java 82456
serviceability/sa/TestJhsdbJstackMixed.java 8248675 linux-aarch64
compiler/codegen/aes/TestAESMain.java 8274323 linux-x64,windows-x64