[PATCH] riscv: Drop const annotation for sp

Kefeng Wang wangkefeng.wang at huawei.com
Wed Mar 17 15:21:21 GMT 2021


Hi Palmer, I have a question about

commit 52e7c52d2ded5908e6a4f8a7248e5fa6e0d6809a
Author: Palmer Dabbelt <palmerdabbelt at google.com>
Date:   Thu Feb 27 11:07:28 2020 -0800

     RISC-V: Stop relying on GCC's register allocator's hueristics

Why do you only use sp_in_global directly when CONFIG_FRAME_POINTER not 
enabled,

and keep the current_sp part when CONFIG_FRAME_POINTER enabled?

If there are special reason, I think I should revert the dec822771b01, 
thanks.


On 2021/3/17 23:08, Kefeng Wang wrote:
> The const annotation should not be used for 'sp', or it will
> become read only and lead to bad stack output.
>
> Fixes: dec822771b01 ("riscv: stacktrace: Move register keyword to beginning of declaration")
> Signed-off-by: Kefeng Wang <wangkefeng.wang at huawei.com>
> ---
>   arch/riscv/kernel/stacktrace.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index 3f893c9d9d85..2b3e0cb90d78 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -14,7 +14,7 @@
>   
>   #include <asm/stacktrace.h>
>   
> -register const unsigned long sp_in_global __asm__("sp");
> +register unsigned long sp_in_global __asm__("sp");
>   
>   #ifdef CONFIG_FRAME_POINTER
>   



More information about the linux-riscv mailing list