intel_iommu: Return error on machines with no PCI
PATCH 1/1 intel_iommu: Return error on machines with no PCI
Starting the following command line causes a segfault qemu-system-x86_64 -S -machine isapc,accel=kvm -device intel-iommu
This is due to the fact that the machine type 'isapc' doesn't have a PCI bus, while intel_iommu doesn't check if the machine has PCI support and subsequently does a null-pointer access. Intel IOMMU shouldn't even work if the target machine doesn't have PCI.
Add a check for PCI on the given machine type and return an error if PCI is not supported.
--- hw/i386/intel_iommu.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/i386/intel_iommu.c +7 -0
@@ -3041,6 +3041,13 @@ static void vtd_realize(DeviceState *dev, Error **errp) } bus = pcms->bus; + +if (!bus) { +error_setg (errp,"Machine-type '%s' does not support PCI" , + mc->name); +return ; + } + x86_iommu->type =TYPE_INTEL ;if (!vtd_decide_config (s, errp)) {
Signature · 1 line
1.8.3.1
Quoted 25 lines · Mohammed Gamal
Starting the following command line causes a segfault qemu-system-x86_64 -S -machine isapc,accel=kvm -device intel-iommu
This is due to the fact that the machine type 'isapc' doesn't have a PCI bus, while
intel_iommudoesn't check if the machine has PCI support and subsequently does a null-pointer access. Intel IOMMU shouldn't even work if the target machine doesn't have PCI.Add a check for PCI on the given machine type and return an error if PCI is not supported.
Signed-off-by Mohammed Gamal <[email protected]>--- hw/i386/intel_iommu.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/i386/intel_iommu.c +0
-0@@ -3041,6 +3041,13 @@ static void vtd_realize(DeviceState *dev, Error **errp) } bus = pcms->bus;
hw/i386/intel_iommu.c static void vtd_realize(DeviceState *dev, Error **errp) · line 3053
Quoted 10 lines
hw/i386/intel_iommu.c +7
-0+ +if (!bus) { +error_setg (errp,"Machine-type '%s' does not support PCI" , + mc->name); +return ; + } + x86_iommu->type =TYPE_INTEL ;if (!vtd_decide_config (s, errp)) {
Patch looks basically fine to me, too, but I think I'd also rather change the "if (!pcms)" at the beginning of the function into "if (!pcms || !pcms->bus)" here to use the same error message for both cases.
Thomas