Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal Memory Dereference in tx_initialize_low_level for ARMv8-A AMP (Cortex-A34) with GNU Toolchain #435

Open
sathya-1207 opened this issue Feb 3, 2025 · 2 comments
Labels
bug Something isn't working hardware New hardware or architecture support request

Comments

@sathya-1207
Copy link

sathya-1207 commented Feb 3, 2025

When building ThreadX for ARM Cortex-A34 in AMP mode using the GNU toolchain, the tx_initialize_low_level file contains the following sequence to save the first available memory address:

tx_initialize_low_level.S

/* Save the first available memory address.  */
// _tx_initialize_unused_memory =  (VOID_PTR) Image$$ZI$$Limit;

LDR     x0, =_tx_initialize_unused_memory   // Pickup address of unused memory ptr
LDR     x1, =__top_of_ram                   // Pickup unused memory address
LDR     x1, [x1]                            //
STR     x1, [x0]                            // Store unused memory address

The issue occurs at the instruction:

LDR     x1, [x1]   // Dereferencing __top_of_ram
  • This dereferences __top_of_ram, which is illegal and results in _tx_initialize_unused_memory being updated with a garbage value.
    After commenting out this block, ThreadX runs successfully, and I can create threads without issues.

Target Device:

  • ARM Cortex-A34
  • ThreadX Version: 6.4.1
  • Toolchain: GNU GCC

To Reproduce

  • Build ThreadX for Cortex-A34 in AMP mode using the GNU toolchain.
  • Run the system and observe _tx_initialize_unused_memory.
  • The value is garbage due to the illegal dereference of __top_of_ram.
  • Commenting out this block allows ThreadX to function correctly.

Expected Behavior
_tx_initialize_unused_memory should be assigned a valid address without dereferencing __top_of_ram, ensuring correct memory initialization. Removing the instruction solves the issue.

  LDR     x1, [x1] 

Impact
Showstopper: Prevents proper initialization and causes unpredictable behavior in ThreadX.

Additional Context

  • This issue is specific to the GNU toolchain. Other toolchains (such as IAR or ARM Compiler) may not be affected.
  • __top_of_ram should likely be treated as an absolute address rather than being dereferenced.
  • Since this issue affects multiple ARMv8-A ports, a global fix may be required across affected architectures (such as Cortex-A53, Cortex-A55, and Cortex-A57, where I have observed the illegal instruction) when using the GNU toolchain.
  • Cortex-M3 and Cortex-R5 ports do not have this issue, which i have already ported. Suggesting that the memory initialization logic for ARMv8-A cores may need review.
@sathya-1207 sathya-1207 added bug Something isn't working hardware New hardware or architecture support request labels Feb 3, 2025
@sathya-1207 sathya-1207 changed the title Illegal Instruction: tx_initialize_low_level: Illegal Memory Dereference in tx_initialize_low_level for ARMv8-A (Cortex-A34) with GNU Toolchain Feb 3, 2025
@sathya-1207 sathya-1207 changed the title Illegal Memory Dereference in tx_initialize_low_level for ARMv8-A (Cortex-A34) with GNU Toolchain Illegal Memory Dereference in tx_initialize_low_level for ARMv8-A AMP (Cortex-A34) with GNU Toolchain Feb 3, 2025
@fdesbiens
Copy link
Contributor

@eclipse-threadx/iot-threadx-committers and @eclipse-threadx/iot-threadx-contributors. Please review this issue and provide feedback. Thanks!

@fdesbiens
Copy link
Contributor

A kind reminder to the members of @eclipse-threadx/iot-threadx-committers and @eclipse-threadx/iot-threadx-contributors to provide feedback. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hardware New hardware or architecture support request
Projects
None yet
Development

No branches or pull requests

2 participants