1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
5 #ifndef _ASM_STACKTRACE_H
6 #define _ASM_STACKTRACE_H
9 #include <asm/ptrace.h>
10 #include <asm/loongarch.h>
11 #include <linux/stringify.h>
21 unsigned long begin
, end
, next_sp
;
29 bool in_irq_stack(unsigned long stack
, struct stack_info
*info
);
30 bool in_task_stack(unsigned long stack
, struct task_struct
*task
, struct stack_info
*info
);
31 int get_stack_info(unsigned long stack
, struct task_struct
*task
, struct stack_info
*info
);
33 #define STR_LONG_L __stringify(LONG_L)
34 #define STR_LONG_S __stringify(LONG_S)
35 #define STR_LONGSIZE __stringify(LONGSIZE)
37 #define STORE_ONE_REG(r) \
38 STR_LONG_S " $r" __stringify(r)", %1, "STR_LONGSIZE"*"__stringify(r)"\n\t"
40 #define CSRRD_ONE_REG(reg) \
41 __stringify(csrrd) " %0, "__stringify(reg)"\n\t"
43 static __always_inline
void prepare_frametrace(struct pt_regs
*regs
)
48 /* Use $ra to save PC */
50 STR_LONG_S
" $ra, %0\n\t"
52 STR_LONG_L
" $ra, %1, "STR_LONGSIZE
"\n\t"
83 : "=m" (regs
->csr_era
)
86 __asm__
__volatile__(CSRRD_ONE_REG(LOONGARCH_CSR_BADV
) : "=r" (regs
->csr_badvaddr
));
87 __asm__
__volatile__(CSRRD_ONE_REG(LOONGARCH_CSR_CRMD
) : "=r" (regs
->csr_crmd
));
88 __asm__
__volatile__(CSRRD_ONE_REG(LOONGARCH_CSR_PRMD
) : "=r" (regs
->csr_prmd
));
89 __asm__
__volatile__(CSRRD_ONE_REG(LOONGARCH_CSR_EUEN
) : "=r" (regs
->csr_euen
));
90 __asm__
__volatile__(CSRRD_ONE_REG(LOONGARCH_CSR_ECFG
) : "=r" (regs
->csr_ecfg
));
91 __asm__
__volatile__(CSRRD_ONE_REG(LOONGARCH_CSR_ESTAT
) : "=r" (regs
->csr_estat
));
94 #endif /* _ASM_STACKTRACE_H */