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

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

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
1 /* 1 /*
2 * Copyright (c) 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 be 3 * Use of this source code is governed by a BSD-style license that can
4 * found in the LICENSE file. 4 * be 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/trusted/service_runtime/nacl_signal.h" 11 #include "native_client/src/trusted/service_runtime/nacl_signal.h"
12 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 12 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
13 #include "native_client/src/trusted/service_runtime/sel_rt.h" 13 #include "native_client/src/trusted/service_runtime/sel_rt.h"
14 #include "native_client/src/trusted/service_runtime/arch/arm/sel_ldr_arm.h" 14 #include "native_client/src/trusted/service_runtime/arch/mips/sel_ldr_mips.h"
15 15
16 void NaClInitGlobals() { 16 void NaClInitGlobals() {
17 NaClLog(2, "NaClInitGlobals\n"); 17 NaClLog(2, "NaClInitGlobals\n");
18 /* intentionally left empty */ 18 /* intentionally left empty */
19 } 19 }
20 20
21 21
22 int NaClThreadContextCtor(struct NaClThreadContext *ntcp, 22 int NaClThreadContextCtor(struct NaClThreadContext *ntcp,
23 struct NaClApp *nap, 23 struct NaClApp *nap,
24 nacl_reg_t prog_ctr, 24 nacl_reg_t prog_ctr,
25 nacl_reg_t stack_ptr, 25 nacl_reg_t stack_ptr,
26 nacl_reg_t tls_idx) { 26 nacl_reg_t tls_idx) {
27 /* 27 /*
28 * This is set by NaClTlsAllocate before we get here, so don't wipe it. 28 * This is set by NaClTlsAllocate before we get here, so don't wipe it.
29 */ 29 */
30 uint32_t r9 = ntcp->r9; 30 uint32_t t8 = ntcp->t8;
31 31
32 UNREFERENCED_PARAMETER(nap); 32 UNREFERENCED_PARAMETER(nap);
33 33
34 /* 34 /*
35 * We call this function so that it does not appear to be dead code, 35 * We call this function so that it does not appear to be dead code,
36 * although it only contains compile-time assertions. 36 * although it only contains compile-time assertions.
37 */ 37 */
38 NaClThreadContextOffsetCheck(); 38 NaClThreadContextOffsetCheck();
39 39
40 memset((void *)ntcp, 0, sizeof(*ntcp)); 40 memset((void *)ntcp, 0, sizeof(*ntcp));
41 ntcp->stack_ptr = stack_ptr; 41 ntcp->stack_ptr = stack_ptr;
42 ntcp->prog_ctr = prog_ctr; 42 ntcp->prog_ctr = prog_ctr;
43 ntcp->tls_idx = tls_idx; 43 ntcp->tls_idx = tls_idx;
44 ntcp->r9 = r9; 44 ntcp->t8 = t8;
45
46 /*
47 * Save the system's state of the FPSCR so we can restore
48 * the same state when returning to trusted code.
49 */
50 __asm__ __volatile__("vmrs %0, fpscr" : "=r" (ntcp->sys_fpscr));
51 45
52 NaClLog(4, "user.tls_idx: 0x%08"NACL_PRIxNACL_REG"\n", tls_idx); 46 NaClLog(4, "user.tls_idx: 0x%08"NACL_PRIxNACL_REG"\n", tls_idx);
53 NaClLog(4, "user.stack_ptr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->stack_ptr); 47 NaClLog(4, "user.stack_ptr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->stack_ptr);
54 NaClLog(4, "user.prog_ctr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->prog_ctr); 48 NaClLog(4, "user.prog_ctr: 0x%08"NACL_PRIxNACL_REG"\n", ntcp->prog_ctr);
55 49
56 return 1; 50 return 1;
57 } 51 }
58 52
59 53
60 uintptr_t NaClGetThreadCtxSp(struct NaClThreadContext *th_ctx) { 54 uintptr_t NaClGetThreadCtxSp(struct NaClThreadContext *th_ctx) {
61 return (uintptr_t) th_ctx->stack_ptr; 55 return (uintptr_t) th_ctx->stack_ptr;
62 } 56 }
63 57
64 58
65 void NaClSetThreadCtxSp(struct NaClThreadContext *th_ctx, uintptr_t sp) { 59 void NaClSetThreadCtxSp(struct NaClThreadContext *th_ctx, uintptr_t sp) {
66 th_ctx->stack_ptr = (uint32_t) sp; 60 th_ctx->stack_ptr = (uint32_t) sp;
67 } 61 }
68 62
69
70 void NaClThreadContextToSignalContext(const struct NaClThreadContext *th_ctx, 63 void NaClThreadContextToSignalContext(const struct NaClThreadContext *th_ctx,
71 struct NaClSignalContext *sig_ctx) { 64 struct NaClSignalContext *sig_ctx) {
72 sig_ctx->r0 = 0; 65 sig_ctx->zero = 0;
73 sig_ctx->r1 = 0; 66 sig_ctx->at = 0;
74 sig_ctx->r2 = 0; 67 sig_ctx->v0 = 0;
75 sig_ctx->r3 = 0; 68 sig_ctx->v1 = 0;
76 sig_ctx->r4 = th_ctx->r4; 69 sig_ctx->a0 = 0;
77 sig_ctx->r5 = th_ctx->r5; 70 sig_ctx->a1 = 0;
78 sig_ctx->r6 = th_ctx->r6; 71 sig_ctx->a2 = 0;
79 sig_ctx->r7 = th_ctx->r7; 72 sig_ctx->a3 = 0;
80 sig_ctx->r8 = th_ctx->r8; 73 sig_ctx->t0 = 0;
81 sig_ctx->r9 = th_ctx->r9; 74 sig_ctx->t1 = 0;
82 sig_ctx->r10 = th_ctx->r10; 75 sig_ctx->t2 = 0;
83 sig_ctx->r11 = th_ctx->fp; 76 sig_ctx->t3 = 0;
84 sig_ctx->r12 = 0; 77 sig_ctx->t4 = 0;
85 sig_ctx->stack_ptr = th_ctx->stack_ptr; 78 sig_ctx->t5 = 0;
86 sig_ctx->lr = 0; 79 sig_ctx->t6 = th_ctx->t6;
Mark Seaborn 2012/09/20 02:40:42 You should set t6 and t7 to 0, or better, their ap
petarj 2012/09/20 15:33:00 Done.
87 sig_ctx->prog_ctr = th_ctx->new_prog_ctr; 80 sig_ctx->t7 = th_ctx->t7;
81 sig_ctx->s0 = th_ctx->s0;
82 sig_ctx->s1 = th_ctx->s1;
83 sig_ctx->s2 = th_ctx->s2;
84 sig_ctx->s3 = th_ctx->s3;
85 sig_ctx->s4 = th_ctx->s4;
86 sig_ctx->s5 = th_ctx->s5;
87 sig_ctx->s6 = th_ctx->s6;
88 sig_ctx->s7 = th_ctx->s7;
89 sig_ctx->t8 = th_ctx->t8;
90 sig_ctx->t9 = 0;
91 sig_ctx->k0 = 0;
92 sig_ctx->k1 = 0;
93 sig_ctx->global_ptr = th_ctx->global_ptr;
94 sig_ctx->stack_ptr = th_ctx->stack_ptr;
95 sig_ctx->frame_ptr = th_ctx->frame_ptr;
96 sig_ctx->return_addr = th_ctx->prog_ctr;
88 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698