pc/platform: detect invalid IOMMU devices

genodelabs/genode#5002
genodelabs/genode#2700
This commit is contained in:
Johannes Schlatow 2023-11-16 09:44:30 +01:00
parent c06b53e52e
commit 4163367b53
2 changed files with 20 additions and 0 deletions

View File

@ -349,6 +349,11 @@ Intel::Io_mmu::Io_mmu(Env & env,
_managed_root_table(_env, table_allocator, *this, !coherent_page_walk()),
_domain_allocator(_max_domains()-1)
{
if (_broken_device()) {
error(name, " reports invalid capability registers. Please disable VT-d/IOMMU.");
return;
}
if (!read<Capability::Sagaw_4_level>() && !read<Capability::Sagaw_3_level>()) {
error("IOMMU does not support 3- or 4-level page tables");
return;

View File

@ -482,6 +482,21 @@ class Intel::Io_mmu : private Attached_mmio,
log("disabled IOMMU ", name());
}
/**
* Some broken BIOSes messes up the ACPI table. In consequence, we may
* try accessing invalid DMAR units. We only check for this to log an
* error as a hint to the user to disable VT-d.
*
* See #2700
*/
bool _broken_device()
{
return read<Capability>() == ~(Capability::access_t)0 ||
read<Extended_capability>() == ~(Extended_capability::access_t)0 ||
read<Capability>() == (Capability::access_t)0 ||
read<Extended_capability>() == (Extended_capability::access_t)0;
}
const uint32_t _supported_page_sizes {
read<Capability::Page_1GB>() << 30 |
read<Capability::Page_2MB>() << 21 | 1u << 12 };