From aaaa6c7e16188fdad94a20a9801dc50c41d5a8e9 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 17 Apr 2024 16:59:43 -0400 Subject: [PATCH] arm64: Initialize stxr_status in asm in vm_do_cheri_revoke() 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. --- sys/arm64/arm64/cheri_revoke_machdep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/arm64/arm64/cheri_revoke_machdep.c b/sys/arm64/arm64/cheri_revoke_machdep.c index e5afcc610670..ea3266242ed5 100644 --- a/sys/arm64/arm64/cheri_revoke_machdep.c +++ b/sys/arm64/arm64/cheri_revoke_machdep.c @@ -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"