src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp
author mbaesken
Wed, 06 Nov 2019 14:04:07 +0100
changeset 58959 b7b170ba3ba9
parent 57594 61c2e3e7315d
permissions -rw-r--r--
8233328: fix minimal VM build on Linux s390x Reviewed-by: lucy, mdoerr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 53605
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
58959
b7b170ba3ba9 8233328: fix minimal VM build on Linux s390x
mbaesken
parents: 57594
diff changeset
     3
 * Copyright (c) 2016, 2019 SAP SE. All rights reserved.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     5
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     9
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    14
 * accompanied this code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    15
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    19
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    22
 * questions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    23
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    24
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    25
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    26
// This file is organized as os_linux_x86.cpp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    27
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
// no precompiled headers
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47607
diff changeset
    29
#include "jvm.h"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "asm/assembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "classfile/classLoader.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "classfile/systemDictionary.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "classfile/vmSymbols.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "code/icBuffer.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "code/nativeInst.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "code/vtableStubs.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "compiler/disassembler.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "interpreter/interpreter.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#include "memory/allocation.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#include "nativeInst_s390.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#include "os_share_linux.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#include "prims/jniFastGetField.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
#include "prims/jvm_misc.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
#include "runtime/arguments.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
#include "runtime/extendedPC.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 48821
diff changeset
    47
#include "runtime/interfaceSupport.inline.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
#include "runtime/java.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
#include "runtime/javaCalls.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
#include "runtime/mutexLocker.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
#include "runtime/osThread.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
#include "runtime/sharedRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
#include "runtime/stubRoutines.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
#include "runtime/thread.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
#include "runtime/timer.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
#include "utilities/events.hpp"
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
    57
#include "utilities/debug.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
#include "utilities/vmError.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
// put OS-includes here
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
# include <sys/types.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
# include <sys/mman.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
# include <pthread.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
# include <signal.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
# include <errno.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
# include <dlfcn.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
# include <stdlib.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
# include <stdio.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
# include <unistd.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
# include <sys/resource.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
# include <pthread.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
# include <sys/stat.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
# include <sys/time.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
# include <sys/utsname.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
# include <sys/socket.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
# include <sys/wait.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
# include <pwd.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
# include <poll.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
# include <ucontext.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
address os::current_stack_pointer() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
  intptr_t* csp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
  // Inline assembly for `z_lgr regno(csp), Z_SP' (Z_SP = Z_R15):
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
  __asm__ __volatile__ ("lgr %0, 15":"=r"(csp):);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
  assert(((uint64_t)csp & (frame::alignment_in_bytes-1)) == 0, "SP must be aligned");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
  return (address) csp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
char* os::non_memory_address_word() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
  // Must never look like an address returned by reserve_memory,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
  // even in its subfields (as defined by the CPU immediate fields,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
  // if the CPU splits constants across multiple instructions).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
  return (char*) -1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
// Frame information (pc, sp, fp) retrieved via ucontext
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
// always looks like a C-frame according to the frame
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
// conventions in frame_s390.hpp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
  return (address)uc->uc_mcontext.psw.addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
  uc->uc_mcontext.psw.addr = (unsigned long)pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
48821
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 47765
diff changeset
   109
