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

Unified Diff: src/trusted/service_runtime/arch/mips/nacl_switch.S

Issue 10919162: [MIPS] Implementation of sel_ldr for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Rebase (Saturday morning). Created 8 years, 3 months 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
Index: src/trusted/service_runtime/arch/mips/nacl_switch.S
diff --git a/src/trusted/service_runtime/arch/mips/nacl_switch.S b/src/trusted/service_runtime/arch/mips/nacl_switch.S
new file mode 100644
index 0000000000000000000000000000000000000000..db13315336e15fe79951761dad151b0924793b07
--- /dev/null
+++ b/src/trusted/service_runtime/arch/mips/nacl_switch.S
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2012 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can
+ * be found in the LICENSE file.
+ */
+
+#include "native_client/src/trusted/service_runtime/arch/mips/sel_rt.h"
+#include "native_client/src/trusted/service_runtime/nacl_config.h"
+
+.text
+
+/*
+ * This trusted code is linked into the service_runtime and
+ * executed when switching from the service runtime to a nacl
+ * module. This happens when a main nacl thread is created and starting to
+ * execute the nacl code, or when nacl module is returning from a system
+ * call. This piece of code lives in a service runtime part of address space.
+ * The one and only argument is in register a0
+ *
+ * a0 -- address of thread context (struct NaClThreadContext)
+ */
+
+DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaClSwitch):
+
+ .set noreorder
+
+/*
+ * We clear registers a1, a2, a3, t0, t1, t2, t3, t4, t5 and ra to avoid
+ * information leaks. The remaining registers are overwritten by the code that
+ * follows after.
+ */
+
+ addu $a1, $zero, $zero
+ addu $a2, $zero, $zero
+ addu $a3, $zero, $zero
+ addu $t0, $zero, $zero
+ addu $t1, $zero, $zero
+ addu $t2, $zero, $zero
+ addu $t3, $zero, $zero
+ addu $t4, $zero, $zero
+ addu $t5, $zero, $zero
+ addu $ra, $zero, $zero
+
+ /* NACL_CALLEE_SAVE_LIST BEGIN */
+
+ lui $t6, %hi(NACL_CONTROL_FLOW_MASK)
+ addiu $t6, $t6, %lo(NACL_CONTROL_FLOW_MASK)
+ lui $t7, %hi(NACL_DATA_FLOW_MASK)
+ addiu $t7, $t7, %lo(NACL_DATA_FLOW_MASK)
+ lw $s0, NACL_THREAD_CONTEXT_OFFSET_S0($a0)
+ lw $s1, NACL_THREAD_CONTEXT_OFFSET_S1($a0)
+ lw $s2, NACL_THREAD_CONTEXT_OFFSET_S2($a0)
+ lw $s3, NACL_THREAD_CONTEXT_OFFSET_S3($a0)
+ lw $s4, NACL_THREAD_CONTEXT_OFFSET_S4($a0)
+ lw $s5, NACL_THREAD_CONTEXT_OFFSET_S5($a0)
+ lw $s6, NACL_THREAD_CONTEXT_OFFSET_S6($a0)
+ lw $s7, NACL_THREAD_CONTEXT_OFFSET_S7($a0)
+ lw $t8, NACL_THREAD_CONTEXT_OFFSET_T8($a0)
+ lw $gp, NACL_THREAD_CONTEXT_OFFSET_GLOBAL_PTR($a0)
+ lw $sp, NACL_THREAD_CONTEXT_OFFSET_STACK_PTR($a0)
+ lw $fp, NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR($a0)
+
+ /* NACL_CALLEE_SAVE_LIST END*/
+
+ lw $v0, NACL_THREAD_CONTEXT_OFFSET_SYSRET($a0)
+ lw $v1, NACL_THREAD_CONTEXT_OFFSET_NEW_PROG_CTR($a0)
+
+ /* At startup, context->sysret contains not the the return value, but the
+ first argument. Put it in a0. */
+ addu $a0, $v0, $zero
+
+ /* Transfer control to untrusted code */
+ jr $v1
+ nop
+
+ .set reorder
+

Powered by Google App Engine
This is Rietveld 408576698