-
Notifications
You must be signed in to change notification settings - Fork 2.1k
pkg/xipfs: add MPU memory isolation to file execution #21760
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
base: master
Are you sure you want to change the base?
Changes from 9 commits
d23267a
2033f34
4c0d1ca
b6aba1e
664951f
bbb4169
b94cafe
06a9a6e
b2512ed
9a78b70
451bd5a
5b86137
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
| extern "C" { | ||
| #endif | ||
|
|
||
| #define THREAD_API_INLINED | ||
|
|
||
| #ifndef DOXYGEN /* Doxygen is in core/include/thread.h */ | ||
|
|
||
|
|
@@ -38,6 +38,62 @@ | |
|
|
||
| #endif /* DOXYGEN */ | ||
|
|
||
| /** | ||
| * @brief All svc dispatch handlers have this type. | ||
| */ | ||
| typedef int (*svc_dispatch_handler_t)( | ||
| unsigned int svc_number, unsigned int *svc_args); | ||
|
|
||
| #ifdef NDEBUG | ||
|
|
||
| # define assert_svc_dispatch_manage_handler() do {} while (0) | ||
|
|
||
| #else | ||
|
|
||
| /** | ||
| * @brief Last file that asserted svc dispatch handler was free. | ||
| */ | ||
| extern const char *_free_svc_dispatch_handler_last_file; | ||
|
|
||
| /** | ||
| * @brief Asserts that SVC dispatch handler is free. | ||
| * | ||
| * @param file Calling file. | ||
| * @param line Line in calling file. | ||
GGuche-2XS-Univ-Lille marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * @see assert_free_svc_dispatch_handler | ||
| */ | ||
| void assert_free_svc_dispatch_handler_ex(const char *file, int line); | ||
|
|
||
| /** | ||
| * @brief Asserts that SVC dispatch handler is free. | ||
| * | ||
| * To be used in files using set_memory_manage_handler. | ||
| * | ||
| * @see set_svc_dispatch_handler | ||
| * @see assert_free_svc_dispatch_handler_ex | ||
| */ | ||
| #define assert_free_svc_dispatch_handler() \ | ||
| assert_free_svc_dispatch_handler_ex(__FILE__, __LINE__); \ | ||
| _free_svc_dispatch_handler_last_file = __FILE__ | ||
|
|
||
| #endif /* NDEBUG */ | ||
|
|
||
| /** | ||
| * @brief SVC dispatch handler setter. | ||
| * | ||
| * @param handler Handler to set | ||
| * | ||
| * @retval < 0 on NULL handler or if a handler has already been set | ||
| * @retval >= 0 otherwise | ||
| */ | ||
| int set_svc_dispatch_handler(svc_dispatch_handler_t handler); | ||
|
||
|
|
||
| /** | ||
| * @brief SVC dispatch handler cleaner. | ||
| */ | ||
| void remove_svc_dispatch_handler(void); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,7 +75,7 @@ | |
| /** | ||
| * @brief Allocation of the interrupt stack | ||
| */ | ||
| __attribute__((used,section(".isr_stack"))) uint8_t isr_stack[ISR_STACKSIZE]; | ||
|
|
||
| /** | ||
| * @brief Pre-start routine for CPU-specific settings | ||
|
|
@@ -472,8 +472,49 @@ | |
| #if defined(CPU_CORE_CORTEX_M3) || defined(CPU_CORE_CORTEX_M33) || \ | ||
| defined(CPU_CORE_CORTEX_M4) || defined(CPU_CORE_CORTEX_M4F) || \ | ||
| defined(CPU_CORE_CORTEX_M7) | ||
|
|
||
| static mem_manage_handler_t _mem_manage_handler = NULL; | ||
|
|
||
| #ifndef NDEBUG | ||
| const char *_free_mem_manage_handler_last_file = NULL; | ||
|
|
||
| void assert_free_mem_manage_handler_ex(const char *file, int line) { | ||
GGuche-2XS-Univ-Lille marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (_mem_manage_handler != NULL) { | ||
| printf( "Memory manage handler is not free : assertion from " | ||
| "file %s at line %d, previously from file %s\n", | ||
| file, line, | ||
| _free_mem_manage_handler_last_file); | ||
|
|
||
| for (;;) {} | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
| int set_memory_manage_handler(mem_manage_handler_t handler) { | ||
GGuche-2XS-Univ-Lille marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (handler == NULL) { | ||
| return -1; | ||
| } | ||
| if (_mem_manage_handler != NULL) { | ||
| return -1; | ||
| } | ||
| _mem_manage_handler = handler; | ||
| return 0; | ||
| } | ||
|
|
||
| void remove_memory_manage_handler(void) { | ||
GGuche-2XS-Univ-Lille marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| _mem_manage_handler = NULL; | ||
| #ifndef NDEBUG | ||
| _free_mem_manage_handler_last_file = NULL; | ||
| #endif | ||
| } | ||
|
|
||
| void mem_manage_default(void) | ||
| { | ||
| if (_mem_manage_handler != NULL) { | ||
| if (_mem_manage_handler() == 1) | ||
| return; | ||
GGuche-2XS-Univ-Lille marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| core_panic(PANIC_MEM_MANAGE, "MEM MANAGE HANDLER"); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,5 @@ | ||
| BOARD_INSUFFICIENT_MEMORY := \ | ||
| blackpill-stm32f103c8 \ | ||
| bluepill-stm32f030c8 \ | ||
| bluepill-stm32f103c8 \ | ||
| i-nucleo-lrwan1 \ | ||
| nucleo-c031c6 \ | ||
| nucleo-f030r8 \ | ||
| nucleo-f031k6 \ | ||
| nucleo-f042k6 \ | ||
| nucleo-f302r8 \ | ||
| nucleo-f303k8 \ | ||
| nucleo-f334r8 \ | ||
| nucleo-l011k4 \ | ||
| nucleo-l031k6 \ | ||
| nucleo-l053r8 \ | ||
| samd10-xmini \ | ||
| slstk3400a \ | ||
| stk3200 \ | ||
| stm32f030f4-demo \ | ||
| stm32f0discovery \ | ||
| stm32g0316-disco \ | ||
| stm32l0538-disco \ | ||
| weact-g030f6 \ | ||
| e104-bt5010a-tb \ | ||
| e104-bt5011a-tb \ | ||
| im880b \ | ||
| # |
Uh oh!
There was an error while loading. Please reload this page.