Commit 0fab70c6 authored by Daniel Krebs's avatar Daniel Krebs

card: don't try to create a VFIO mapping if IOMMU is disabled

In this case, VFIO cannot create DMA mappings.
parent 106829fa
......@@ -165,6 +165,11 @@ PCIeCard::lookupIp(const Vlnv& vlnv) const
bool
PCIeCard::mapMemoryBlock(const MemoryBlock& block)
{
if(not vfioContainer->isIommuEnabled()) {
logger->warn("VFIO mapping not supported without IOMMU");
return false;
}
auto& mm = MemoryManager::get();
const auto& addrSpaceId = block.getAddrSpaceId();
......@@ -175,7 +180,6 @@ PCIeCard::mapMemoryBlock(const MemoryBlock& block)
logger->debug("Create VFIO mapping for {}", addrSpaceId);
}
auto translationFromProcess = mm.getTranslationFromProcess(addrSpaceId);
uintptr_t processBaseAddr = translationFromProcess.getLocalAddr(0);
uintptr_t iovaAddr = vfioContainer->memoryMap(processBaseAddr,
......@@ -188,10 +192,8 @@ PCIeCard::mapMemoryBlock(const MemoryBlock& block)
return false;
}
mm.createMapping(iovaAddr, 0, block.getSize(),
"vfio",
"VFIO-D2H",
this->addrSpaceIdDeviceToHost,
addrSpaceId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment