Commit 4f3f9008 authored by Bin Meng's avatar Bin Meng Committed by Paul Walmsley

riscv: Using CSR numbers to access CSRs

Since commit a3182c91 ("RISC-V: Access CSRs using CSR numbers"),
we should prefer accessing CSRs using their CSR numbers, but there
are several leftovers like sstatus / sptbr we missed.
Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarPaul Walmsley <paul.walmsley@sifive.com>
parent 015b2693
...@@ -167,7 +167,7 @@ ENTRY(handle_exception) ...@@ -167,7 +167,7 @@ ENTRY(handle_exception)
tail do_IRQ tail do_IRQ
1: 1:
/* Exceptions run with interrupts enabled */ /* Exceptions run with interrupts enabled */
csrs sstatus, SR_SIE csrs CSR_SSTATUS, SR_SIE
/* Handle syscalls */ /* Handle syscalls */
li t0, EXC_SYSCALL li t0, EXC_SYSCALL
...@@ -222,7 +222,7 @@ ret_from_syscall: ...@@ -222,7 +222,7 @@ ret_from_syscall:
ret_from_exception: ret_from_exception:
REG_L s0, PT_SSTATUS(sp) REG_L s0, PT_SSTATUS(sp)
csrc sstatus, SR_SIE csrc CSR_SSTATUS, SR_SIE
andi s0, s0, SR_SPP andi s0, s0, SR_SPP
bnez s0, resume_kernel bnez s0, resume_kernel
...@@ -265,7 +265,7 @@ work_pending: ...@@ -265,7 +265,7 @@ work_pending:
bnez s1, work_resched bnez s1, work_resched
work_notifysig: work_notifysig:
/* Handle pending signals and notify-resume requests */ /* Handle pending signals and notify-resume requests */
csrs sstatus, SR_SIE /* Enable interrupts for do_notify_resume() */ csrs CSR_SSTATUS, SR_SIE /* Enable interrupts for do_notify_resume() */
move a0, sp /* pt_regs */ move a0, sp /* pt_regs */
move a1, s0 /* current_thread_info->flags */ move a1, s0 /* current_thread_info->flags */
tail do_notify_resume tail do_notify_resume
......
...@@ -23,7 +23,7 @@ ENTRY(__fstate_save) ...@@ -23,7 +23,7 @@ ENTRY(__fstate_save)
li a2, TASK_THREAD_F0 li a2, TASK_THREAD_F0
add a0, a0, a2 add a0, a0, a2
li t1, SR_FS li t1, SR_FS
csrs sstatus, t1 csrs CSR_SSTATUS, t1
frcsr t0 frcsr t0
fsd f0, TASK_THREAD_F0_F0(a0) fsd f0, TASK_THREAD_F0_F0(a0)
fsd f1, TASK_THREAD_F1_F0(a0) fsd f1, TASK_THREAD_F1_F0(a0)
...@@ -58,7 +58,7 @@ ENTRY(__fstate_save) ...@@ -58,7 +58,7 @@ ENTRY(__fstate_save)
fsd f30, TASK_THREAD_F30_F0(a0) fsd f30, TASK_THREAD_F30_F0(a0)
fsd f31, TASK_THREAD_F31_F0(a0) fsd f31, TASK_THREAD_F31_F0(a0)
sw t0, TASK_THREAD_FCSR_F0(a0) sw t0, TASK_THREAD_FCSR_F0(a0)
csrc sstatus, t1 csrc CSR_SSTATUS, t1
ret ret
ENDPROC(__fstate_save) ENDPROC(__fstate_save)
...@@ -67,7 +67,7 @@ ENTRY(__fstate_restore) ...@@ -67,7 +67,7 @@ ENTRY(__fstate_restore)
add a0, a0, a2 add a0, a0, a2
li t1, SR_FS li t1, SR_FS
lw t0, TASK_THREAD_FCSR_F0(a0) lw t0, TASK_THREAD_FCSR_F0(a0)
csrs sstatus, t1 csrs CSR_SSTATUS, t1
fld f0, TASK_THREAD_F0_F0(a0) fld f0, TASK_THREAD_F0_F0(a0)
fld f1, TASK_THREAD_F1_F0(a0) fld f1, TASK_THREAD_F1_F0(a0)
fld f2, TASK_THREAD_F2_F0(a0) fld f2, TASK_THREAD_F2_F0(a0)
...@@ -101,6 +101,6 @@ ENTRY(__fstate_restore) ...@@ -101,6 +101,6 @@ ENTRY(__fstate_restore)
fld f30, TASK_THREAD_F30_F0(a0) fld f30, TASK_THREAD_F30_F0(a0)
fld f31, TASK_THREAD_F31_F0(a0) fld f31, TASK_THREAD_F31_F0(a0)
fscsr t0 fscsr t0
csrc sstatus, t1 csrc CSR_SSTATUS, t1
ret ret
ENDPROC(__fstate_restore) ENDPROC(__fstate_restore)
...@@ -61,7 +61,7 @@ _start_kernel: ...@@ -61,7 +61,7 @@ _start_kernel:
* floating point in kernel space * floating point in kernel space
*/ */
li t0, SR_FS li t0, SR_FS
csrc sstatus, t0 csrc CSR_SSTATUS, t0
/* Pick one hart to run the main boot sequence */ /* Pick one hart to run the main boot sequence */
la a3, hart_lottery la a3, hart_lottery
......
...@@ -18,7 +18,7 @@ ENTRY(__asm_copy_from_user) ...@@ -18,7 +18,7 @@ ENTRY(__asm_copy_from_user)
/* Enable access to user memory */ /* Enable access to user memory */
li t6, SR_SUM li t6, SR_SUM
csrs sstatus, t6 csrs CSR_SSTATUS, t6
add a3, a1, a2 add a3, a1, a2
/* Use word-oriented copy only if low-order bits match */ /* Use word-oriented copy only if low-order bits match */
...@@ -47,7 +47,7 @@ ENTRY(__asm_copy_from_user) ...@@ -47,7 +47,7 @@ ENTRY(__asm_copy_from_user)
3: 3:
/* Disable access to user memory */ /* Disable access to user memory */
csrc sstatus, t6 csrc CSR_SSTATUS, t6
li a0, 0 li a0, 0
ret ret
4: /* Edge case: unalignment */ 4: /* Edge case: unalignment */
...@@ -72,7 +72,7 @@ ENTRY(__clear_user) ...@@ -72,7 +72,7 @@ ENTRY(__clear_user)
/* Enable access to user memory */ /* Enable access to user memory */
li t6, SR_SUM li t6, SR_SUM
csrs sstatus, t6 csrs CSR_SSTATUS, t6
add a3, a0, a1 add a3, a0, a1
addi t0, a0, SZREG-1 addi t0, a0, SZREG-1
...@@ -94,7 +94,7 @@ ENTRY(__clear_user) ...@@ -94,7 +94,7 @@ ENTRY(__clear_user)
3: 3:
/* Disable access to user memory */ /* Disable access to user memory */
csrc sstatus, t6 csrc CSR_SSTATUS, t6
li a0, 0 li a0, 0
ret ret
4: /* Edge case: unalignment */ 4: /* Edge case: unalignment */
...@@ -114,11 +114,11 @@ ENDPROC(__clear_user) ...@@ -114,11 +114,11 @@ ENDPROC(__clear_user)
/* Fixup code for __copy_user(10) and __clear_user(11) */ /* Fixup code for __copy_user(10) and __clear_user(11) */
10: 10:
/* Disable access to user memory */ /* Disable access to user memory */
csrs sstatus, t6 csrs CSR_SSTATUS, t6
mv a0, a2 mv a0, a2
ret ret
11: 11:
csrs sstatus, t6 csrs CSR_SSTATUS, t6
mv a0, a1 mv a0, a1
ret ret
.previous .previous
...@@ -57,12 +57,7 @@ void switch_mm(struct mm_struct *prev, struct mm_struct *next, ...@@ -57,12 +57,7 @@ void switch_mm(struct mm_struct *prev, struct mm_struct *next,
cpumask_clear_cpu(cpu, mm_cpumask(prev)); cpumask_clear_cpu(cpu, mm_cpumask(prev));
cpumask_set_cpu(cpu, mm_cpumask(next)); cpumask_set_cpu(cpu, mm_cpumask(next));
/* csr_write(CSR_SATP, virt_to_pfn(next->pgd) | SATP_MODE);
* Use the old spbtr name instead of using the current satp
* name to support binutils 2.29 which doesn't know about the
* privileged ISA 1.10 yet.
*/
csr_write(sptbr, virt_to_pfn(next->pgd) | SATP_MODE);
local_flush_tlb_all(); local_flush_tlb_all();
flush_icache_deferred(next); flush_icache_deferred(next);
......
...@@ -435,7 +435,7 @@ static void __init setup_vm_final(void) ...@@ -435,7 +435,7 @@ static void __init setup_vm_final(void)
clear_fixmap(FIX_PMD); clear_fixmap(FIX_PMD);
/* Move to swapper page table */ /* Move to swapper page table */
csr_write(sptbr, PFN_DOWN(__pa(swapper_pg_dir)) | SATP_MODE); csr_write(CSR_SATP, PFN_DOWN(__pa(swapper_pg_dir)) | SATP_MODE);
local_flush_tlb_all(); local_flush_tlb_all();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment