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

Side by Side 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: Second update per Mark's comments. 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file.
5 */
6
7 #include "native_client/src/trusted/service_runtime/arch/mips/sel_rt.h"
8 #include "native_client/src/trusted/service_runtime/nacl_config.h"
9
10 .text
11
12 /*
13 * This trusted code is linked into the service_runtime and
14 * executed when switching from the service runtime to a nacl
15 * module. This happens when a main nacl thread is created and starting to
16 * execute the nacl code, or when nacl module is returning from a system
17 * call. This piece of code lives in a service runtime part of address space.
18 * The one and only argument is in register a0
19 *
20 * a0 -- address of thread context (struct NaClThreadContext)
21 */
22
23 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaClSwitch):
24
25 .set noreorder
26
27 /*
28 * We clear registers a1, a2, a3, t0, t1, t2, t3, t4, t5 and ra to avoid
29 * information leaks. The remaining registers are overwritten by the code that
30 * follows after.
31 */
32
33 addu $a1, $zero, $zero
34 addu $a2, $zero, $zero
35 addu $a3, $zero, $zero
36 addu $t0, $zero, $zero
37 addu $t1, $zero, $zero
38 addu $t2, $zero, $zero
39 addu $t3, $zero, $zero
40 addu $t4, $zero, $zero
41 addu $t5, $zero, $zero
42 addu $ra, $zero, $zero
43
44 /* NACL_CALLEE_SAVE_LIST BEGIN */
45
46 lw $t6, NACL_THREAD_CONTEXT_OFFSET_T6($a0)
47 lw $t7, NACL_THREAD_CONTEXT_OFFSET_T7($a0)
48 lw $s0, NACL_THREAD_CONTEXT_OFFSET_S0($a0)
49 lw $s1, NACL_THREAD_CONTEXT_OFFSET_S1($a0)
50 lw $s2, NACL_THREAD_CONTEXT_OFFSET_S2($a0)
51 lw $s3, NACL_THREAD_CONTEXT_OFFSET_S3($a0)
52 lw $s4, NACL_THREAD_CONTEXT_OFFSET_S4($a0)
53 lw $s5, NACL_THREAD_CONTEXT_OFFSET_S5($a0)
54 lw $s6, NACL_THREAD_CONTEXT_OFFSET_S6($a0)
55 lw $s7, NACL_THREAD_CONTEXT_OFFSET_S7($a0)
56 lw $t8, NACL_THREAD_CONTEXT_OFFSET_T8($a0)
57 lw $gp, NACL_THREAD_CONTEXT_OFFSET_GLOBAL_PTR($a0)
58 lw $sp, NACL_THREAD_CONTEXT_OFFSET_STACK_PTR($a0)
59 lw $fp, NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR($a0)
60
61 /* NACL_CALLEE_SAVE_LIST END*/
62
63 lw $v0, 60($a0) /* context->sysret */
Mark Seaborn 2012/09/18 03:24:34 Can you use NACL_THREAD_CONTEXT_OFFSET_SYSRET here
petarj 2012/09/19 17:27:51 Done.
64 lw $v1, 64($a0) /* context->new_prog_ctr */
Mark Seaborn 2012/09/18 03:24:34 Same here: use a #defined constant.
petarj 2012/09/19 17:27:51 Done.
65
66 /* At startup, context->sysret contains not the the return value, but the
67 first argument. Put it in a0. */
68 addu $a0, $v0, $zero
69
70 /* Transfer control to untrusted code */
71 jr $v1
72 nop
73
74 .set reorder
75
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698