zephyr/misc/debug/Kconfig
Benjamin Walsh 760f191b1e debug: add safe memory access routines
Introduces the following routines to provide safe access to memory:
   _mem_probe()
   _mem_safe_read()
   _mem_safe_write()
   _mem_safe_write_to_text_section()
Those routines will return an error if the memory is not accessible rather
than potentially crash.

This implementation is based on the image's boundaries; thus it allows
read/write access to the data/bss/init sections and read access only to
the text/rodata sections.  All other memory is considered invalid, even
if addressable. This includes the leftover from the RAM at the end of
the image, since there is no support for using it (e.g. there is no
dynamic allocator).

Change-Id: I6093688ecfd9b00d61be0fd453ada7bb8915c897
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:42 -05:00

65 lines
2.0 KiB
Plaintext

# Kconfig - debug configuration options
#
# Copyright (c) 2015 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
menu "Safe memory access"
config MEM_SAFE
bool
prompt "Enable safe memory access"
default n
help
Add the routines available in mem_safe.h to the system. This is added as a
kconfig option instead of simply linking against the library because some
implementations might require initialization.
choice
prompt "Safe memory access implementation"
default MEM_SAFE_CHECK_BOUNDARIES
config MEM_SAFE_CHECK_BOUNDARIES
bool
prompt "Software validation of memory access within memory regions"
help
This implementation checks the application image's text/rodata boundaries
for its read-only region and the data/bss/noinit boundaries for its
read-write region, in software.
Other regions can be added as needed by using the sys_mem_safe_region_add()
API. The number of regions that can be added is controlled via the
MEM_SAFE_NUM_REGIONS kconfig option.
This implementation requires initialization and thus consumes some boot
time.
endchoice
config MEM_SAFE_NUM_EXTRA_REGIONS
int
prompt "Number of safe memory access regions that can be added at runtime"
depends on MEM_SAFE_CHECK_BOUNDARIES
default 0
help
The functions available in mem_safe.h check if memory is within read-only
or read-write regions before accessing it instead of crashing. The kernel
image is added as a valid region automatically, but other regions can be
added if the application makes access to additional memory outside of the
image's boundaries.
endmenu