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

Side by Side Diff: src/trusted/service_runtime/arch/mips/nacl_switch.S

Issue 11308039: MIPS: Fix NaClSwitch() to set $t9 to the address of the entry point (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/trusted/service_runtime/arch/mips/sel_rt.h" 7 #include "native_client/src/trusted/service_runtime/arch/mips/sel_rt.h"
8 #include "native_client/src/trusted/service_runtime/nacl_config.h" 8 #include "native_client/src/trusted/service_runtime/nacl_config.h"
9 9
10 .text 10 .text
11 11
12 /* 12 /*
13 * This trusted code is linked into the service_runtime and 13 * This trusted code is linked into the service_runtime and
14 * executed when switching from the service runtime to a nacl 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 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 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. 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 18 * The one and only argument is in register a0
19 * 19 *
20 * a0 -- address of thread context (struct NaClThreadContext) 20 * a0 -- address of thread context (struct NaClThreadContext)
21 */ 21 */
22 22
23 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaClSwitch): 23 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaClSwitch):
24 24
25 .set noreorder 25 .set noreorder
26 26
27 /* 27 /*
28 * We clear registers a1, a2, a3, t0, t1, t2, t3, t4, t5 and ra to avoid 28 * We clear the following registers to avoid information leaks. The
29 * information leaks. The remaining registers are overwritten by the code that 29 * remaining registers are overwritten by the code that follows
30 * follows after. 30 * after.
31 */ 31 */
32 32 addu $v1, $zero, $zero
33 addu $a1, $zero, $zero 33 addu $a1, $zero, $zero
34 addu $a2, $zero, $zero 34 addu $a2, $zero, $zero
35 addu $a3, $zero, $zero 35 addu $a3, $zero, $zero
36 addu $t0, $zero, $zero 36 addu $t0, $zero, $zero
37 addu $t1, $zero, $zero 37 addu $t1, $zero, $zero
38 addu $t2, $zero, $zero 38 addu $t2, $zero, $zero
39 addu $t3, $zero, $zero 39 addu $t3, $zero, $zero
40 addu $t4, $zero, $zero 40 addu $t4, $zero, $zero
41 addu $t5, $zero, $zero 41 addu $t5, $zero, $zero
42 addu $ra, $zero, $zero 42 addu $ra, $zero, $zero
(...skipping 12 matching lines...) Expand all
55 lw $s5, NACL_THREAD_CONTEXT_OFFSET_S5($a0) 55 lw $s5, NACL_THREAD_CONTEXT_OFFSET_S5($a0)
56 lw $s6, NACL_THREAD_CONTEXT_OFFSET_S6($a0) 56 lw $s6, NACL_THREAD_CONTEXT_OFFSET_S6($a0)
57 lw $s7, NACL_THREAD_CONTEXT_OFFSET_S7($a0) 57 lw $s7, NACL_THREAD_CONTEXT_OFFSET_S7($a0)
58 lw $t8, NACL_THREAD_CONTEXT_OFFSET_T8($a0) 58 lw $t8, NACL_THREAD_CONTEXT_OFFSET_T8($a0)
59 lw $sp, NACL_THREAD_CONTEXT_OFFSET_STACK_PTR($a0) 59 lw $sp, NACL_THREAD_CONTEXT_OFFSET_STACK_PTR($a0)
60 lw $fp, NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR($a0) 60 lw $fp, NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR($a0)
61 61
62 /* NACL_CALLEE_SAVE_LIST END*/ 62 /* NACL_CALLEE_SAVE_LIST END*/
63 63
64 lw $v0, NACL_THREAD_CONTEXT_OFFSET_SYSRET($a0) 64 lw $v0, NACL_THREAD_CONTEXT_OFFSET_SYSRET($a0)
65 lw $v1, NACL_THREAD_CONTEXT_OFFSET_NEW_PROG_CTR($a0) 65 lw $t9, NACL_THREAD_CONTEXT_OFFSET_NEW_PROG_CTR($a0)
66 66
67 /* At startup, context->sysret contains not the the return value, but the 67 /* At startup, context->sysret contains not the the return value, but the
68 first argument. Put it in a0. */ 68 first argument. Put it in a0. */
69 addu $a0, $v0, $zero 69 addu $a0, $v0, $zero
70 70
71 /* Transfer control to untrusted code */ 71 /*
72 jr $v1 72 * Transfer control to untrusted code.
73 *
74 * We leave $t9 containing the address of the function being called,
75 * as required by the MIPS ABI.
76 */
77 jr $t9
73 nop 78 nop
74 79
75 .set reorder 80 .set reorder
76 81
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698