Commit Graph

28 Commits

Author SHA1 Message Date
Alexey Lapshin
4b54c49203 heap: fix gcc-12 compile errors 2023-02-22 05:33:03 +00:00
Guillaume Souchere
b1f9d7a8ee Merge branch 'feature/use-linked-list-for-heap-trace-records' into 'master'
heap: fix Leaks perf on large records by using doubly linked list

Closes IDFGH-9121 and IDF-1244

See merge request espressif/esp-idf!22009
2023-02-15 15:14:19 +08:00
Cao Sen Miao
fd3e0b0b18 esp32h2(ci): enable target test 2023-02-15 10:20:43 +08:00
Guillaume Souchere
2cf9236f6c heap trace standalone: Fix initialization of the unused linked list, update tests
- Call TAILQ_INSERT_TAIL in linked_list_setup to add unused records from the tail of the list
- Fix test "heap trace leak check" to expect that after a free, the record is zeroed instead of checking that
  the whole list of records is moved by one index in the array.
- Use esp_rom_printf() under lock instead of printf() since it does not rely on interrupts.
2023-02-14 09:48:14 +01:00
Marius Vikhammer
25abc7f6d8 ci: update idf-core related tests for C6 2023-02-13 13:01:57 +08:00
Guillaume Souchere
ba1d7f8d1c heap: Fix erroneous value returned by heap_caps_get_allocated_size() when poisoning is enabled
When light (or comprehensive) poisoning is enabled, the size requested by the user for allocation
is extended by a few bytes to store the canary header and footer. heap_caps_get_allocated_size() should
return the original size asked by the user (without the additional canary bytes).

test_malloc.c extended with a new test assuring that  heap_caps_get_allocated_size() returns the proper size
regardless of the degree of poisoning.
2023-02-01 10:04:38 +01:00
Guillaume Souchere
6382f28998 heap: Modify the memory type of the memory used as startup stack when memory protection is enabled
If memory protection is enabled on esp32c3 and esp32s3, we don't want to the heap component to see
the startup stack memory as D/IRAM but as DRAM only. Introduce a new type to make this possible in
the same fashion the regular D/IRAM regions are handled.
2023-01-26 10:52:34 +01:00
Guillaume Souchere
11f99ef649 heap: Add memory protection activation test
Check that when trying to allocate in IRAM with the system memory protection enabled,
null pointer is returned, or that an address in IRAM is returned if the memory protection
is disabled.
2023-01-25 07:20:57 +01:00
Cao Sen Miao
94120b82c2 esp32h2: add build test 2023-01-17 10:29:04 +08:00
Guillaume Souchere
b5bacffbd3 esp_hw_support: allow writing in IRAM when CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT is not set for esp32C2
when CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT is not set, the PMP rule for esp32c2 shoud allow write access.
Fix esp_cpu_configure_region_protection() in cpu.c accordingly.
2023-01-02 08:41:16 +01:00
Guillaume Souchere
a218139d25 heap: RE-enable ESP32C2 test in test_apps 2023-01-02 08:40:59 +01:00
Guillaume Souchere
a74ae7fba7 Merge branch 'feature/heap-trace-improve-spi-ram-support' into 'master'
heap_trace: improvements to formatting, code, comments of heap trace standalone

Closes IDFGH-8699

See merge request espressif/esp-idf!21506
2022-12-28 15:07:30 +08:00
Guillaume Souchere
89c0a259ee heap-trace: Add missing tests for heap_trace_summary() and heap_trace_dump_caps()
Note: the checks for the tests marked as [test-dump] are done in the pytest function
test_heap_trace_dump() since they are relying on the content of the heap_trace_dump_caps()
output.
2022-12-27 10:24:14 +01:00
Guillaume Souchere
4d16f46a88 esp_system: fix placement of __stack_chk_fail from flash to RAM
When stack check is enabled, certain functions (sometimes placed in RAM)
are being decorated with stack guards and a call to __stask_chk_fail() in
case ofr stack corruption. For this reason, __stack_chk_fail() must be
placed in RAM too.

Add stack check config in heap tests on all targets to find eventual flash to RAM
calls due to stack checks when running callgraph_check.py
2022-12-07 08:49:12 +01:00
Song Ruo Jing
1575b9e43a ci: Disable all currently failed target tests for esp32c6 2022-11-28 12:09:08 +08:00
Guillaume Souchere
ab1bd08ab9 tools: update list of references to not include symbold used by __assert_func calls
On xtensa architecture, the call to __assert_func uses a reference to __func__ that can
sometimes be placed in flash. Since the __asert_func can be called from functions in IRAM
the check_callgraph script can report an error when checking for invalid calls from IRAM
to flash sections. However, the __asert_func prevents this scenario at runtime so the
check_callgraph script reports a 'flas positive' situation. For this reasson, all references
to __func__$x found prior to a call to __assert_func are droped in the parsing of the rtl files.
2022-11-24 10:31:14 +01:00
Guillaume Souchere
0376e6ec79 heap: add check for usage of flash content from iram
this commits:
- adds build-time test to check that no call to flash regions are done from IRAM functions

- resolves problems related to IRAM function using content in flash memory

- update heap_caps_alloc_failed to use a default function name in DRAM
  when necessary instead of creating a function name variable in DRAM for
  each call of heap_caps_alloc_failed. This allows to save some extra bytes
  in RAM.
2022-11-24 10:31:14 +01:00
Song Ruo Jing
be0fdfa176 soc: Add a soc cap, SOC_CLK_RC_FAST_D256_SUPPORTED, for whether the target has the RC_FAST_D256 clock 2022-11-01 11:23:26 +08:00
Guillaume Souchere
6f11d0f297 heap: Update target and host tests after incorporation of the new TLSF implementation
- update the target and host tests to consider the new TLSF api and the metadata size
  only when the target is not using the rom implementation of the TLSF
2022-10-26 18:15:40 +02:00
Ivan Grokhotkov
7e2f261a58
freertos, app_trace, heap: use esp_cpu_get_cycle_count to get ccount
portGET_RUN_TIME_COUNTER_VALUE should only be used in the kernel.
2022-10-12 11:20:55 +02:00
Guillaume Souchere
cd805a5ab1 heap: Fix memory boundary condition checks when adding new region
Previously, condition_4 was making impossible the valid scenario
start > heap_start && end == heap_end.

Now, the end == heap_end and start == heap_start case is handled
separately allowing the case start > heap_start && ned == heap_end
to be considered a valid scenario
2022-10-07 13:22:30 +02:00
Guillaume Souchere
2b5a844640 heap: fix the boundary checks when adding a new region 2022-10-05 15:08:21 +02:00
Guillaume Souchere
2cce5e98b1 heap: add dynamic poisoning threshold in pytest env to allow test with known memory leak to pass 2022-10-05 15:07:37 +02:00
Guillaume Souchere
a29627f59d heap: fix the size of buffers in ignored tests
the ignored tests are updated with the minimum required buffer size to create
a new heap using the tlsf heap callocator.
2022-10-05 15:07:06 +02:00
Marius Vikhammer
1327a82b65 heap: fix random alloc test timing out in CI 2022-09-27 16:51:54 +08:00
Guillaume Souchere
bf18a05a5f unit-tests: Move the leak related tests from the heap component to test_utils 2022-09-23 09:49:09 +02:00
Guillaume Souchere
82c98c7f48 heap: Add test_apps configs 2022-09-23 09:49:09 +02:00
Guillaume Souchere
405c26da6d heap: migrate unit tests to pytest 2022-09-23 09:49:07 +02:00