Skip to content

Fixed module thread reset on Cortex-A7 builds without MMU support - #857

Open
fdesbiens wants to merge 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix/module-reset-without-memory-protection
Open

fdesbiens wants to merge 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix/module-reset-without-memory-protection

Conversation

@fdesbiens

Copy link
Copy Markdown
Contributor

Thread reset rebuilds a module thread's entry frame from tx_thread_module_stack_start, _end and _size, but _txm_module_manager_thread_create recorded those fields only when TXM_MODULE_MEMORY_PROTECTION is non-zero. The Cortex-A7 module ports define it as zero when TXM_MODULE_MEMORY_PROTECTION_ENABLED is removed, so resetting any module thread on such a build placed the frame 76 bytes below a null stack end, at 0xFFFFFFB4. Every other module port defines the constant as non-zero and is not affected.

Thread create now records the module stack fields for every module thread. Guarding the restore in reset was rejected because it would keep a second code path and leave those threads invisible to the stack overlap check in thread create. On Cortex-A7 builds without MMU support, that check now refuses a module stack overlapping another module thread's stack with TX_PTR_ERROR, as on the other ports.

A new host test runs thread create and reset against the Cortex-A7 port headers, as shipped and with MMU support compiled out. Without the fix the second build fails 6 of 14 expectations, with a reset frame end of 0; with it, 15/15 module manager host tests pass in each of the five non-MISRA configurations. The QEMU module harness passed 4/4 on Cortex-M3 and Cortex-M4, with and without pointer context. Not run on Cortex-A7 hardware.

Thread reset rebuilds a module thread's entry frame from tx_thread_module_stack_start,
_end and _size, but _txm_module_manager_thread_create recorded those fields only when
TXM_MODULE_MEMORY_PROTECTION is non-zero. The Cortex-A7 module ports define it as zero
when TXM_MODULE_MEMORY_PROTECTION_ENABLED is removed, so resetting any module thread
on such a build placed the frame 76 bytes below a null stack end, at 0xFFFFFFB4. Every
other module port defines the constant as non-zero and is not affected.

Thread create now records the module stack fields for every module thread. Guarding the
restore in reset was rejected because it would keep a second code path and leave those
threads invisible to the stack overlap check in thread create. On Cortex-A7 builds
without MMU support, that check now refuses a module stack overlapping another module
thread's stack with TX_PTR_ERROR, as on the other ports.

A new host test runs thread create and reset against the Cortex-A7 port headers, as
shipped and with MMU support compiled out. Without the fix the second build fails 6 of
14 expectations, with a reset frame end of 0; with it, 15/15 module manager host tests
pass in each of the five non-MISRA configurations. The QEMU module harness passed 4/4
on Cortex-M3 and Cortex-M4, with and without pointer context. Not run on Cortex-A7
hardware.

Assisted-by: Claude Code (Opus 5.5) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant