]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
riscv: avoid Imbalance in RAS
authorJisheng Zhang <jszhang@kernel.org>
Sat, 20 Jul 2024 17:06:59 +0000 (01:06 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Mon, 16 Sep 2024 03:58:25 +0000 (20:58 -0700)
Inspired by[1], modify the code to remove the code of modifying ra to
avoid imbalance RAS (return address stack) which may lead to incorret
predictions on return.

Link: https://lore.kernel.org/linux-riscv/20240607061335.2197383-1-cyrilbur@tenstorrent.com/
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Cyril Bur <cyrilbur@tenstorrent.com>
Link: https://lore.kernel.org/r/20240720170659.1522-1-jszhang@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/entry.S

index fc41472d512e9abd2262bc5ce37001aa560de0bb..c200d329d4bdbed2b5e95ed3f320164800912178 100644 (file)
@@ -326,8 +326,8 @@ SYM_CODE_START(ret_from_fork)
        jalr s0
 1:
        move a0, sp /* pt_regs */
-       la ra, ret_from_exception
-       tail syscall_exit_to_user_mode
+       call syscall_exit_to_user_mode
+       j ret_from_exception
 SYM_CODE_END(ret_from_fork)
 
 #ifdef CONFIG_IRQ_STACKS