d904612
diff --git a/src/cpu/zero/vm/stack_zero.hpp b/src/cpu/zero/vm/stack_zero.hpp
d904612
--- jdk8/hotspot/src/cpu/zero/vm/stack_zero.hpp
d904612
+++ jdk8/hotspot/src/cpu/zero/vm/stack_zero.hpp
d904612
@@ -99,7 +99,7 @@
d904612
   int shadow_pages_size() const {
d904612
     return _shadow_pages_size;
d904612
   }
d904612
-  int abi_stack_available(Thread *thread) const;
d904612
+  ssize_t abi_stack_available(Thread *thread) const;
d904612
 
d904612
  public:
d904612
   void overflow_check(int required_words, TRAPS);
d904612
diff --git a/src/cpu/zero/vm/stack_zero.inline.hpp b/src/cpu/zero/vm/stack_zero.inline.hpp
d904612
--- jdk8/hotspot/src/cpu/zero/vm/stack_zero.inline.hpp
d904612
+++ jdk8/hotspot/src/cpu/zero/vm/stack_zero.inline.hpp
d904612
@@ -47,10 +47,11 @@
d904612
 // This method returns the amount of ABI stack available for us
d904612
 // to use under normal circumstances.  Note that the returned
d904612
 // value can be negative.
d904612
-inline int ZeroStack::abi_stack_available(Thread *thread) const {
d904612
-  int stack_used = thread->stack_base() - (address) &stack_used;
d904612
-  int stack_free = thread->stack_size() - stack_used;
d904612
-  return stack_free - shadow_pages_size();
d904612
+inline ssize_t ZeroStack::abi_stack_available(Thread *thread) const {
d904612
+  ssize_t stack_used = thread->stack_base() - (address) &stack_used
d904612
+    + (StackYellowPages+StackRedPages+StackShadowPages) * os::vm_page_size();
d904612
+  ssize_t stack_free = thread->stack_size() - stack_used;
d904612
+  return stack_free;
d904612
 }
d904612
 
d904612
 #endif // CPU_ZERO_VM_STACK_ZERO_INLINE_HPP
d904612
diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
d904612
--- jdk8/hotspot/src/os/linux/vm/os_linux.cpp
d904612
+++ jdk8/hotspot/src/os/linux/vm/os_linux.cpp
d904612
@@ -4700,6 +4700,13 @@
d904612
   os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
d904612
             (size_t)(StackYellowPages+StackRedPages+StackShadowPages) * Linux::page_size() +
d904612
                     (2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::vm_default_page_size());
d904612
+#ifdef ZERO
d904612
+  // If this is Zero, allow at the very minimum one page each for the
d904612
+  // Zero stack and the native stack.  This won't make any difference
d904612
+  // for 4k pages, but is significant for large pages.
d904612
+  os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
d904612
+             (size_t)(StackYellowPages+StackRedPages+StackShadowPages+2) * Linux::page_size());
d904612
+#endif
d904612
 
d904612
   size_t threadStackSizeInBytes = ThreadStackSize * K;
d904612
   if (threadStackSizeInBytes != 0 &&