riscv: support dumping privilege stack during coredump
Adds some bits to enable dumping privilege stack during coredump. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
4c5e33b2c2
commit
2c551554e2
2 changed files with 20 additions and 0 deletions
|
|
@ -115,6 +115,7 @@ config RISCV
|
|||
bool
|
||||
select ARCH_IS_SET
|
||||
select ARCH_SUPPORTS_COREDUMP
|
||||
select ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
|
||||
select ARCH_SUPPORTS_ROM_START if !SOC_FAMILY_ESPRESSIF_ESP32
|
||||
select ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
|
||||
select ARCH_HAS_CODE_DATA_RELOCATION
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/debug/coredump.h>
|
||||
|
||||
#ifndef CONFIG_64BIT
|
||||
|
|
@ -116,3 +117,21 @@ uint16_t arch_coredump_tgt_code_get(void)
|
|||
{
|
||||
return COREDUMP_TGT_RISC_V;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK)
|
||||
void arch_coredump_priv_stack_dump(struct k_thread *thread)
|
||||
{
|
||||
uintptr_t start_addr, end_addr;
|
||||
|
||||
/* See: zephyr/include/zephyr/arch/riscv/arch.h */
|
||||
if (IS_ENABLED(CONFIG_PMP_POWER_OF_TWO_ALIGNMENT)) {
|
||||
start_addr = thread->arch.priv_stack_start + Z_RISCV_STACK_GUARD_SIZE;
|
||||
} else {
|
||||
start_addr = thread->stack_info.start - CONFIG_PRIVILEGED_STACK_SIZE;
|
||||
}
|
||||
end_addr = Z_STACK_PTR_ALIGN(thread->arch.priv_stack_start + K_KERNEL_STACK_RESERVED +
|
||||
CONFIG_PRIVILEGED_STACK_SIZE);
|
||||
|
||||
coredump_memory_dump(start_addr, end_addr);
|
||||
}
|
||||
#endif /* CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK */
|
||||
|
|
|
|||
Loading…
Reference in a new issue