423 Commits

Author SHA1 Message Date
5040e20979 base-linux: return invalid Dataspace for missing ROM modules
The changes made in the commit for removal of 'Service_denied' from
core's ROM service (#5251) result in an 'Region_conflict' exception
as the Dataspace_component object is constructed even for
non-existing ROM modules and thus leads to an attach attempt with
a dataspace with a size of 0 (see 'Region_map_mmap::attach').

To prevent this from happening the Dataspace_component is destructed
in case the underlying Untyped_capability is invalid. With this change
the behaviour is now in line with other base platforms where attaching
such a dataspace results in an 'Attached_dataspace::Invalid_dataspace'
exception.

Issue #5595.
2025-06-06 11:24:43 +02:00
6a9d2bd1d5 depot: update recipe hashes 2025-05-28 08:23:47 +02:00
f39336b402 Unify fixed-width C types
Fixes #5589
2025-05-28 08:23:46 +02:00
7107719d23 util/bit_allocator.h: remove C++ exceptions
This change affects the users of util/bit_array.h as well, e.g.,
os/packet_allocator.h, libc, and part_block.

Issue #5245
2025-05-28 08:23:45 +02:00
9567e1e7ad base/include: compatibility to -fno-exceptions
This commit introduces 'raise(Unexpected_error)' for situations
that were formerly reflected directly as exceptions. Those conditions
still result in an exception but with added diagnostics.

The few parts of the API that strictly rely on C++ exceptions
(Xml_node, GENODE_RPC_THROW) are now guarded via __EXCEPTIONS.

Issue #5245
2025-05-27 08:33:23 +02:00
805cbd539c base-linux: remove exceptions
Issue #5245
2025-05-27 08:33:23 +02:00
eecafa0459 core: remove 'new' from CPU service
Issue #5245
2025-05-27 08:33:22 +02:00
53e76243a1 lx_hybrid: add delete(void*, unsigned long) for 32 bit
Genode tool-chain creates calls to delete(void*, unsigned long) on
32-bit targets, because size_t is unsinged long. In contrast the
host-tool chain that links hybrid targets only contains delete(void*,
unsigned) because size_t is unsigned fot these platforms. Hence, we
create a wrapper for delete(*, unsigned long) that calls the unsigned
version.

issue #5560
2025-05-27 08:32:05 +02:00
b73d407ed3 core: remove Core_virtual_memory_exhausted
Issue #5245
2025-05-27 08:32:05 +02:00
bb94c2b3b1 root/component.h: support errors as return values
The '_create_session' method returns now a 'Create_result' instead
of a pointer. This result can either be a reference to the new
session object or an 'Create_error' code.

The '_upgrade_session' and '_destroy_session' method now take a
reference instead of a pointer as argument.

Fixes #5562
2025-05-27 08:32:05 +02:00
c8579c4e77 base-linux: fix compile errors with GCC 14 and older glibc
Fixes #5567
2025-05-27 08:32:05 +02:00
214d6b5061 core: remove signal_receiver.cc
This part of the signal API is not used by because core never receives
signals.
2025-05-27 08:32:04 +02:00
cae031a44b base-linux: pass XDG_RUNTIME_DIR to components
This prevents the following warning and configures access to freedesktop
runtime data of the current user for hybrid components, e.g., fb_sdl.

  error: XDG_RUNTIME_DIR is invalid or not set in the environment.
2025-05-27 08:32:04 +02:00
7d74277ee5 base: remove diagnostic throws from base lib
Replace try/catch/throw by guard objects.
In panic situations, print an error and sleep forever.
Infinitely block invalid IPC calls.
Weasel out of cap ref count overflows by clamping count to max.
Accept ID-space ambiguities but be verbose about it.
Skip Duration::add when detecting an integer overflow.

Issue #5245
2025-05-27 08:32:03 +02:00
8a5dd8944a core: remove 'Service_denied' from io_mem_session
Issue #5251
2025-05-27 08:32:02 +02:00
7e6ae1a959 core: remove 'Service_denied' from ROM service
Core's ROM service does not longer reflect a missing ROM module at
session-creation time but delivers an invalid dataspace capability.

