genode/repos/base/include/util
Martin Stein 1336b0a751 mmio: upper-bounds checks
The classes Genode::Mmio, Genode::Register_set, Genode::Attached_mmio, and
Platform::Device::Mmio now receive a template parameter 'size_t SIZE'. In each
type that derives from one of these classes, it is now statically checked that
the range of each Genode::Register::Register- and
Genode::Register_set::Register_array-deriving sub-type is within [0..SIZE).

That said, SIZE is the minimum size of the memory region provided to the above
mentioned Mmio classes in order to avoid page faults or memory corruption when
accessing the registers and register arrays declared inside.

Note, that the range end of a register array is not the end of the last item
but the end of integer access that is used for accessing the last bit in the
last item.

The constructors of Genode::Mmio, Genode::Attached_mmio, and
Platform::Device::Mmio now receive an argument 'Byte_range_ptr range' that is
expected to be the range of the backing memory region. In each type that derives
from on of these classes, it is now dynamically checked that 'range.num_bytes
>= SIZE', thereby implementing the above mention protection against page faults
and memory corruption.

The rest of the commit adapts the code throughout the Genode Labs repositories
regarding the changes. Note that for that code inside Core, the commits mostly
uses a simplified approach by constructing MMIO objects with range
[base..base+SIZE) and not with a mapping- or specification-related range size.
This should be fixed in the future.

Furthermore, there are types that derive from an MMIO class but don't declare
any registers or register arrays (especially with Platform::Device::Mmio). In
this case SIZE is set to 0. This way, the parameters must be actively corrected
by someone who later wants to add registers or register arrays, plus the places
can be easily found by grep'ing for Mmio<0>.

Fix #4081
2024-02-26 08:59:07 +01:00
..
arg_string.h base: remove internal use of format strings 2023-03-13 14:32:38 +01:00
array.h Allow derived classes of Genode::Array 2022-02-15 10:10:01 +01:00
attempt.h base: pass lambdas by reference in util/attempt.h 2022-02-15 10:16:51 +01:00
avl_tree.h Add missing override annotations 2019-02-19 11:12:11 +01:00
bit_allocator.h util/bit_array.h: remove use of memset and memcpy 2020-05-05 13:30:15 +02:00
bit_array.h util/bit_array.h: remove use of memset and memcpy 2020-05-05 13:30:15 +02:00
construct_at.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
dictionary.h util/dictionary.h: alphabetically sorted for_each 2023-01-24 12:07:31 +01:00
fifo.h base: make 'Fifo::Element::enqueued' const 2019-11-19 14:54:13 +01:00
flex_iterator.h base: avoid warnings about shift operations 2018-11-16 14:37:18 +01:00
interface.h Follow practices suggested by "Effective C++" 2018-01-17 12:14:35 +01:00
list_model.h list_model.h: rename 'apply_first' to 'with_first' 2023-11-28 14:24:24 +01:00
list.h base: Make Genode::List clang friendly. 2021-01-25 13:58:10 +01:00
meta.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
misc_math.h util/misc_math.h: remove abs function 2023-02-27 08:22:49 +01:00
mmio.h mmio: upper-bounds checks 2024-02-26 08:59:07 +01:00
noncopyable.h base: cleanup Noncopyable declarations/coding style 2021-02-23 11:51:57 +01:00
print_lines.h base: print last character of unterminated strings 2023-08-24 14:12:21 +02:00
reconstructible.h reconstructible: Fix alignas specifier placement. 2021-10-15 15:45:52 +02:00
register_set.h mmio: upper-bounds checks 2024-02-26 08:59:07 +01:00
register.h register framework: read bitfields to fitting uint 2023-07-14 12:01:18 +02:00
retry.h Genode::retry(): fix compile error with GCC 6 2017-05-31 13:15:50 +02:00
string.h util/string.h: add Const_byte_range_ptr::contains() 2023-12-15 14:11:56 +01:00
token.h base: extend constness of Genode::Token 2023-11-28 14:24:24 +01:00
touch.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
xml_generator.h base: remove internal use of format strings 2023-03-13 14:32:38 +01:00
xml_node.h xml_node: skip whitespace in differs_from 2023-10-25 08:58:53 +02:00