mirror of
https://github.com/apache/nuttx.git
synced 2026-10-04 04:38:10 +00:00
arch/arm/mps: Let user code run modules from the text and data heaps.
In a protected build a module loaded by exec() runs as a user task, and the loader puts it in the text and data heaps, which on this chip are SRAM2. Nothing gave user code access to SRAM2: the region that would have done so, in arm_addregion(), exists only with CONFIG_MM_REGIONS > 1, and it is built with mpu_user_intsram(), which on ARMv8-M is execute-never. So the module faulted on its first instruction. The protected build now maps SRAM2 for user code to read, write and execute when either heap is in use. Privileged execution stays allowed, since a kernel module loaded with insmod lands in the same heaps. On mps3-an547:knsh under QEMU, with CONFIG_ELF, both heaps and the ROMFS variant of examples/elf, errno faulted on its first instruction with an instruction access violation at 0x21000001. Now every module of the example runs to the end. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
parent
b960000dc8
commit
3297bbec44
1 changed files with 10 additions and 0 deletions
|
|
@ -164,6 +164,16 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
|
|||
/* Allow user-mode access to the user heap memory */
|
||||
|
||||
mpu_user_intsram(ubase, usize);
|
||||
|
||||
# if defined(CONFIG_ARCH_USE_TEXT_HEAP) || defined(CONFIG_ARCH_USE_DATA_HEAP)
|
||||
/* A module loaded for a user task runs out of the text and data heaps in
|
||||
* SRAM2, so user code must be able to execute it as well as read and
|
||||
* write it. mpu_user_intsram() would make it execute-never.
|
||||
*/
|
||||
|
||||
mpu_configure_region(MPS_SRAM2_START, MPS_SRAM2_SIZE,
|
||||
MPU_RBAR_AP_RWRW, MPU_RLAR_NONCACHEABLE);
|
||||
# endif
|
||||
#elif defined(CONFIG_BUILD_PIC)
|
||||
|
||||
/* Use different heap useful to debug */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue