mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-03 07:21:55 -06:00
hw/i386/amd_iommu: Fix device setup failure when PT is on.
Commitc1f46999ef
("amd_iommu: Add support for pass though mode") introduces the support for "pt" flag by enabling nodma memory when "pt=off". This allowed VFIO devices to successfully register notifiers by using nodma region. But, This also broke things when guest is booted with the iommu=nopt because, devices bypass the IOMMU and use untranslated addresses (IOVA) to perform DMA reads/writes to the nodma memory region, ultimately resulting in a failure to setup the devices in the guest. Fix the above issue by always enabling the amdvi_dev_as->iommu memory region. But this will once again cause VFIO devices to fail while registering the notifiers with AMD IOMMU memory region. Fixes:c1f46999ef
("amd_iommu: Add support for pass though mode") Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> Message-Id: <20250516100535.4980-2-sarunkod@amd.com> Fixes:c1f46999ef
("amd_iommu: Add support for pass though mode") Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
This commit is contained in:
parent
ac8fc4ccac
commit
31753d5a33
1 changed files with 2 additions and 10 deletions
|
@ -1426,7 +1426,6 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
|
||||||
AMDVIState *s = opaque;
|
AMDVIState *s = opaque;
|
||||||
AMDVIAddressSpace **iommu_as, *amdvi_dev_as;
|
AMDVIAddressSpace **iommu_as, *amdvi_dev_as;
|
||||||
int bus_num = pci_bus_num(bus);
|
int bus_num = pci_bus_num(bus);
|
||||||
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
|
|
||||||
|
|
||||||
iommu_as = s->address_spaces[bus_num];
|
iommu_as = s->address_spaces[bus_num];
|
||||||
|
|
||||||
|
@ -1486,15 +1485,8 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
|
||||||
AMDVI_INT_ADDR_FIRST,
|
AMDVI_INT_ADDR_FIRST,
|
||||||
&amdvi_dev_as->iommu_ir, 1);
|
&amdvi_dev_as->iommu_ir, 1);
|
||||||
|
|
||||||
if (!x86_iommu->pt_supported) {
|
|
||||||
memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, false);
|
memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, false);
|
||||||
memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu),
|
memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu), true);
|
||||||
true);
|
|
||||||
} else {
|
|
||||||
memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu),
|
|
||||||
false);
|
|
||||||
memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return &iommu_as[devfn]->as;
|
return &iommu_as[devfn]->as;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue