I4AJ95:New features in Bisheng JDK 302

This commit is contained in:
kuenking111 2021-09-17 16:17:39 +08:00
parent 397ee452e0
commit 441e565b80
16 changed files with 5690 additions and 1 deletions

View File

@ -0,0 +1,121 @@
From e10cb7fc2dc99af5f7ccb4947fe828c008843f22 Mon Sep 17 00:00:00 2001
From: mashoubing <mashoubing1@huawei.com>
Date: Tue, 14 Sep 2021 20:26:58 +0800
Subject: [PATCH 21/23] 8143251:Thread suspend on
VM_G1IncCollectionPause::doit_epilogue()
Summary: gc:call system.gc after remark cause Process suspending
LLT: NA
Patch Type:backport
Bug url:NA
---
.../gc_implementation/g1/g1CollectedHeap.cpp | 14 +++++++++----
.../gc_implementation/g1/g1CollectedHeap.hpp | 2 ++
.../g1/g1CollectorPolicy.cpp | 21 +++++++++++++------
.../g1/g1CollectorPolicy.hpp | 5 +++++
4 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
index 1afc2e331..8ed6207ad 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -2383,15 +2383,21 @@ size_t G1CollectedHeap::recalculate_used() const {
return blk.result();
}
+bool G1CollectedHeap::is_user_requested_concurrent_full_gc(GCCause::Cause cause) {
+ switch (cause) {
+ case GCCause::_java_lang_system_gc: return ExplicitGCInvokesConcurrent;
+ case GCCause::_update_allocation_context_stats_inc: return true;
+ case GCCause::_wb_conc_mark: return true;
+ default : return false;
+ }
+}
+
bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
switch (cause) {
case GCCause::_gc_locker: return GCLockerInvokesConcurrent;
- case GCCause::_java_lang_system_gc: return ExplicitGCInvokesConcurrent;
case GCCause::_g1_humongous_allocation: return true;
- case GCCause::_update_allocation_context_stats_inc: return true;
- case GCCause::_wb_conc_mark: return true;
case GCCause::_g1_periodic_collection: return true;
- default: return false;
+ default: return is_user_requested_concurrent_full_gc(cause);
}
}
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
index 2858ebfba..d83e6cb65 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
@@ -715,6 +715,8 @@ public:
_in_cset_fast_test.clear();
}
+ bool is_user_requested_concurrent_full_gc(GCCause::Cause cause);
+
// This is called at the start of either a concurrent cycle or a Full
// GC to update the number of old marking cycles started.
void increment_old_marking_cycles_started();
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
index 6d817883a..099762f2b 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
@@ -1504,6 +1504,11 @@ bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(
}
}
+void G1CollectorPolicy::initiate_conc_mark() {
+ set_during_initial_mark_pause();
+ clear_initiate_conc_mark_if_possible();
+}
+
void
G1CollectorPolicy::decide_on_conc_mark_initiation() {
// We are about to decide on whether this pause will be an
@@ -1523,15 +1528,19 @@ G1CollectorPolicy::decide_on_conc_mark_initiation() {
if (!about_to_start_mixed_phase() && gcs_are_young()) {
// Initiate a new initial mark only if there is no marking or reclamation going
// on.
- set_during_initial_mark_pause();
-
- // And we can now clear initiate_conc_mark_if_possible() as
- // we've already acted on it.
- clear_initiate_conc_mark_if_possible();
-
+ initiate_conc_mark();
ergo_verbose0(ErgoConcCycles,
"initiate concurrent cycle",
ergo_format_reason("concurrent cycle initiation requested"));
+ } else if (_g1->is_user_requested_concurrent_full_gc(_g1->gc_cause())) {
+ // Initiate a user requested initial mark. An initial mark must be young only
+ // GC, so the collector state must be updated to reflect this.
+ set_gcs_are_young(true);
+ _last_young_gc = false;
+ initiate_conc_mark();
+ ergo_verbose0(ErgoConcCycles,
+ "initiate concurrent cycle",
+ ergo_format_reason("user requested concurrent cycle"));
} else {
// The concurrent marking thread is still finishing up the
// previous cycle. If we start one right now the two cycles
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
index 6438e5e90..1a0d20d6f 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
@@ -808,6 +808,11 @@ private:
// (should not be called directly).
void add_region_to_incremental_cset_common(HeapRegion* hr);
+ // Set the state to start a concurrent marking cycle and clear
+ // _initiate_conc_mark_if_possible because it has now been
+ // acted on.
+ void initiate_conc_mark();
+
public:
// Add hr to the LHS of the incremental collection set.
void add_region_to_incremental_cset_lhs(HeapRegion* hr);
--
2.22.0

View File

@ -0,0 +1,64 @@
From 6456acbb0412f0a0f3e7374b27e66a504ece36ff Mon Sep 17 00:00:00 2001
From: c00229008 <chenshanyao@huawei.com>
Date: Wed, 4 Aug 2021 09:43:49 +0800
Subject: [PATCH 01/23] 8167014: jdeps failed with "Missing message:
warn.skipped.entry"
Summary: <langtools>: jdeps failed with "Missing message: warn.skipped.entry"
LLT: tomcat-websocket-10.0.8.jar
Patch Type: backport
Bug url: https://bugs.openjdk.java.net/browse/JDK-8167014
---
.../share/classes/com/sun/tools/jdeps/ClassFileReader.java | 5 ++++-
.../src/share/classes/com/sun/tools/jdeps/JdepsTask.java | 6 ++++--
.../classes/com/sun/tools/jdeps/resources/jdeps.properties | 1 +
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java
index f41f2d0ba..07da40357 100644
--- a/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java
+++ b/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java
@@ -337,7 +337,10 @@ public class ClassFileReader {
cf = reader.readClassFile(jf, nextEntry);
return true;
} catch (ClassFileError | IOException ex) {
- skippedEntries.add(nextEntry.getName());
+ skippedEntries.add(String.format("%s: %s (%s)",
+ ex.getMessage(),
+ nextEntry.getName(),
+ jf.getName()));
}
nextEntry = nextEntry();
}
diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
index 91002d319..97dba138e 100644
--- a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
+++ b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
@@ -559,8 +559,10 @@ class JdepsTask {
a.addClass(d.getOrigin());
}
}
- for (String name : a.reader().skippedEntries()) {
- warning("warn.skipped.entry", name, a.getPathName());
+ if (!options.nowarning) {
+ for (String name : a.reader().skippedEntries()) {
+ warning("warn.skipped.entry", name, a.getPathName());
+ }
}
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
index 51d11b88a..501c4d6cd 100644
--- a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
+++ b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
@@ -92,6 +92,7 @@ err.option.unsupported={0} not supported: {1}
err.profiles.msg=No profile information
err.invalid.path=invalid path: {0}
warn.invalid.arg=Invalid classname or pathname not exist: {0}
+warn.skipped.entry={0}
warn.split.package=package {0} defined in {1} {2}
warn.replace.useJDKInternals=\
JDK internal APIs are unsupported and private to JDK implementation that are\n\
--
2.22.0

View File

@ -0,0 +1,305 @@
From a83cfc9dc14746ad816933008e700d6d35dcf5f6 Mon Sep 17 00:00:00 2001
From: wangkun <wangkun49@huawei.com>
Date: Sat, 11 Sep 2021 09:45:39 +0800
Subject: [PATCH 12/23] 8197387: Run the jcmd tool as the root user to access
the Java process that is not run by the root user.
Summary: <tools> : Run the jcmd tool as the root user to access the Java process that is not run by the root user.
LLT: NA
Patch Type: backport
Bug url: https://bugs.openjdk.java.net/browse/JDK-8197387
---
hotspot/src/os/aix/vm/attachListener_aix.cpp | 11 +++++------
hotspot/src/os/bsd/vm/attachListener_bsd.cpp | 11 +++++------
hotspot/src/os/linux/vm/attachListener_linux.cpp | 11 +++++------
hotspot/src/os/posix/vm/os_posix.cpp | 14 ++++++++++++++
hotspot/src/os/posix/vm/os_posix.hpp | 10 ++++++++++
.../src/os/solaris/vm/attachListener_solaris.cpp | 12 ++++++------
.../native/sun/tools/attach/AixVirtualMachine.c | 5 +++--
.../native/sun/tools/attach/BsdVirtualMachine.c | 6 ++++--
.../native/sun/tools/attach/LinuxVirtualMachine.c | 6 ++++--
.../sun/tools/attach/SolarisVirtualMachine.c | 6 ++++--
10 files changed, 60 insertions(+), 32 deletions(-)
diff --git a/hotspot/src/os/aix/vm/attachListener_aix.cpp b/hotspot/src/os/aix/vm/attachListener_aix.cpp
index 5b7cb29f1..d23756ead 100644
--- a/hotspot/src/os/aix/vm/attachListener_aix.cpp
+++ b/hotspot/src/os/aix/vm/attachListener_aix.cpp
@@ -382,10 +382,9 @@ AixAttachOperation* AixAttachListener::dequeue() {
RESTARTABLE(::close(s), res);
continue;
}
- uid_t euid = geteuid();
- gid_t egid = getegid();
-
- if (cred_info.euid != euid || cred_info.egid != egid) {
+ if (!os::Posix::matches_effective_uid_and_gid_or_root(cred_info.euid, cred_info.egid)) {
+ log_debug(attach)("euid/egid check failed (%d/%d vs %d/%d)",
+ cred_info.euid, cred_info.egid, geteuid(), getegid());
int res;
RESTARTABLE(::close(s), res);
continue;
@@ -541,8 +540,8 @@ bool AttachListener::is_init_trigger() {
}
if (ret == 0) {
// simple check to avoid starting the attach mechanism when
- // a bogus user creates the file
- if (st.st_uid == geteuid()) {
+ // a bogus non-root user creates the file
+ if (os::Posix::matches_effective_uid_or_root(st.st_uid)) {
init();
return true;
}
diff --git a/hotspot/src/os/bsd/vm/attachListener_bsd.cpp b/hotspot/src/os/bsd/vm/attachListener_bsd.cpp
index 4a580b486..4dd938954 100644
--- a/hotspot/src/os/bsd/vm/attachListener_bsd.cpp
+++ b/hotspot/src/os/bsd/vm/attachListener_bsd.cpp
@@ -348,10 +348,9 @@ BsdAttachOperation* BsdAttachListener::dequeue() {
::close(s);
continue;
}
- uid_t euid = geteuid();
- gid_t egid = getegid();
-
- if (puid != euid || pgid != egid) {
+ if (!os::Posix::matches_effective_uid_and_gid_or_root(puid, pgid)) {
+ log_debug(attach)("euid/egid check failed (%d/%d vs %d/%d)", puid, pgid,
+ geteuid(), getegid());
::close(s);
continue;
}
@@ -502,8 +501,8 @@ bool AttachListener::is_init_trigger() {
RESTARTABLE(::stat(path, &st), ret);
if (ret == 0) {
// simple check to avoid starting the attach mechanism when
- // a bogus user creates the file
- if (st.st_uid == geteuid()) {
+ // a bogus non-root user creates the file
+ if (os::Posix::matches_effective_uid_or_root(st.st_uid)) {
init();
return true;
}
diff --git a/hotspot/src/os/linux/vm/attachListener_linux.cpp b/hotspot/src/os/linux/vm/attachListener_linux.cpp
index 1ca089740..2a87e0d7f 100644
--- a/hotspot/src/os/linux/vm/attachListener_linux.cpp
+++ b/hotspot/src/os/linux/vm/attachListener_linux.cpp
@@ -343,10 +343,9 @@ LinuxAttachOperation* LinuxAttachListener::dequeue() {
::close(s);
continue;
}
- uid_t euid = geteuid();
- gid_t egid = getegid();
-
- if (cred_info.uid != euid || cred_info.gid != egid) {
+ if (!os::Posix::matches_effective_uid_and_gid_or_root(cred_info.uid, cred_info.gid)) {
+ tty->print_cr("euid/egid check failed (%d/%d vs %d/%d)",
+ cred_info.uid, cred_info.gid, geteuid(), getegid());
::close(s);
continue;
}
@@ -512,8 +511,8 @@ bool AttachListener::is_init_trigger() {
}
if (ret == 0) {
// simple check to avoid starting the attach mechanism when
- // a bogus user creates the file
- if (st.st_uid == geteuid()) {
+ // a bogus non-root user creates the file
+ if (os::Posix::matches_effective_uid_or_root(st.st_uid)) {
init();
return true;
}
diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp
index ac00e85ba..e7f1fddb9 100644
--- a/hotspot/src/os/posix/vm/os_posix.cpp
+++ b/hotspot/src/os/posix/vm/os_posix.cpp
@@ -44,6 +44,8 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
#endif
#define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
+#define ROOT_UID 0
+
// Check core dump limit and report possible place where core can be found
void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
int n;
@@ -858,6 +860,18 @@ void os::Posix::print_siginfo_brief(outputStream* os, const siginfo_t* si) {
}
}
+bool os::Posix::is_root(uid_t uid){
+ return ROOT_UID == uid;
+}
+
+bool os::Posix::matches_effective_uid_or_root(uid_t uid) {
+ return is_root(uid) || geteuid() == uid;
+}
+
+bool os::Posix::matches_effective_uid_and_gid_or_root(uid_t uid, gid_t gid) {
+ return is_root(uid) || (geteuid() == uid && getegid() == gid);
+}
+
Thread* os::ThreadCrashProtection::_protected_thread = NULL;
os::ThreadCrashProtection* os::ThreadCrashProtection::_crash_protection = NULL;
volatile intptr_t os::ThreadCrashProtection::_crash_mux = 0;
diff --git a/hotspot/src/os/posix/vm/os_posix.hpp b/hotspot/src/os/posix/vm/os_posix.hpp
index 5cdbb9ae6..d3e55d020 100644
--- a/hotspot/src/os/posix/vm/os_posix.hpp
+++ b/hotspot/src/os/posix/vm/os_posix.hpp
@@ -59,6 +59,16 @@ public:
// A POSIX conform, platform-independend siginfo print routine.
static void print_siginfo_brief(outputStream* os, const siginfo_t* si);
+ // Returns true if given uid is root.
+ static bool is_root(uid_t uid);
+
+ // Returns true if given uid is effective or root uid.
+ static bool matches_effective_uid_or_root(uid_t uid);
+
+ // Returns true if either given uid is effective uid and given gid is
+ // effective gid, or if given uid is root.
+ static bool matches_effective_uid_and_gid_or_root(uid_t uid, gid_t gid);
+
};
/*
diff --git a/hotspot/src/os/solaris/vm/attachListener_solaris.cpp b/hotspot/src/os/solaris/vm/attachListener_solaris.cpp
index 37400795e..001f8cbce 100644
--- a/hotspot/src/os/solaris/vm/attachListener_solaris.cpp
+++ b/hotspot/src/os/solaris/vm/attachListener_solaris.cpp
@@ -205,12 +205,12 @@ static int check_credentials() {
return -1; // unable to get them
}
- // get our euid/eguid (probably could cache these)
- uid_t euid = geteuid();
- gid_t egid = getegid();
+ // get euid/egid from ucred_free
+ uid_t ucred_euid = ucred_geteuid(cred_info);
+ gid_t ucred_egid = ucred_getegid(cred_info);
// check that the effective uid/gid matches - discuss this with Jeff.
- if (cred_info.dc_euid == euid && cred_info.dc_egid == egid) {
+ if (os::Posix::matches_effective_uid_and_gid_or_root(ucred_euid, ucred_egid)) {
return 0; // okay
} else {
return -1; // denied
@@ -644,8 +644,8 @@ bool AttachListener::is_init_trigger() {
}
if (ret == 0) {
// simple check to avoid starting the attach mechanism when
- // a bogus user creates the file
- if (st.st_uid == geteuid()) {
+ // a bogus non-root user creates the file
+ if (os::Posix::matches_effective_uid_or_root(st.st_uid)) {
init();
return true;
}
diff --git a/jdk/src/aix/native/sun/tools/attach/AixVirtualMachine.c b/jdk/src/aix/native/sun/tools/attach/AixVirtualMachine.c
index a1e6539e4..b67a0fe5a 100644
--- a/jdk/src/aix/native/sun/tools/attach/AixVirtualMachine.c
+++ b/jdk/src/aix/native/sun/tools/attach/AixVirtualMachine.c
@@ -54,6 +54,7 @@
} while((_result == -1) && (errno == EINTR)); \
} while(0)
+#define ROOT_UID 0
/*
* Class: sun_tools_attach_AixVirtualMachine
@@ -188,11 +189,11 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_AixVirtualMachine_checkPermissions
if (res == 0) {
char msg[100];
jboolean isError = JNI_FALSE;
- if (sb.st_uid != uid) {
+ if (sb.st_uid != uid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
isError = JNI_TRUE;
- } else if (sb.st_gid != gid) {
+ } else if (sb.st_gid != gid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
isError = JNI_TRUE;
diff --git a/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c
index f5afaab57..daf7b7ed9 100644
--- a/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c
+++ b/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c
@@ -50,6 +50,8 @@
} while((_result == -1) && (errno == EINTR)); \
} while(0)
+#define ROOT_UID 0
+
/*
* Class: sun_tools_attach_BsdVirtualMachine
* Method: socket
@@ -153,11 +155,11 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_BsdVirtualMachine_checkPermissions
if (res == 0) {
char msg[100];
jboolean isError = JNI_FALSE;
- if (sb.st_uid != uid) {
+ if (sb.st_uid != uid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
isError = JNI_TRUE;
- } else if (sb.st_gid != gid) {
+ } else if (sb.st_gid != gid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
isError = JNI_TRUE;
diff --git a/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c
index 6017308d0..32b7f8785 100644
--- a/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c
+++ b/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c
@@ -49,6 +49,8 @@
} while((_result == -1) && (errno == EINTR)); \
} while(0)
+#define ROOT_UID 0
+
/*
* Defines a callback that is invoked for each process
*/
@@ -371,11 +373,11 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_LinuxVirtualMachine_checkPermission
if (res == 0) {
char msg[100];
jboolean isError = JNI_FALSE;
- if (sb.st_uid != uid) {
+ if (sb.st_uid != uid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
isError = JNI_TRUE;
- } else if (sb.st_gid != gid) {
+ } else if (sb.st_gid != gid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
isError = JNI_TRUE;
diff --git a/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c
index d2710aaab..217943988 100644
--- a/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c
+++ b/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c
@@ -45,6 +45,8 @@
} while((_result == -1) && (errno == EINTR)); \
} while(0)
+#define ROOT_UID 0
+
/*
* Class: sun_tools_attach_SolarisVirtualMachine
* Method: open
@@ -116,11 +118,11 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_SolarisVirtualMachine_checkPermissi
if (res == 0) {
char msg[100];
jboolean isError = JNI_FALSE;
- if (sb.st_uid != uid) {
+ if (sb.st_uid != uid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
isError = JNI_TRUE;
- } else if (sb.st_gid != gid) {
+ } else if (sb.st_gid != gid && uid != ROOT_UID) {
jio_snprintf(msg, sizeof(msg)-1,
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
isError = JNI_TRUE;
--
2.22.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,232 @@
From d58382eb0c18949cd04b76c12c556e6f11036573 Mon Sep 17 00:00:00 2001
From: miaozhuojun <mouzhuojun@huawei.com>
Date: Sat, 11 Sep 2021 11:35:19 +0800
Subject: [PATCH 14/23] 8268453: sun/security/pkcs12/EmptyPassword.java fails
with Sequence tag error
Summary: < JDK> : 8268453: sun/security/pkcs12/EmptyPassword.java fails with Sequence tag error
LLT: ./jdk8u/jdk/test/sun/security/pkcs12/EmptyPassword.java
Patch Type: backport
Bug url: https://bugs.openjdk.java.net/browse/JDK-8268453
---
.../sun/security/pkcs12/PKCS12KeyStore.java | 125 +++++++++---------
1 file changed, 64 insertions(+), 61 deletions(-)
diff --git a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
index cdd01d6ab..ea3d61f30 100644
--- a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
+++ b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
@@ -286,6 +286,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
} catch (Exception e) {
if (password.length == 0) {
// Retry using an empty password with a NUL terminator.
+ if (debug != null) {
+ debug.println("Retry with a NUL password");
+ }
return f.tryOnce(new char[1]);
}
throw e;
@@ -366,7 +369,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
try {
PBEParameterSpec pbeSpec;
- int ic = 0;
+ int ic;
if (algParams != null) {
try {
@@ -380,68 +383,72 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
if (ic > MAX_ITERATION_COUNT) {
throw new IOException("PBE iteration count too large");
}
+ } else {
+ ic = 0;
}
- byte[] keyInfo = RetryWithZero.run(pass -> {
+ key = RetryWithZero.run(pass -> {
// Use JCE
SecretKey skey = getPBEKey(pass);
Cipher cipher = Cipher.getInstance(
mapPBEParamsToAlgorithm(algOid, algParams));
cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
- return cipher.doFinal(encryptedKey);
- }, password);
-
- /*
- * Parse the key algorithm and then use a JCA key factory
- * to re-create the key.
- */
- DerValue val = new DerValue(keyInfo);
- DerInputStream in = val.toDerInputStream();
- int i = in.getInteger();
- DerValue[] value = in.getSequence(2);
- if (value.length < 1 || value.length > 2) {
- throw new IOException("Invalid length for AlgorithmIdentifier");
- }
- AlgorithmId algId = new AlgorithmId(value[0].getOID());
- String keyAlgo = algId.getName();
-
- // decode private key
- if (entry instanceof PrivateKeyEntry) {
- KeyFactory kfac = KeyFactory.getInstance(keyAlgo);
- PKCS8EncodedKeySpec kspec = new PKCS8EncodedKeySpec(keyInfo);
- key = kfac.generatePrivate(kspec);
-
- if (debug != null) {
- debug.println("Retrieved a protected private key at alias" +
- " '" + alias + "' (" +
- new AlgorithmId(algOid).getName() +
- " iterations: " + ic + ")");
+ byte[] keyInfo = cipher.doFinal(encryptedKey);
+ /*
+ * Parse the key algorithm and then use a JCA key factory
+ * to re-create the key.
+ */
+ DerValue val = new DerValue(keyInfo);
+ DerInputStream in = val.toDerInputStream();
+ int i = in.getInteger();
+ DerValue[] value = in.getSequence(2);
+ if (value.length < 1 || value.length > 2) {
+ throw new IOException("Invalid length for AlgorithmIdentifier");
}
+ AlgorithmId algId = new AlgorithmId(value[0].getOID());
+ String keyAlgo = algId.getName();
- // decode secret key
- } else {
- byte[] keyBytes = in.getOctetString();
- SecretKeySpec secretKeySpec =
- new SecretKeySpec(keyBytes, keyAlgo);
-
- // Special handling required for PBE: needs a PBEKeySpec
- if (keyAlgo.startsWith("PBE")) {
- SecretKeyFactory sKeyFactory =
- SecretKeyFactory.getInstance(keyAlgo);
- KeySpec pbeKeySpec =
- sKeyFactory.getKeySpec(secretKeySpec, PBEKeySpec.class);
- key = sKeyFactory.generateSecret(pbeKeySpec);
+ // decode private key
+ if (entry instanceof PrivateKeyEntry) {
+ KeyFactory kfac = KeyFactory.getInstance(keyAlgo);
+ PKCS8EncodedKeySpec kspec = new PKCS8EncodedKeySpec(keyInfo);
+ Key tmp = kfac.generatePrivate(kspec);
+
+ if (debug != null) {
+ debug.println("Retrieved a protected private key at alias" +
+ " '" + alias + "' (" +
+ new AlgorithmId(algOid).getName() +
+ " iterations: " + ic + ")");
+ }
+ return tmp;
+ // decode secret key
} else {
- key = secretKeySpec;
- }
+ byte[] keyBytes = in.getOctetString();
+ SecretKeySpec secretKeySpec =
+ new SecretKeySpec(keyBytes, keyAlgo);
+
+ // Special handling required for PBE: needs a PBEKeySpec
+ Key tmp;
+ if (keyAlgo.startsWith("PBE")) {
+ SecretKeyFactory sKeyFactory =
+ SecretKeyFactory.getInstance(keyAlgo);
+ KeySpec pbeKeySpec =
+ sKeyFactory.getKeySpec(secretKeySpec, PBEKeySpec.class);
+ tmp = sKeyFactory.generateSecret(pbeKeySpec);
+ } else {
+ tmp = secretKeySpec;
+ }
- if (debug != null) {
- debug.println("Retrieved a protected secret key at alias " +
- "'" + alias + "' (" +
- new AlgorithmId(algOid).getName() +
- " iterations: " + ic + ")");
+ if (debug != null) {
+ debug.println("Retrieved a protected secret key at alias " +
+ "'" + alias + "' (" +
+ new AlgorithmId(algOid).getName() +
+ " iterations: " + ic + ")");
+ }
+ return tmp;
}
- }
+ }, password);
+
} catch (Exception e) {
UnrecoverableKeyException uke =
new UnrecoverableKeyException("Get Key failed: " +
@@ -1984,7 +1991,6 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
* Spin over the ContentInfos.
*/
for (int i = 0; i < count; i++) {
- byte[] safeContentsData;
ContentInfo safeContents;
DerInputStream sci;
byte[] eAlgId = null;
@@ -1992,14 +1998,13 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
sci = new DerInputStream(safeContentsArray[i].toByteArray());
safeContents = new ContentInfo(sci);
contentType = safeContents.getContentType();
- safeContentsData = null;
if (contentType.equals((Object)ContentInfo.DATA_OID)) {
if (debug != null) {
debug.println("Loading PKCS#7 data");
}
- safeContentsData = safeContents.getData();
+ loadSafeContents(new DerInputStream(safeContents.getData()));
} else if (contentType.equals((Object)ContentInfo.ENCRYPTED_DATA_OID)) {
if (password == null) {
@@ -2029,7 +2034,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
if (seq[2].isConstructed())
newTag |= 0x20;
seq[2].resetTag(newTag);
- safeContentsData = seq[2].getOctetString();
+ byte[] rawData = seq[2].getOctetString();
// parse Algorithm parameters
DerInputStream in = seq[1].toDerInputStream();
@@ -2060,14 +2065,14 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
" iterations: " + ic + ")");
}
- byte[] rawData = safeContentsData;
try {
- safeContentsData = RetryWithZero.run(pass -> {
+ RetryWithZero.run(pass -> {
// Use JCE
SecretKey skey = getPBEKey(pass);
Cipher cipher = Cipher.getInstance(algOid.toString());
cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
- return cipher.doFinal(rawData);
+ loadSafeContents(new DerInputStream(cipher.doFinal(rawData)));
+ return null;
}, password);
} catch (Exception e) {
throw new IOException("keystore password was incorrect",
@@ -2078,8 +2083,6 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
throw new IOException("public key protected PKCS12" +
" not supported");
}
- DerInputStream sc = new DerInputStream(safeContentsData);
- loadSafeContents(sc, password);
}
// The MacData is optional.
@@ -2204,7 +2207,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
else return null;
}
- private void loadSafeContents(DerInputStream stream, char[] password)
+ private void loadSafeContents(DerInputStream stream)
throws IOException, NoSuchAlgorithmException, CertificateException
{
DerValue[] safeBags = stream.getSequence(2);
--
2.22.0

View File

@ -0,0 +1,110 @@
From b14ebd1d4a12023d8dac06d44556b3559a10d76d Mon Sep 17 00:00:00 2001
From: wangkun <wangkun49@huawei.com>
Date: Mon, 30 Aug 2021 19:44:38 +0800
Subject: [PATCH 11/23] 8255058: C1 assert(is_virtual()) failed: type check
Summary: < C1> : 8255058 C1 assert(is_virtual()) failed: type check
LLT: hotspot/test/compiler/c1/TestPinnedConstantExceptionEdge.java
Patch Type: backport
Bug url: https://bugs.openjdk.java.net/browse/JDK-8255058
---
hotspot/src/share/vm/c1/c1_LinearScan.cpp | 4 +-
.../c1/TestPinnedConstantExceptionEdge.java | 71 +++++++++++++++++++
2 files changed, 73 insertions(+), 2 deletions(-)
create mode 100644 hotspot/test/compiler/c1/TestPinnedConstantExceptionEdge.java
diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp
index 1f6281bf2..ec4a67eda 100644
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp
@@ -1915,8 +1915,8 @@ void LinearScan::resolve_exception_edge(XHandler* handler, int throwing_op_id, i
move_resolver.set_multiple_reads_allowed();
Constant* con = from_value->as_Constant();
- if (con != NULL && !con->is_pinned()) {
- // unpinned constants may have no register, so add mapping from constant to interval
+ if (con != NULL && (!con->is_pinned() || con->operand()->is_constant())) {
+ // Need a mapping from constant to interval if unpinned (may have no register) or if the operand is a constant (no register).
move_resolver.add_mapping(LIR_OprFact::value_type(con->type()), to_interval);
} else {
// search split child at the throwing op_id
diff --git a/hotspot/test/compiler/c1/TestPinnedConstantExceptionEdge.java b/hotspot/test/compiler/c1/TestPinnedConstantExceptionEdge.java
new file mode 100644
index 000000000..18f145eb7
--- /dev/null
+++ b/hotspot/test/compiler/c1/TestPinnedConstantExceptionEdge.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8255058
+ * @summary Add check in LinearScan::resolve_exception_edge for pinned constant that is not virtual which cannot be used to find an interval which
+ resulted in an assertion error.
+ * @run main/othervm -Xcomp -XX:TieredStopAtLevel=1 -XX:CompileCommand=dontinline,compiler.c1.TestPinnedConstantExceptionEdge::dontInline
+ * -XX:CompileCommand=compileonly,compiler.c1.TestPinnedConstantExceptionEdge::* compiler.c1.TestPinnedConstantExceptionEdge
+ */
+package compiler.c1;
+
+public class TestPinnedConstantExceptionEdge {
+
+ public static long iFld = 0;
+ public static boolean b1;
+ public static boolean b2;
+
+ public static void test() {
+ int x = 5;
+ int y = 11;
+ for (int i = 1; i < 8; i++) {
+ for (int j = 1; j < 2; ++j) {
+ if (b1) {
+ try {
+ y = (x / x);
+ y = (500 / i);
+ y = (-214 / i);
+ } catch (ArithmeticException a_e) {}
+ // Recursion too deep in UseCountComputer::uses_do and therefore constant 1 is pinned.
+ iFld += (b1 ? 1 : 0) + (b2 ? 1 : 0) + 5 + 7 + 6 + 5 + y
+ + dontInline(7) + dontInline(5) + 8 + 8 + 9
+ + dontInline(3) + dontInline(3) + dontInline(4)
+ + dontInline(dontInline(5)) + dontInline(2);
+ return;
+ }
+ }
+ }
+ }
+
+ // Not inlined
+ public static int dontInline(int a) {
+ return 0;
+ }
+
+ public static void main(String[] strArr) {
+ test();
+ }
+}
+
--
2.22.0

View File

@ -0,0 +1,49 @@
From f061aeed6337ea1a5fdfe9b05c0eee4b26d6b26b Mon Sep 17 00:00:00 2001
From: mashoubing <mashoubing1@huawei.com>
Date: Thu, 16 Sep 2021 14:28:41 +0800
Subject: [PATCH 22/23] G1Uncommit: Introduce G1PeriodGCNotRetry control
whether periodic GC retry again when denied
Summary:gc:periodic gc spin in retry gc
LLT: NA
Patch Type: huawei
Bug url:
---
.../src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp | 6 ++++++
hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp | 3 +++
2 files changed, 9 insertions(+)
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
index 8ed6207ad..4f45bba52 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -2577,6 +2577,12 @@ void G1CollectedHeap::collect(GCCause::Cause cause) {
}
if (retry_gc) {
+ if (cause == GCCause::_g1_periodic_collection && G1PeriodGCNotRetry) {
+ gclog_or_tty->date_stamp(PrintGCDateStamps);
+ gclog_or_tty->stamp(PrintGCTimeStamps);
+ gclog_or_tty->print_cr("Periodic GC is denied and not try !");
+ return;
+ }
if (GC_locker::is_active_and_needs_gc()) {
GC_locker::stall_until_clear();
}
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp
index ee7f14278..edac4d72c 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp
@@ -333,6 +333,9 @@
product(bool, G1Uncommit, false, \
"Allow G1 to uncommit unused memory.") \
\
+ product(bool, G1PeriodGCNotRetry, true, \
+ "Not allow denied G1 Periodic GC try again.") \
+ \
product(bool, G1UncommitLog, false, \
"Enable G1 uncommit logs.") \
\
--
2.22.0

View File

@ -0,0 +1,546 @@
From 63cadc56420c73719e7a08587984bf5d96d3b063 Mon Sep 17 00:00:00 2001
From: miaozhuojun <mouzhuojun@huawei.com>
Date: Sat, 11 Sep 2021 14:48:00 +0800
Subject: [PATCH 23/23] JDK debug version crash when using AppCDS
Summary: <AppCDS> : JDK debug version crash when using AppCDS
LLT: ./jdk8u-dev/hotspot/test/runtime/NMT/NMTWithCDS.java
Patch Type: huawei
Bug url: NA
---
.../vm/interpreterGenerator_aarch64.hpp | 2 -
.../vm/templateInterpreter_aarch64.cpp | 144 +++++++++---------
.../vm/templateInterpreter_aarch64.hpp | 72 +++++++++
.../share/vm/interpreter/cppInterpreter.cpp | 13 +-
.../share/vm/interpreter/cppInterpreter.hpp | 3 +-
.../src/share/vm/interpreter/interpreter.cpp | 19 +--
.../vm/interpreter/templateInterpreter.cpp | 14 +-
.../vm/interpreter/templateInterpreter.hpp | 3 +-
hotspot/src/share/vm/memory/universe.cpp | 8 +
hotspot/src/share/vm/runtime/init.cpp | 6 +-
10 files changed, 165 insertions(+), 119 deletions(-)
diff --git a/hotspot/src/cpu/aarch64/vm/interpreterGenerator_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/interpreterGenerator_aarch64.hpp
index a275a6a99..40af38a79 100644
--- a/hotspot/src/cpu/aarch64/vm/interpreterGenerator_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/interpreterGenerator_aarch64.hpp
@@ -50,8 +50,6 @@ void generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpa
address generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind);
void lock_method(void);
void generate_stack_overflow_check(void);
- void load_String_value(Register src, Register dst);
- void load_String_offset(Register src, Register dst);
void emit_array_address(Register src, Register idx, Register dst, BasicType type);
address generate_Dgemm_dgemm_entry();
address generate_Dgemv_dgemv_entry();
diff --git a/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp
index b5f56fd03..f356fbf81 100644
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp
@@ -849,27 +849,6 @@ address InterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpret
return generate_native_entry(false);
}
-// Access the char-array of String
-void InterpreterGenerator::load_String_value(Register src, Register dst) {
- // Need to cooperate with JDK-8243996
- int value_offset = java_lang_String::value_offset_in_bytes();
-
- __ add(src, src, value_offset);
- __ load_heap_oop(dst, Address(src));
-}
-
-void InterpreterGenerator::load_String_offset(Register src, Register dst) {
- __ mov(dst, 0);
-
- // Get String value offset, because of order of initialization for Interpreter,
- // we have to hardcode the offset for String value. (JDK-8243996)
- if (java_lang_String::has_offset_field()) {
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- __ add(src, src, offset_offset);
- __ ldrw(dst, Address(src));
- }
-}
-
void InterpreterGenerator::emit_array_address(Register src, Register idx,
Register dst, BasicType type) {
int offset_in_bytes = arrayOopDesc::base_offset_in_bytes(type);
@@ -900,7 +879,7 @@ void InterpreterGenerator::emit_array_address(Register src, Register idx,
*
*/
address InterpreterGenerator::generate_Dgemm_dgemm_entry() {
- if (!UseF2jBLASIntrinsics || (StubRoutines::dgemmDgemm() == NULL)) return NULL;
+ if (StubRoutines::dgemmDgemm() == NULL) return NULL;
address entry = __ pc();
@@ -917,19 +896,29 @@ address InterpreterGenerator::generate_Dgemm_dgemm_entry() {
const Register lda = c_rarg6;
const Register B = c_rarg7;
const FloatRegister beta = c_farg1;
- const Register tmp1 = rscratch1;
- const Register tmp2 = rscratch2;
-
- // trana
- __ ldr(ta, Address(esp, 17 * wordSize));
- load_String_value(ta, tmp1);
- load_String_offset(ta, tmp2);
- emit_array_address(tmp1, tmp2, ta, T_CHAR);
- // tranb
- __ ldr(tb, Address(esp, 16 * wordSize));
- load_String_value(tb, tmp1);
- load_String_offset(tb, tmp2);
- emit_array_address(tmp1, tmp2, tb, T_CHAR);
+
+ // trana/tranb
+ __ ldr(r0, Address(esp, 17 * wordSize));
+ __ ldr(r1, Address(esp, 16 * wordSize));
+
+ // Get String value offset, because of order of initialization for Interpreter,
+ // we have to hardcode the offset for String value and offset. These instructions
+ // generated there will be patched in interpreter_patch after java.lang.String has
+ // been loaded.
+ // load String offset
+ __ mov(r2, 0); // __ ldrw(r2, Address(r0, java_lang_String::offset_offset_in_bytes()))
+ __ mov(r3, 0); // __ ldrw(r3, Address(r1, java_lang_String::offset_offset_in_bytes()))
+
+ // load String value
+ __ mov(r4, 0xc); // __ mov(r4, java_lang_String::value_offset_in_bytes())
+ __ add(r0, r0, r4);
+ __ load_heap_oop(r0, Address(r0));
+ __ add(r1, r1, r4);
+ __ load_heap_oop(r1, Address(r1));
+
+ emit_array_address(r0, r2, ta, T_CHAR);
+ emit_array_address(r1, r3, tb, T_CHAR);
+
// m, n, k
__ ldrw(m, Address(esp, 15 * wordSize));
__ ldrw(n, Address(esp, 14 * wordSize));
@@ -937,16 +926,15 @@ address InterpreterGenerator::generate_Dgemm_dgemm_entry() {
// alpha
__ ldrd(alpha, Address(esp, 11 * wordSize));
// A
- __ ldr(tmp1, Address(esp, 10 * wordSize));
- __ mov(tmp2, 0);
- __ ldrw(tmp2, Address(esp, 9 * wordSize));
- emit_array_address(tmp1, tmp2, A, T_DOUBLE);
+ __ ldr(r5, Address(esp, 10 * wordSize));
+ __ ldrw(r6, Address(esp, 9 * wordSize));
+ emit_array_address(r5, r6, A, T_DOUBLE);
// lda
__ ldrw(lda, Address(esp, 8 * wordSize));
// B
- __ ldr(tmp1, Address(esp, 7 * wordSize));
- __ ldrw(tmp2, Address(esp, 6 * wordSize));
- emit_array_address(tmp1, tmp2, B, T_DOUBLE);
+ __ ldr(rscratch1, Address(esp, 7 * wordSize));
+ __ ldrw(rscratch2, Address(esp, 6 * wordSize));
+ emit_array_address(rscratch1, rscratch2, B, T_DOUBLE);
// beta
__ ldrd(beta, Address(esp, 3 * wordSize));
// Start pushing arguments to machine stack.
@@ -960,22 +948,22 @@ address InterpreterGenerator::generate_Dgemm_dgemm_entry() {
__ andr(sp, r13, -16);
__ str(lr, Address(sp, -wordSize));
// ldc
- __ ldrw(tmp1, Address(esp, 0x0));
- __ strw(tmp1, Address(sp, 2 * -wordSize));
+ __ ldrw(rscratch1, Address(esp, 0x0));
+ __ strw(rscratch1, Address(sp, 2 * -wordSize));
// C
- __ ldr(tmp1, Address(esp, 2 * wordSize));
- __ ldrw(tmp2, Address(esp, wordSize));
- emit_array_address(tmp1, tmp2, tmp1, T_DOUBLE);
- __ str(tmp1, Address(sp, 3 * -wordSize));
+ __ ldr(rscratch1, Address(esp, 2 * wordSize));
+ __ ldrw(rscratch2, Address(esp, wordSize));
+ emit_array_address(rscratch1, rscratch2, rscratch1, T_DOUBLE);
+ __ str(rscratch1, Address(sp, 3 * -wordSize));
// ldb
- __ ldrw(tmp2, Address(esp, 5 * wordSize));
- __ strw(tmp2, Address(sp, 4 * -wordSize));
+ __ ldrw(rscratch2, Address(esp, 5 * wordSize));
+ __ strw(rscratch2, Address(sp, 4 * -wordSize));
// Call function
__ add(sp, sp, 4 * -wordSize);
address fn = CAST_FROM_FN_PTR(address, StubRoutines::dgemmDgemm());
- __ mov(tmp1, fn);
- __ blr(tmp1);
+ __ mov(rscratch1, fn);
+ __ blr(rscratch1);
__ ldr(lr, Address(sp, 3 * wordSize));
// For assert(Rd != sp || imm % 16 == 0)
@@ -1001,9 +989,6 @@ address InterpreterGenerator::generate_Dgemv_dgemv_entry() {
const FloatRegister alpha = v0; // alpha
const FloatRegister beta = v1; // beta
- const Register tmp1 = rscratch1;
- const Register tmp2 = rscratch2;
-
// esp: expression stack of caller
// dgemv parameter ---> the position in stack ---> move to register
// | char* trans | | esp + 15 | | r0 |
@@ -1032,10 +1017,21 @@ address InterpreterGenerator::generate_Dgemv_dgemv_entry() {
// trans
- __ ldr(trans, Address(esp, 15 * wordSize));
- load_String_value(trans, tmp1);
- load_String_offset(trans, tmp2);
- emit_array_address(tmp1, tmp2, trans, T_CHAR);
+ __ ldr(r0, Address(esp, 15 * wordSize));
+
+ // Get String value offset, because of order of initialization for Interpreter,
+ // we have to hardcode the offset for String value and offset. These instructions
+ // generated there will be patched in interpreter_patch after java.lang.String has
+ // been loaded.
+ // load String offset
+ __ mov(r1, 0); // __ ldrw(r1, Address(r0, java_lang_String::offset_offset_in_bytes()))
+
+ // load String value
+ __ mov(r2, 0xc); // __ mov(r2, java_lang_String::value_offset_in_bytes())
+ __ add(r0, r0, r2);
+ __ load_heap_oop(r0, Address(r0));
+ emit_array_address(r0, r1, trans, T_CHAR);
+
// m, n
__ ldrw(m, Address(esp, 14 * wordSize));
__ ldrw(n, Address(esp, 13 * wordSize));
@@ -1044,19 +1040,17 @@ address InterpreterGenerator::generate_Dgemv_dgemv_entry() {
__ ldrd(alpha, Address(esp, 11 * wordSize));
// a
- __ ldr(tmp1, Address(esp, 10 * wordSize));
- __ mov(tmp2, zr);
- __ ldrw(tmp2, Address(esp, 9 * wordSize));
- emit_array_address(tmp1, tmp2, a, T_DOUBLE);
+ __ ldr(r3, Address(esp, 10 * wordSize));
+ __ ldrw(r4, Address(esp, 9 * wordSize));
+ emit_array_address(r3, r4, a, T_DOUBLE);
// lda
__ ldrw(lda, Address(esp, 8 * wordSize));
// x
- __ ldr(tmp1, Address(esp, 7 * wordSize));
- __ mov(tmp2, zr);
- __ ldrw(tmp2, Address(esp, 6 * wordSize));
- emit_array_address(tmp1, tmp2, x, T_DOUBLE);
+ __ ldr(r5, Address(esp, 7 * wordSize));
+ __ ldrw(r6, Address(esp, 6 * wordSize));
+ emit_array_address(r5, r6, x, T_DOUBLE);
// incx
__ ldrw(incx, Address(esp, 5 * wordSize));
@@ -1065,25 +1059,24 @@ address InterpreterGenerator::generate_Dgemv_dgemv_entry() {
__ ldrd(beta, Address(esp, 3 * wordSize));
// y
- __ ldr(tmp1, Address(esp, 2 * wordSize));
- __ mov(tmp2, zr);
- __ ldrw(tmp2, Address(esp, wordSize));
- emit_array_address(tmp1, tmp2, y, T_DOUBLE);
+ __ ldr(rscratch1, Address(esp, 2 * wordSize));
+ __ ldrw(rscratch2, Address(esp, wordSize));
+ emit_array_address(rscratch1, rscratch2, y, T_DOUBLE);
// resume sp, restore lr
__ andr(sp, r13, -16);
__ str(lr, Address(sp, -wordSize));
// incy, push on stack
- __ ldrw(tmp1, Address(esp, 0));
- __ strw(tmp1, Address(sp, 2 * -wordSize));
+ __ ldrw(rscratch1, Address(esp, 0));
+ __ strw(rscratch1, Address(sp, 2 * -wordSize));
__ add(sp, sp, -2 * wordSize);
// call function
address fn = CAST_FROM_FN_PTR(address, StubRoutines::dgemvDgemv());
- __ mov(tmp1, fn);
- __ blr(tmp1);
+ __ mov(rscratch1, fn);
+ __ blr(rscratch1);
// resume lr
__ ldr(lr, Address(sp, wordSize));
@@ -1960,7 +1953,6 @@ void AbstractInterpreter::layout_activation(Method* method,
method->constants()->cache();
}
-
//-----------------------------------------------------------------------------
// Exceptions
diff --git a/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.hpp
index 36e1aa89d..3ca17e3c4 100644
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/templateInterpreter_aarch64.hpp
@@ -28,6 +28,78 @@
#define CPU_AARCH64_VM_TEMPLATEINTERPRETER_AARCH64_HPP
+ public:
+ static void patch_method(AbstractInterpreter::MethodKind kind) {
+ unsigned value_offset = java_lang_String::value_offset_in_bytes();
+ unsigned offset_offset = 0;
+ address entry = entry_for_kind(kind);
+
+ if (entry == NULL) {
+ return;
+ }
+
+ switch (kind) {
+ case AbstractInterpreter::org_netlib_blas_Dgemm_dgemm:
+ if (StubRoutines::_dgemmDgemm == NULL) {
+ break;
+ }
+ // 0 : ldr x0, [x20, #136]
+ // 1 : ldr x1, [x20, #128]
+ // 2 : mov x2, #0x0 ==================> ldr w2, [x0, <java_lang_String::value_offset_in_bytes()>]
+ // 3 : mov x3, #0x0 ==================> ldr w3, [x1, <java_lang_String::value_offset_in_bytes()>]
+ // 4 : orr x4, xzr, #0xc =============> orr x4, xzr, <java_lang_String::value_offset_in_bytes()>
+ if (java_lang_String::has_offset_field()) {
+ guarantee(Instruction_aarch64::extract(((unsigned*)entry)[2], 31, 23) == 0b110100101 &&
+ Instruction_aarch64::extract(((unsigned*)entry)[3], 31, 23) == 0b110100101,
+ "wrong insns in patch");
+ offset_offset = java_lang_String::offset_offset_in_bytes();
+ // ldr w2, [x0, <java_lang_String::value_offset_in_bytes()>]
+ address tmp = entry + 4 * 2;
+ Instruction_aarch64::patch(tmp, 31, 22, 0b1011100101); // opc
+ Instruction_aarch64::patch(tmp, 21, 10, offset_offset >> 2); // imm12
+ Instruction_aarch64::patch(tmp, 9, 5, 0); // Rn
+ Instruction_aarch64::patch(tmp, 4, 0, 2); // Rt
+ // ldr w3, [x1, <java_lang_String::value_offset_in_bytes()>]
+ tmp = entry + 4 * 3;
+ Instruction_aarch64::patch(tmp, 31, 22, 0b1011100101); // opc
+ Instruction_aarch64::patch(tmp, 21, 10, offset_offset >> 2); // imm12
+ Instruction_aarch64::patch(tmp, 9, 5, 1); // Rn
+ Instruction_aarch64::patch(tmp, 4, 0, 3); // Rt
+ }
+ guarantee(Instruction_aarch64::extract(((unsigned*)entry)[4], 31, 23) == 0b101100100 &&
+ Instruction_aarch64::extract(((unsigned*)entry)[4], 9, 0) == 0b1111100100, "wrong insns in patch");
+ Instruction_aarch64::patch(entry + 4 * 4, 22, 10,
+ (uint64_t)encode_logical_immediate(false, (uint64_t)value_offset)); // imm16
+ ICache::invalidate_range(entry, 4 * 5);
+ break;
+ case AbstractInterpreter::org_netlib_blas_Dgemv_dgemv:
+ if (StubRoutines::_dgemvDgemv == NULL) {
+ break;
+ }
+ // 0 : ldr x0, [x20, #120]
+ // 1 : mov x1, #0x0 ==================> ldr w1, [r0, <java_lang_String::offset_offset_in_bytes()>]
+ // 2 : orr x2, xzr, #0xc =============> orr x2, xzr, <java_lang_String::value_offset_in_bytes()>
+ if (java_lang_String::has_offset_field()) {
+ guarantee(Instruction_aarch64::extract(((unsigned*)entry)[1], 31, 23) == 0b110100101, "wrong insns in patch");
+ offset_offset = java_lang_String::offset_offset_in_bytes();
+ // ldr w1, [x0, <java_lang_String::value_offset_in_bytes()>]
+ address tmp = entry + 4 * 1;
+ Instruction_aarch64::patch(tmp, 31, 22, 0b1011100101); // opc
+ Instruction_aarch64::patch(tmp, 21, 10, offset_offset >> 2); // imm12
+ Instruction_aarch64::patch(tmp, 9, 5, 0); // Rn
+ Instruction_aarch64::patch(tmp, 4, 0, 1); // Rt
+ }
+ guarantee(Instruction_aarch64::extract(((unsigned*)entry)[2], 31, 23) == 0b101100100 &&
+ Instruction_aarch64::extract(((unsigned*)entry)[2], 9, 0) == 0b1111100010, "wrong insns in patch");
+ Instruction_aarch64::patch(entry + 4 * 2, 22, 10,
+ (uint64_t)encode_logical_immediate(false, (uint64_t)value_offset)); // imm16
+ ICache::invalidate_range(entry, 4 * 3);
+ break;
+ default:
+ break;
+ }
+ }
+
protected:
// Size of interpreter code. Increase if too small. Interpreter will
diff --git a/hotspot/src/share/vm/interpreter/cppInterpreter.cpp b/hotspot/src/share/vm/interpreter/cppInterpreter.cpp
index 9e48a1d94..0007aa8be 100644
--- a/hotspot/src/share/vm/interpreter/cppInterpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/cppInterpreter.cpp
@@ -31,20 +31,17 @@
#ifdef CC_INTERP
# define __ _masm->
-void CppInterpreter::initialize_stub() {
+void CppInterpreter::initialize() {
if (_code != NULL) return;
- int code_size = InterpreterCodeSize;
- NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
- _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
- "Interpreter");
-}
-
-void CppInterpreter::initialize_code() {
AbstractInterpreter::initialize();
// generate interpreter
{ ResourceMark rm;
TraceTime timer("Interpreter generation", TraceStartupTime);
+ int code_size = InterpreterCodeSize;
+ NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
+ _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
+ "Interpreter");
InterpreterGenerator g(_code);
if (PrintInterpreter) print();
}
diff --git a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp
index 58efcfaf2..6a6447503 100644
--- a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp
@@ -54,8 +54,7 @@ class CppInterpreter: public AbstractInterpreter {
public:
// Initialization/debugging
- static void initialize_stub();
- static void initialize_code();
+ static void initialize();
// this only returns whether a pc is within generated code for the interpreter.
// This is a moderately dubious interface for the c++ interpreter. Only
diff --git a/hotspot/src/share/vm/interpreter/interpreter.cpp b/hotspot/src/share/vm/interpreter/interpreter.cpp
index a313f2e63..bfcb1bea2 100644
--- a/hotspot/src/share/vm/interpreter/interpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/interpreter.cpp
@@ -85,6 +85,7 @@ void InterpreterCodelet::print_on(outputStream* st) const {
// Implementation of platform independent aspects of Interpreter
void AbstractInterpreter::initialize() {
+ if (_code != NULL) return;
// make sure 'imported' classes are initialized
if (CountBytecodes || TraceBytecodes || StopInterpreterAt) BytecodeCounter::reset();
if (PrintBytecodeHistogram) BytecodeHistogram::reset();
@@ -112,22 +113,8 @@ void AbstractInterpreter::print() {
}
-// The reason that interpreter initialization is split into two parts is that the first part
-// needs to run before methods are loaded (which with CDS implies linked also), and the other
-// part needs to run after. The reason is that when methods are loaded (with CDS) or linked
-// (without CDS), the i2c adapters are generated that assert we are currently in the interpreter.
-// Asserting that requires knowledge about where the interpreter is in memory. Therefore,
-// establishing the interpreter address must be done before methods are loaded. However,
-// we would like to actually generate the interpreter after methods are loaded. That allows
-// us to remove otherwise hardcoded offsets regarding fields that are needed in the interpreter
-// code. This leads to a split if 1. reserving the memory for the interpreter, 2. loading methods
-// and 3. generating the interpreter.
-void interpreter_init_stub() {
- Interpreter::initialize_stub();
-}
-
-void interpreter_init_code() {
- Interpreter::initialize_code();
+void interpreter_init() {
+ Interpreter::initialize();
#ifndef PRODUCT
if (TraceBytecodes) BytecodeTracer::set_closure(BytecodeTracer::std_closure());
#endif // PRODUCT
diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp
index f38f05117..09298a7fc 100644
--- a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp
@@ -32,20 +32,12 @@
# define __ _masm->
-void TemplateInterpreter::initialize_stub() {
+void TemplateInterpreter::initialize() {
if (_code != NULL) return;
// assertions
assert((int)Bytecodes::number_of_codes <= (int)DispatchTable::length,
"dispatch table too small");
- // allocate interpreter
- int code_size = InterpreterCodeSize;
- NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
- _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
- "Interpreter");
-}
-
-void TemplateInterpreter::initialize_code() {
AbstractInterpreter::initialize();
TemplateTable::initialize();
@@ -53,6 +45,10 @@ void TemplateInterpreter::initialize_code() {
// generate interpreter
{ ResourceMark rm;
TraceTime timer("Interpreter generation", TraceStartupTime);
+ int code_size = InterpreterCodeSize;
+ NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
+ _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
+ "Interpreter");
InterpreterGenerator g(_code);
if (PrintInterpreter) print();
}
diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp
index 96da6353c..5f76dca8a 100644
--- a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp
@@ -132,8 +132,7 @@ class TemplateInterpreter: public AbstractInterpreter {
public:
// Initialization/debugging
- static void initialize_stub();
- static void initialize_code();
+ static void initialize();
// this only returns whether a pc is within generated code for the interpreter.
static bool contains(address pc) { return _code != NULL && _code->contains(pc); }
diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp
index d9e670bee..1d05bcc73 100644
--- a/hotspot/src/share/vm/memory/universe.cpp
+++ b/hotspot/src/share/vm/memory/universe.cpp
@@ -425,6 +425,14 @@ void Universe::genesis(TRAPS) {
// Initialize dependency array for null class loader
ClassLoaderData::the_null_class_loader_data()->init_dependencies(CHECK);
+ // Patch the BLAS Interpreter intrinsics with java.lang.String
+ // offset after java.lang.String has been loaded.
+#if defined(TARGET_OS_ARCH_linux_aarch64) && !defined(CC_INTERP)
+ if (UseF2jBLASIntrinsics) {
+ Interpreter::patch_method(Interpreter::org_netlib_blas_Dgemm_dgemm);
+ Interpreter::patch_method(Interpreter::org_netlib_blas_Dgemv_dgemv);
+ }
+#endif
}
// CDS support for patching vtables in metadata in the shared archive.
diff --git a/hotspot/src/share/vm/runtime/init.cpp b/hotspot/src/share/vm/runtime/init.cpp
index 4c133bd4e..d15e40d44 100644
--- a/hotspot/src/share/vm/runtime/init.cpp
+++ b/hotspot/src/share/vm/runtime/init.cpp
@@ -54,8 +54,7 @@ void VM_Version_init();
void os_init_globals(); // depends on VM_Version_init, before universe_init
void stubRoutines_init1();
jint universe_init(); // depends on codeCache_init and stubRoutines_init
-void interpreter_init_stub(); // before any methods loaded
-void interpreter_init_code(); // after methods loaded, but before they are linked
+void interpreter_init(); // before any methods loaded
void invocationCounter_init(); // before any methods loaded
void marksweep_init();
void accessFlags_init();
@@ -107,7 +106,7 @@ jint init_globals() {
if (status != JNI_OK)
return status;
- interpreter_init_stub(); // before methods get loaded
+ interpreter_init(); // before any methods loaded
invocationCounter_init(); // before any methods loaded
marksweep_init();
accessFlags_init();
@@ -115,7 +114,6 @@ jint init_globals() {
InterfaceSupport_init();
SharedRuntime::generate_stubs();
universe2_init(); // dependent on codeCache_init and stubRoutines_init1
- interpreter_init_code(); // after universe2_init and before any method gets linked
referenceProcessor_init();
jni_handles_init();
#if INCLUDE_VM_STRUCTS
--
2.22.0

View File

@ -0,0 +1,96 @@
From ec7d9d798c17df377dc8d4c00d8f285ea32e590e Mon Sep 17 00:00:00 2001
From: mashoubing <mashoubing1@huawei.com>
Date: Mon, 13 Sep 2021 15:22:21 +0800
Subject: [PATCH 18/23] PS:introduce UsePSRelaxedForwardee to enable using
relaxed CAS in copy_to_survivor_space
Summary:gc:ps use relaxed CAS for better performance in weak memory model
LLT:NA
Patch Type:huawei
Bug url:NA
---
.../parallelScavenge/psPromotionManager.inline.hpp | 10 ++++++++--
.../parallelScavenge/psScavenge.inline.hpp | 2 +-
hotspot/src/share/vm/oops/oop.inline.hpp | 2 +-
hotspot/src/share/vm/runtime/globals.hpp | 4 ++++
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp
index e517abcee..c58e3d1ef 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp
@@ -203,15 +203,17 @@ oop PSPromotionManager::copy_to_survivor_space(oop o) {
assert(new_obj != NULL, "allocation should have succeeded");
+ Prefetch::write(new_obj, PrefetchCopyIntervalInBytes);
// Copy obj
Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size);
// Now we have to CAS in the header.
-#ifdef AARCH64
+
// CAS with memory fence cost a lot within copy_to_survivor_space on aarch64.
- // To minimize the cost, we use a normal CAS to do object forwarding, plus a
+ // To minimize the cost, we can use a normal CAS to do object forwarding, plus a
// memory fence only upon CAS succeeds. To further reduce the fence insertion,
// we can skip the fence insertion for leaf objects (objects don't have reference fields).
+#if defined(AARCH64) && defined(PRODUCT)
if (o->relax_cas_forward_to(new_obj, test_mark)) {
#else
if (o->cas_forward_to(new_obj, test_mark)) {
@@ -271,6 +273,10 @@ oop PSPromotionManager::copy_to_survivor_space(oop o) {
#ifndef PRODUCT
// This code must come after the CAS test, or it will print incorrect
// information.
+ // When UsePSRelaxedForwardee is true or object o is gc leaf, CAS failed threads can't access forwardee's content,
+ // as relaxed CAS cann't gurantee new obj's content visible for these CAS failed threads.The below log output is
+ // dangerous. So we just support UsePSRelaxedForwardee and gc leaf in product.
+ // Everywhere access forwardee's content must be careful.
if (TraceScavenge) {
gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring",
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
index 1a722a7ca..3cfabe486 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
@@ -78,7 +78,7 @@ inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
#ifndef PRODUCT
// This code must come after the CAS test, or it will print incorrect
// information.
- if (TraceScavenge && o->is_forwarded()) {
+ if (TraceScavenge && o->is_forwarded()) {
gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
"forwarding",
new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
diff --git a/hotspot/src/share/vm/oops/oop.inline.hpp b/hotspot/src/share/vm/oops/oop.inline.hpp
index 00fb2374e..ed37d0558 100644
--- a/hotspot/src/share/vm/oops/oop.inline.hpp
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp
@@ -705,7 +705,7 @@ inline bool oopDesc::relax_cas_forward_to(oop p, markOop compare) {
if (old_markoop == compare) {
// Once the CAS succeeds, leaf object never needs to be visible to other threads (finished
// collection by current thread), so we can save the fence.
- if (!p->klass()->oop_is_gc_leaf()) {
+ if (!(UsePSRelaxedForwardee || p->klass()->oop_is_gc_leaf())) {
OrderAccess::fence();
}
return true;
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index cef343a0e..9779653ba 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -1441,6 +1441,10 @@ class CommandLineFlags {
product(bool, UseParallelGC, false, \
"Use the Parallel Scavenge garbage collector") \
\
+ experimental(bool, UsePSRelaxedForwardee, false, \
+ "Use the UsePSRelaxedForwardee to enable ps use relaxed" \
+ "during young gc copying object") \
+ \
product(bool, UseParallelOldGC, false, \
"Use the Parallel Old garbage collector") \
\
--
2.22.0

2127
Parallel-Full-GC-for-G1.patch Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,85 @@
From ef5d7213507f8148ae0b3fd7f82ea4afa5695d72 Mon Sep 17 00:00:00 2001
From: hubodao <hubodao@huawei.com>
Date: Sat, 11 Sep 2021 09:56:54 +0800
Subject: [PATCH 13/23] create jfr dump file with pid or timestamp if specified
Summary: <JFR> : create jfr dump file with pid or timestamp if specified
LLT: NA
Patch Type: huawei
Bug url: NA
---
hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp | 16 ++++++++++++++--
.../jdk/jfr/jcmd/TestJcmdDumpWithFileName.java | 16 ++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp b/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp
index 167405e39..9585de28c 100644
--- a/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp
+++ b/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp
@@ -226,7 +226,13 @@ void JfrDumpFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
jstring filepath = NULL;
if (_filename.is_set() && _filename.value() != NULL) {
- filepath = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ const char* extended_path = make_log_name(_filename.value(), NULL);
+ if (extended_path != NULL) {
+ filepath = JfrJavaSupport::new_string(extended_path, CHECK);
+ FREE_C_HEAP_ARRAY(char, extended_path, mtInternal);
+ } else {
+ filepath = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ }
}
jobject maxage = NULL;
@@ -394,7 +400,13 @@ void JfrStartFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
jstring filename = NULL;
if (_filename.is_set() && _filename.value() != NULL) {
- filename = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ const char* dumpPath = make_log_name(_filename.value(), NULL);
+ if (dumpPath != NULL) {
+ filename = JfrJavaSupport::new_string(dumpPath, CHECK);
+ FREE_C_HEAP_ARRAY(char, dumpPath, mtInternal);
+ } else {
+ filename = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ }
}
jobject maxage = NULL;
diff --git a/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java b/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java
index 40ff35b4d..f0c39564f 100644
--- a/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java
+++ b/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java
@@ -48,6 +48,7 @@ public class TestJcmdDumpWithFileName {
testDumpAll();
testDumpNamed();
testDumpNamedWithFilename();
+ testDumpNamedWithFilenameExpansion();
}
private static void testDumpAll() throws Exception {
@@ -96,6 +97,21 @@ public class TestJcmdDumpWithFileName {
}
cleanup();
}
+
+ private static void testDumpNamedWithFilenameExpansion() throws Exception {
+ long pid = ProcessTools.getProcessId();
+ Path dumpPath = Paths.get("dumpPath-%p-%t.jfr").toAbsolutePath();
+ try (Recording r = new Recording()) {
+ r.setName("testDumpNamedWithFilenameExpansion");
+ r.setDestination(dumpPath);
+ r.start();
+ JcmdHelper.jcmd("JFR.dump", "name=testDumpNamedWithFilenameExpansion", "filename=" + dumpPath.toString());
+ Stream<Path> stream = Files.find(Paths.get("."), 1, (s, a) -> s.toString()
+ .matches("^.*dumpPath-pid" + pid + ".\\d{4}.\\d{2}.\\d{2}.\\d{2}.\\d{2}.\\d{2}" + ".jfr") && (a.size() > 0L));
+ Asserts.assertTrue(stream.findAny().isPresent());
+ }
+ cleanup();
+ }
private static boolean namedFile(Path dumpFile) throws IOException {
return Files.exists(dumpFile) && (Files.size(dumpFile) > 0);
--
2.22.0

View File

@ -0,0 +1,71 @@
From f8729bde39c847f09fb0af0a43efe474a6e87f56 Mon Sep 17 00:00:00 2001
From: s00478819 <sunjianye@huawei.com>
Date: Sat, 11 Sep 2021 11:46:37 +0800
Subject: [PATCH 15/23] enhance the TimeZone's path solution on Euler
Summary: <JDK>: enhance the TimeZone's path solution on Euler
LLT: NA
Patch Type: huawei
Bug url: NA
---
.../solaris/native/java/util/TimeZone_md.c | 33 ++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/jdk/src/solaris/native/java/util/TimeZone_md.c b/jdk/src/solaris/native/java/util/TimeZone_md.c
index 990e4afb2..c183a723d 100644
--- a/jdk/src/solaris/native/java/util/TimeZone_md.c
+++ b/jdk/src/solaris/native/java/util/TimeZone_md.c
@@ -61,10 +61,12 @@ static char *isFileIdentical(char* buf, size_t size, char *pathname);
static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
+static const char *DEFAULT_ZONEINFO_FILE_DIRNAME = "/etc";
#else
static const char *SYS_INIT_FILE = "/etc/default/init";
static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo";
static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime";
+static const char *DEFAULT_ZONEINFO_FILE_DIRNAME = "/usr/share/lib/zoneinfo";
#endif /* defined(__linux__) || defined(_ALLBSD_SOURCE) */
static const char popularZones[][4] = {"UTC", "GMT"};
@@ -317,7 +319,36 @@ getPlatformTimeZoneID()
return NULL;
}
linkbuf[len] = '\0';
- tz = getZoneName(linkbuf);
+
+ /* linkbuf may be a relative symlink or has more than one characters, like '.' and '/' ,
+ * which will cause the function call getZoneName return to an abnormal timeZone name.
+ * For example, linkbuf is "../usr/share/zoneinfo//Asia/Shanghai", then the call of
+ * getZoneName(linkbuf) will get "/Asia/Shanghai", not "Asia/Shanghai".
+ * So we covert it to an absolute path by adding the file's (which is define by macro
+ * DEFAULT_ZONEINFO_FILE) dirname and then call glibc's realpath API to canonicalize
+ * the path.
+ */
+ char abslinkbuf[2 * (PATH_MAX + 1)];
+ if (linkbuf[0] != '/') {
+ if (sprintf(abslinkbuf, "%s/%s", DEFAULT_ZONEINFO_FILE_DIRNAME, linkbuf) < 0) {
+ jio_fprintf(stderr, (const char *) "failed to generate absolute path\n");
+ return NULL;
+ }
+ } else {
+ strncpy(abslinkbuf, linkbuf, len + 1);
+ }
+
+ /* canonicalize the path */
+ char resolvedpath[PATH_MAX + 1];
+ resolvedpath[PATH_MAX] = '\0';
+ char *path = realpath(abslinkbuf, resolvedpath);
+ if (path == NULL) {
+ jio_fprintf(stderr, (const char *) "failed to get real path, symlink is %s\n",
+ abslinkbuf);
+ return NULL;
+ }
+
+ tz = getZoneName(resolvedpath);
if (tz != NULL) {
tz = strdup(tz);
return tz;
--
2.22.0

View File

@ -0,0 +1,43 @@
From 4ea57acdd47696dd1d36c6efb1cc404b03b76aaf Mon Sep 17 00:00:00 2001
From: zhangyipeng <zhangyipeng7@huawei.com>
Date: Mon, 13 Sep 2021 09:31:12 +0800
Subject: [PATCH 17/23] add 007 0024-fix-appcds-s-option-AppCDSLockFile
Summary: < JDK> : add 007 0024-fix-appcds-s-option-AppCDSLockFile
LLT: NA
Patch Type: huawei
Bug url: NA
---
hotspot/src/share/vm/memory/filemap.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp
index 5858c9355..99b1f58d0 100644
--- a/hotspot/src/share/vm/memory/filemap.cpp
+++ b/hotspot/src/share/vm/memory/filemap.cpp
@@ -379,16 +379,20 @@ void FileMapInfo::open_for_write() {
if (realpath(filePath, buf) == NULL) {
fail_stop("A risky filePath:%s, buf:%s, length:%d", filePath, buf, length);
}
+ // Appcds lock file's path doesn't support "%p". Check it here.
+ const char* pts = strstr(AppCDSLockFile, "%p");
+ if (pts != NULL) {
+ fail_stop("Invalid appcds lock file path name, %s.", AppCDSLockFile);
+ }
_appcds_file_lock_path = os::strdup(AppCDSLockFile, mtInternal);
if (_appcds_file_lock_path == NULL) {
fail_stop("Failed to create appcds file lock.");
}
int lock_fd = open(_appcds_file_lock_path, O_CREAT | O_WRONLY | O_EXCL, S_IRUSR | S_IWUSR);
if (lock_fd < 0) {
- tty->print_cr("The lock path is: %s", _appcds_file_lock_path);
tty->print_cr("Failed to create jsa file !\n Please check: \n 1. The directory exists.\n "
"2. You have the permission.\n 3. Make sure no other process using the same lock file.\n");
- JVM_Exit(0);
+ fail_stop("Failed to create appcds lock file, the lock path is: %s.", _appcds_file_lock_path);
}
tty->print_cr("You are using file lock %s in concurrent mode", AppCDSLockFile);
}
--
2.22.0

View File

@ -0,0 +1,32 @@
From d94e836f5dc230839aacb4585dcc30575c94d785 Mon Sep 17 00:00:00 2001
From: zhangyipeng <zhangyipeng7@huawei.com>
Date: Sat, 11 Sep 2021 15:24:54 +0800
Subject: [PATCH 16/23] fix wrong commitID in release file
Summary: <make> : fix wrong commitID in release file
LLT: NA
Patch Type: huawei
Bug url: NA
---
make/common/MakeBase.gmk | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk
index 9b7ad7024..8179139ec 100644
--- a/make/common/MakeBase.gmk
+++ b/make/common/MakeBase.gmk
@@ -322,9 +322,10 @@ define GetSourceTips
fi; \
done >> $@), \
$(if $(and $(GIT), $(wildcard $(TOPDIR)/.git)), \
+ $$($(CD) $(SRC_ROOT) ; \
$(PRINTF) ".:git:%s%s\n" \
"$$(git log -n1 --format=%H | cut -c1-12)" \
- "$$(if test -n "$$(git status --porcelain)"; then printf '+'; fi)" >> $@, ))
+ "$$(if test -n "$$(git status --porcelain)"; then printf '+'; fi)" >> $@), ))
$(PRINTF) "\n" >> $@
endef
--
2.22.0

576
fix_bug_in_keypairgenerator.patch Executable file
View File

@ -0,0 +1,576 @@
diff --git a/jdk/make/CopyFiles.gmk b/jdk/make/CopyFiles.gmk
index ad8db6e5..10d37b9e 100644
--- a/jdk/make/CopyFiles.gmk
+++ b/jdk/make/CopyFiles.gmk
@@ -609,14 +609,16 @@ endif
##########################################################################################
-ifeq ($(OPENJDK_TARGET_CPU_ARCH), aarch64)
+ifeq ($(ENABLE_KAE), true)
+ ifeq ($(OPENJDK_TARGET_CPU_ARCH), aarch64)
- KAE_CONF_PATH= $(JDK_OUTPUTDIR)/lib/ext
- $(KAE_CONF_PATH)/kaeprovider.conf: $(JDK_TOPDIR)/src/share/lib/security/kaeprovider.conf
+ KAE_CONF_PATH= $(JDK_OUTPUTDIR)/lib/ext
+ $(KAE_CONF_PATH)/kaeprovider.conf: $(JDK_TOPDIR)/src/share/lib/security/kaeprovider.conf
$(call install-file)
- COPY_FILES += $(KAE_CONF_PATH)/kaeprovider.conf
+ COPY_FILES += $(KAE_CONF_PATH)/kaeprovider.conf
+ endif
endif
##########################################################################################
diff --git a/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEECDHKeyAgreement.java b/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEECDHKeyAgreement.java
index ac05e6d5..7a9cc5cc 100644
--- a/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEECDHKeyAgreement.java
+++ b/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEECDHKeyAgreement.java
@@ -97,7 +97,7 @@ public class KAEECDHKeyAgreement extends KeyAgreementSpi {
curveName = KAEUtils.getCurveBySize(keyLenBits);
if (curveName == null) {
- throw new InvalidParameterException("unknown keyLenBits" + keyLenBits);
+ throw new InvalidParameterException("unknown keyLenBits " + keyLenBits);
}
if (KAEUtils.getCurveByAlias(curveName) != null) {
curveName = KAEUtils.getCurveByAlias(curveName);
diff --git a/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEProvider.java b/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEProvider.java
index 83ed8649..8ba70200 100644
--- a/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEProvider.java
+++ b/jdk/src/solaris/classes/org/openeuler/security/openssl/KAEProvider.java
@@ -104,6 +104,8 @@ public class KAEProvider extends Provider {
if (needLog && "true".equalsIgnoreCase(props.getProperty("kae.log"))) {
logStart(excp);
needLog = false; // Log only once
+ } else {
+ KAEProvider.excp = null; // Ignore exception.
}
if (!"false".equalsIgnoreCase(props.getProperty("kae.md5"))) {
putMD5();
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c
index d1aedf5f..bad16fb7 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c
@@ -47,7 +47,7 @@ static int RSACryptNotOAEPPadding(JNIEnv* env, jlong keyAddress, jint inLen, jby
int resultSize = 0;
// get RSA
- EVP_PKEY* pkey = (EVP_PKEY*)keyAddress;
+ EVP_PKEY* pkey = (EVP_PKEY*) keyAddress;
// rsa = pkey->rsa
RSA* rsa = EVP_PKEY_get1_RSA(pkey);
@@ -198,8 +198,8 @@ static int RSACryptOAEPPadding(JNIEnv* env, jlong keyAddress, jint inLen, jbyteA
* set rsa mgf1 md
* set rsa oaep md
*/
- if(!SetRSAPadding(env, pkeyCtx, paddingType) || !SetRSAMgf1Md(env, pkeyCtx, mgf1MdAlgoUTF) ||
- !SetRSAOaepMd(env, pkeyCtx, oaepMdAlgoUTF)) {
+ if (!SetRSAPadding(env, pkeyCtx, paddingType) || !SetRSAMgf1Md(env, pkeyCtx, mgf1MdAlgoUTF) ||
+ !SetRSAOaepMd(env, pkeyCtx, oaepMdAlgoUTF)) {
goto cleanup;
}
@@ -213,7 +213,7 @@ static int RSACryptOAEPPadding(JNIEnv* env, jlong keyAddress, jint inLen, jbyteA
goto cleanup;
}
(*env)->GetByteArrayRegion(env, label, 0, labelSize, labelBytes);
- if(!SetRSAOaepLabel(env, pkeyCtx, labelBytes, labelSize)) {
+ if (!SetRSAOaepLabel(env, pkeyCtx, labelBytes, labelSize)) {
free(labelBytes);
goto cleanup;
}
@@ -434,7 +434,7 @@ JNIEXPORT jint JNICALL Java_org_openeuler_security_openssl_KAERSACipher_nativeRS
*/
JNIEXPORT jint JNICALL Java_org_openeuler_security_openssl_KAERSACipher_nativeRSAEncryptOAEPPadding(JNIEnv* env,
jclass cls, jlong keyAddress, jint inLen, jbyteArray in, jbyteArray out,
- jint paddingType,jstring oaepMdAlgo, jstring mgf1MdAlgo, jbyteArray label) {
+ jint paddingType, jstring oaepMdAlgo, jstring mgf1MdAlgo, jbyteArray label) {
return RSACryptOAEPPadding(env, keyAddress, inLen, in, out, paddingType, oaepMdAlgo, mgf1MdAlgo, label,
EVP_PKEY_encrypt_init, "EVP_PKEY_encrypt_init",
EVP_PKEY_encrypt, "EVP_PKEY_encrypt");
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_exception.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_exception.c
index 1d1736f5..9ccc617c 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_exception.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_exception.c
@@ -23,7 +23,6 @@
#include <openssl/evp.h>
#include <openssl/err.h>
-#include "kae_util.h"
#include "kae_log.h"
#include "kae_exception.h"
@@ -58,6 +57,8 @@ void KAE_ThrowEvpException(JNIEnv* env, int reason, const char* msg, void (* def
case EVP_R_BAD_DECRYPT:
case EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH:
case EVP_F_EVP_PKEY_DECRYPT:
+ case EVP_R_PUBLIC_KEY_NOT_RSA:
+ case EVP_R_CTRL_NOT_IMPLEMENTED:
KAE_ThrowByName(env, "javax/crypto/BadPaddingException", msg);
break;
default:
@@ -128,4 +129,4 @@ void KAE_ThrowSignatureException(JNIEnv* env, const char* msg) {
void KAE_ThrowClassNotFoundException(JNIEnv* env, const char* msg) {
KAE_ThrowByName(env, "java/lang/ClassNotFoundException", msg);
-}
\ No newline at end of file
+}
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keyagreement_dh.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keyagreement_dh.c
index 26ce9a8e..b1c27241 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keyagreement_dh.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keyagreement_dh.c
@@ -112,7 +112,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_openeuler_security_openssl_KAEDHKeyAgreeme
BN_bin2bn(secret, computekeyLength, computeKeyRetBn);
- retByteArray = KAE_GetByteArrayFromBigNum(env, computeKeyRetBn, NULL);
+ retByteArray = KAE_GetByteArrayFromBigNum(env, computeKeyRetBn);
if (retByteArray == NULL) {
KAE_ThrowRuntimeException(env, "GetByteArrayFromBigNum failed in nativeComputeKey.");
goto cleanup;
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_dh.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_dh.c
index 808a2626..54dc07ed 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_dh.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_dh.c
@@ -97,13 +97,13 @@ JNIEXPORT jobjectArray JNICALL Java_org_openeuler_security_openssl_KAEDHKeyPairG
pri_key_bn = DH_get0_priv_key(dh);
pub_key_bn = DH_get0_pub_key(dh);
- pub_key = KAE_GetByteArrayFromBigNum(env, pub_key_bn, NULL);
+ pub_key = KAE_GetByteArrayFromBigNum(env, pub_key_bn);
if (pub_key == NULL) {
KAE_ThrowOOMException(env, "PublicKey allocate failed in nativeGenerateKeyPair.");
goto cleanup;
}
- pri_key = KAE_GetByteArrayFromBigNum(env, pri_key_bn, NULL);
+ pri_key = KAE_GetByteArrayFromBigNum(env, pri_key_bn);
if (pri_key == NULL) {
KAE_ThrowRuntimeException(env, "GetByteArrayFromBigNum failed in nativeGenerateKeyPair.");
goto cleanup;
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_ec.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_ec.c
index 0f32674c..fbd16841 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_ec.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_ec.c
@@ -43,7 +43,12 @@ typedef enum ECDHParamIndex {
ecdhCofactor
} ECDHParamIndex;
-static const char* ecdhParamNames[] = {"p", "a", "b", "x", "y", "order", "cofactor"};
+// ECDH Key index.
+typedef enum ECDHKeyIndex {
+ ecdhWX = 0,
+ ecdhWY,
+ ecdhS
+} ECDHKeyIndex;
static void FreeECDHCurveParam(JNIEnv* env, BIGNUM* p, BIGNUM* a, BIGNUM* b, jbyteArray paramP,
jbyteArray paramA, jbyteArray paramB)
@@ -69,7 +74,7 @@ static void FreeECDHCurveParam(JNIEnv* env, BIGNUM* p, BIGNUM* a, BIGNUM* b, jby
}
// Set p, a, b in group to params.
-static bool SetECDHCurve(JNIEnv* env, EC_GROUP* group, jobjectArray params, ECDHParamIndex ecdhParamIndex)
+static bool SetECDHCurve(JNIEnv* env, EC_GROUP* group, jobjectArray params)
{
BIGNUM* p = NULL;
BIGNUM* a = NULL;
@@ -86,25 +91,22 @@ static bool SetECDHCurve(JNIEnv* env, EC_GROUP* group, jobjectArray params, ECDH
}
// Set p.
- const char* ecdhParamName = ecdhParamNames[ecdhParamIndex];
- if ((paramP = KAE_GetByteArrayFromBigNum(env, p, ecdhParamName)) == NULL) {
+ if ((paramP = KAE_GetByteArrayFromBigNum(env, p)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhParamIndex, paramP);
+ (*env)->SetObjectArrayElement(env, params, ecdhP, paramP);
// Set a.
- ecdhParamName = ecdhParamNames[++ecdhParamIndex];
- if ((paramA = KAE_GetByteArrayFromBigNum(env, a, ecdhParamName)) == NULL) {
+ if ((paramA = KAE_GetByteArrayFromBigNum(env, a)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhParamIndex, paramA);
+ (*env)->SetObjectArrayElement(env, params, ecdhA, paramA);
// Set b.
- ecdhParamName = ecdhParamNames[++ecdhParamIndex];
- if ((paramB = KAE_GetByteArrayFromBigNum(env, b, ecdhParamName)) == NULL) {
+ if ((paramB = KAE_GetByteArrayFromBigNum(env, b)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhParamIndex, paramB);
+ (*env)->SetObjectArrayElement(env, params, ecdhB, paramB);
FreeECDHCurveParam(env, p, a, b, paramP, paramA, paramB);
return true;
@@ -114,7 +116,7 @@ cleanup:
}
// Set generator(x, y) in group to params.
-static bool SetECDHPoint(JNIEnv* env, EC_GROUP* group, jobjectArray params, ECDHParamIndex ecdhParamIndex)
+static bool SetECDHPoint(JNIEnv* env, EC_GROUP* group, jobjectArray params)
{
BIGNUM* x = NULL;
BIGNUM* y = NULL;
@@ -135,18 +137,16 @@ static bool SetECDHPoint(JNIEnv* env, EC_GROUP* group, jobjectArray params, ECDH
}
// Set x.
- const char* ecdhParamName = ecdhParamNames[ecdhParamIndex];
- if ((paramX = KAE_GetByteArrayFromBigNum(env, x, ecdhParamName)) == NULL) {
+ if ((paramX = KAE_GetByteArrayFromBigNum(env, x)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhParamIndex, paramX);
+ (*env)->SetObjectArrayElement(env, params, ecdhX, paramX);
// Set y.
- ecdhParamName = ecdhParamNames[++ecdhParamIndex];
- if ((paramY = KAE_GetByteArrayFromBigNum(env, y, ecdhParamName)) == NULL) {
+ if ((paramY = KAE_GetByteArrayFromBigNum(env, y)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhParamIndex, paramY);
+ (*env)->SetObjectArrayElement(env, params, ecdhY, paramY);
BN_free(x);
BN_free(y);
(*env)->DeleteLocalRef(env, paramX);
@@ -170,7 +170,7 @@ cleanup:
}
// Set order, cofactor in group to params.
-static bool SetECDHOrderAndCofactor(JNIEnv* env, EC_GROUP* group, jobjectArray params, ECDHParamIndex ecdhParamIndex)
+static bool SetECDHOrderAndCofactor(JNIEnv* env, EC_GROUP* group, jobjectArray params)
{
BIGNUM* order = NULL;
BIGNUM* cofactor = NULL;
@@ -184,21 +184,19 @@ static bool SetECDHOrderAndCofactor(JNIEnv* env, EC_GROUP* group, jobjectArray p
}
// Set order.
- const char* ecdhParamName = ecdhParamNames[ecdhParamIndex];
- if ((paramOrder = KAE_GetByteArrayFromBigNum(env, order, ecdhParamName)) == NULL) {
+ if ((paramOrder = KAE_GetByteArrayFromBigNum(env, order)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhParamIndex, paramOrder);
+ (*env)->SetObjectArrayElement(env, params, ecdhOrder, paramOrder);
if (!EC_GROUP_get_cofactor(group, cofactor, NULL)) {
goto cleanup;
}
// Set cofactor.
- ecdhParamName = ecdhParamNames[++ecdhParamIndex];
- if ((paramCofactor = KAE_GetByteArrayFromBigNum(env, cofactor, ecdhParamName)) == NULL) {
+ if ((paramCofactor = KAE_GetByteArrayFromBigNum(env, cofactor)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhParamIndex, paramCofactor);
+ (*env)->SetObjectArrayElement(env, params, ecdhCofactor, paramCofactor);
BN_free(order);
BN_free(cofactor);
(*env)->DeleteLocalRef(env, paramOrder);
@@ -222,7 +220,7 @@ cleanup:
}
static void FreeECDHKeyParam(JNIEnv* env,
- BIGNUM* wX, BIGNUM* wY, jbyteArray paramWX, jbyteArray paramWY, jbyteArray paramS)
+ BIGNUM* wX, BIGNUM* wY, jbyteArray keyWX, jbyteArray keyWY, jbyteArray keyS)
{
if (wX != NULL) {
BN_free(wX);
@@ -230,28 +228,28 @@ static void FreeECDHKeyParam(JNIEnv* env,
if (wY != NULL) {
BN_free(wY);
}
- if (paramWX != NULL) {
- (*env)->DeleteLocalRef(env, paramWX);
+ if (keyWX != NULL) {
+ (*env)->DeleteLocalRef(env, keyWX);
}
- if (paramWY != NULL) {
- (*env)->DeleteLocalRef(env, paramWY);
+ if (keyWY != NULL) {
+ (*env)->DeleteLocalRef(env, keyWY);
}
- if (paramS != NULL) {
- (*env)->DeleteLocalRef(env, paramS);
+ if (keyS != NULL) {
+ (*env)->DeleteLocalRef(env, keyS);
}
}
// Set publicKey(wX, wY) and privateKey(s) in eckey to params.
static bool SetECDHKey(JNIEnv* env, const EC_GROUP* group, jobjectArray params,
- ECDHParamIndex ecdhKeyIndex, const EC_KEY* eckey)
+ const EC_KEY* eckey)
{
BIGNUM* wX = NULL;
BIGNUM* wY = NULL;
const EC_POINT* pub = NULL;
const BIGNUM* s = NULL;
- jbyteArray paramWX = NULL;
- jbyteArray paramWY = NULL;
- jbyteArray paramS = NULL;
+ jbyteArray keyWX = NULL;
+ jbyteArray keyWY = NULL;
+ jbyteArray keyS = NULL;
if ((wX = BN_new()) == NULL || (wY = BN_new()) == NULL) {
KAE_ThrowOOMException(env, "failed to allocate array");
goto cleanup;
@@ -266,53 +264,47 @@ static bool SetECDHKey(JNIEnv* env, const EC_GROUP* group, jobjectArray params,
}
// Set wX.
- const char* ecdhParamName = ecdhParamNames[ecdhKeyIndex];
- if ((paramWX = KAE_GetByteArrayFromBigNum(env, wX, ecdhParamName)) == NULL) {
+ if ((keyWX = KAE_GetByteArrayFromBigNum(env, wX)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhKeyIndex, paramWX);
+ (*env)->SetObjectArrayElement(env, params, ecdhWX, keyWX);
// Set wY.
- ecdhParamName = ecdhParamNames[++ecdhKeyIndex];
- if ((paramWY = KAE_GetByteArrayFromBigNum(env, wY, ecdhParamName)) == NULL) {
+ if ((keyWY = KAE_GetByteArrayFromBigNum(env, wY)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhKeyIndex, paramWY);
+ (*env)->SetObjectArrayElement(env, params, ecdhWY, keyWY);
// Set s.
- ecdhParamName = ecdhParamNames[++ecdhKeyIndex];
- if ((paramS = KAE_GetByteArrayFromBigNum(env, s, ecdhParamName)) == NULL) {
+ if ((keyS = KAE_GetByteArrayFromBigNum(env, s)) == NULL) {
goto cleanup;
}
- (*env)->SetObjectArrayElement(env, params, ecdhKeyIndex, paramS);
- FreeECDHKeyParam(env, wX, wY, paramWX, paramWY, paramS);
+ (*env)->SetObjectArrayElement(env, params, ecdhS, keyS);
+ FreeECDHKeyParam(env, wX, wY, keyWX, keyWY, keyS);
return true;
cleanup:
- FreeECDHKeyParam(env, wX, wY, paramWX, paramWY, paramS);
+ FreeECDHKeyParam(env, wX, wY, keyWX, keyWY, keyS);
return false;
}
// Convert EC_GROUP in openssl to byte[][] in java
static jobjectArray NewECDHParam(JNIEnv* env, EC_GROUP* group)
{
- jclass byteArrayClass = NULL;
- jobjectArray params = NULL;
-
- byteArrayClass = (*env)->FindClass(env, "[B");
- params = (*env)->NewObjectArray(env, KAE_EC_PARAM_NUM_SIZE, byteArrayClass, NULL);
+ jclass byteArrayClass = (*env)->FindClass(env, "[B");
+ jobjectArray params = (*env)->NewObjectArray(env, KAE_EC_PARAM_NUM_SIZE, byteArrayClass, NULL);
if (params == NULL) {
KAE_ThrowOOMException(env, "failed to allocate array");
goto cleanup;
}
- if (!SetECDHCurve(env, group, params, ecdhP)) {
+ if (!SetECDHCurve(env, group, params)) {
goto cleanup;
}
- if (!SetECDHPoint(env, group, params, ecdhX)) {
+ if (!SetECDHPoint(env, group, params)) {
goto cleanup;
}
- if (!SetECDHOrderAndCofactor(env, group, params, ecdhOrder)) {
+ if (!SetECDHOrderAndCofactor(env, group, params)) {
goto cleanup;
}
@@ -332,16 +324,13 @@ cleanup:
// Convert EC_KEY in openssl to byte[][] in java
static jobjectArray NewECDHKey(JNIEnv* env, const EC_GROUP* group, const EC_KEY* eckey)
{
- jclass byteArrayClass = NULL;
- jobjectArray params = NULL;
-
- byteArrayClass = (*env)->FindClass(env, "[B");
- params = (*env)->NewObjectArray(env, KAE_EC_KEY_NUM_SIZE, byteArrayClass, NULL);
+ jclass byteArrayClass = (*env)->FindClass(env, "[B");
+ jobjectArray params = (*env)->NewObjectArray(env, KAE_EC_KEY_NUM_SIZE, byteArrayClass, NULL);
if (params == NULL) {
KAE_ThrowOOMException(env, "failed to allocate array");
goto cleanup;
}
- if (!SetECDHKey(env, group, params, 0, eckey)) {
+ if (!SetECDHKey(env, group, params, eckey)) {
goto cleanup;
}
@@ -435,6 +424,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_openeuler_security_openssl_KAEECKeyPairG
JNIEnv* env, jclass cls, jstring curveName)
{
EC_GROUP* group = NULL;
+ jobjectArray ecdhParam = NULL;
const char *curve = (*env)->GetStringUTFChars(env, curveName, 0);
KAE_TRACE("KAEECKeyPairGenerator_nativeGenerateParam(curveName = %s)", curve);
@@ -447,7 +437,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_openeuler_security_openssl_KAEECKeyPairG
if ((group = EC_GROUP_new_by_curve_name(nid)) == NULL) {
goto cleanup;
}
- jobjectArray ecdhParam = NewECDHParam(env, group);
+ ecdhParam = NewECDHParam(env, group);
if (group != NULL) {
EC_GROUP_free(group);
@@ -476,6 +466,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_openeuler_security_openssl_KAEECKeyPairG
{
EC_GROUP* group = NULL;
EC_KEY* eckey = NULL;
+ jobjectArray ecdhKey = NULL;
if ((group = GetGroupByParam(env, pArr, aArr, bArr, xArr, yArr, orderArr, cofactorInt)) == NULL) {
goto cleanup;
@@ -492,7 +483,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_openeuler_security_openssl_KAEECKeyPairG
goto cleanup;
}
- jobjectArray ecdhKey = NewECDHKey(env, group, eckey);
+ ecdhKey = NewECDHKey(env, group, eckey);
EC_KEY_free(eckey);
EC_GROUP_free(group);
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c
index de724593..0b23aa7d 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c
@@ -27,9 +27,6 @@
#include "kae_exception.h"
#include "org_openeuler_security_openssl_KAERSAKeyPairGenerator.h"
#define KAE_RSA_PARAM_SIZE 8
-#define SUCCESS 1
-#define FAILED -1
-
// rsa param index
typedef enum RSAParamIndex {
@@ -102,15 +99,11 @@ static void ReleaseRSA(RSA* rsa) {
/*
* Set rsa key param, follow the steps below
- * step 1. Get rsa param name
- * step 2. Get rsa param value
- * step 3. Convert paramValue (BIGNUM) to jbyteArray
- * step 4. Set the rsa param to the param array
+ * step 1. Get rsa param value
+ * step 2. Convert paramValue (BIGNUM) to jbyteArray
+ * step 3. Set the rsa param to the param array
*/
static bool SetRSAKeyParam(JNIEnv* env, RSA* rsa, jobjectArray params, RSAParamIndex rsaParamIndex) {
- // get rsa param name
- const char* rsaParamName = rsaParamNames[rsaParamIndex];
-
// get rsa param value
const BIGNUM* rsaParamValue = GetRSAParamFunctionList[rsaParamIndex](rsa);
if (rsaParamValue == NULL) {
@@ -118,7 +111,7 @@ static bool SetRSAKeyParam(JNIEnv* env, RSA* rsa, jobjectArray params, RSAParamI
}
// Convert paramValue to jbyteArray
- jbyteArray param = KAE_GetByteArrayFromBigNum(env, rsaParamValue, rsaParamName);
+ jbyteArray param = KAE_GetByteArrayFromBigNum(env, rsaParamValue);
if (param == NULL) {
return false;
}
@@ -156,8 +149,8 @@ static jobjectArray NewRSAKeyParams(JNIEnv* env, RSA* rsa) {
* Method: nativeGenerateKeyPair
* Signature: (I[B)[[B
*/
-JNIEXPORT jobjectArray JNICALL Java_org_openeuler_security_openssl_KAERSAKeyPairGenerator_nativeGenerateKeyPair
- (JNIEnv* env, jclass cls, jint keySize, jbyteArray publicExponent) {
+JNIEXPORT jobjectArray JNICALL Java_org_openeuler_security_openssl_KAERSAKeyPairGenerator_nativeGenerateKeyPair (
+ JNIEnv* env, jclass cls, jint keySize, jbyteArray publicExponent) {
if (publicExponent == NULL) {
return NULL;
}
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c
index 81c7b3ef..71c28bde 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c
@@ -170,7 +170,7 @@ Java_org_openeuler_security_openssl_KAESymmetricCipherBase_nativeInit(JNIEnv* en
}
if (!EVP_CipherInit_ex(ctx, cipher, kaeEngine, (const unsigned char*)keyBytes,
- (const unsigned char*)ivBytes, encrypt ? 1 : 0)) {
+ (const unsigned char*)ivBytes, encrypt ? 1 : 0)) {
KAE_ThrowFromOpenssl(env, "EVP_CipherInit_ex failed", KAE_ThrowRuntimeException);
goto cleanup;
}
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.c
index a92ba406..0e656a83 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.c
@@ -77,7 +77,7 @@ void KAE_ReleaseBigNumFromByteArray(BIGNUM* bn) {
}
}
-jbyteArray KAE_GetByteArrayFromBigNum(JNIEnv* env, const BIGNUM* bn, const char* sourceName) {
+jbyteArray KAE_GetByteArrayFromBigNum(JNIEnv* env, const BIGNUM* bn) {
if (bn == NULL) {
return NULL;
}
@@ -89,12 +89,12 @@ jbyteArray KAE_GetByteArrayFromBigNum(JNIEnv* env, const BIGNUM* bn, const char*
bnSize += 1;
jbyteArray javaBytes = (*env)->NewByteArray(env, bnSize);
if (javaBytes == NULL) {
- KAE_ThrowOOMException(env, "new byte array failed");
+ KAE_ThrowOOMException(env, "New byte array failed.");
return NULL;
}
jbyte* bytes = (*env)->GetByteArrayElements(env, javaBytes, NULL);
if (bytes == NULL) {
- KAE_ThrowNullPointerException(env,"GetByteArrayElements failed");
+ KAE_ThrowNullPointerException(env, "GetByteArrayElements failed.");
return NULL;
}
unsigned char* tmp = (unsigned char*) bytes;
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.h b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.h
index fee81627..13bd5976 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.h
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_util.h
@@ -34,7 +34,7 @@ BIGNUM* KAE_GetBigNumFromByteArray(JNIEnv* env, jbyteArray byteArray);
void KAE_ReleaseBigNumFromByteArray(BIGNUM* bn);
/* BIGNUM convert to jbyteArray */
-jbyteArray KAE_GetByteArrayFromBigNum(JNIEnv* env, const BIGNUM* bn, const char* sourceName);
+jbyteArray KAE_GetByteArrayFromBigNum(JNIEnv* env, const BIGNUM* bn);
void SetKaeEngine(ENGINE* engine);
diff --git a/jdk/test/micro/org/openeuler/bench/security/openssl/DHKeyAgreementBenchMark.java b/jdk/test/micro/org/openeuler/bench/security/openssl/DHKeyAgreementBenchMark.java
index 8a9a2d5d..c204f4ce 100644
--- a/jdk/test/micro/org/openeuler/bench/security/openssl/DHKeyAgreementBenchMark.java
+++ b/jdk/test/micro/org/openeuler/bench/security/openssl/DHKeyAgreementBenchMark.java
@@ -43,9 +43,13 @@ public class DHKeyAgreementBenchMark extends BenchmarkBase {
@Param({"512", "1024", "2048", "3072", "4096"})
private int keySize;
- private KeyPairGenerator aliceKpairGen, bobKpairGen, carolKpairGen;
+ private KeyPairGenerator aliceKpairGen;
+ private KeyPairGenerator bobKpairGen;
+ private KeyPairGenerator carolKpairGen;
- private KeyPair aliceKpair, bobKpair, carolKpair;
+ private KeyPair aliceKpair;
+ private KeyPair bobKpair;
+ private KeyPair carolKpair;
private DHParameterSpec dhSkipParamSpec;

View File

@ -916,7 +916,7 @@ Provides: java-%{javaver}-%{origin}-accessibility%{?1} = %{epoch}:%{version}-%{r
Name: java-%{javaver}-%{origin}
Version: %{javaver}.%{updatever}.%{buildver}
Release: 2
Release: 3
# java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons
# and this change was brought into RHEL-4. java-1.5.0-ibm packages
# also included the epoch in their virtual provides. This created a
@ -1103,6 +1103,21 @@ Patch202: Fix-RSACipher-memory-usage.patch
Patch203: fix-lock-ordering-issue-when-calling-JVMTI-GetLoaded.patch
Patch204: 8069191.patch
Patch205: fix_g1uncommit_ygc_expand_crash.patch
Patch206: 8167014-jdeps-failed-with-Missing-message-warn-skippen-entry.patch
Patch207: fix_bug_in_keypairgenerator.patch
Patch208: C1-assert-is_virtual-failed-type-check.patch
Patch209: 8197387-Run-the-jcmd-tool-as-the-root-user-to-access.patch
Patch210: create-jfr-dump-file-with-pid-or-timestamp-if-specif.patch
Patch211: 8268453-sun-security-pkcs12-EmptyPassword.java-fails.patch
Patch212: enhance-the-TimeZone-s-path-solution-on-Euler.patch
Patch213: fix-wrong-commitID-in-release-file.patch
Patch214: fix-appcds-s-option-AppCDSLockFile.patch
Patch215: PS-introduce-UsePSRelaxedForwardee-to-enable-using-r.patch
Patch216: Parallel-Full-GC-for-G1.patch
Patch217: 8202142-jfr-event-io-TestInstrumentation-is-unstable.patch
Patch218: 8143251-Thread-suspend-on-VM_G1IncCollectionPause-do.patch
Patch219: G1Uncommit-Introduce-G1PeriodGCNotRetry-control-whet.patch
Patch220: JDK-debug-version-crash-when-using-AppCDS.patch
#############################################
#
@ -1554,6 +1569,21 @@ pushd %{top_level_dir_name}
%patch203 -p1
%patch204 -p1
%patch205 -p1
%patch206 -p1
%patch207 -p1
%patch208 -p1
%patch209 -p1
%patch210 -p1
%patch211 -p1
%patch212 -p1
%patch213 -p1
%patch214 -p1
%patch215 -p1
%patch216 -p1
%patch217 -p1
%patch218 -p1
%patch219 -p1
%patch220 -p1
popd
# System library fixes
@ -2169,6 +2199,23 @@ require "copy_jdk_configs.lua"
%endif
%changelog
* Fri Sep 17 2021 kuenking111 <wangkun49@huawei.com> - 1:1.8.0.302-b07.3
- add 8167014-jdeps-failed-with-Missing-message-warn-skippen-entry.patch
- add fix_bug_in_keypairgenerator.patch
- add C1-assert-is_virtual-failed-type-check.patch
- add 8197387-Run-the-jcmd-tool-as-the-root-user-to-access.patch
- add create-jfr-dump-file-with-pid-or-timestamp-if-specif.patch
- add 8268453-sun-security-pkcs12-EmptyPassword.java-fails.patch
- add enhance-the-TimeZone-s-path-solution-on-Euler.patch
- add fix-wrong-commitID-in-release-file.patch
- add fix-appcds-s-option-AppCDSLockFile.patch
- add PS-introduce-UsePSRelaxedForwardee-to-enable-using-r.patch
- add Parallel-Full-GC-for-G1.patch
- add 8202142-jfr-event-io-TestInstrumentation-is-unstable.patch
- add 8143251-Thread-suspend-on-VM_G1IncCollectionPause-do.patch
- add G1Uncommit-Introduce-G1PeriodGCNotRetry-control-whet.patch
- add JDK-debug-version-crash-when-using-AppCDS.patch
* Fri Aug 20 2021 kuenking111 <wangkun49@huawei.com> - 1:1.8.0.302-b07.2
- add fix_g1uncommit_ygc_expand_crash.patch