Skip to content

Commit

Permalink
arm64: Initialize stxr_status in asm in vm_do_cheri_revoke()
Browse files Browse the repository at this point in the history
If the capability under test changes between the initial load (done to
clear the tag before storing it) and the load-link, the initial
comparison fails and the inline asm block is supposed to leave
stxr_status set to 2.  However, the lack of an input constraint meant
that the compiler simply elided the initialization of stxr_status, which
could lead to an infinite loop.

This could be fixed by making stxr_status an input operand, but it seems
safer to just initialize it in the asm block.
  • Loading branch information
markjdb committed Apr 17, 2024
1 parent af5403b commit aaaa6c7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions sys/arm64/arm64/cheri_revoke_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ vm_do_cheri_revoke(int *res, const struct vm_cheri_revoke_cookie *crc,
* stxr returns 0 or 1, so use a value of 2
* to indicate that it was not executed.
*/
stxr_status = 2;

__asm__ __volatile__ (
"mov %[stxr_status], #2\n\t"
#ifndef __CHERI_PURE_CAPABILITY__
"bx #4\n\t"
".arch_extension c64\n\t"
Expand Down

0 comments on commit aaaa6c7

Please sign in to comment.