[PATCH v2] riscv: fix using wrong load type

Yao Zi ziyao at disroot.org
Mon Aug 18 20:33:26 PDT 2025


On Tue, Aug 19, 2025 at 10:19:31AM +0800, Jimmy Ho wrote:
> thread_info.cpu field is 32 bits wide,
> but is accessed using an XLEN-bit load, which might be 64bit load, fix it
> 
> Signed-off-by: Jimmy Ho <jimmy.ho at sifive.com>
> 
> Changes in v2:
> - add a comment to explain why use lw instead of REG_L.
> - correct commit message
> ---
>  arch/riscv/kernel/entry.S | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
> index 3a0ec6fd5956..82306cecfdcb 100644
> --- a/arch/riscv/kernel/entry.S
> +++ b/arch/riscv/kernel/entry.S
> @@ -45,8 +45,10 @@
>  	 * Computes:
>  	 * a0 = &new_vmalloc[BIT_WORD(cpu)]
>  	 * a1 = BIT_MASK(cpu)
> +	 * 
> +	 * using lw instead of REG_L is because the thread_info.cpu field is 32 bits wide
>  	 */
> -	REG_L 	a2, TASK_TI_CPU(tp)
> +	lw a2, TASK_TI_CPU(tp)
	~~~~~
In this code block, a TAB instead of a space is placed between opcode
and operands. I think it's better to keep them aligned.

And should this patch carry a Fixes tag?

Best regards,
Yao Zi



More information about the linux-riscv mailing list