nuttx/arch
liang.huang da968584be arch/risc-v: switch to target addrenv when backtracing another tcb
up_backtrace() on a different tcb dereferences that task's own stack
to walk its frame pointer chain, but never selected that task's
address environment first. Under CONFIG_ARCH_ADDRENV each task's
stack lives behind its own page tables mapped at the same fixed
virtual range, so reading tcb->stack_base_ptr without first switching
to that task's addrenv reads whatever physical page the caller's own
mapping of that virtual range happens to point to, not the target
task's real stack. A cross-tid dumpstack of a task running in a
different address environment therefore returns garbage or an
all-zero backtrace instead of failing cleanly or resolving the real
call chain.

Add an addrenv parameter to backtrace() and select the target tcb's
addrenv_own only around the two dereferences that read the target's
saved ra/fp (ra = *(fp - 1), next_fp = *(fp - 2)), then restore the
caller's own addrenv before writing the result into buffer. buffer
belongs to the caller, not the target tcb, so it must always be
written back in the caller's own address environment; writing it
while the target's addrenv is still selected would corrupt the
access instead of fixing it.

Signed-off-by: liang.huang <liang.huang@houmo.ai>
2026-08-03 20:58:32 +08:00
..
arm arch/common: fix host_flags_to_mode() O_RDONLY sentinel collision 2026-08-03 20:58:21 +08:00
arm64 arch/common: fix host_flags_to_mode() O_RDONLY sentinel collision 2026-08-03 20:58:21 +08:00
avr arch/avr/src/avrdx/avrdx_delay: add custom up_udelay function 2026-06-17 17:10:02 +08:00
ceva arch/ceva: Replace board_app_initialize 2026-05-02 18:36:46 +08:00
dummy
hc style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
mips drivers: Fix comment typos — 'Pubic' → 'Public' across drivers and headers. 2026-07-04 02:00:24 +08:00
misoc include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
or1k include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
renesas drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
risc-v arch/risc-v: switch to target addrenv when backtracing another tcb 2026-08-03 20:58:32 +08:00
sim !include/fcntl.h: align open flags with Linux values 2026-07-03 10:33:47 +08:00
sparc drivers: Fix comment typos — 'Pubic' → 'Public' across drivers and headers. 2026-07-04 02:00:24 +08:00
tricore arch/tricore: Add hardware debug breakpoint and watchpoint support. 2026-05-22 15:38:36 +08:00
x86 drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
x86_64 !include/fcntl.h: align open flags with Linux values 2026-07-03 10:33:47 +08:00
xtensa drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
z16 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
z80 style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
CMakeLists.txt arch/z80: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
Kconfig sched/clock/clock_delay: added config flag to remove weak up_udelay 2026-06-17 17:10:02 +08:00