Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8274730: AArch64: AES/GCM acceleration is broken by the fix for JDK-8273297 #5819

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -56,7 +56,7 @@
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 const int htbl_entries = 0;

static constexpr bool isSimpleConstant64(jlong value) {
// Will one (StoreL ConL) be cheaper than two (StoreI ConI)?.
@@ -3094,7 +3094,8 @@ class StubGenerator: public StubCodeGenerator {
// key = c_rarg4
// state = c_rarg5 - GHASH.state
// subkeyHtbl = c_rarg6 - powers of H
// counter = c_rarg7 - pointer to 16 bytes of CTR
// subkeyHtbl_48_entries = c_rarg7 (not used)
// counter = [sp, #0] pointer to 16 bytes of CTR
// return - number of processed bytes
address generate_galoisCounterMode_AESCrypt() {
address ghash_polynomial = __ pc();
@@ -3107,6 +3108,8 @@ class StubGenerator: public StubCodeGenerator {
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", "galoisCounterMode_AESCrypt");
address start = __ pc();
__ enter();

const Register in = c_rarg0;
const Register len = c_rarg1;
const Register ct = c_rarg2;
@@ -3118,10 +3121,12 @@ 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;
__ enter();
// Save state before entering routine
__ sub(sp, sp, 4 * 16);
__ st1(v12, v13, v14, v15, __ T16B, Address(sp));
@@ -6794,14 +6794,20 @@ bool LibraryCallKit::inline_galoisCounterMode_AESCrypt() {
ciKlass* klass = ciTypeArrayKlass::make(T_LONG);
Node* klass_node = makecon(TypeKlassPtr::make(klass));

// htbl entries is set to 96 only fox x86-64
// Does this target support this intrinsic?
if (Matcher::htbl_entries == -1) return false;

// new array to hold 48 computed htbl entries
Copy link
Contributor

@vnkozlov vnkozlov Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this comment under (Matcher::htbl_entries != 0) check.

Node* subkeyHtbl_48_entries = new_array(klass_node, intcon(Matcher::htbl_entries), 0);
if (subkeyHtbl_48_entries == NULL) return false;

Node* subkeyHtbl_48_entries_start = array_element_address(subkeyHtbl_48_entries, intcon(0), T_LONG);
Node* subkeyHtbl_48_entries_start;
if (Matcher::htbl_entries != 0) {
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);
Copy link
Contributor

@vnkozlov vnkozlov Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, don't split such line.

} 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,