riscv: fix jal offsets in patched alternatives
authorJisheng Zhang <jszhang@kernel.org>
Fri, 13 Jan 2023 21:22:05 +0000 (22:22 +0100)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 25 Jan 2023 02:43:56 +0000 (18:43 -0800)
commit9d5567ccf96fb2f1eb83d531eee23ead4aa8f2a3
treeddec5fe948a1e29c2fa309ad03b046dbb164323c
parent451fb217cdca0ead3f396f00f8da331401344950
riscv: fix jal offsets in patched alternatives

Alternatives live in a different section, so offsets used by jal
instruction will point to wrong locations after the patch got applied.

Similar to arm64, adjust the location to consider that offset.

Co-developed-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
Link: https://lore.kernel.org/r/20230113212205.3534622-1-heiko@sntech.de
Fixes: 27c653c06505 ("RISC-V: fix auipc-jalr addresses in patched alternatives")
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/include/asm/insn.h
arch/riscv/kernel/alternative.c