Skip to content

Commit 4c5a901

Browse files
NonerKaoMina-Chou
authored andcommitted
riscv: andes: Support Andes supervisor detailed trap cause (sdcause)
Reformed from the following patches on RISCV-Linux-5.4: - (edf0bb0) Support sdcause - (7ed459d) Fix sdcause read using wrong register Reformed from the following patches on ast-v5_4_0-branch: - (7fca221) riscv: andes: fix make failure with riscv generic defconfig (torvalds#206) Signed-off-by: Alan Kao <alankao@andestech.com>
1 parent 4385a9d commit 4c5a901

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

arch/riscv/include/asm/ptrace.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ struct pt_regs {
4949
unsigned long status;
5050
unsigned long badaddr;
5151
unsigned long cause;
52+
53+
#ifdef CONFIG_ARCH_ANDES
54+
/* Andes supervisor detailed trap cause */
55+
unsigned long sdcause;
56+
#endif
5257
/* a0 value before the syscall */
5358
unsigned long orig_a0;
5459
};

arch/riscv/kernel/asm-offsets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ void asm_offsets(void)
125125
OFFSET(PT_STATUS, pt_regs, status);
126126
OFFSET(PT_BADADDR, pt_regs, badaddr);
127127
OFFSET(PT_CAUSE, pt_regs, cause);
128+
#ifdef CONFIG_ARCH_ANDES
129+
OFFSET(PT_SDCAUSE, pt_regs, sdcause);
130+
#endif
128131

129132
OFFSET(SUSPEND_CONTEXT_REGS, suspend_context, regs);
130133

arch/riscv/kernel/entry.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <asm/asm-offsets.h>
1717
#include <asm/errata_list.h>
1818
#include <linux/sizes.h>
19+
#include <linux/soc/andes/csr.h>
1920

2021
.section .irqentry.text, "ax"
2122

@@ -151,12 +152,18 @@ SYM_CODE_START(handle_exception)
151152
csrr s3, CSR_TVAL
152153
csrr s4, CSR_CAUSE
153154
csrr s5, CSR_SCRATCH
155+
#ifdef CONFIG_ARCH_ANDES
156+
csrr s6, CSR_SDCAUSE
157+
#endif
154158
REG_S s0, PT_SP(sp)
155159
REG_S s1, PT_STATUS(sp)
156160
REG_S s2, PT_EPC(sp)
157161
REG_S s3, PT_BADADDR(sp)
158162
REG_S s4, PT_CAUSE(sp)
159163
REG_S s5, PT_TP(sp)
164+
#ifdef CONFIG_ARCH_ANDES
165+
REG_S s6, PT_SDCAUSE(sp)
166+
#endif
160167

161168
/*
162169
* Set the scratch register to 0, so that if a recursive exception

arch/riscv/kernel/process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void __show_regs(struct pt_regs *regs)
9191
pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
9292
regs->t5, regs->t6);
9393

94-
pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n",
95-
regs->status, regs->badaddr, regs->cause);
94+
pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT " sdcause: " REG_FMT "\n",
95+
regs->status, regs->badaddr, regs->cause, regs->sdcause);
9696
}
9797
void show_regs(struct pt_regs *regs)
9898
{

0 commit comments

Comments
 (0)