acpi_drv: add config for ignoring DMAR table

By not evaluating the DMAR table, we disable the IOMMU.

genodelabs/genode#5002
This commit is contained in:
Johannes Schlatow 2023-11-15 14:39:56 +01:00
parent 196133c582
commit c06b53e52e
4 changed files with 24 additions and 8 deletions

View File

@ -33,3 +33,12 @@ Usage
! !
!<start name="platform_drv"> !<start name="platform_drv">
! ... ! ...
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:
! <config ignore_drhd="yes"/>

View File

@ -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 */ /* parse table */
Acpi_table acpi_table(env, alloc); 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(); for (Dmar_entry *entry = Dmar_entry::list()->first();
entry; entry = entry->next()) { entry; entry = entry->next()) {
entry->apply([&] (Dmar_common const &dmar) { entry->apply([&] (Dmar_common const &dmar) {
if (dmar.read<Dmar_common::Type>() == Dmar_common::Type::DRHD) { if (!ignore_drhd &&
dmar.read<Dmar_common::Type>() == Dmar_common::Type::DRHD)
{
Dmar_drhd drhd(dmar.base()); Dmar_drhd drhd(dmar.base());
size_t size_log2 = drhd.read<Dmar_drhd::Size::Num_pages>() + 12; size_t size_log2 = drhd.read<Dmar_drhd::Size::Num_pages>() + 12;

View File

@ -17,6 +17,7 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/allocator.h> #include <base/allocator.h>
#include <util/xml_node.h>
namespace Acpi namespace Acpi
@ -24,7 +25,7 @@ namespace Acpi
/** /**
* Generate report rom * Generate report rom
*/ */
void generate_report(Genode::Env&, Genode::Allocator&); void generate_report(Genode::Env&, Genode::Allocator&, Genode::Xml_node const&);
} }
#endif /* _ACPI_H_ */ #endif /* _ACPI_H_ */

View File

@ -15,6 +15,7 @@
#include <base/component.h> #include <base/component.h>
#include <base/heap.h> #include <base/heap.h>
#include <base/log.h> #include <base/log.h>
#include <base/attached_rom_dataspace.h>
#include <util/xml_generator.h> #include <util/xml_generator.h>
/* local includes */ /* local includes */
@ -30,15 +31,16 @@ namespace Acpi {
struct Acpi::Main struct Acpi::Main
{ {
Genode::Env &_env; Genode::Env &_env;
Genode::Heap _heap { _env.ram(), _env.rm() }; Genode::Heap _heap { _env.ram(), _env.rm() };
Attached_rom_dataspace _config { _env, "config" };
struct Acpi_reporter struct Acpi_reporter
{ {
Acpi_reporter(Env &env, Heap &heap) Acpi_reporter(Env &env, Heap &heap, Xml_node const &config_xml)
{ {
try { try {
Acpi::generate_report(env, heap); Acpi::generate_report(env, heap, config_xml);
} catch (Genode::Xml_generator::Buffer_exceeded) { } catch (Genode::Xml_generator::Buffer_exceeded) {
error("ACPI report too large - failure"); error("ACPI report too large - failure");
throw; 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 }; Smbios_table_reporter _smbt_reporter { _env, _heap };
Main(Env &env) : _env(env) { } Main(Env &env) : _env(env) { }