static address ucontext_get_lr(const ucontext_t * uc) {
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 47765
diff changeset
   110
  return (address)uc->uc_mcontext.gregs[14/*LINK*/];
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 47765
diff changeset
   111
}
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 47765
diff changeset
   112
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
  return (intptr_t*)uc->uc_mcontext.gregs[15/*REG_SP*/];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
  return NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
                    intptr_t** ret_sp, intptr_t** ret_fp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
  ExtendedPC  epc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
  const ucontext_t* uc = (const ucontext_t*)ucVoid;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
  if (uc != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
    epc = ExtendedPC(os::Linux::ucontext_get_pc(uc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
    if (ret_sp) { *ret_sp = os::Linux::ucontext_get_sp(uc); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
    if (ret_fp) { *ret_fp = os::Linux::ucontext_get_fp(uc); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
    // Construct empty ExtendedPC for return value checking.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
    epc = ExtendedPC(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
    if (ret_sp) { *ret_sp = (intptr_t *)NULL; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
    if (ret_fp) { *ret_fp = (intptr_t *)NULL; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
  return epc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
frame os::fetch_frame_from_context(const void* ucVoid) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
  intptr_t* sp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
  intptr_t* fp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
  ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
  return frame(sp, epc.pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   148
bool os::Linux::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   149
  address pc = (address) os::Linux::ucontext_get_pc(uc);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   150
  if (Interpreter::contains(pc)) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   151
    // Interpreter performs stack banging after the fixed frame header has
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   152
    // been generated while the compilers perform it before. To maintain
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   153
    // semantic consistency between interpreted and compiled frames, the
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   154
    // method returns the Java sender of the current frame.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   155
    *fr = os::fetch_frame_from_context(uc);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   156
    if (!fr->is_first_java_frame()) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   157
      assert(fr->safe_for_sender(thread), "Safety check");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   158
      *fr = fr->java_sender();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   159
    }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   160
  } else {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   161
    // More complex code with compiled code.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   162
    assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   163
    CodeBlob* cb = CodeCache::find_blob(pc);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   164
    if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   165
      // Not sure where the pc points to, fallback to default
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   166
      // stack overflow handling. In compiled code, we bang before
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   167
      // the frame is complete.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   168
      return false;
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   169
    } else {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   170
      intptr_t* sp = os::Linux::ucontext_get_sp(uc);
48821
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 47765
diff changeset
   171
      address lr = ucontext_get_lr(uc);
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 47765
diff changeset
   172
      *fr = frame(sp, lr);
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   173
      if (!fr->is_java_frame()) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   174
        assert(fr->safe_for_sender(thread), "Safety check");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   175
        assert(!fr->is_first_frame(), "Safety check");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   176
        *fr = fr->java_sender();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   177
      }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   178
    }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   179
  }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   180
  assert(fr->is_java_frame(), "Safety check");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   181
  return true;
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   182
}
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   183
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   184
frame os::get_sender_for_C_frame(frame* fr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
  if (*fr->sp() == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
    // fr is the last C frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
    return frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   190
  // If its not one of our frames, the return pc is saved at gpr14
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
  // stack slot. The call_stub stores the return_pc to the stack slot
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
  // of gpr10.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
  if ((Interpreter::code() != NULL && Interpreter::contains(fr->pc())) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
      (CodeCache::contains(fr->pc()) && !StubRoutines::contains(fr->pc()))) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
    return frame(fr->sender_sp(), fr->sender_pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
    if (StubRoutines::contains(fr->pc())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
      StubCodeDesc* desc = StubCodeDesc::desc_for(fr->pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
      if (desc && !strcmp(desc->name(),"call_stub")) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
        return frame(fr->sender_sp(), fr->callstub_sender_pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
        return frame(fr->sender_sp(), fr->sender_pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
      return frame(fr->sender_sp(), fr->native_sender_pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   206
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   207
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   208
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
frame os::current_frame() {
42556
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   211
  // Expected to return the stack pointer of this method.
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   212
  // But if inlined, returns the stack pointer of our caller!
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
  intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
  assert (csp != NULL, "sp should not be NULL");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
  // Pass a dummy pc. This way we don't have to load it from the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
  // stack, since we don't know in which slot we can find it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
  frame topframe(csp, (address)0x8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
  if (os::is_first_C_frame(&topframe)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
    // Stack is not walkable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
    return frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
    frame senderFrame = os::get_sender_for_C_frame(&topframe);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
    assert(senderFrame.pc() != NULL, "Sender pc should not be NULL");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
    // Return sender of sender of current topframe which hopefully
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
    // both have pc != NULL.
42556
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   226
#ifdef _NMT_NOINLINE_   // Is set in slowdebug builds.
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   227
    // Current_stack_pointer is not inlined, we must pop one more frame.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
    frame tmp = os::get_sender_for_C_frame(&topframe);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
    return os::get_sender_for_C_frame(&tmp);
42556
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   230
#else
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   231
    return os::get_sender_for_C_frame(&topframe);
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   232
#endif
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   235
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
// Utility functions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
extern "C" JNIEXPORT int
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
JVM_handle_linux_signal(int sig,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
                        siginfo_t* info,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
                        void* ucVoid,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
                        int abort_if_unrecognized) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
  ucontext_t* uc = (ucontext_t*) ucVoid;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
  Thread* t = Thread::current_or_null_safe();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
  // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   248
  // (no destructors can be run).
46644
a5813fb66270 8183925: Decouple crash protection from watcher thread
rehn
parents: 46361
diff changeset
   249
  os::ThreadCrashProtection::check_crash_protection(sig, t);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   250
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
  SignalHandlerMark shm(t);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   252
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   253
  // Note: it's not uncommon that JNI code uses signal/sigset to install
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   254
  // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   255
  // or have a SIGILL handler when detecting CPU type). When that happens,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   256
  // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
  // avoid unnecessary crash when libjsig is not preloaded, try handle signals
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
  // that do not require siginfo/ucontext first.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
  if (sig == SIGPIPE) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
    if (os::Linux::chained_handler(sig, info, ucVoid)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
      return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
      if (PrintMiscellaneous && (WizardMode || Verbose)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
        warning("Ignoring SIGPIPE - see bug 4229104");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
      return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   271
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   272
  if ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison) {
55653
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55490
diff changeset
   273
    if (handle_assert_poison_fault(ucVoid, info->si_addr)) {
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55490
diff changeset
   274
      return 1;
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55490
diff changeset
   275
    }
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   276
  }
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   277
#endif
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   278
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
  JavaThread* thread = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   280
  VMThread* vmthread = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
  if (os::Linux::signal_handlers_are_installed) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
    if (t != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
      if(t->is_Java_thread()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
        thread = (JavaThread*)t;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
      } else if(t->is_VM_thread()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
        vmthread = (VMThread *)t;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
  // Moved SafeFetch32 handling outside thread!=NULL conditional block to make
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
  // it work if no associated JavaThread object exists.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
  if (uc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
    address const pc = os::Linux::ucontext_get_pc(uc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
    if (pc && StubRoutines::is_safefetch_fault(pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
      os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
      return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
  // Decide if this trap can be handled by a stub.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
  address stub    = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
  address pc      = NULL;  // Pc as retrieved from PSW. Usually points past failing instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   304
  address trap_pc = NULL;  // Pc of the instruction causing the trap.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   305
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   306
  //%note os_trap_1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
  if (info != NULL && uc != NULL && thread != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
    pc = os::Linux::ucontext_get_pc(uc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
    if (TraceTraps) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
      tty->print_cr("     pc at " INTPTR_FORMAT, p2i(pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
    if ((unsigned long)(pc - (address)info->si_addr) <= (unsigned long)Assembler::instr_maxlen() ) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
      trap_pc = (address)info->si_addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   314
      if (TraceTraps) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   315
        tty->print_cr("trap_pc at " INTPTR_FORMAT, p2i(trap_pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   316
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   317
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   318
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   319
    // Handle ALL stack overflow variations here
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   320
    if (sig == SIGSEGV) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   321
      address addr = (address)info->si_addr; // Address causing SIGSEGV, usually mem ref target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   322
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   323
      // Check if fault address is within thread stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   324
      if (thread->on_local_stack(addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   325
        // stack overflow
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   326
        if (thread->in_stack_yellow_reserved_zone(addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   327
          if (thread->thread_state() == _thread_in_Java) {
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   328
            if (thread->in_stack_reserved_zone(addr)) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   329
              frame fr;
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   330
              if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   331
                assert(fr.is_java_frame(), "Must be a Javac frame");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   332
                frame activation =
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   333
                  SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   334
                if (activation.sp() != NULL) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   335
                  thread->disable_stack_reserved_zone();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   336
                  if (activation.is_interpreted_frame()) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   337
                    thread->set_reserved_stack_activation((address)activation.fp());
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   338
                  } else {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   339
                    thread->set_reserved_stack_activation((address)activation.unextended_sp());
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   340
                  }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   341
                  return 1;
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   342
                }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   343
              }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   344
            }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   345
            // Throw a stack overflow exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   346
            // Guard pages will be reenabled while unwinding the stack.
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   347
            thread->disable_stack_yellow_reserved_zone();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   348
            stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   349
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   350
            // Thread was in the vm or native code. Return and try to finish.
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42906
diff changeset
   351
            thread->disable_stack_yellow_reserved_zone();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   352
            return 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   353
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   354
        } else if (thread->in_stack_red_zone(addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   355
          // Fatal red zone violation.  Disable the guard pages and fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   356
          // to handle_unexpected_exception way down below.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   357
          thread->disable_stack_red_zone();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   358
          tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   359
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   360
          // This is a likely cause, but hard to verify. Let's just print
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   361
          // it as a hint.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   362
          tty->print_raw_cr("Please check if any of your loaded .so files has "
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   363
                            "enabled executable stack (see man page execstack(8))");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   364
        } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   365
          // Accessing stack address below sp may cause SEGV if current
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   366
          // thread has MAP_GROWSDOWN stack. This should only happen when
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   367
          // current thread was created by user code with MAP_GROWSDOWN flag
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   368
          // and then attached to VM. See notes in os_linux.cpp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   369
          if (thread->osthread()->expanding_stack() == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   370
             thread->osthread()->set_expanding_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   371
             if (os::Linux::manually_expand_stack(thread, addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   372
               thread->osthread()->clear_expanding_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   373
               return 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   374
             }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   375
             thread->osthread()->clear_expanding_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   376
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   377
             fatal("recursive segv. expanding stack.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   378
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   379
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   380
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   381
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   382
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   383
    if (thread->thread_state() == _thread_in_Java) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   384
      // Java thread running in Java code => find exception handler if any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   385
      // a fault inside compiled code, the interpreter, or a stub
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   386
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   387
      // Handle signal from NativeJump::patch_verified_entry().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   388
      if (sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   389
        if (TraceTraps) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   390
          tty->print_cr("trap: zombie_not_entrant (SIGILL)");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   391
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   392
        stub = SharedRuntime::get_handle_wrong_method_stub();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   393
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   394
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   395
      else if (sig == SIGSEGV &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   396
               os::is_poll_address((address)info->si_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   397
        if (TraceTraps) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   398
          tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   399
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   400
        stub = SharedRuntime::get_poll_stub(pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   401
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   402
        // Info->si_addr only points to the page base address, so we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   403
        // must extract the real si_addr from the instruction and the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   404
        // ucontext.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   405
        assert(((NativeInstruction*)pc)->is_safepoint_poll(), "must be safepoint poll");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   406
        const address real_si_addr = ((NativeInstruction*)pc)->get_poll_address(uc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   407
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   408
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   409
      // SIGTRAP-based implicit null check in compiled code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   410
      else if ((sig == SIGFPE) &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   411
               TrapBasedNullChecks &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   412
               (trap_pc != NULL) &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   413
               Assembler::is_sigtrap_zero_check(trap_pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   414
        if (TraceTraps) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   415
          tty->print_cr("trap: NULL_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   416
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   417
        stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   418
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   419
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   420
      else if (sig == SIGSEGV && ImplicitNullChecks &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   421
               CodeCache::contains((void*) pc) &&
52462
4ad404da0088 8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents: 52460
diff changeset
   422
               MacroAssembler::uses_implicit_null_check(info->si_addr)) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   423
        if (TraceTraps) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   424
          tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   425
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   426
        stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   427
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   428
58959
b7b170ba3ba9 8233328: fix minimal VM build on Linux s390x
mbaesken
parents: 57594
diff changeset
   429
#ifdef COMPILER2
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   430
      // SIGTRAP-based implicit range check in compiled code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   431
      else if (sig == SIGFPE && TrapBasedRangeChecks &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   432
               (trap_pc != NULL) &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   433
               Assembler::is_sigtrap_range_check(trap_pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   434
        if (TraceTraps) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   435
          tty->print_cr("trap: RANGE_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   436
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   437
        stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   438
      }
58959
b7b170ba3ba9 8233328: fix minimal VM build on Linux s390x
mbaesken
parents: 57594
diff changeset
   439
#endif
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   440
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   441
      else if (sig == SIGFPE && info->si_code == FPE_INTDIV) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   442
        stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   443
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   444
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   445
      else if (sig == SIGBUS) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   446
        // BugId 4454115: A read from a MappedByteBuffer can fault here if the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   447
        // underlying file has been truncated. Do not crash the VM in such a case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   448
        CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
42556
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   449
        CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   450
        if (nm != NULL && nm->has_unsafe_access()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   451
          // We don't really need a stub here! Just set the pending exeption and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   452
          // continue at the next instruction after the faulting read. Returning
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   453
          // garbage from this read is ok.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   454
          thread->set_pending_unsafe_access_error();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   455
          uc->uc_mcontext.psw.addr = ((unsigned long)pc) + Assembler::instr_len(pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   456
          return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   457
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   458
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   459
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   460
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   461
    else { // thread->thread_state() != _thread_in_Java
47607
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   462
      if ((sig == SIGILL) && VM_Version::is_determine_features_test_running()) {
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   463
        // SIGILL must be caused by VM_Version::determine_features()
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   464
        // when attempting to execute a non-existing instruction.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   465
        //*(int *) (pc-6)=0; // Patch instruction to 0 to indicate that it causes a SIGILL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   466
                             // Flushing of icache is not necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   467
        stub = pc; // Continue with next instruction.
47607
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   468
      } else if ((sig == SIGFPE) && VM_Version::is_determine_features_test_running()) {
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   469
        // SIGFPE is known to be caused by trying to execute a vector instruction
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   470
        // when the vector facility is installed, but operating system support is missing.
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   471
        VM_Version::reset_has_VectorFacility();
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   472
        stub = pc; // Continue with next instruction.
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 53605
diff changeset
   473
      } else if ((thread->thread_state() == _thread_in_vm ||
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 53605
diff changeset
   474
                  thread->thread_state() == _thread_in_native) &&
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   475
                 sig == SIGBUS && thread->doing_unsafe_access()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   476
        // We don't really need a stub here! Just set the pending exeption and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   477
        // continue at the next instruction after the faulting read. Returning
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   478
        // garbage from this read is ok.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   479
        thread->set_pending_unsafe_access_error();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   480
        os::Linux::ucontext_set_pc(uc, pc + Assembler::instr_len(pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   481
        return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   482
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   483
    }
57594
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   484
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   485
    // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   486
    // and the heap gets shrunk before the field access.
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   487
    if ((sig == SIGSEGV) || (sig == SIGBUS)) {
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   488
      address addr = JNI_FastGetField::find_slowcase_pc(pc);
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   489
      if (addr != (address)-1) {
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   490
        stub = addr;
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   491
      }
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   492
    }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   493
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   494
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   495
  if (stub != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   496
    // Save all thread context in case we need to restore it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   497
    if (thread != NULL) thread->set_saved_exception_pc(pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   498
    os::Linux::ucontext_set_pc(uc, stub);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   499
    return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   500
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   501
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   502
  // signal-chaining
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   503
  if (os::Linux::chained_handler(sig, info, ucVoid)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   504
    return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   505
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   506
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   507
  if (!abort_if_unrecognized) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   508
    // caller wants another chance, so give it to him
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   509
    return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   510
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   511
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   512
  if (pc == NULL && uc != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   513
    pc = os::Linux::ucontext_get_pc(uc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   514
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   515
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   516
  // unmask current signal
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   517
  sigset_t newset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   518
  sigemptyset(&newset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   519
  sigaddset(&newset, sig);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   520
  sigprocmask(SIG_UNBLOCK, &newset, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   521
46361
b4c026dd6128 8176872: [s390] wrong pc shown in error logs
stuefe
parents: 43420
diff changeset
   522
  // Hand down correct pc for SIGILL, SIGFPE. pc from context
b4c026dd6128 8176872: [s390] wrong pc shown in error logs
stuefe
parents: 43420
diff changeset
   523
  // usually points to the instruction after the failing instruction.
b4c026dd6128 8176872: [s390] wrong pc shown in error logs
stuefe
parents: 43420
diff changeset
   524
  // Note: this should be combined with the trap_pc handling above,
b4c026dd6128 8176872: [s390] wrong pc shown in error logs
stuefe
parents: 43420
diff changeset
   525
  // because it handles the same issue.
b4c026dd6128 8176872: [s390] wrong pc shown in error logs
stuefe
parents: 43420
diff changeset
   526
  if (sig == SIGILL || sig == SIGFPE) {
47607
c2ff34932cbd 8188857: [s390]: CPU feature detection incomplete
lucy
parents: 47586
diff changeset
   527
    pc = (address)info->si_addr;
46361
b4c026dd6128 8176872: [s390] wrong pc shown in error logs
stuefe
parents: 43420
diff changeset
   528
  }
b4c026dd6128 8176872: [s390] wrong pc shown in error logs
stuefe
parents: 43420
diff changeset
   529
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   530
  VMError::report_and_die(t, sig, pc, info, ucVoid);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   531
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   532
  ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   533
  return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   534
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   535
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   536
void os::Linux::init_thread_fpu_state(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   537
  // Nothing to do on z/Architecture.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   538
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   539
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   540
int os::Linux::get_fpu_control_word(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   541
  // Nothing to do on z/Architecture.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   542
  return 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   543
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   544
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   545
void os::Linux::set_fpu_control_word(int fpu_control) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   546
  // Nothing to do on z/Architecture.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   547
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   548
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   549
////////////////////////////////////////////////////////////////////////////////
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   550
// thread stack
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   551
42906
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   552
// Minimum usable stack sizes required to get to user code. Space for
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   553
// HotSpot guard pages is added later.
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   554
size_t os::Posix::_compiler_thread_min_stack_allowed = (52 DEBUG_ONLY(+ 32)) * K;
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   555
size_t os::Posix::_java_thread_min_stack_allowed = (32 DEBUG_ONLY(+ 8)) * K;
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   556
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 32 * K;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   557
42905
1af223983f82 8169373: Work around linux NPTL stack guard error.
goetz
parents: 42556
diff changeset
   558
// Return default stack size for thr_type.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   559
size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
42905
1af223983f82 8169373: Work around linux NPTL stack guard error.
goetz
parents: 42556
diff changeset
   560
  // Default stack size (compiler thread needs larger stack).
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   561
  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   562
  return s;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   563
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   564
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   565
/////////////////////////////////////////////////////////////////////////////
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   566
// helper functions for fatal error handler
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   567
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   568
void os::print_context(outputStream *st, const void *context) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   569
  if (context == NULL) return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   570
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   571
  const ucontext_t* uc = (const ucontext_t*)context;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   572
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   573
  st->print_cr("Processor state:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   574
  st->print_cr("----------------");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   575
  st->print_cr("        ip = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   576
  st->print_cr(" proc mask = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.mask);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   577
  st->print_cr("   fpc reg = 0x%8.8x "          , uc->uc_mcontext.fpregs.fpc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   578
  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   579
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   580
  st->print_cr("General Purpose Registers:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   581
  st->print_cr("--------------------------");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   582
  for( int i = 0; i < 16; i+=2 ) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   583
    st->print("  r%-2d = " INTPTR_FORMAT "  " ,  i,   uc->uc_mcontext.gregs[i]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   584
    st->print("  r%-2d = " INTPTR_FORMAT "  |",  i+1, uc->uc_mcontext.gregs[i+1]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   585
    st->print("  r%-2d = %23.1ld  "           ,  i,   uc->uc_mcontext.gregs[i]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   586
    st->print("  r%-2d = %23.1ld  "           ,  i+1, uc->uc_mcontext.gregs[i+1]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   587
    st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   588
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   589
  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   590
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   591
  st->print_cr("Access Registers:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   592
  st->print_cr("-----------------");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   593
  for( int i = 0; i < 16; i+=2 ) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   594
    st->print("  ar%-2d = 0x%8.8x  ", i,   uc->uc_mcontext.aregs[i]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   595
    st->print("  ar%-2d = 0x%8.8x  ", i+1, uc->uc_mcontext.aregs[i+1]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   596
    st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   597
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   598
  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   599
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   600
  st->print_cr("Float Registers:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   601
  st->print_cr("----------------");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   602
  for (int i = 0; i < 16; i += 2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   603
    st->print("  fr%-2d = " INTPTR_FORMAT "  " , i,   (int64_t)(uc->uc_mcontext.fpregs.fprs[i].d));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   604
    st->print("  fr%-2d = " INTPTR_FORMAT "  |", i+1, (int64_t)(uc->uc_mcontext.fpregs.fprs[i+1].d));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   605
    st->print("  fr%-2d = %23.15e  "           , i,   (uc->uc_mcontext.fpregs.fprs[i].d));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   606
    st->print("  fr%-2d = %23.15e  "           , i+1, (uc->uc_mcontext.fpregs.fprs[i+1].d));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   607
    st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   608
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   609
  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   610
  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   611
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   612
  intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   613
  st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   614
  print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   615
  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   616
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   617
  // Note: it may be unsafe to inspect memory near pc. For example, pc may
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   618
  // point to garbage if entry point in an nmethod is corrupted. Leave
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   619
  // this at the end, and hope for the best.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   620
  address pc = os::Linux::ucontext_get_pc(uc);
53605
853c68ff2ed7 8217879: hs_err should print more instructions in hex dump
shade
parents: 52462
diff changeset
   621
  print_instructions(st, pc, /*intrsize=*/4);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   622
  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   623
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   624
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   625
void os::print_register_info(outputStream *st, const void *context) {
51139
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   626
  if (context == NULL) return;
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   627
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   628
  const ucontext_t *uc = (const ucontext_t*)context;
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   629
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   630
  st->print_cr("Register to memory mapping:");
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   631
  st->cr();
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   632
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   633
  st->print("pc ="); print_location(st, (intptr_t)uc->uc_mcontext.psw.addr);
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   634
  for (int i = 0; i < 16; i++) {
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   635
    st->print("r%-2d=", i);
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   636
    print_location(st, uc->uc_mcontext.gregs[i]);
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   637
  }
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   638
  st->cr();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   639
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   640
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   641
#ifndef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   642
void os::verify_stack_alignment() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   643
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   644
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   645
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   646
int os::extra_bang_size_in_bytes() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   647
  // z/Architecture does not require the additional stack bang.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   648
  return 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   649
}