genode/repos/base/include
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
..
base Make Session_object::warning const 2024-02-26 08:31:03 +01:00
cpu base: provide generic cpu/string.h 2023-01-24 12:07:28 +01:00
cpu_session base: make RPC framework compatible to C++20 2023-05-30 12:03:29 +02:00
cpu_thread base: remove deprecated cancel_blocking() support 2020-07-13 11:33:12 +02:00
dataspace Consistent spelling of "writeable" 2022-02-15 10:23:58 +01:00
drivers mmio: upper-bounds checks 2024-02-26 08:59:07 +01:00
io_mem_session base: make RPC framework compatible to C++20 2023-05-30 12:03:29 +02:00
io_port_session base: make RPC framework compatible to C++20 2023-05-30 12:03:29 +02:00
irq_session base: add irq_type session argument 2023-11-28 19:35:16 +01:00
log_session base: make RPC framework compatible to C++20 2023-05-30 12:03:29 +02:00
parent base: mark Parent::Close_result with [[nodiscard]] 2020-01-03 14:44:15 +01:00
pd_session base: extend PD session by system_control_cap 2023-10-04 13:22:07 +02:00
region_map base: stricter distinction between rx and rwx 2023-06-16 11:24:26 +02:00
rm_session Remove format strings from connection types 2023-03-13 14:32:37 +01:00
rom_session base: make RPC framework compatible to C++20 2023-05-30 12:03:29 +02:00
root Replace Genode::strncpy by Genode::copy_cstring 2020-05-27 11:56:45 +02:00
session Streamline exception types 2017-05-31 13:16:07 +02:00
spec mmio: upper-bounds checks 2024-02-26 08:59:07 +01:00
timer nic_router: avoid marginal timeout updates 2022-08-10 13:33:02 +02:00
timer_session timer-session: decrease min timeout to 1 ms 2023-09-29 12:17:45 +02:00
trace trace: add GENODE_TRACE_CHECKPOINT macros 2022-08-17 11:54:19 +02:00
trace_session trace: remove parent_levels session argument 2023-12-13 12:28:52 +01:00
util mmio: upper-bounds checks 2024-02-26 08:59:07 +01:00
vm_session base: rework vmm library API 2023-10-04 13:22:03 +02:00