/hg/icedtea8-forest/hotspot: 7 new changesets

andrew at icedtea.classpath.org andrew at icedtea.classpath.org
Thu May 3 03:53:38 UTC 2018


changeset 4e2adbc3d2b5 in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=4e2adbc3d2b5
author: aph
date: Thu Apr 19 04:45:41 2018 +0100

	8197429, PR3546: Increased stack guard causes segfaults on x86-32
	Reviewed-by: dholmes


changeset 91ab2eac9856 in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=91ab2eac9856
author: aph
date: Wed Aug 02 17:22:40 2017 +0100

	8185723, PR3553: Zero: segfaults on Power PC 32-bit
	Reviewed-by: roland


changeset be1379a186ba in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=be1379a186ba
author: glaubitz
date: Sat Apr 28 05:28:10 2018 +0100

	8186461, PR3557: Zero's atomic_copy64() should use SPE instructions on linux-powerpcspe
	Reviewed-by: aph


changeset 6275d7b41909 in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=6275d7b41909
author: aph
date: Mon May 28 08:01:18 2012 -0400

	PR3559: Use ldrexd for atomic reads on ARMv7.

	2012-05-28  Andrew Haley  <aph at redhat.com>

		* os_linux_zero.hpp (atomic_copy64): Use ldrexd for atomic reads
		on ARMv7.


changeset 5460c427c0dc in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=5460c427c0dc
author: aph
date: Mon Apr 23 19:32:41 2018 +0100

	8200556, PR3566: AArch64: assertion failure in slowdebug builds
	Reviewed-by: adinn


changeset ffd5260fe5ad in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=ffd5260fe5ad
author: poonam
date: Wed May 02 17:48:42 2018 +0100

	8187577, PR3546: JVM crash during gc doing concurrent marking
	Summary: Inform G1's SATB that a klass has been resurrected and it should not be unloaded
	Reviewed-by: coleenp, tschatzl, kbarrett


changeset de79964656fc in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=de79964656fc
author: mbalao
date: Thu May 03 04:16:52 2018 +0100

	8201509, PR3579: Zero: S390 31bit atomic_copy64 inline assembler is wrong
	Summary: The inline assembler for the S390 (S390 and not _LP64) has src and dst reversed thereby corrupting data
	Reviewed-by: shade


diffstat:

 src/cpu/aarch64/vm/nativeInst_aarch64.cpp    |   2 +-
 src/os/linux/vm/os_linux.cpp                 |   4 +
 src/os/linux/vm/os_linux.hpp                 |   4 +-
 src/os_cpu/linux_x86/vm/os_linux_x86.cpp     |  31 ++++++++++-
 src/os_cpu/linux_zero/vm/os_linux_zero.hpp   |  30 +++++++---
 src/share/vm/prims/jvmtiGetLoadedClasses.cpp |  20 ++++++-
 test/runtime/StackGap/T.java                 |  33 +++++++++++
 test/runtime/StackGap/exestack-gap.c         |  82 ++++++++++++++++++++++++++++
 test/runtime/StackGap/testme.sh              |  48 ++++++++++++++++
 9 files changed, 241 insertions(+), 13 deletions(-)

diffs (372 lines):

diff -r 20a18751757a -r de79964656fc src/cpu/aarch64/vm/nativeInst_aarch64.cpp
--- a/src/cpu/aarch64/vm/nativeInst_aarch64.cpp	Tue Mar 27 18:24:55 2018 +0100
+++ b/src/cpu/aarch64/vm/nativeInst_aarch64.cpp	Thu May 03 04:16:52 2018 +0100
@@ -302,7 +302,7 @@
   CodeBuffer cb(code_pos, instruction_size);
   MacroAssembler a(&cb);
 
-  a.mov(rscratch1, entry);
+  a.movptr(rscratch1, (uintptr_t)entry);
   a.br(rscratch1);
 
   ICache::invalidate_range(code_pos, instruction_size);
diff -r 20a18751757a -r de79964656fc src/os/linux/vm/os_linux.cpp
--- a/src/os/linux/vm/os_linux.cpp	Tue Mar 27 18:24:55 2018 +0100
+++ b/src/os/linux/vm/os_linux.cpp	Thu May 03 04:16:52 2018 +0100
@@ -674,6 +674,10 @@
   }
 }
 
