Skip to content

Commit

Permalink
Remove redundant mask of stack high water mark in switcher.
Browse files Browse the repository at this point in the history
Now that the stack high water mark is explicilty 16-byte aligned we no
longer need to mask it in the switcher.

See CHERIoT-Platform/cheriot-sail#49
  • Loading branch information
ronorton authored and davidchisnall committed Apr 5, 2024
1 parent 9663d28 commit 332a0d5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions sdk/core/switcher/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ __Z26compartment_switcher_entryz:
csetboundsexact ct2, csp, s1
csetaddr csp, ct2, s0
#ifdef CONFIG_MSHWM
// Read and align the stack high water mark
// Read the stack high water mark (which is 16-byte aligned)
csrr gp, CSR_MSHWM
and gp, gp, ~0xf
// Skip zeroing if high water mark >= stack pointer
bge t2, sp, after_zero
// Use stack high water mark as base address for zeroing. If this faults
Expand Down Expand Up @@ -793,12 +792,11 @@ exception_entry_asm:
cincoffset csp, csp, SPILL_SLOT_SIZE
#ifndef CONFIG_NO_SWITCHER_SAFETY
#ifdef CONFIG_MSHWM
// read and align the stack high water mark
// read the stack high water mark, which is 16-byte aligned
// we will use this as base address for stack clearing
// note that it cannot be greater than stack top as we
// we set it to stack top when we pushed to trusted stack frame
csrr tp, CSR_MSHWM
and tp, tp, ~0xf
#else
cgetbase tp, csp
#endif
Expand Down

0 comments on commit 332a0d5

Please sign in to comment.