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

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

Issue 11368024: [MIPS] Restore the trusted stack in NaClSyscallSeg. (Closed) Base URL: http://git.chromium.org/native_client/src/native_client.git@master
Patch Set: Remove saving of $gp. 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The Native Client Authors. All rights reserved. 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 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be 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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * When service runtime serves a system call, it first creates a structure which 63 * When service runtime serves a system call, it first creates a structure which
64 * utilizes these arguments. The structure is created by Decoder functions in 64 * utilizes these arguments. The structure is created by Decoder functions in
65 * nacl_syscall_handlers.c. (nacl_syscall_handlers.c is an automatically 65 * nacl_syscall_handlers.c. (nacl_syscall_handlers.c is an automatically
66 * generated file and placed in 66 * generated file and placed in
67 * scons-out//gen/native_client/src/trusted/service_runtime). 67 * scons-out//gen/native_client/src/trusted/service_runtime).
68 */ 68 */
69 69
70 /* Place a0-a3 argument registers in the reserved 16-byte region in caller's 70 /* Place a0-a3 argument registers in the reserved 16-byte region in caller's
71 stack frame (o32 ABI), and place return address on top of that. */ 71 stack frame (o32 ABI), and place return address on top of that. */
72 72
73 .cpload $t9 73 .cpload $t9
Mark Seaborn 2012/11/01 18:01:57 Can you add a comment here saying that this restor
petarj 2012/11/02 12:37:52 Done.
74 74
75 sw $a3, 12($sp) 75 sw $a3, 12($sp)
76 sw $a2, 8($sp) 76 sw $a2, 8($sp)
77 sw $a1, 4($sp) 77 sw $a1, 4($sp)
78 sw $a0, 0($sp) 78 sw $a0, 0($sp)
79 /* Save return address for returning to untrusted code. */ 79 /* Save return address for returning to untrusted code. */
80 sw $ra, -4($sp) 80 sw $ra, -4($sp)
81 /* Save return address that indicates which trampoline was called. */ 81 /* Save return address that indicates which trampoline was called. */
82 sw $t5, -8($sp) 82 sw $t5, -8($sp)
83 83
(...skipping 15 matching lines...) Expand all
99 99
100 sw $s0, NACL_THREAD_CONTEXT_OFFSET_S0($a1) 100 sw $s0, NACL_THREAD_CONTEXT_OFFSET_S0($a1)
101 sw $s1, NACL_THREAD_CONTEXT_OFFSET_S1($a1) 101 sw $s1, NACL_THREAD_CONTEXT_OFFSET_S1($a1)
102 sw $s2, NACL_THREAD_CONTEXT_OFFSET_S2($a1) 102 sw $s2, NACL_THREAD_CONTEXT_OFFSET_S2($a1)
103 sw $s3, NACL_THREAD_CONTEXT_OFFSET_S3($a1) 103 sw $s3, NACL_THREAD_CONTEXT_OFFSET_S3($a1)
104 sw $s4, NACL_THREAD_CONTEXT_OFFSET_S4($a1) 104 sw $s4, NACL_THREAD_CONTEXT_OFFSET_S4($a1)
105 sw $s5, NACL_THREAD_CONTEXT_OFFSET_S5($a1) 105 sw $s5, NACL_THREAD_CONTEXT_OFFSET_S5($a1)
106 sw $s6, NACL_THREAD_CONTEXT_OFFSET_S6($a1) 106 sw $s6, NACL_THREAD_CONTEXT_OFFSET_S6($a1)
107 sw $s7, NACL_THREAD_CONTEXT_OFFSET_S7($a1) 107 sw $s7, NACL_THREAD_CONTEXT_OFFSET_S7($a1)
108 sw $t8, NACL_THREAD_CONTEXT_OFFSET_T8($a1) 108 sw $t8, NACL_THREAD_CONTEXT_OFFSET_T8($a1)
109 sw $gp, NACL_THREAD_CONTEXT_OFFSET_GLOBAL_PTR($a1)
110 sw $sp, NACL_THREAD_CONTEXT_OFFSET_STACK_PTR($a1) 109 sw $sp, NACL_THREAD_CONTEXT_OFFSET_STACK_PTR($a1)
111 sw $fp, NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR($a1) 110 sw $fp, NACL_THREAD_CONTEXT_OFFSET_FRAME_PTR($a1)
112 111
113 /* Restore the thread index. */ 112 /* Restore the thread index. */
114 srl $a0, $a0, 2 113 srl $a0, $a0, 2
115 114
116 /* Reserve 16-byte for arguments (o32 ABI) */ 115 /* Restore the trusted stack */
117 addiu $sp, $sp, -16 116 lw $sp, NACL_THREAD_CONTEXT_OFFSET_TRUSTED_STACK_PTR($a1)
117
118 lw $t9,%call16(NaClSyscallCSegHook)($gp) 118 lw $t9,%call16(NaClSyscallCSegHook)($gp)
119 jr $t9 119 jr $t9
120 nop 120 nop
121 121
122 /* NOTREACHED */ 122 /* NOTREACHED */
123 123
124 /* 124 /*
125 * If the thread returns, which must not happen, it will be halted 125 * If the thread returns, which must not happen, it will be halted
126 * by the following instruction 126 * by the following instruction
127 */ 127 */
128 128
129 NACL_HALT 129 NACL_HALT
130 130
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698