riscv: abstract out CSR names for supervisor vs machine mode
Many of the privileged CSRs exist in a supervisor and machine version that are used very similarly. Provide versions of the CSR names and fields that map to either the S-mode or M-mode variant depending on a new CONFIG_RISCV_M_MODE kconfig symbol. Contains contributions from Damien Le Moal <Damien.LeMoal@wdc.com> and Paul Walmsley <paul.walmsley@sifive.com>. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Thomas Gleixner <tglx@linutronix.de> # for drivers/clocksource, drivers/irqchip [paul.walmsley@sifive.com: updated to apply] Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
This commit is contained in:
committed by
Paul Walmsley
parent
0c3ac28931
commit
a4c3733d32
@@ -41,7 +41,7 @@ void die(struct pt_regs *regs, const char *str)
|
||||
print_modules();
|
||||
show_regs(regs);
|
||||
|
||||
ret = notify_die(DIE_OOPS, str, regs, 0, regs->scause, SIGSEGV);
|
||||
ret = notify_die(DIE_OOPS, str, regs, 0, regs->cause, SIGSEGV);
|
||||
|
||||
bust_spinlocks(0);
|
||||
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
|
||||
@@ -86,7 +86,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code,
|
||||
#define DO_ERROR_INFO(name, signo, code, str) \
|
||||
asmlinkage __visible void name(struct pt_regs *regs) \
|
||||
{ \
|
||||
do_trap_error(regs, signo, code, regs->sepc, "Oops - " str); \
|
||||
do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
|
||||
}
|
||||
|
||||
DO_ERROR_INFO(do_trap_unknown,
|
||||
@@ -124,9 +124,9 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
|
||||
asmlinkage __visible void do_trap_break(struct pt_regs *regs)
|
||||
{
|
||||
if (user_mode(regs))
|
||||
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc);
|
||||
else if (report_bug(regs->sepc, regs) == BUG_TRAP_TYPE_WARN)
|
||||
regs->sepc += get_break_insn_length(regs->sepc);
|
||||
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc);
|
||||
else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN)
|
||||
regs->epc += get_break_insn_length(regs->epc);
|
||||
else
|
||||
die(regs, "Kernel BUG");
|
||||
}
|
||||
@@ -153,9 +153,9 @@ void __init trap_init(void)
|
||||
* Set sup0 scratch register to 0, indicating to exception vector
|
||||
* that we are presently executing in the kernel
|
||||
*/
|
||||
csr_write(CSR_SSCRATCH, 0);
|
||||
csr_write(CSR_SCRATCH, 0);
|
||||
/* Set the exception vector address */
|
||||
csr_write(CSR_STVEC, &handle_exception);
|
||||
csr_write(CSR_TVEC, &handle_exception);
|
||||
/* Enable all interrupts */
|
||||
csr_write(CSR_SIE, -1);
|
||||
csr_write(CSR_IE, -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user