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

Side by Side Diff: src/trusted/service_runtime/arch/mips/sel_rt.c

Issue 1536713003: [MIPS] Make $t8 point to the address of TLS pointers (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client@master
Patch Set: Move EditMipsCode() below EditArmCode(). Created 4 years, 11 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
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 /* 7 /*
8 * NaCl Secure Runtime 8 * NaCl Secure Runtime
9 */ 9 */
10 #include "native_client/src/include/portability_string.h" 10 #include "native_client/src/include/portability_string.h"
11 #include "native_client/src/shared/platform/nacl_global_secure_random.h"
11 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" 12 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
12 #include "native_client/src/trusted/service_runtime/nacl_signal.h" 13 #include "native_client/src/trusted/service_runtime/nacl_signal.h"
13 #include "native_client/src/trusted/service_runtime/nacl_tls.h" 14 #include "native_client/src/trusted/service_runtime/nacl_tls.h"
14 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 15 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
15 #include "native_client/src/trusted/service_runtime/sel_rt.h" 16 #include "native_client/src/trusted/service_runtime/sel_rt.h"
16 #include "native_client/src/trusted/service_runtime/arch/mips/sel_ldr_mips.h" 17 #include "native_client/src/trusted/service_runtime/arch/mips/sel_ldr_mips.h"
17 18
19 uint32_t nacl_guard_token;
20
18 void NaClInitGlobals(void) { 21 void NaClInitGlobals(void) {
19 NaClLog(2, "NaClInitGlobals\n"); 22 NaClLog(2, "NaClInitGlobals\n");
20 /* intentionally left empty */ 23 nacl_guard_token = NaClGlobalSecureRngUint32();
21 } 24 }
22 25
23 26
24 int NaClAppThreadInitArchSpecific(struct NaClAppThread *natp, 27 int NaClAppThreadInitArchSpecific(struct NaClAppThread *natp,
25 nacl_reg_t prog_ctr, 28 nacl_reg_t prog_ctr,
26 nacl_reg_t stack_ptr) { 29 nacl_reg_t stack_ptr) {
27 struct NaClThreadContext *ntcp = &natp->user; 30 struct NaClThreadContext *ntcp = &natp->user;
28 31
29 /* 32 /*
30 * We call this function so that it does not appear to be dead code, 33 * We call this function so that it does not appear to be dead code,
31 * although it only contains compile-time assertions. 34 * although it only contains compile-time assertions.
32 */ 35 */
33 NaClThreadContextOffsetCheck(); 36 NaClThreadContextOffsetCheck();
34 37
35 memset((void *)ntcp, 0, sizeof(*ntcp)); 38 memset((void *)ntcp, 0, sizeof(*ntcp));
36 ntcp->stack_ptr = stack_ptr; 39 ntcp->stack_ptr = stack_ptr;
37 ntcp->prog_ctr = prog_ctr; 40 ntcp->prog_ctr = prog_ctr;
38 ntcp->tls_idx = NaClTlsAllocate(natp); 41 ntcp->tls_idx = NaClTlsAllocate(natp);
39 if (ntcp->tls_idx == NACL_TLS_INDEX_INVALID) 42 if (ntcp->tls_idx == NACL_TLS_INDEX_INVALID)
40 return 0; 43 return 0;
44 ntcp->t8 = (uintptr_t) &ntcp->tls_value1;
45 ntcp->guard_token = nacl_guard_token;
41 46
42 NaClLog(4, "user.tls_idx: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->tls_idx); 47 NaClLog(4, "user.tls_idx: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->tls_idx);
43 NaClLog(4, "user.stack_ptr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->stack_ptr); 48 NaClLog(4, "user.stack_ptr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->stack_ptr);
44 NaClLog(4, "user.prog_ctr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->prog_ctr); 49 NaClLog(4, "user.prog_ctr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->prog_ctr);
45 50
46 return 1; 51 return 1;
47 } 52 }
48 53
49 54
50 void NaClThreadContextToSignalContext(const struct NaClThreadContext *th_ctx, 55 void NaClThreadContextToSignalContext(const struct NaClThreadContext *th_ctx,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 sig_ctx->t2 = 0; 105 sig_ctx->t2 = 0;
101 sig_ctx->t3 = 0; 106 sig_ctx->t3 = 0;
102 sig_ctx->t4 = 0; 107 sig_ctx->t4 = 0;
103 sig_ctx->t5 = 0; 108 sig_ctx->t5 = 0;
104 sig_ctx->t9 = 0; 109 sig_ctx->t9 = 0;
105 sig_ctx->k0 = 0; 110 sig_ctx->k0 = 0;
106 sig_ctx->k1 = 0; 111 sig_ctx->k1 = 0;
107 sig_ctx->global_ptr = 0; 112 sig_ctx->global_ptr = 0;
108 sig_ctx->return_addr = 0; 113 sig_ctx->return_addr = 0;
109 } 114 }
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/arch/mips/sel_rt.h ('k') | tests/thread_capture/arch/mips/thread_capture_test_injection.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698