1104 Commits

Author SHA1 Message Date
Christian Helmuth
5076554f20 depot: update recipe hashes 2025-01-30 16:32:35 +01:00
Benjamin Lamowski
02b7878229 hw: always serialize rdtsc reads
While implementing TSC calibration in #5215, the issue of properly serializing
TSC reads came up. Some learnings of the discussion were noted in #5430.

Using `cpuid` for serialization as in Trace::timestamp() is portable,
but will cause VM exits on VMX and SVM and is therefore unsuitable to
retain a roughly working calibration loop while running virtualized.
On the other hand on most AMD systems, dispatch serializing `lfence`
needs to be explicitly enabled via a non-architectural MSR.

Enable setting up dispatch serializing lfence on AMD systems and always
serialize rdtsc accesses in Hw::Tsc::rdtsc() for maximum reliability.

Issues #5215, #5430
2025-01-30 16:30:14 +01:00
Benjamin Lamowski
ec5e1a6b4b hw: calibrate Local APIC via ACPI timer
Upto now, bootstrap used the Programmable Interval Timer to set a
suitable divider and determine the frequency of the Local APIC.
The PIT is not available on recent x86_64 hardware anymore.

Move Local APIC calibration to bootstrap and use the ACPI timer as a
reference. Clean up hw's timer implementation a little and disable the
PIT in bootstrap.

Fixes #5215
2025-01-30 16:30:14 +01:00
Benjamin Lamowski
89f7834b17 hw: calibrate TSC via ACPI timer
To get the Time Stamp Counter's frequency, hw relied on a complex and
incomplete algorithm.

Since this is a one-time initialization issue, move TSC calibration to
bootstrap and implement it using the ACPI timer.

Issue #5215
2025-01-30 16:30:14 +01:00
Norman Feske
d1c4bc5115 vm_session: use Callable for with_state
Issue #5420
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
b0052a71be hw: remove unused object pool of pager ojects
Fix genodelabs/genode#5417
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
0d648eae62 hw: sanitize kernel's signal datastructures
* Move all Kernel::Signal_* structures to kernel/signal.*
* Remove return value of kill_signal_context, which wasn't evaluated
* Remove Kernel::Signal_context::can_kill
* Remove Kernel::Signal_context::can_submit
* Remove Kernel::Signal_receiver::can_add_handler
* Turn nullptr into cxx nullptr instead of just zero
* Turn boolean values into true/false instead of one/zero
* Always add to signal FIFO also if submit counter
  cannot get increased enough

Fix genodelabs/genode#5416
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
2728853005 hw: implement helping of pager threads
Instead of blocking in case of exceptions and MMU faults, delegate
the faulter's scheduling context to the assigned pager thread.

Fix genodelabs/genode#5318
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
1194652d20 hw: move remaining pager code to pager.cc
Consolidate core's ha-specific pager code in one and the same compilation unit.

Ref genodelabs/genode#5318
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
fd78fb4de3 hw: pager thread per cpu
Instatiate a separate pager thread for each cpu core. Every time a pager
object gets managed by the Pager_entrypoint, assign it to the pager thread
on the same cpu core.

Ref genodelabs/genode#5318
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
ae1e4918a7 hw: use enums in stack base definition
Ref genodelabs/genode#5319
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
f97c8cacde hw: sanitze cpu context
* Rename Kernel::Cpu_job to Kernel::Cpu_context (alias Kernel::Cpu::Context)
* State first Cpu affinity of Cpu::Context at construction time
* Move cpu affinity argument from kernel syscall create_thread to start_thread
* Ensure that Cpu pointer is always valid

Fix genodelabs/genode#5319
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
e275787119 hw: add missing six-arguments syscall for riscv
Ref genodelabs/genode#5319
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
025043cdcf hw: generalize IPC-helping to a common mechanism
* Removes helping from Ipc_node and Thread class
* Implement helping as mechanism of Scheduler::Context

Ref genodelabs/genode#5318
2025-01-30 16:30:14 +01:00
Stefan Kalkowski
dc37c396cf hw: ensure board_name is set as depot build
When no BOARD variable is set via the build environment,
the board_name in the platform_info ROM needs to be set either.

