mmu: add CONFIG_SRAM_REGION_PERMISSIONS

If CONFIG_MMU is active, choose whether to separate text,
rodata, and ram into their own page-aligned regions so that
they have have different MMU permissions applied.

If disabled, all RAM pages will have RWX permission to
supervisor mode, but some memory may be saved due to lack
of page alignment padding between these regions.

This used to always happen. This patch adds the Kconfig,
linker script changes to come in a subsequent patch.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-07-08 21:21:10 -07:00 committed by Anas Nashif
parent fd07e2557d
commit 88ddce652c

View file

@ -208,6 +208,7 @@ config USERSPACE
bool "User mode threads"
depends on ARCH_HAS_USERSPACE
depends on RUNTIME_ERROR_CHECKS
select SRAM_REGION_PERMISSIONS if MMU
help
When enabled, threads may be created or dropped down to user mode,
which has significantly restricted permissions and must interact
@ -507,6 +508,17 @@ config MMU_PAGE_SIZE
Size of memory pages. Varies per MMU but 4K is common. For MMUs that
support multiple page sizes, put the smallest one here.
config SRAM_REGION_PERMISSIONS
bool "Assign appropriate permissions to kernel areas in SRAM"
depends on MMU
default y
help
If enabled, the program text, rodata, and data parts of the kernel in
the permanent mappings created at build time will have appropriate
permissions set. Uses extra memory due to page-alignment constraints.
If not enabled, all SRAM mappings will allow supervisor mode to
read, write, and execute. User mode support requires this.
config MEMORY_PROTECTION
bool
help