]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/arm: Ensure restoration of `x0` on binary system calls
authorSergiu Moga <sergiu@unikraft.io>
Thu, 11 Jan 2024 10:48:18 +0000 (12:48 +0200)
committerRazvan Deaconescu <razvan.deaconescu@upb.ro>
Thu, 18 Jan 2024 13:41:22 +0000 (15:41 +0200)
Commit 76d5701c19b0 ("lib/syscall_shim: Save `struct uk_syscall_ctx` on binary syscalls")
placed the `1:` label to be used by binary system calls to avoid
subtracting the register frame size that would normally be done during
the handling of other trap types and instead use the per-thread auxiliary
stack from which `UK_SYSCALL_CTX_SIZE` was already previously subtracted.
However, this label placement skips restoration of `x0` which was
originally stored in the `TPIDRRO_EL0` system register.

Fix this by always restoring the `x0` register on both paths: binary
system call traps and other traps.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1256

plat/kvm/arm/exceptions.S

index 457b919def0373e384b02861b797eada38fa0d50..388fa016f3927a5d3b0facf92451ab9a309380ef 100644 (file)
        str     x0, [sp, #__SP_OFFSET]  /* Store old SP in auxiliary stack */
        b       1f
 0:
-       /* Restore x0 */
-       mrs     x0, tpidrro_el0
-
        sub     sp, sp, #__TRAP_STACK_SIZE
 1:
+       /* Restore x0 */
+       mrs     x0, tpidrro_el0
 
        /* Save general purpose registers */
        stp     x0, x1, [sp, #16 * 0]