Ref genodelabs/genode#5360
Fix genodelabs/genode#5414
2025-01-30 16:30:14 +01:00
Alexander Boettcher
0d81a104ad base: use Map_local_result in io_mem _map_local(...)
Issue #5406
2025-01-30 16:30:13 +01:00
Norman Feske
2ac0a7368c base: remove base/internal/unmanaged_singleton.h
Fixes #5418
2025-01-30 16:30:13 +01:00
Benjamin Lamowski
05522696c7 hw: x86_64: refactor Vm_session_component
On x86, the `Vm_session_component` obscured the differences between SVM
and VMX.

Separate the implementations, factor out common functionality and
address a number of long-standing issues in the process:

- Allocate nested page tables from Core_ram_allocator as a more suitable
  abstraction and account for the required memory, subtract the
  necessary amount of RAM from the session's `Ram_quota` *before*
  constructing the session object, to make sure that the memory
  allocated from the `Core_ram_allocator` is available from the VMM's
  RAM quota.
- Move the allocation of Vcpu_state and Vcpu_data into the Core::Vcpu
  class and use the Core RAM Allocator to allocate memory with a known
  physical address.
- Remove the fixed number of virtual CPUs and the associated reservation
  of memory by using a Registry for a flexible amount of vCPUs.

Issue #5221
2025-01-30 16:30:13 +01:00
Benjamin Lamowski
922fdd1628 hw: factor out Vmid_allocator
Move the static `Vmid_allocator` in each `Vm_session_component` into a
common header file.

Issue #5221
2025-01-30 16:30:13 +01:00
Norman Feske
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
Norman Feske
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
Benjamin Lamowski
5e3a898109 base: add create_vcpu to Vm_session interface
`Vm_session_component::create_vcpu()` is present across all supported
kernels, yet until now it was not part of the `Vm_session` interface.

Add the method to the `Vm_session` interface. This unifies calls in the
base library and is the basis to remove the need for a common base class
for separate `Vm_session` implementations for SVM and VMX on x86_64.

Issue #5221
2025-01-30 16:20:39 +01:00
Christian Helmuth
cd6701c483 depot: update recipe hashes 2024-12-11 08:35:22 +01:00
Benjamin Lamowski
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
Stefan Kalkowski
4730312c1e hw: register state and backtrace when core faults
If one of core's threads is causing an MMU fault, dump the
register state and stack backtrace of the faulting stack to
aid debugging.

Fix genodelabs/genode#5387
2024-11-27 13:33:24 +01:00
Christian Helmuth
011b44c282 depot: update recipe hashes 2024-11-20 08:58:39 +01:00
Norman Feske
14e3339ce6 base-hw: remove outdated comment 2024-11-20 08:58:39 +01:00
Norman Feske
052dd903a4 base-hw: rm C++ exception from syscall dispatcher
This patch removes the only residual C++ exception from the kernel part
of core, eliminating the risk of the kernel thread trying to enter the
kernel itself via the C++ exception-handling path. When throwing an
exception, __cxa_allocate_exception invokes the cxx_heap, which
synchronizes accesses via a Genode::Mutex. In the contention case,
the blocking of the mutex issues a syscall to pause the caller.
The patch fixes the problem by replacing the exception with a return
value.

Fixes #5382
Issue #5245
2024-11-20 08:58:39 +01:00
Stefan Kalkowski
ed2d9fef47 hw: do not flush core/kernel's page-tables
Fix genodelabs/genode#5380
2024-11-20 08:58:39 +01:00
Stefan Kalkowski
7dbc9129db hw: detach UTCB from core PD in thread destruction
Ref genodelabs/genode#5380
2024-11-20 08:58:39 +01:00
Stefan Kalkowski
9a7fe5e775 hw: implement Core_region_map::detach
Ref genodelabs/genode#5380
2024-11-20 08:56:48 +01:00
Christian Helmuth
30f3ef25ad depot: update recipe hashes 2024-10-30 14:02:44 +01:00
Stefan Kalkowski
e344fa8c23 base-hw: export board name in platform info
We need to differentiate the board within the SoC generic
platform driver. Therefore, export its name within the
platform info ROM.

