genode/repos/dde_bsd/src/lib/audio
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
..
include dde_bsd: update audio driver to OpenBSD 7.3 2023-05-30 12:03:26 +02:00
spec Introduce 'spec' subdirectories to outline aspects 2015-09-16 13:58:50 +02:00
bsd_emul_pci.c dde_bsd: update audio driver to OpenBSD 7.3 2023-05-30 12:03:26 +02:00
bsd_emul.c dde_bsd: update audio driver to OpenBSD 7.3 2023-05-30 12:03:26 +02:00
bsd.h dde_bsd: use generic platform API 2022-10-12 12:09:33 +02:00
driver.cc dde_bsd: update mixer state report on HP sense 2023-07-14 12:06:31 +02:00
dummies.cc dde_bsd: update audio driver to OpenBSD 7.3 2023-05-30 12:03:26 +02:00
mem.cc dde_bsd: decrease overall memory consumption 2023-07-14 12:06:31 +02:00
misc.cc Replace use of base/snprintf.h by format library 2023-03-13 14:32:53 +01:00
pci.cc mmio: upper-bounds checks 2024-02-26 08:59:07 +01:00
scheduler.cc dde_*: remove the use of deprecated APIs 2019-01-30 13:49:54 +01:00
timer.cc dde_bsd: update audio driver to OpenBSD 7.1 2022-10-12 12:09:36 +02:00