| OLD | NEW |
| 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/nacl_config.h" | 7 #include "native_client/src/trusted/service_runtime/nacl_config.h" |
| 8 | 8 |
| 9 .text | 9 .text |
| 10 | 10 |
| 11 /* | 11 /* |
| 12 * This trusted code is linked into the service_runtime and | 12 * This trusted code is linked into the service_runtime and |
| 13 * executed when switching from the service runtime to a nacl | 13 * executed when switching from the service runtime to a nacl |
| 14 * module. This happens when a main nacl thread is created and starting to | 14 * module. This happens when a main nacl thread is created and starting to |
| 15 * execute the nacle code, or when nacl module is returning from a system | 15 * execute the nacle code, or when nacl module is returning from a system |
| 16 * call. This piece of code lives in a service runtime part of address space. | 16 * call. This piece of code lives in a service runtime part of address space. |
| 17 * the one and only argument is in register r0 | 17 * the one and only argument is in register r0 |
| 18 * | 18 * |
| 19 * r0 -- address of thread context (struct NaClThreadContext) | 19 * r0 -- address of thread context (struct NaClThreadContext) |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaClSwitch): | 22 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaClSwitch): |
| 23 | 23 |
| 24 /* | 24 /* |
| 25 * We clear registers r2, r3, lr, flag and status fields in CPSR | 25 * We clear registers r2, r3, r12 (ip), lr, flag and status fields in |
| 26 * (status register) to avoid information leaks. The remaining | 26 * CPSR (status register) to avoid information leaks. The remaining |
| 27 * registers are overwritten by the code that follows after. | 27 * registers are overwritten by the code that follows after. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 mov r2, #0 | 30 mov r2, #0 |
| 31 mov r3, #0 | 31 mov r3, #0 |
| 32 mov r12, #0 |
| 32 mov lr, #0 | 33 mov lr, #0 |
| 33 msr cpsr_fs, #0 | 34 msr cpsr_fs, #0 |
| 34 | 35 |
| 35 ldmia r0!, NACL_CALLEE_SAVE_LIST | 36 ldmia r0!, NACL_CALLEE_SAVE_LIST |
| 36 add r0, #4 /* skip prog_ctr in struct NaClThreadContext */ | 37 add r0, #4 /* skip prog_ctr in struct NaClThreadContext */ |
| 37 /* Read sysret and new_prog_ctr from struct NaClThreadContext */ | 38 /* Read sysret and new_prog_ctr from struct NaClThreadContext */ |
| 38 ldmia r0, {r0, r1} | 39 ldmia r0, {r0, r1} |
| 39 /* Transfer control to untrusted code */ | 40 /* Transfer control to untrusted code */ |
| 40 bx r1 | 41 bx r1 |
| OLD | NEW |