Ref issue#5360
2024-10-11 14:46:23 +02:00
Christian Helmuth
61c9706353 depot: update recipe hashes 2024-10-08 11:30:26 +02:00
Alexander Boettcher
ff506b0375 vm/x86: support extended fpu state transfer
Extend Genode's vCPU FPU state and adjust all users to copy
at most FPU data they actually support.

Issue #5314
2024-10-07 15:54:59 +02:00
Alexander Boettcher
eb7aea82b8 hw/x86: prefer acpi rsdp v2 of multiboot2
over rsdp v1. The multiboot2 provided rsdp_v1 version may not contain the
xsdt pointer, but may have the very same acpi revision as the acpi rsdp v2
version of multiboot2.

Fixes #5332
2024-10-07 14:44:30 +02:00
Christian Helmuth
26002a5482 depot: update recipe hashes 2024-08-29 12:32:25 +02:00
Stefan Kalkowski
a7b4add27c hw: move cpu kernel object into cpu local area
Fix genodelabs/genode#5310
2024-08-27 15:29:36 +02:00
Stefan Kalkowski
9258004cc7 hw: move stack into cpu local mem area
Ref genodelabs/genode#5310
2024-08-27 15:29:36 +02:00
Stefan Kalkowski
6afe4f79a2 base: tie quota_lim_downscale template to size_t
* Always use size_t instead of template type
* Thereby we can remove 128-bit type from all architectures in base-hw

Ref genodelabs/genode#5310
2024-08-27 15:26:51 +02:00
Stefan Kalkowski
7770285aed hw: remove duplicated definition of x86 local APIC
Ref genodelabs/genode#5310
2024-08-27 15:26:51 +02:00
Norman Feske
19c13877ca Replace use of 'typedef' by 'using'
Issue #5227
2024-07-02 12:00:11 +02:00
Norman Feske
361557e1f0 base-*: omit () for lambas w/o argument
Issue #5227
2024-07-02 12:00:11 +02:00
Norman Feske
a2b0553c51 base-*: use C++20 function template syntax
Issue #5227
2024-07-02 12:00:11 +02:00
Norman Feske
d44ec53cd3 core: tie Platform_thread to Platform_pd
This patch tightens the coupling of the 'Platform_thread' objects
with their corresponding 'Platform_pd' objects by specifying the
'Platform_pd' as constructor argument, keeping the relationship
as a reference (instead of a pointer), and constraining the
lifetime of 'Platform_pd' objects to the lifetime of the PD.

It thereby clears the way to simplify the thread creation since all
PD-related information (like quota budgets) are now known at the
construction time of the 'Platform_thread'.

The return value of 'Platform_thread::start' has been removed because it
is not evaluated by 'Cpu_thread_component'.

Related to #5256
2024-07-02 11:59:16 +02:00
Norman Feske
5a6c4d6ff2 base-hw: handle cap-slab exhaust in Thread::start
This interim solution for issue #5256 solves the problem for the
thread.run script.

Issue #5256
2024-07-02 11:59:16 +02:00
Stefan Kalkowski
d9d2a7584e base-hw: remove cortex spec directories
For consistency reasons, remove the cortex_a8, cortex_a9, and cortex_a15
spec directories. Such SPEC variables do not exist since a while.
Also rename remaining translation_table.h header to page_table.h to
stay consistent with the class names inside.

Fix genodelabs/genode#5253
2024-07-02 11:59:16 +02:00
Norman Feske
0105494223 Rework Region_map interface
- Remove exceptions
- Use 'Attr' struct for attach arguments
- Let 'attach' return 'Range' instead of 'Local_addr'
- Renamed 'Region_map::State' to 'Region_map::Fault'

Issue #5245
Fixes #5070
2024-07-02 11:59:16 +02:00
Norman Feske
d866b6b053 Remove exceptions from Cpu_session interface
The 'Thread_creation_failed' error is now reflected as
'Thread::Start_result' return value. This change also removes the
use of 'Invalid_thread' within core as this exception is an alias
of Cpu_session::Thread_creation_failed.

Issue #5245
2024-07-02 11:59:16 +02:00
Stefan Kalkowski
e93f5fe8e0 base-hw: move imx53-specifics to imx repository
Ref genodelabs/genode#5252
2024-06-20 13:25:06 +02:00