1 /*
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
276
277 //%note os_trap_1
278 if (info != NULL && uc != NULL && thread != NULL) {
279 pc = (address) os::Linux::ucontext_get_pc(uc);
280
281 if (StubRoutines::is_safefetch_fault(pc)) {
282 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
283 return 1;
284 }
285
286 address addr = (address) info->si_addr;
287
288 // Make sure the high order byte is sign extended, as it may be masked away by the hardware.
289 if ((uintptr_t(addr) & (uintptr_t(1) << 55)) != 0) {
290 addr = address(uintptr_t(addr) | (uintptr_t(0xFF) << 56));
291 }
292
293 // Handle ALL stack overflow variations here
294 if (sig == SIGSEGV) {
295 // check if fault address is within thread stack
296 if (thread->on_local_stack(addr)) {
297 // stack overflow
298 if (thread->in_stack_yellow_reserved_zone(addr)) {
299 if (thread->thread_state() == _thread_in_Java) {
300 if (thread->in_stack_reserved_zone(addr)) {
301 frame fr;
302 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
303 assert(fr.is_java_frame(), "Must be a Java frame");
304 frame activation =
305 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
306 if (activation.sp() != NULL) {
307 thread->disable_stack_reserved_zone();
308 if (activation.is_interpreted_frame()) {
309 thread->set_reserved_stack_activation((address)(
310 activation.fp() + frame::interpreter_frame_initial_sp_offset));
311 } else {
312 thread->set_reserved_stack_activation((address)activation.unextended_sp());
313 }
314 return 1;
315 }
316 }
|
1 /*
2 * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
276
277 //%note os_trap_1
278 if (info != NULL && uc != NULL && thread != NULL) {
279 pc = (address) os::Linux::ucontext_get_pc(uc);
280
281 if (StubRoutines::is_safefetch_fault(pc)) {
282 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
283 return 1;
284 }
285
286 address addr = (address) info->si_addr;
287
288 // Make sure the high order byte is sign extended, as it may be masked away by the hardware.
289 if ((uintptr_t(addr) & (uintptr_t(1) << 55)) != 0) {
290 addr = address(uintptr_t(addr) | (uintptr_t(0xFF) << 56));
291 }
292
293 // Handle ALL stack overflow variations here
294 if (sig == SIGSEGV) {
295 // check if fault address is within thread stack
296 if (thread->is_in_full_stack(addr)) {
297 // stack overflow
298 if (thread->in_stack_yellow_reserved_zone(addr)) {
299 if (thread->thread_state() == _thread_in_Java) {
300 if (thread->in_stack_reserved_zone(addr)) {
301 frame fr;
302 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
303 assert(fr.is_java_frame(), "Must be a Java frame");
304 frame activation =
305 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
306 if (activation.sp() != NULL) {
307 thread->disable_stack_reserved_zone();
308 if (activation.is_interpreted_frame()) {
309 thread->set_reserved_stack_activation((address)(
310 activation.fp() + frame::interpreter_frame_initial_sp_offset));
311 } else {
312 thread->set_reserved_stack_activation((address)activation.unextended_sp());
313 }
314 return 1;
315 }
316 }
|