Skip to content

Commit b44c3e3

Browse files
committed
switcher: fix error handling in topmost invocation
We were not installing the correct thing into ct0 (which would then get moved into csp) prior to reaching .Linvoke_error_handler when the thread was in its initial compartment invocation. FIXES: CHERIoT-Platform#321
1 parent 6a9d604 commit b44c3e3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sdk/core/switcher/entry.S

+5-5
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ exception_entry_asm:
637637
// Get the previous trusted stack frame
638638

639639
// Load the caller's csp
640-
clc ca0, TrustedStackFrame_offset_csp(ctp)
640+
clc ct0, TrustedStackFrame_offset_csp(ctp)
641641

642642
// If this is the top stack frame, then the csp field is the value on
643643
// entry. If it's any other frame then we need to go to the previous one
@@ -647,12 +647,12 @@ exception_entry_asm:
647647
// The address of the stack pointer will point to the bottom of the
648648
// caller's save area, so we set the bounds to be the base up to the
649649
// current address.
650-
cgetaddr a1, ca0
651-
cgetbase a2, ca0
650+
cgetaddr a1, ct0
651+
cgetbase a2, ct0
652652
sub a1, a1, a2
653-
csetaddr ca0, ca0, a2
653+
csetaddr ct0, ct0, a2
654654
// The code that installs the context expects csp to be in ct0
655-
csetboundsexact ct0, ca0, a1
655+
csetboundsexact ct0, ct0, a1
656656
.Lrecovered_stack:
657657
li a0, 1
658658

0 commit comments

Comments
 (0)