Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Commit 35b03bf

Browse files
committed
adjust cfi expressions to use the correct parent_ctx offset
the struct at rbp changed between first authorship and today, to fix a bug where lucet instances were accidentally tied to their starting thread
1 parent 9a40df4 commit 35b03bf

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

lucet-runtime/lucet-runtime-internals/src/context/context_asm.S

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ _unwind_stub:
9292
// able to figure this out based on the saved rsp value, things go wrong if this is missing.
9393

9494
.cfi_escape 0x0f, /* DW_CFA_def_cfa_expression */ \
95-
8, /* uleb128 length of expression bytes */ \
96-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
95+
9, /* uleb128 length of expression bytes */ \
96+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
9797
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
9898
0x23, 0x08, /* DW_OP_plus_uconst (add 8 to the base of context to point to saved rsp) */ \
9999
0x06, /* deref */ \
@@ -104,8 +104,8 @@ _unwind_stub:
104104
// the extra `lucet_context_swap` call frame we want to skip over
105105

106106
.cfi_escape 0x16, 0x07, /* DW_CFA_val_expression(7=rsp) */ \
107-
8, /* uleb128 length of expression bytes */ \
108-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
107+
9, /* uleb128 length of expression bytes */ \
108+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
109109
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
110110
0x23, 0x08, /* DW_OP_plus_uconst (add 8 to the base of context to point to saved rsp) */ \
111111
0x06, /* deref */ \
@@ -115,44 +115,44 @@ _unwind_stub:
115115
// the corresponding field on the `Context` struct
116116

117117
.cfi_escape 0x10, 0x03, /* DW_CFA_expression(3=rbx) */ \
118-
3, /* uleb128 length of expression bytes */ \
119-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
118+
4, /* uleb128 length of expression bytes */ \
119+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
120120
0x06 /* DW_OP_deref should then leave the parent context pointer on the stack */ \
121121
/* rbx is at offset 0 */
122122

123123
.cfi_escape 0x10, 0x06, /* DW_CFA_expression(6=rbp) */ \
124-
5, /* uleb128 length of expression bytes */ \
125-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
124+
6, /* uleb128 length of expression bytes */ \
125+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
126126
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
127127
0x23, 0x10 /* DW_OP_plus_uconst (add 16 to the base of context to point to saved rbp) */
128128

129129
.cfi_escape 0x10, 0x05, /* DW_CFA_expression(5=rdi) */ \
130-
5, /* uleb128 length of expression bytes */ \
131-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
130+
6, /* uleb128 length of expression bytes */ \
131+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
132132
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
133133
0x23, 0x18 /* DW_OP_plus_uconst (add 24 to the base of context to point to saved rdi) */
134134

135135
.cfi_escape 0x10, 0x0c, /* DW_CFA_expression(12=r12) */ \
136-
5, /* uleb128 length of expression bytes */ \
137-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
136+
6, /* uleb128 length of expression bytes */ \
137+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
138138
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
139139
0x23, 0x20 /* DW_OP_plus_uconst (add 32 to the base of context to point to saved r12) */
140140

141141
.cfi_escape 0x10, 0x0d, /* DW_CFA_expression(13=r13) */ \
142-
5, /* uleb128 length of expression bytes */ \
143-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
142+
6, /* uleb128 length of expression bytes */ \
143+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
144144
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
145145
0x23, 0x28 /* DW_OP_plus_uconst (add 40 to the base of context to point to saved r13) */
146146

147147
.cfi_escape 0x10, 0x0e, /* DW_CFA_expression(14=r14) */ \
148-
5, /* uleb128 length of expression bytes */ \
149-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
148+
6, /* uleb128 length of expression bytes */ \
149+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
150150
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
151151
0x23, 0x30 /* DW_OP_plus_uconst (add 48 to the base of context to point to saved r14) */
152152

153153
.cfi_escape 0x10, 0x0f, /* DW_CFA_expression(15=r15) */ \
154-
5, /* uleb128 length of expression bytes */ \
155-
0x76, 0x18, /* DW_OP_breg5 (put rbp + 24 on the stack; should be a pointer to the parent context's address) */ \
154+
6, /* uleb128 length of expression bytes */ \
155+
0x76, 0xf0, 0x01, /* DW_OP_breg5 (put rbp + 240 on the stack; should be a pointer to the parent context's address) */ \
156156
0x06, /* DW_OP_deref should then leave the parent context pointer on the stack */ \
157157
0x23, 0x38 /* DW_OP_plus_uconst (add 56 to the base of context to point to saved r15) */
158158

0 commit comments

Comments
 (0)