nuttx/mm/Kconfig
Ville Juven 0476e30a6d mm/kmm_map: Add support to dynamically map pages into kernel virtual memory
This adds functionality to map pages dynamically into kernel virtual
memory. This allows implementing I/O remap for example, which is a useful
(future) feature.

Now, the first target is to support mapping user pages for the kernel.

Why? There are some userspace structures that might be needed when the
userspace process is not running. Semaphores are one such example. Signals
and the WDT timeout both need access to the user semaphore to work
properly. Even though for this only obtaining the kernel addressable
page pool virtual address is needed, for completeness a procedure is
provided to map several pages.
2023-06-02 10:50:26 +08:00

322 lines
9.9 KiB
Plaintext

#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
choice
prompt "Build heap manager"
default MM_DEFAULT_MANAGER
config MM_DEFAULT_MANAGER
bool "Default heap manager"
---help---
NuttX original memory manager strategy.
config MM_TLSF_MANAGER
bool "TLSF heap manager"
---help---
TLSF memory manager strategy.
config MM_CUSTOMIZE_MANAGER
bool "Customized heap manager"
---help---
Customized memory manager policy. The build will fail
if the MM heap module not defined by customer.
endchoice
config MM_KERNEL_HEAP
bool "Kernel dedicated heap"
default n if BUILD_FLAT
default y if BUILD_PROTECTED || BUILD_KERNEL
---help---
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
available to that platform specific code. However, the
up_allocate_kheap() interface may chose to ignore this setting if it
has a more appropriate heap allocation strategy.
config MM_KERNEL_HEAPSIZE
int "Kernel heap size"
default 8192
depends on MM_KERNEL_HEAP
---help---
This is the size of the a protected, kernel-mode heap (in bytes).
The remaining of available memory is given to the unprotected
user-mode heap. This value may need to be aligned to units of the
size of the smallest memory protection region.
config MM_DFAULT_ALIGNMENT
int "Memory default alignment in bytes"
default 0
range 0 64
---help---
The memory default alignment in bytes, if this value is 0, the real
memory default alignment is equal to sizoef(uintptr), if this value
is not 0, this value must be 2^n and at least sizeof(uintptr).
config MM_SMALL
bool "Small memory model"
default n
depends on MM_DEFAULT_MANAGER
---help---
Each memory allocation has a small allocation overhead. The size
of that overhead is normally determined by the "width" of the
address support by the MCU. MCUs that support 16-bit addressability
have smaller overhead than devices that support 32-bit addressability.
However, there are many MCUs that support 32-bit addressability *but*
have internal SRAM of size less than or equal to 64Kb. In this case,
MM_SMALL can be defined so that those MCUs will also benefit
from the smaller, 16-bit-based allocation overhead.
WARNING: This selection will also change the alignment of allocated
memory. For example, on ARM memory will have 8-byte alignment by
default. If MM_SMALL is selected, then allocated memory will have
only 4-byte alignment. This may be important on some platforms where
64-bit data is in allocated structures and 8-byte alignment is required.
config MM_REGIONS
int "Number of memory regions"
default 1
---help---
If the architecture includes multiple, non-contiguous regions of
memory to allocate from, this specifies the number of memory regions
that the memory manager must handle and enables the API
mm_addregion(heap, start, end);
config ARCH_HAVE_HEAP2
bool
default n
if ARCH_HAVE_HEAP2
config HEAP2_BASE
hex "Start address of second user heap region"
default 0x00000000
---help---
The base address of the second heap region.
config HEAP2_SIZE
int "Size of the second user heap region"
default 0
---help---
The size of the second heap region.
endif # ARCH_HAVE_HEAP2
config GRAN
bool "Enable Granule Allocator"
default n
---help---
Enable granule allocator support. Allocations will be aligned to the
granule size; allocations will be in units of the granule size.
Larger granules will give better performance and less overhead but
more losses of memory due to alignment and quantization waste.
NOTE: The current implementation also restricts the maximum
allocation size to 32 granules. That restriction could be
eliminated with some additional coding effort.
config GRAN_INTR
bool "Interrupt level support"
default n
depends on GRAN
---help---
Normally mutual exclusive access to granule allocator data is assured
using a semaphore. If this option is set then, instead, mutual
exclusion logic will disable interrupts. While this options is more
invasive to system performance, it will also support use of the granule
allocator from interrupt level logic.
config DEBUG_GRAN
bool "Granule Allocator Debug"
default n
depends on GRAN && DEBUG_FEATURES
---help---
Just like DEBUG_MM, but only generates output from the gran
allocation logic.
config MM_PGALLOC
bool "Enable Page Allocator"
default n
depends on ARCH_USE_MMU
select GRAN
---help---
Enable support for a MMU physical page allocator based on the
granule allocator.
if MM_PGALLOC
config MM_PGSIZE
int "Page Size"
default 4096
---help---
The MMU page size. Must be one of {1024, 2048, 4096, 8192, or
16384}. This is easily extensible, but only those values are
currently support.
config DEBUG_PGALLOC
bool "Page Allocator Debug"
default n
depends on DEBUG_FEATURES
---help---
Just like DEBUG_MM, but only generates output from the page
allocation logic.
endif # MM_PGALLOC
config MM_SHM
bool "Shared memory support"
default n
depends on MM_PGALLOC && BUILD_KERNEL
select ARCH_VMA_MAPPING
---help---
Build in support for the shared memory interfaces shmget(), shmat(),
shmctl(), and shmdt().
config MM_KMAP
bool "Support for dynamic kernel virtual mappings"
default n
depends on MM_PGALLOC && BUILD_KERNEL
select ARCH_VMA_MAPPING
---help---
Build support for dynamically mapping pages from the page pool into
kernel virtual memory. This includes pages that are already mapped
for user.
config MM_HEAP_MEMPOOL_THRESHOLD
int "The size of threshold to avoid using multiple mempool in heap"
default 0
---help---
If the size of the memory requested by the user is less
than the threshold, the memory will be requested from the
multiple mempool by default.
config MM_HEAP_MEMPOOL_EXPAND
int "The expand size for each mempool in multiple mempool"
default 4096
depends on MM_HEAP_MEMPOOL_THRESHOLD != 0
---help---
This size describes the size of each expansion of each memory
pool with insufficient memory in the multi-level memory pool.
config MM_HEAP_MEMPOOL_DICTIONARY_EXPAND
int "The expand size for multiple mempool's dictonary"
default MM_HEAP_MEMPOOL_EXPAND
depends on MM_HEAP_MEMPOOL_THRESHOLD != 0
---help---
This size describes the multiple mempool dictonary expend.
config FS_PROCFS_EXCLUDE_MEMPOOL
bool "Exclude mempool"
default DEFAULT_SMALL
depends on FS_PROCFS
config MM_KASAN
bool "Kernel Address Sanitizer"
default n
---help---
KASan is a fast compiler-based tool for detecting memory
bugs in native code. After turn on this option, Please
add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too.
config MM_KASAN_ALL
bool "Enable KASan for the entire image"
depends on MM_KASAN
default y
---help---
This option activates address sanitizer for the entire image.
If you don't enable this option, you have to explicitly specify
"-fsanitize=kernel-address" for the files/directories you want
to check. Enabling this option will get image size increased
and performance decreased significantly.
config MM_UBSAN
bool "Undefined Behavior Sanitizer"
default n
---help---
UBSan is a fast undefined behavior detector. UBSan modifies
the program at compile-time to catch various kinds of
undefined behavior during program execution
config MM_UBSAN_ALL
bool "Enable UBSan for the entire image"
depends on MM_UBSAN
default y
---help---
This option activates UBSan instrumentation for the
entire image. If you don't enable this option, you have to
explicitly specify "-fsanitize=undefined" for
the files/directories you want to check. Enabling this option
will get image size increased and performance decreased
significantly.
config MM_UBSAN_OPTION
string "UBSan options"
depends on MM_UBSAN
default "-fsanitize=undefined"
---help---
This option activates specified UBSan instrumentation. Please
refer to https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
for available options.
config MM_UBSAN_TRAP_ON_ERROR
bool "Enable UBSan trap on error to crash immediately"
depends on MM_UBSAN
default n
---help---
The undefined instruction trap should cause your program to crash,
save the code space significantly.
config MM_FILL_ALLOCATIONS
bool "Fill allocations with debug value"
default n
---help---
Fill all malloc() allocations with 0xAA. This helps
detecting uninitialized variable errors.
config MM_BACKTRACE
int "The depth of backtrace"
default -1
---help---
Config the depth of backtrace in memory block by specified this
config: disable backtrace by -1, only record pid info by zero and
enable record backtrace info by 8(fixed depth).
config MM_BACKTRACE_DEFAULT
bool "Enable the backtrace record by default"
default n
depends on MM_BACKTRACE > 0
config MM_DUMP_ON_FAILURE
bool "Dump heap info on allocation failure"
default n
depends on DEBUG_MM
config MM_DUMP_DETAILS_ON_FAILURE
bool "Dump all used memory blocks on allocation failure"
default n
depends on MM_DUMP_ON_FAILURE
config MM_PANIC_ON_FAILURE
bool "Panic on allocation failure"
default n
depends on DEBUG_MM
source "mm/iob/Kconfig"