riscv: fix scratch register clearing in M-mode.
authorGreentime Hu <greentime.hu@sifive.com>
Thu, 19 Dec 2019 06:44:59 +0000 (14:44 +0800)
committerPaul Walmsley <paul.walmsley@sifive.com>
Fri, 20 Dec 2019 11:32:24 +0000 (03:32 -0800)
This patch fixes that the sscratch register clearing in M-mode. It cleared
sscratch register in M-mode, but it should clear mscratch register. That will
cause kernel trap if the CPU core doesn't support S-mode when trying to access
sscratch.

Fixes: 9e80635619b5 ("riscv: clear the instruction cache and all registers when booting")
Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
arch/riscv/kernel/head.S

index 84a6f0a..797802c 100644 (file)
@@ -246,7 +246,7 @@ ENTRY(reset_regs)
        li      t4, 0
        li      t5, 0
        li      t6, 0
-       csrw    sscratch, 0
+       csrw    CSR_SCRATCH, 0
 
 #ifdef CONFIG_FPU
        csrr    t0, CSR_MISA