From c06b53e52e7a14c68aec347c5305d217a34b414f Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Wed, 15 Nov 2023 14:39:56 +0100 Subject: [PATCH] acpi_drv: add config for ignoring DMAR table By not evaluating the DMAR table, we disable the IOMMU. genodelabs/genode#5002 --- repos/os/src/drivers/acpi/README | 9 +++++++++ repos/os/src/drivers/acpi/acpi.cc | 8 ++++++-- repos/os/src/drivers/acpi/acpi.h | 3 ++- repos/os/src/drivers/acpi/main.cc | 12 +++++++----- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/repos/os/src/drivers/acpi/README b/repos/os/src/drivers/acpi/README index a82319f469..504677b9a1 100644 --- a/repos/os/src/drivers/acpi/README +++ b/repos/os/src/drivers/acpi/README @@ -33,3 +33,12 @@ Usage ! ! ! ... + +Config +------ + +This server also reports available DMA remapping units (IOMMU) as specified in +the 'DMAR' table. In order to disable the IOMMU, you may provide the following +config: + +! diff --git a/repos/os/src/drivers/acpi/acpi.cc b/repos/os/src/drivers/acpi/acpi.cc index 05166147d5..9c64b3bb8a 100644 --- a/repos/os/src/drivers/acpi/acpi.cc +++ b/repos/os/src/drivers/acpi/acpi.cc @@ -1611,7 +1611,8 @@ static void attribute_hex(Xml_generator &xml, char const *name, } -void Acpi::generate_report(Genode::Env &env, Genode::Allocator &alloc) +void Acpi::generate_report(Genode::Env &env, Genode::Allocator &alloc, + Xml_node const &config_xml) { /* parse table */ Acpi_table acpi_table(env, alloc); @@ -1667,11 +1668,14 @@ void Acpi::generate_report(Genode::Env &env, Genode::Allocator &alloc) }); }; + bool ignore_drhd = config_xml.attribute_value("ignore_drhd", false); for (Dmar_entry *entry = Dmar_entry::list()->first(); entry; entry = entry->next()) { entry->apply([&] (Dmar_common const &dmar) { - if (dmar.read() == Dmar_common::Type::DRHD) { + if (!ignore_drhd && + dmar.read() == Dmar_common::Type::DRHD) + { Dmar_drhd drhd(dmar.base()); size_t size_log2 = drhd.read() + 12; diff --git a/repos/os/src/drivers/acpi/acpi.h b/repos/os/src/drivers/acpi/acpi.h index 04a862664a..ecdeb439fe 100644 --- a/repos/os/src/drivers/acpi/acpi.h +++ b/repos/os/src/drivers/acpi/acpi.h @@ -17,6 +17,7 @@ /* Genode includes */ #include #include +#include namespace Acpi @@ -24,7 +25,7 @@ namespace Acpi /** * Generate report rom */ - void generate_report(Genode::Env&, Genode::Allocator&); + void generate_report(Genode::Env&, Genode::Allocator&, Genode::Xml_node const&); } #endif /* _ACPI_H_ */ diff --git a/repos/os/src/drivers/acpi/main.cc b/repos/os/src/drivers/acpi/main.cc index 2daa9d6868..27dcdc8b65 100644 --- a/repos/os/src/drivers/acpi/main.cc +++ b/repos/os/src/drivers/acpi/main.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include /* local includes */ @@ -30,15 +31,16 @@ namespace Acpi { struct Acpi::Main { - Genode::Env &_env; - Genode::Heap _heap { _env.ram(), _env.rm() }; + Genode::Env &_env; + Genode::Heap _heap { _env.ram(), _env.rm() }; + Attached_rom_dataspace _config { _env, "config" }; struct Acpi_reporter { - Acpi_reporter(Env &env, Heap &heap) + Acpi_reporter(Env &env, Heap &heap, Xml_node const &config_xml) { try { - Acpi::generate_report(env, heap); + Acpi::generate_report(env, heap, config_xml); } catch (Genode::Xml_generator::Buffer_exceeded) { error("ACPI report too large - failure"); throw; @@ -49,7 +51,7 @@ struct Acpi::Main } }; - Acpi_reporter _acpi_reporter { _env, _heap }; + Acpi_reporter _acpi_reporter { _env, _heap, _config.xml() }; Smbios_table_reporter _smbt_reporter { _env, _heap }; Main(Env &env) : _env(env) { }