From 1df55bd2dc066593823efa16b8fc834178ab55ce Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Wed, 26 Mar 2025 15:14:59 +0100 Subject: [PATCH] platform: use default domain only as fallback The default IOMMU domain is used as a default if the kernel has IOMMU support and if devices are not linked explicitly linked to a IOMMU device. As soon as an IOMMU device is present, the kernel IOMMU is never used. Hence, there is no point in maintaining the default domain if there are other domains present. genodelabs/genode#5494 --- repos/os/src/driver/platform/io_mmu_domain_registry.h | 7 +++++-- repos/os/src/driver/platform/session_component.cc | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/repos/os/src/driver/platform/io_mmu_domain_registry.h b/repos/os/src/driver/platform/io_mmu_domain_registry.h index 78138b3ddb..0a489a3a39 100644 --- a/repos/os/src/driver/platform/io_mmu_domain_registry.h +++ b/repos/os/src/driver/platform/io_mmu_domain_registry.h @@ -87,10 +87,13 @@ class Driver::Io_mmu_domain_registry : public Registry template void for_each_domain(FN && fn) { + bool use_default { true }; for_each([&] (Io_mmu_domain & wrapper) { - fn(wrapper.domain); }); + fn(wrapper.domain); + use_default = false; + }); - if (_default_domain.constructed()) + if (use_default && _default_domain.constructed()) fn(_default_domain->domain); } diff --git a/repos/os/src/driver/platform/session_component.cc b/repos/os/src/driver/platform/session_component.cc index ad770a4556..59378e63aa 100644 --- a/repos/os/src/driver/platform/session_component.cc +++ b/repos/os/src/driver/platform/session_component.cc @@ -463,9 +463,10 @@ Session_component::Session_component(Env & env, _ram_quota_guard().withdraw(Ram_quota{5*1024}); /** - * Until we integrated IOMMU support within the platform driver, we assume - * there is a kernel_iommu used by each device if _iommu is set. We therefore - * construct a corresponding domain object at session construction. + * Fallback, in case there is no IOMMU present but the kernel implements it, + * is to let every device use the kernel IOMMU implicitly. + * We therefore construct a corresponding domain object at session + * construction. */ if (kernel_iommu) _io_mmu_devices.for_each([&] (Io_mmu & io_mmu_dev) {