Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: src/trusted/service_runtime/thread_suspension_unwind.c

Issue 121833002: [MIPS] Add support for thread_suspension test (Closed) Base URL: http://git.chromium.org/native_client/src/native_client.git@master
Patch Set: Remove strayed backslashes. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/service_runtime/arch/mips/sel_rt.c ('k') | tests/thread_suspension/suspend_test_guest.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/service_runtime/thread_suspension_unwind.c
diff --git a/src/trusted/service_runtime/thread_suspension_unwind.c b/src/trusted/service_runtime/thread_suspension_unwind.c
index 22f82f235b852c08bc4d3ad7f3fab96f5fea1f5e..0bb274d56a217ef498d7d67805e7f44b6af32fab 100644
--- a/src/trusted/service_runtime/thread_suspension_unwind.c
+++ b/src/trusted/service_runtime/thread_suspension_unwind.c
@@ -15,9 +15,6 @@
#include "native_client/src/trusted/service_runtime/sel_ldr.h"
-#if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 || \
- NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm
-
static void GetNaClSyscallSeg(struct NaClApp *nap,
uintptr_t *nacl_syscall_seg,
uintptr_t *nacl_syscall_seg_regs_saved) {
@@ -78,6 +75,13 @@ static int Unwind(struct NaClAppThread *natp, struct NaClSignalContext *regs,
regs->prog_ctr = NaClSandboxCodeAddr(nap, regs->lr);
return 1;
}
+#elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips
+ if (regs->prog_ctr >= NACL_TRAMPOLINE_START &&
+ regs->prog_ctr < NACL_TRAMPOLINE_END) {
+ *unwind_case = NACL_UNWIND_in_trampoline;
+ regs->prog_ctr = NaClSandboxCodeAddr(nap, regs->return_addr);
+ return 1;
+ }
#endif
#if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
@@ -113,15 +117,19 @@ static int Unwind(struct NaClAppThread *natp, struct NaClSignalContext *regs,
if (regs->prog_ctr >= nacl_syscall_seg &&
regs->prog_ctr < nacl_syscall_seg_regs_saved) {
*unwind_case = NACL_UNWIND_in_syscallseg;
- if (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86) {
- if (NACL_BUILD_SUBARCH == 32) {
- /* Pop user + trampoline return addresses */
- regs->stack_ptr += 4 + 8;
- } else {
- /* Pop user return address. */
- regs->stack_ptr += 8;
- }
- }
+#if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
+ /* Pop user + trampoline return addresses */
+ regs->stack_ptr += 4 + 8;
+#elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 64
+ /* Pop user return address. */
+ regs->stack_ptr += 8;
+#elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips
+ /*
+ * On MIPS, $ra is not modified from the start of the trampoline to the
+ * point where registers are saved.
+ */
+ regs->prog_ctr = NaClSandboxCodeAddr(nap, regs->return_addr);
+#endif
return 1;
}
@@ -146,7 +154,10 @@ void NaClGetRegistersForContextSwitch(struct NaClAppThread *natp,
if (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 ||
(NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm &&
- *unwind_case != NACL_UNWIND_in_trampoline)) {
+ *unwind_case != NACL_UNWIND_in_trampoline) ||
+ (NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips &&
+ *unwind_case != NACL_UNWIND_in_trampoline &&
+ *unwind_case != NACL_UNWIND_in_syscallseg)) {
/*
* Read the return address from the untrusted stack.
* NaClCopyInFromUser() can fault or return an error here, but only
@@ -164,16 +175,3 @@ void NaClGetRegistersForContextSwitch(struct NaClAppThread *natp,
regs->prog_ctr = NaClSandboxCodeAddr(natp->nap, user_ret);
}
}
-
-#else
-
-/* TODO(mseaborn): Extend this to handle MIPS. */
-void NaClGetRegistersForContextSwitch(struct NaClAppThread *natp,
- struct NaClSignalContext *regs,
- enum NaClUnwindCase *unwind_case) {
- UNREFERENCED_PARAMETER(natp);
- UNREFERENCED_PARAMETER(regs);
- *unwind_case = 0;
-}
-
-#endif
« no previous file with comments | « src/trusted/service_runtime/arch/mips/sel_rt.c ('k') | tests/thread_suspension/suspend_test_guest.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698