+void os::Linux::expand_stack_to(address bottom) {
+  _expand_stack_to(bottom);
+}
+
 bool os::Linux::manually_expand_stack(JavaThread * t, address addr) {
   assert(t!=NULL, "just checking");
   assert(t->osthread()->expanding_stack(), "expand should be set");
diff -r 20a18751757a -r de79964656fc src/os/linux/vm/os_linux.hpp
--- a/src/os/linux/vm/os_linux.hpp	Tue Mar 27 18:24:55 2018 +0100
+++ b/src/os/linux/vm/os_linux.hpp	Thu May 03 04:16:52 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -245,6 +245,8 @@
   static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
 
 private:
+  static void expand_stack_to(address bottom);
+
   typedef int (*sched_getcpu_func_t)(void);
   typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
   typedef int (*numa_max_node_func_t)(void);
diff -r 20a18751757a -r de79964656fc src/os_cpu/linux_x86/vm/os_linux_x86.cpp
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Tue Mar 27 18:24:55 2018 +0100
+++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu May 03 04:16:52 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -892,6 +892,25 @@
 void os::workaround_expand_exec_shield_cs_limit() {
 #if defined(IA32) && !defined(ZERO)
   size_t page_size = os::vm_page_size();
+
+  /*
+   * JDK-8197429
+   *
+   * Expand the stack mapping to the end of the initial stack before
+   * attempting to install the codebuf.  This is needed because newer
+   * Linux kernels impose a distance of a megabyte between stack
+   * memory and other memory regions.  If we try to install the
+   * codebuf before expanding the stack the installation will appear
+   * to succeed but we'll get a segfault later if we expand the stack
+   * in Java code.
+   *
+   */
+  if (os::Linux::is_initial_thread()) {
+    address limit = Linux::initial_thread_stack_bottom();
+    limit += (StackYellowPages + StackRedPages) * page_size;
+    os::Linux::expand_stack_to(limit);
+  }
+
   /*
    * Take the highest VA the OS will give us and exec
    *
@@ -910,6 +929,16 @@
   char* hint = (char*) (Linux::initial_thread_stack_bottom() -
                         ((StackYellowPages + StackRedPages + 1) * page_size));
   char* codebuf = os::attempt_reserve_memory_at(page_size, hint);
+
+  if (codebuf == NULL) {
+    // JDK-8197429: There may be a stack gap of one megabyte between
+    // the limit of the stack and the nearest memory region: this is a
+    // Linux kernel workaround for CVE-2017-1000364.  If we failed to
+    // map our codebuf, try again at an address one megabyte lower.
+    hint -= 1 * M;
+    codebuf = os::attempt_reserve_memory_at(page_size, hint);
+  }
+
   if ( (codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true)) ) {
     return; // No matter, we tried, best effort.
   }
diff -r 20a18751757a -r de79964656fc src/os_cpu/linux_zero/vm/os_linux_zero.hpp
--- a/src/os_cpu/linux_zero/vm/os_linux_zero.hpp	Tue Mar 27 18:24:55 2018 +0100
+++ b/src/os_cpu/linux_zero/vm/os_linux_zero.hpp	Thu May 03 04:16:52 2018 +0100
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2007, 2008, 2010 Red Hat, Inc.
+ * Copyright 2007, 2008, 2010, 2018, Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,18 +36,30 @@
 
   // Atomically copy 64 bits of data
   static void atomic_copy64(volatile void *src, volatile void *dst) {
-#if defined(PPC32)
+#if defined(PPC32) && !defined(__SPE__)
     double tmp;
-    asm volatile ("lfd  %0, 0(%1)\n"
-                  "stfd %0, 0(%2)\n"
-                  : "=f"(tmp)
-                  : "b"(src), "b"(dst));
+    asm volatile ("lfd  %0, %2\n"
+                  "stfd %0, %1\n"
+                  : "=&f"(tmp), "=Q"(*(volatile double*)dst)
+                  : "Q"(*(volatile double*)src));
+#elif defined(PPC32) && defined(__SPE__)
+    long tmp;
+    asm volatile ("evldd  %0, %2\n"
+                  "evstdd %0, %1\n"
+                  : "=&r"(tmp), "=Q"(*(volatile long*)dst)
+                  : "Q"(*(volatile long*)src));
 #elif defined(S390) && !defined(_LP64)
     double tmp;
-    asm volatile ("ld  %0, 0(%1)\n"
-                  "std %0, 0(%2)\n"
+    asm volatile ("ld  %0, %2\n"
+                  "std %0, %1\n"
+                  : "=&f"(tmp), "=Q"(*(volatile double*)dst)
+                  : "Q"(*(volatile double*)src));
+#elif defined(__ARM_ARCH_7A__)
+    jlong tmp;
+    asm volatile ("ldrexd  %0, [%1]\n"
                   : "=r"(tmp)
-                  : "a"(src), "a"(dst));
+                  : "r"(src), "m"(src));
+    *(jlong *) dst = tmp;
 #else
     *(jlong *) dst = *(jlong *) src;
 #endif
diff -r 20a18751757a -r de79964656fc src/share/vm/prims/jvmtiGetLoadedClasses.cpp
--- a/src/share/vm/prims/jvmtiGetLoadedClasses.cpp	Tue Mar 27 18:24:55 2018 +0100
+++ b/src/share/vm/prims/jvmtiGetLoadedClasses.cpp	Thu May 03 04:16:52 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -27,6 +27,9 @@
 #include "memory/universe.inline.hpp"
 #include "prims/jvmtiGetLoadedClasses.hpp"
 #include "runtime/thread.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
+#endif
 
 
 // The closure for GetLoadedClasses
@@ -35,6 +38,20 @@
   Stack<jclass, mtInternal> _classStack;
   JvmtiEnv* _env;
 
+// Tell the GC to keep this klass alive
+static void ensure_klass_alive(oop o) {
+  // A klass that was previously considered dead can be looked up in the
+  // CLD/SD, and its _java_mirror or _class_loader can be stored in a root
+  // or a reachable object making it alive again. The SATB part of G1 needs
+  // to get notified about this potential resurrection, otherwise the marking
+  // might not find the object.
+#if INCLUDE_ALL_GCS
+  if (UseG1GC && o != NULL) {
+    G1SATBCardTableModRefBS::enqueue(o);
+  }
+#endif
+}
+
 public:
   LoadedClassesClosure(JvmtiEnv* env) {
     _env = env;
@@ -43,6 +60,7 @@
   void do_klass(Klass* k) {
     // Collect all jclasses
     _classStack.push((jclass) _env->jni_reference(k->java_mirror()));
+    ensure_klass_alive(k->java_mirror());
   }
 
   int extract(jclass* result_list) {
diff -r 20a18751757a -r de79964656fc test/runtime/StackGap/T.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/StackGap/T.java	Thu May 03 04:16:52 2018 +0100
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc. 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.
+ */
+
+public class T {
+
+  public static void test(int n) {
+    if (n == 0) return;
+    System.out.println (n);
+    test (n - 1);
+
+  }
+
+}
diff -r 20a18751757a -r de79964656fc test/runtime/StackGap/exestack-gap.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/StackGap/exestack-gap.c	Thu May 03 04:16:52 2018 +0100
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc. 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.
+ */
+
+#include <jni.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+JNIEnv* create_vm(JavaVM **jvm, char *extra_option)
+{
+    JNIEnv* env;
+    JavaVMInitArgs args;
+    JavaVMOption options[4];
+    args.version = JNI_VERSION_1_8;
+    args.nOptions = 3 + (extra_option != NULL);
+    options[0].optionString = "-Xss2048k";
+    char classpath[4096];
+    snprintf(classpath, sizeof classpath,
+             "-Djava.class.path=%s", getenv("CLASSPATH"));
+    options[1].optionString = classpath;
+    options[2].optionString = "-XX:+UnlockExperimentalVMOptions";
+    if (extra_option) {
+      options[3].optionString = extra_option;
+    }
+    args.options = &options[0];
+    args.ignoreUnrecognized = 0;
+    int rv;
+    rv = JNI_CreateJavaVM(jvm, (void**)&env, &args);
+    if (rv < 0) return NULL;
+    return env;
+}
+
+void run(char *extra_arg) {
+  JavaVM *jvm;
+  jclass T_class;
+  jmethodID test_method;
+  JNIEnv *env = create_vm(&jvm, extra_arg);
+  if (env == NULL)
+    exit(1);
+  T_class = (*env)->FindClass(env, "T");
+  if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
+    (*env)->ExceptionDescribe(env);
+    exit(1);
+  }
+  test_method = (*env)->GetStaticMethodID(env, T_class, "test", "(I)V");
+  if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
+    (*env)->ExceptionDescribe(env);
+    exit(1);
+  }
+  (*env)->CallStaticVoidMethod(env, T_class, test_method, 1000);
+}
+
+
+int main(int argc, char **argv)
+{
+  if (argc > 1) {
+    run(argv[1]);
+  } else {
+    run(NULL);
+  }
+
+  return 0;
+}
diff -r 20a18751757a -r de79964656fc test/runtime/StackGap/testme.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/StackGap/testme.sh	Thu May 03 04:16:52 2018 +0100
@@ -0,0 +1,48 @@
+# Copyright (c) 2014, 2018, 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.
+#!/bin/sh
+
+#
+# @test testme.sh
+# @summary Linux kernel stack guard should not cause segfaults on x86-32
+# @compile T.java
+# @run shell testme.sh
+#
+
+if [ "${TESTSRC}" = "" ]
+then
+  TESTSRC=${PWD}
+  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
+fi
+echo "TESTSRC=${TESTSRC}"
+## Adding common setup Variables for running shell tests.
+. ${TESTSRC}/../../test_env.sh
+
+if [ "${VM_OS}" != "linux" ]
+then
+  echo "Test only valid for Linux"
+  exit 0
+fi
+
+LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH
+
+${TESTNATIVEPATH}/stack-gap || exit $?


More information about the distro-pkg-dev mailing list