This patch also removes the duplication of linux/dataspace_component.cc.

Issue #5251
2025-05-27 08:32:02 +02:00
bfccd98179 core: remove 'Service_denied' from io_port_session
Issue #5251
2025-05-27 08:32:02 +02:00
bab2abd7ae base: distinguish alloc errors in rpc_cap_factory
Issue #5057
2025-05-27 08:32:02 +02:00
29b89df1c6 base/thread.h: avoid pointers for stack allocation
This has become possible by the added support of reference types for
'Unique_attempt'.

Issue #5539
2025-05-27 08:32:02 +02:00
3090bed4a0 core: rework IRQ-number allocation
Replace use of deallocate=false by keeping the IRQ number as guard
object. Don't throw 'Service_denied'. Remove superfluous debug messages.

Issue #5502
Issue #5251
2025-05-27 08:32:02 +02:00
a128bbd6b8 depot: update recipe hashes 2025-04-29 11:23:22 +02:00
016d63703d depot: update recipe hashes 2025-04-10 14:55:59 +02:00
1ef80e86e2 base: introduce Local_rm for local Region_map
The new 'Local_rm' type offers a narrow interface for the interaction
with the component-local address space, managing the lifetime of
attachments by using the 'Allocation' API.

Fixes #5516
2025-04-10 14:55:57 +02:00
84eb264786 util/attempt.h: mark 'Attempt' types as nodiscard
This catches bugs early on. E.g., when leaving an 'Allocation'
unused, it gets immediately deallocated, which is most probably not
intended. For regular 'Attempt' objects, this change encourages
the proper propagation of errors, or at least the logging of unexpected
conditions.

Fixes #5513
2025-04-10 14:55:21 +02:00
e380d0da95 base: use 'Allocation' interface for mem alloc
This patch converts the memory-allocator interfaces ('Allocator',
'Range_allocator') and their implementations ('Heap', 'Sliced heap',
'Slab', 'Allocator_avl', 'Synced_allocator') to the new 'Allocation'
utility. The new interface resides at base/memory.h whereas the
traditional allocators implement the new interface.

Down the road, the traditional allocators can successively be decoupled
from the traditional 'Allocator' and 'Range_allocator' interfaces.

Issue #5502
Issue #5245
2025-04-10 14:55:21 +02:00
b4a746bc89 base/error.h: add raise() interface
The new 'raise' function can be used instead of 'throw' to keep the
framework headers void of C++ throw statements, which would otherwise
prevent the compilation of the headers with -fno-exceptions.

In the presence of the C++ runtime, the 'raise' implementation reflects
the supplied error value(s) as C++ exceptions of the appropriate type.
In the (future) optional absence of the C++ runtime, 'raise' remains
unresolved, which then gives us the assurance that the binary contains
no code path leading to 'raise', all error conditions must have been
covered in other ways than 'raise'.

For this reason, 'Genode::raise' is not provided by the base library
but the cxx library (C++ runtime). Once we allow components to opt out
of the cxx library, 'raise' will automatically become unresolved for
those strict components.

Issue #5245
2025-04-10 14:55:21 +02:00
fee2f354dc util/attempt.h: introduce 'Ok' type
This type alleviates the need to re-introduce custom '*_ok' types
whenever a result can be an error but no value.
2025-04-10 14:55:20 +02:00
689fc1eb93 Introduce new 'Ram' API types
The new types in base/ram.h model different allocation scenarios and
error cases by mere C++ types without using exceptions. They are meant
to replace the former 'Ram_allocator' interface. As of now, the
'Unmapped_allocator' closely captures the former 'Ram_allocator'
semantics. The 'Constrained_allocator' is currently an alias for
'Unmapped_allocator' but is designated for eventually allocating
mapped RAM.

In contrast to the 'Ram_allocator' interface, which talked about
dataspace capabilites but left the lifetime management of the
allocated RAM to the caller, the new API represents an allocation
as a guard type 'Allocation', which deallocates on destruction by
default.

