mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
mm: Enable a dedicated kernel heap on BUILD_FLAT via MM_KERNEL_HEAP
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
committed by
Xiang Xiao
parent
047f7f8d3a
commit
a3e253b4a3
@@ -644,6 +644,9 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
|
|||||||
* as determined by CONFIG_MM_KERNEL_HEAP=y. This function allocates (and
|
* as determined by CONFIG_MM_KERNEL_HEAP=y. This function allocates (and
|
||||||
* protects) the kernel-space heap.
|
* protects) the kernel-space heap.
|
||||||
*
|
*
|
||||||
|
* For Flat build (CONFIG_BUILD_FLAT=y), this function enables a separate
|
||||||
|
* (although unprotected) heap for the kernel.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_MM_KERNEL_HEAP
|
#ifdef CONFIG_MM_KERNEL_HEAP
|
||||||
|
|||||||
@@ -86,11 +86,17 @@
|
|||||||
# define MM_KERNEL_USRHEAP_INIT 1
|
# define MM_KERNEL_USRHEAP_INIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The kernel heap is never accessible from user code */
|
/* When building the Userspace image under CONFIG_BUILD_KERNEL or
|
||||||
|
* CONFIG_BUILD_PROTECTED (i.e. !defined(__KERNEL__)), CONFIG_MM_KERNEL_HEAP
|
||||||
|
* must be undefined to ensure the kernel heap is never accessible from user
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_BUILD_KERNEL) || defined(CONFIG_BUILD_PROTECTED)
|
||||||
# ifndef __KERNEL__
|
# ifndef __KERNEL__
|
||||||
# undef CONFIG_MM_KERNEL_HEAP
|
# undef CONFIG_MM_KERNEL_HEAP
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
|
|||||||
+17
-9
@@ -26,16 +26,24 @@ config MM_CUSTOMIZE_MANAGER
|
|||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config MM_KERNEL_HEAP
|
config MM_KERNEL_HEAP
|
||||||
bool "Support a protected, kernel heap"
|
bool "Kernel dedicated heap"
|
||||||
default y
|
default n if BUILD_FLAT
|
||||||
depends on !BUILD_FLAT
|
default y if BUILD_PROTECTED || BUILD_KERNEL
|
||||||
---help---
|
---help---
|
||||||
Partition heap memory into two parts: (1) a protected, kernel-mode
|
Under Flat build, this option will enable a separate heap for the kernel.
|
||||||
heap accessible only by the NuttX kernel, and (2) an unprotected
|
By separating the kernel and userspace heaps, the user is granted more
|
||||||
user-mode heap for use by applications. If you are only interested
|
control over the heaps placement within the memory hierarchy, which is
|
||||||
in protected the kernel from read access, then this option is not
|
specially useful for microcontrollers that provide External RAM.
|
||||||
necessary. If you wish to secure the kernel data as well, then
|
Besides segregating the kernel and userspace allocations, this feature
|
||||||
this option should be selected.
|
does not prevent the userspace from accessing the kernel heap.
|
||||||
|
|
||||||
|
As for Protected and Kernel builds, this feature partitions heap memory
|
||||||
|
into two parts:
|
||||||
|
(1) a protected, kernel-mode heap accessible only by the NuttX kernel,
|
||||||
|
and (2) an unprotected user-mode heap for use by applications.
|
||||||
|
If you are only interested in protecting the kernel from read access,
|
||||||
|
then this option is not necessary. If you wish to secure the kernel data
|
||||||
|
as well, then this option should be selected.
|
||||||
|
|
||||||
The kernel heap size that is used is provided a a platform-specific
|
The kernel heap size that is used is provided a a platform-specific
|
||||||
up_allocate_kheap() interface. This configuration setting is made
|
up_allocate_kheap() interface. This configuration setting is made
|
||||||
|
|||||||
@@ -43,8 +43,10 @@
|
|||||||
*
|
*
|
||||||
* CONFIG_BUILD_FLAT:
|
* CONFIG_BUILD_FLAT:
|
||||||
* There is only kernel mode "blob" containing both kernel and
|
* There is only kernel mode "blob" containing both kernel and
|
||||||
* application code. There is only one heap that is used by both the
|
* application code. Depending upon the setting of CONFIG_MM_KERNEL_HEAP
|
||||||
* kernel and application logic.
|
* there may be a single shared heap (used by both the kernel and
|
||||||
|
* application logic) or there may be separate (although unprotected)
|
||||||
|
* kernel and user heaps.
|
||||||
*
|
*
|
||||||
* In this configuration, this function is called early in nx_start()
|
* In this configuration, this function is called early in nx_start()
|
||||||
* to initialize the common heap.
|
* to initialize the common heap.
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ ifeq ($(CONFIG_BINFMT_LOADABLE),y)
|
|||||||
CSRCS += group_exitinfo.c
|
CSRCS += group_exitinfo.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_BUILD_FLAT),y)
|
ifeq ($(CONFIG_MM_KERNEL_HEAP),y)
|
||||||
CSRCS += group_malloc.c group_realloc.c group_zalloc.c group_free.c
|
CSRCS += group_malloc.c group_realloc.c group_zalloc.c group_free.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user