< prev index next >

src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp

Print this page
rev 58072 : [mq]: v2
   1 /*
   2  * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 123   // even in its subfields (as defined by the CPU immediate fields,
 124   // if the CPU splits constants across multiple instructions).
 125   return (char*) -1;
 126 }
 127 
 128 //
 129 // Validate a ucontext retrieved from walking a uc_link of a ucontext.
 130 // There are issues with libthread giving out uc_links for different threads
 131 // on the same uc_link chain and bad or circular links.
 132 //
 133 bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect) {
 134   if (valid >= suspect ||
 135       valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags ||
 136       valid->uc_stack.ss_sp    != suspect->uc_stack.ss_sp    ||
 137       valid->uc_stack.ss_size  != suspect->uc_stack.ss_size) {
 138     DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");)
 139     return false;
 140   }
 141 
 142   if (thread->is_Java_thread()) {
 143     if (!valid_stack_address(thread, (address)suspect)) {
 144       DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");)
 145       return false;
 146     }
 147     if (!valid_stack_address(thread,  (address) suspect->uc_mcontext.gregs[REG_SP])) {
 148       DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");)
 149       return false;
 150     }
 151   }
 152   return true;
 153 }
 154 
 155 // We will only follow one level of uc_link since there are libthread
 156 // issues with ucontext linking and it is better to be safe and just
 157 // let caller retry later.
 158 const ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread,
 159   const ucontext_t *uc) {
 160 
 161   const ucontext_t *retuc = NULL;
 162 
 163   if (uc != NULL) {
 164     if (uc->uc_link == NULL) {
 165       // cannot validate without uc_link so accept current ucontext
 166       retuc = uc;
 167     } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) {


   1 /*
   2  * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 123   // even in its subfields (as defined by the CPU immediate fields,
 124   // if the CPU splits constants across multiple instructions).
 125   return (char*) -1;
 126 }
 127 
 128 //
 129 // Validate a ucontext retrieved from walking a uc_link of a ucontext.
 130 // There are issues with libthread giving out uc_links for different threads
 131 // on the same uc_link chain and bad or circular links.
 132 //
 133 bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect) {
 134   if (valid >= suspect ||
 135       valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags ||
 136       valid->uc_stack.ss_sp    != suspect->uc_stack.ss_sp    ||
 137       valid->uc_stack.ss_size  != suspect->uc_stack.ss_size) {
 138     DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");)
 139     return false;
 140   }
 141 
 142   if (thread->is_Java_thread()) {
 143     if (!thread->is_in_full_stack((address)suspect)) {
 144       DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");)
 145       return false;
 146     }
 147     if (!thread->is_in_full_stack((address) suspect->uc_mcontext.gregs[REG_SP])) {
 148       DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");)
 149       return false;
 150     }
 151   }
 152   return true;
 153 }
 154 
 155 // We will only follow one level of uc_link since there are libthread
 156 // issues with ucontext linking and it is better to be safe and just
 157 // let caller retry later.
 158 const ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread,
 159   const ucontext_t *uc) {
 160 
 161   const ucontext_t *retuc = NULL;
 162 
 163   if (uc != NULL) {
 164     if (uc->uc_link == NULL) {
 165       // cannot validate without uc_link so accept current ucontext
 166       retuc = uc;
 167     } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) {


< prev index next >