Allocation errors are captured by a 'Result' type that follows
the 'Attempt' pattern.

As a transitionary feature, the patch largely maintains API
compatibility with the original 'Ram_allocator' by providing
the original (exception-based) 'Ram_allocator::alloc' and
'Ram_allocator::free' methods as a wrapper around the new
'Ram::Constrained_allocator'. So components can be gradually
updated to the new 'Ram::' interface.

Issue #5502
2025-04-10 14:55:15 +02:00
7e420a68a6 Remove C++ exceptions from 'Thread' API
After constructed, a 'Thread' object may remain in a dysfunctional state
should the stack allocation have failed. This condition is no longer
reflected as a C++ exception but as result value of 'Thread::info()'.

Keep 'Thread::name' as public constant because the stack is not always
available for storing the name.

The 'stack_top' accessor has been removed because this information is
already provided by 'Thread::info()'.

Issue #5245
2025-04-10 14:27:21 +02:00
ff83de2bbc base: decouple 'Pd_session' from 'Ram_allocator'
With this patch, the 'Pd_session' interface no longer implements the
'Ram_allocator' interface, which allows us to change the
'Genode::Ram_allocator' semantics (as a subsequent step) without
affecting core's PD service.

The patch also replaces the client-local implementation of
'Pd_session_client::dataspace_size' by the proper RPC call 'ram_size' to
core, which mitigates the potential risk of de-referencing a dataspace
cap of an untrusted origin. E.g., in scenarios where the monitor
component requests the size of a dataspace allocated by the debugging
target.

Since 'ram_size' is an RPC call, it cannot be const. Hence, the
'Ram_alloctor::dataspace_size' has become non-const.

The new 'Pd_ram_allocator' implements the 'Ram_allocator' interface by
using a PD session.

Issue #5502
2025-04-10 14:24:31 +02:00
aa9ff3894c base: scoped access of Native_thread
With planned removal of Thread:: exceptions, we need to consider that a
'Thread' object may exist without a valid 'Stack' and therefore without
a valid 'Native_thread', which is hosted as part of the 'Stack'.

This patch reworks the code that accesses the 'Native_thread' to use the
new 'Thread::with_native_thread' interface. Within the local scope,
the native thread is referred to as 'nt'.

The _init_platform_thread and _deinit_platform_thread() have been
replaced by _init_native_thread and _deinit_native_thread, which take
a 'Stack &' as argument.

As a safety caution, 'Native_thread' objects can no longer be copied.

Issue #5245
2025-04-10 14:24:11 +02:00
2d89b53b0c depot: update recipe hashes 2025-02-27 12:53:40 +01:00
cefcd1fffa base-linux: use 'assert'-proc in run scripts
Issue #5432
2025-02-24 16:39:20 +01:00
2c8beb462f file-system session: root dir via session label
This patch changes the way of how the client-selected sub directory is
communicated to the server. The former opaque session argument is now
passed as last label element, which allows for the flexible tweaking
of this argument by init's session-routing and label-rewriting
mechansims. In particular, it alleviates the need for creating chroot
component instances.

This change requires the following four adaptations at the
configuration level:

- Each file-system session request must now carry a path starting
  with / as last session arguments. Hence, <vfs> <fs> nodes that
  feature a 'label' attributes must extend the attribute value
  with " -> /". For <fs> nodes with no label attribute, "/" is
  used as last label argument by default.

- For matching session-routing rules at init's configuration,
  the matching of full labels should be replaced by 'label_prefix'
  matches, excluding the last (path) argument.

- Wherever a label of a file-system session is rewritten by using
  init's 'label' attribute of a <parent> or <child> target node,
  the new attribute 'identity' should be used instead. This replaces
  the identity part of the label while preserving the client's
  directory argument.

- Analogously to the matching of session-routing rules, server-side
  policy-selection rules that formerly matched a concrete 'label'
  must be changed to match a 'label_prefix' instead.

