aboutsummaryrefslogtreecommitdiffstats
path: root/community/openjdk11/ppc64le.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/openjdk11/ppc64le.patch')
-rw-r--r--community/openjdk11/ppc64le.patch107
1 files changed, 72 insertions, 35 deletions
diff --git a/community/openjdk11/ppc64le.patch b/community/openjdk11/ppc64le.patch
index 88ee55ae05e..3aba9929f5e 100644
--- a/community/openjdk11/ppc64le.patch
+++ b/community/openjdk11/ppc64le.patch
@@ -1,3 +1,12 @@
+Subject: Fix compilation with different ucontext_t on musl
+Upstream: No
+Author: Simon Frankenberger <simon-alpine@fraho.eu>
+
+The machine state registers have to be accessed differently when
+running on musl libc. This patch fix this by replacing
+"uc_mcontext.regs->grp" with "uc_mcontext.gp_regs"
+and accessing the named fields (like "->nip") by the array index constants.
+
--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
+++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
@@ -1290,7 +1290,11 @@
@@ -60,7 +69,7 @@
}
--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp
-@@ -768,7 +768,7 @@
+@@ -921,7 +921,7 @@
unsigned long auxv = getauxval(AT_HWCAP2);
if (auxv & PPC_FEATURE2_HTM_NOSC) {
@@ -71,7 +80,17 @@
// POWER9 DD2.1 NV has a few issues that need a couple of firmware
--- old/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp
+++ new/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp
-@@ -108,24 +108,42 @@
+@@ -76,6 +76,9 @@
+ # include <poll.h>
+ # include <ucontext.h>
+
++#if ! (defined(__GLIBC__) || defined(__UCLIBC__))
++# include <asm/ptrace.h>
++#endif
+
+ address os::current_stack_pointer() {
+ intptr_t* csp;
+@@ -108,24 +111,42 @@
// - if uc was filled by getcontext(), it is undefined - getcontext() does not fill
// it because the volatile registers are not needed to make setcontext() work.
// Hopefully it was zero'd out beforehand.
@@ -80,7 +99,7 @@
return (address)uc->uc_mcontext.regs->nip;
+#else // Musl
+ guarantee(uc->uc_mcontext.gp_regs != NULL, "only use ucontext_get_pc in sigaction context");
-+ return (address)uc->uc_mcontext.gp_regs[32];
++ return (address)uc->uc_mcontext.gp_regs[PT_NIP];
+#endif
}
@@ -93,7 +112,7 @@
uc->uc_mcontext.regs->nip = (unsigned long)pc;
+#else // Musl
+ guarantee(uc->uc_mcontext.gp_regs != NULL, "only use ucontext_set_pc in sigaction context");
-+ uc->uc_mcontext.gp_regs[32] = (unsigned long)pc;
++ uc->uc_mcontext.gp_regs[PT_NIP] = (unsigned long)pc;
+#endif
}
@@ -101,7 +120,7 @@
+#if defined(__GLIBC__) || defined(__UCLIBC__)
return (address)uc->uc_mcontext.regs->link;
+#else // Musl
-+ return (address)uc->uc_mcontext.gp_regs[36];
++ return (address)uc->uc_mcontext.gp_regs[PT_LNK];
+#endif
}
@@ -114,33 +133,31 @@
}
intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) {
-@@ -133,7 +151,11 @@
+@@ -133,7 +154,11 @@
}
static unsigned long ucontext_get_trap(const ucontext_t * uc) {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
return uc->uc_mcontext.regs->trap;
+#else // Musl
-+ return uc->uc_mcontext.gp_regs[40];
++ return uc->uc_mcontext.gp_regs[PT_TRAP];
+#endif
}
ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
-@@ -259,7 +281,13 @@
+@@ -265,7 +290,11 @@
// 3.2.1 "Machine State Register"), however note that ISA notation for bit
// numbering is MSB 0, so for normal bit numbering (LSB 0) they come to be
// bits 33 and 34. It's not related to endianness, just a notation matter.
+#if defined(__GLIBC__) || defined(__UCLIBC__)
if (second_uc->uc_mcontext.regs->msr & 0x600000000) {
+#else // Musl
-+ // why 33?
-+ // see comment for glibc NGREG: "r0-r31, nip, msr, lr, etc."
-+ if (second_uc->uc_mcontext.gp_regs[33] & 0x600000000) {
++ if (second_uc->uc_mcontext.gp_regs[PT_MSR] & 0x600000000) {
+#endif
if (TraceTraps) {
tty->print_cr("caught signal in transaction, "
"ignoring to jump to abort handler");
-@@ -586,6 +614,7 @@
+@@ -593,6 +622,7 @@
const ucontext_t* uc = (const ucontext_t*)context;
st->print_cr("Registers:");
@@ -148,14 +165,14 @@
st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.regs->nip);
st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.regs->link);
st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.regs->ctr);
-@@ -594,8 +623,18 @@
+@@ -601,8 +631,18 @@
st->print("r%-2d=" INTPTR_FORMAT " ", i, uc->uc_mcontext.regs->gpr[i]);
if (i % 3 == 2) st->cr();
}
+#else // Musl
-+ st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[32]);
-+ st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[36]);
-+ st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[35]);
++ st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[PT_NIP]);
++ st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[PT_LNK]);
++ st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[PT_CTR]);
st->cr();
+ for (int i = 0; i < 32; i++) {
+ st->print("r%-2d=" INTPTR_FORMAT " ", i, uc->uc_mcontext.gp_regs[i]);
@@ -167,7 +184,7 @@
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
-@@ -618,12 +657,22 @@
+@@ -625,12 +665,22 @@
st->print_cr("Register to memory mapping:");
st->cr();
@@ -176,9 +193,9 @@
st->print("lr ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->link);
st->print("ctr ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->ctr);
+#else // Musl
-+ st->print("pc ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[32]);
-+ st->print("lr ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[36]);
-+ st->print("ctr ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[35]);
++ st->print("pc ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[PT_NIP]);
++ st->print("lr ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[PT_LNK]);
++ st->print("ctr ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[PT_CTR]);
+#endif
for (int i = 0; i < 32; i++) {
st->print("r%-2d=", i);
@@ -192,29 +209,49 @@
}
--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
+++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
-@@ -56,8 +56,13 @@
+@@ -27,6 +27,10 @@
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/thread.hpp"
+
++#if ! (defined(__GLIBC__) || defined(__UCLIBC__))
++#include <asm/ptrace.h>
++#endif
++
+ frame JavaThread::pd_last_frame() {
+ assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
+
+@@ -58,14 +62,22 @@
// if we were running Java code when SIGPROF came in.
if (isInJava) {
ucontext_t* uc = (ucontext_t*) ucontext;
+#if defined(__GLIBC__) || defined(__UCLIBC__)
- frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/],
- (address)uc->uc_mcontext.regs->nip);
+ address pc = (address)uc->uc_mcontext.regs->nip;
+#else // Musl
-+ frame ret_frame((intptr_t*)uc->uc_mcontext.gp_regs[1/*REG_SP*/],
-+ (address)uc->uc_mcontext.gp_regs[32]);
++ address pc = (address)uc->uc_mcontext.gp_regs[PT_NIP];
+#endif
- if (ret_frame.pc() == NULL) {
+ if (pc == NULL) {
// ucontext wasn't useful
-@@ -69,7 +74,11 @@
- if (!((Method*)(istate->method))->is_metaspace_object()) {
- return false;
- }
+ return false;
+ }
+
++#if defined(__GLIBC__) || defined(__UCLIBC__)
+ frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/], pc);
++#else // Musl
++ frame ret_frame((intptr_t*)uc->uc_mcontext.gp_regs[1/*REG_SP*/], pc);
++#endif
+
+ if (ret_frame.fp() == NULL) {
+ // The found frame does not have a valid frame pointer.
+@@ -84,7 +96,11 @@
+ if (!Method::is_valid_method(m)) return false;
+ if (!Metaspace::contains((const void*)m->constMethod())) return false;
+
+#if defined(__GLIBC__) || defined(__UCLIBC__)
- uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
+ uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
+#else // Musl
-+ uint64_t reg_bcp = uc->uc_mcontext.gp_regs[14/*R14_bcp*/];
++ uint64_t reg_bcp = uc->uc_mcontext.gp_regs[14/*R14_bcp*/];
+#endif
- uint64_t istate_bcp = istate->bcp;
- uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base());
- uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size());
+ uint64_t istate_bcp = istate->bcp;
+ uint64_t code_start = (uint64_t)(m->code_base());
+ uint64_t code_end = (uint64_t)(m->code_base() + m->code_size());