Skip to content

Commit

Permalink
riscv: support dumping privilege stack during coredump
Browse files Browse the repository at this point in the history
Adds some bits to enable dumping privilege stack during
coredump.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
  • Loading branch information
dcpleung committed Sep 17, 2024
1 parent 63dbb51 commit 8002cd1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions arch/riscv/core/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/debug/coredump.h>

#ifndef CONFIG_64BIT
Expand Down Expand Up @@ -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;

start_addr = thread->arch.priv_stack_start;

if (start_addr == 0U) {
return;
}

start_addr += Z_RISCV_STACK_GUARD_SIZE;
end_addr = start_addr + Z_STACK_PTR_ALIGN(CONFIG_PRIVILEGED_STACK_SIZE);

coredump_memory_dump(start_addr, end_addr);
}
#endif /* CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK */

0 comments on commit 8002cd1

Please sign in to comment.