As a good practice, 'label_prefix' values should end with " ->" if
possible, which clearly delimits the identity part of the label
used by the matching.

Issue #5445
2025-02-24 16:39:20 +01:00
2719b37107 run: use ram attribute in start nodes
Issue #5448
2025-02-24 16:39:20 +01:00
5076554f20 depot: update recipe hashes 2025-01-30 16:32:35 +01:00
63b49fcdb3 Enable -ffreestanding by default
Fixes #5429
2025-01-30 16:30:14 +01:00
ab736c04f6 core: remove Core_env
This patch adjusts the last remaining callers of 'core_env' and removes
the 'Core_env' interface.

- Core's RAM/cap accounts are now represented by 'Core_account'
  implementing the 'Pd_account' interface.

- The former parts of 'Core_env' are now initialized in sequence
  in 'bootstrap_component'.

- 'Core_child' has been moved to a header to reduce the code in
  'main.cc' to a bare minimum. This as a preparation for the
  plan of making 'main.cc' specific for each kernel.

Fixes #5408
2025-01-30 16:24:36 +01:00
fc11e26511 core: pass ram, rm, io-ports to local services
This patch replaces the use of 'core_env()' in 'platform_services.cc' by
the function arguments 'core_ram', 'core_rm', and 'io_port_ranges'.

It also removes the 'Pd_session' argument from 'Io_port_root' and
'Irq_root' to avoid the reliance on the 'Pd_session' interface within
core,

Issue #5408
2025-01-30 16:24:36 +01:00
43d7c3bd11 core: don't rely on Core_env in platform.cc
Replace the use of the global 'core_env()' accessor by the explicit
delegation of interfaces.

- For allocating UTCBs in base-hw, 'Platform_thread' requires
  a way to allocate dataspaces ('Ram_allocator') accounted to the
  corresponding CPU session, a way to locally map the allocated
  dataspaces (core's 'Region_map'), and a way to determine the
  physical address (via 'Rpc_entrypoint') used for the initial
  UTCB mapping of main threads. Hence those interfaces must be
  passed to 'Platform_thread'.

- NOVA's pager code needs to look up 'Cpu_thread_component'
  objects using a map item as key. The lookup requires the
  'Rpc_entrypoint' that hold the 'Cpu_thread_component' objects.
  To make this 'Rpc_entrypoint' available, this patch adds
  the 'init_page_fault_handing' function.

- The 'Region_map_mmap' for Linux requires a way to look up
  'Linux_dataspace' objects for given dataspace capabilities.
  This lookup requires the 'Rpc_entrypoint' holding the dataspaces,
  which is now passed to 'platform.cc' via the new Linux-specific
  'Core_region_map::init' function.

Issue #5408
2025-01-30 16:24:35 +01:00
cd6701c483 depot: update recipe hashes 2024-12-11 08:35:22 +01:00
b21c8729ea base: provide core_ram_allocator via platform_add_local_services()
This is a prerequisite to rework the allocation of core data structures
for VM sessions in hw.

Issue #5221
2024-12-10 14:11:57 +01:00
011b44c282 depot: update recipe hashes 2024-11-20 08:58:39 +01:00
61c9706353 depot: update recipe hashes 2024-10-08 11:30:26 +02:00
26002a5482 depot: update recipe hashes 2024-08-29 12:32:25 +02:00
943dfa10e7 base/child.h: remove exceptions from process init
This patch replaces the former Child::Process and
Child::Process::Loaded_executable classes by static functions that
return failure conditions as return values.

Issue #5245
2024-07-02 12:00:11 +02:00
0288cffaee Remove exceptions from 'Parent' interface
Issue #5245
2024-07-02 12:00:11 +02:00
19c13877ca Replace use of 'typedef' by 'using'
Issue #5227
2024-07-02 12:00:11 +02:00
361557e1f0 base-*: omit () for lambas w/o argument
Issue #5227
2024-07-02 12:00:11 +02:00
a2b0553c51 base-*: use C++20 function template syntax
Issue #5227
2024-07-02 12:00:11 +02:00