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:
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
|
||||
* 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
|
||||
|
|
|
@ -86,10 +86,16 @@
|
|||
# define MM_KERNEL_USRHEAP_INIT 1
|
||||
#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.
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
# undef CONFIG_MM_KERNEL_HEAP
|
||||
#if defined(CONFIG_BUILD_KERNEL) || defined(CONFIG_BUILD_PROTECTED)
|
||||
# ifndef __KERNEL__
|
||||
# undef CONFIG_MM_KERNEL_HEAP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
|
26
mm/Kconfig
26
mm/Kconfig
|
@ -26,16 +26,24 @@ config MM_CUSTOMIZE_MANAGER
|
|||
endchoice
|
||||
|
||||
config MM_KERNEL_HEAP
|
||||
bool "Support a protected, kernel heap"
|
||||
default y
|
||||
depends on !BUILD_FLAT
|
||||
bool "Kernel dedicated heap"
|
||||
default n if BUILD_FLAT
|
||||
default y if BUILD_PROTECTED || BUILD_KERNEL
|
||||
---help---
|
||||
Partition 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 protected 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.
|
||||
Under Flat build, this option will enable a separate heap for the kernel.
|
||||
By separating the kernel and userspace heaps, the user is granted more
|
||||
control over the heaps placement within the memory hierarchy, which is
|
||||
specially useful for microcontrollers that provide External RAM.
|
||||
Besides segregating the kernel and userspace allocations, this feature
|
||||
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
|
||||
up_allocate_kheap() interface. This configuration setting is made
|
||||
|
|
|
@ -43,8 +43,10 @@
|
|||
*
|
||||
* CONFIG_BUILD_FLAT:
|
||||
* There is only kernel mode "blob" containing both kernel and
|
||||
* application code. There is only one heap that is used by both the
|
||||
* kernel and application logic.
|
||||
* application code. Depending upon the setting of CONFIG_MM_KERNEL_HEAP
|
||||
* 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()
|
||||
* to initialize the common heap.
|
||||
|
|
|
@ -48,7 +48,7 @@ ifeq ($(CONFIG_BINFMT_LOADABLE),y)
|
|||
CSRCS += group_exitinfo.c
|
||||
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
|
||||
endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue