[vmkit-commits] [vmkit] r144667 - in /vmkit/trunk/lib/Mvm/CommonThread: Makefile Sigsegv-linux-x86.inc Sigsegv.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Nov 15 10:55:49 PST 2011


Author: geoffray
Date: Tue Nov 15 12:55:49 2011
New Revision: 144667

URL: http://llvm.org/viewvc/llvm-project?rev=144667&view=rev
Log:
Support hardware NPE and stack overflow on linux/x86.


Added:
    vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x86.inc
      - copied, changed from r144574, vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x64.inc
Modified:
    vmkit/trunk/lib/Mvm/CommonThread/Makefile
    vmkit/trunk/lib/Mvm/CommonThread/Sigsegv.cpp

Modified: vmkit/trunk/lib/Mvm/CommonThread/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/Makefile?rev=144667&r1=144666&r2=144667&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/Makefile (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/Makefile Tue Nov 15 12:55:49 2011
@@ -8,7 +8,7 @@
 ##===----------------------------------------------------------------------===##
 LEVEL = ../../..
 
-EXTRA_DIST = Sigsegv-linux-x64.inc Sigsegv-macos-x64.inc
+EXTRA_DIST = Sigsegv-linux-x64.inc Sigsegv-macos-x64.inc Sigsegv-linux-x86.inc
 
 include $(LEVEL)/Makefile.config
 

Copied: vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x86.inc (from r144574, vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x64.inc)
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x86.inc?p2=vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x86.inc&p1=vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x64.inc&r1=144574&r2=144667&rev=144667&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x64.inc (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/Sigsegv-linux-x86.inc Tue Nov 15 12:55:49 2011
@@ -14,8 +14,9 @@
     ".align 8\n"
     ".globl HandleNullPointer\n"
   "HandleNullPointer:\n"
+    "push %eax\n"
     // Save the faulting address to fake a real method call.
-    "pushq %rdi\n"
+    "push %eax\n"
     "jmp   ThrowNullPointerException\n"
     );
   
@@ -25,23 +26,24 @@
     ".align 8\n"
     ".globl HandleStackOverflow\n"
   "HandleStackOverflow:\n"
-    "pushq %rbp\n"
-    "movq %rsi, %rbp\n"
-    "callq   ThrowStackOverflowError\n"
+    "push %ebp\n"
+    "mov %eax, %ebp\n"
+    "push %ebx\n"
+    "call   ThrowStackOverflowError\n"
     );
 }
 
 void Handler::UpdateRegistersForNPE() {
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_RIP] + 1;
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RIP] = (word_t)HandleNullPointer;
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EAX] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP] + 1;
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP] = (word_t)HandleNullPointer;
 }
 
 void Handler::UpdateRegistersForStackOverflow() {
   word_t alt_stack = mvm::Thread::get()->GetAlternativeStackStart();
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]);
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSI] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP];
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSP] = alt_stack;
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RIP] = (word_t)HandleStackOverflow;
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]);
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EAX] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP];
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_ESP] = alt_stack;
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP] = (word_t)HandleStackOverflow;
 }
 
 bool System::SupportsHardwareNullCheck() {

Modified: vmkit/trunk/lib/Mvm/CommonThread/Sigsegv.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/Sigsegv.cpp?rev=144667&r1=144666&r2=144667&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/Sigsegv.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/Sigsegv.cpp Tue Nov 15 12:55:49 2011
@@ -30,6 +30,8 @@
 
 #if defined(ARCH_X64) && defined(LINUX_OS)
 #include "Sigsegv-linux-x64.inc"
+#elif defined(ARCH_X86) && defined(LINUX_OS)
+#include "Sigsegv-linux-x86.inc"
 #elif defined(ARCH_X64) && defined(MACOS_OS)
 #include "Sigsegv-macos-x64.inc"
 #else
@@ -50,7 +52,7 @@
 }
 #endif
 
-extern "C" void ThrowStackOverflowError(word_t ip, word_t fp) {
+extern "C" void ThrowStackOverflowError(word_t ip) {
   mvm::Thread* th = mvm::Thread::get();
   mvm::FrameInfo* FI = th->MyVM->IPToFrameInfo(ip);
   if (FI->Metadata == NULL) {





More information about the vmkit-commits mailing list