|
|
016a62 |
From f117f5fb216e45796a32579c03673c1d79164037 Mon Sep 17 00:00:00 2001
|
|
|
016a62 |
From: Peter Xu <peterx@redhat.com>
|
|
|
016a62 |
Date: Wed, 9 Oct 2019 12:39:46 +0100
|
|
|
016a62 |
Subject: [PATCH 20/22] pc/q35: Disallow vfio-pci hotplug without VT-d caching
|
|
|
016a62 |
mode
|
|
|
016a62 |
|
|
|
016a62 |
RH-Author: Peter Xu <peterx@redhat.com>
|
|
|
016a62 |
Message-id: <20191009123947.21505-5-peterx@redhat.com>
|
|
|
016a62 |
Patchwork-id: 91352
|
|
|
016a62 |
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 4/5] pc/q35: Disallow vfio-pci hotplug without VT-d caching mode
|
|
|
016a62 |
Bugzilla: 1738440
|
|
|
016a62 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
016a62 |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
016a62 |
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
|
|
|
016a62 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
016a62 |
|
|
|
016a62 |
Conflicts:
|
|
|
016a62 |
|
|
|
016a62 |
hw/i386/pc.c: context differs on quite a few places in
|
|
|
016a62 |
pc_machine_class_init(), but none of them is really relevant to
|
|
|
016a62 |
current change.
|
|
|
016a62 |
|
|
|
016a62 |
Instead of bailing out when trying to hotplug a vfio-pci device with
|
|
|
016a62 |
below configuration:
|
|
|
016a62 |
|
|
|
016a62 |
-device intel-iommu,caching-mode=off
|
|
|
016a62 |
|
|
|
016a62 |
With this we can return a warning message to the user via QMP/HMP and
|
|
|
016a62 |
the VM will continue to work after failing the hotplug:
|
|
|
016a62 |
|
|
|
016a62 |
(qemu) device_add vfio-pci,bus=root.3,host=05:00.0,id=vfio1
|
|
|
016a62 |
Error: Device assignment is not allowed without enabling caching-mode=on for Intel IOMMU.
|
|
|
016a62 |
|
|
|
016a62 |
Reviewed-by: Eric Auger <eric.auger@redhat.com>
|
|
|
016a62 |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
016a62 |
Message-Id: <20190916080718.3299-4-peterx@redhat.com>
|
|
|
016a62 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
016a62 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
016a62 |
(cherry picked from commit c6cbc29d36fe8df078776ed715c37cebac582238)
|
|
|
016a62 |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
016a62 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
016a62 |
---
|
|
|
016a62 |
hw/i386/pc.c | 21 +++++++++++++++++++++
|
|
|
016a62 |
1 file changed, 21 insertions(+)
|
|
|
016a62 |
|
|
|
016a62 |
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
|
|
|
016a62 |
index 9e1e6ae..d6c4050 100644
|
|
|
016a62 |
--- a/hw/i386/pc.c
|
|
|
016a62 |
+++ b/hw/i386/pc.c
|
|
|
016a62 |
@@ -2340,6 +2340,26 @@ static void x86_nmi(NMIState *n, int cpu_index, Error **errp)
|
|
|
016a62 |
}
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
+
|
|
|
016a62 |
+static bool pc_hotplug_allowed(MachineState *ms, DeviceState *dev, Error **errp)
|
|
|
016a62 |
+{
|
|
|
016a62 |
+ X86IOMMUState *iommu = x86_iommu_get_default();
|
|
|
016a62 |
+ IntelIOMMUState *intel_iommu;
|
|
|
016a62 |
+
|
|
|
016a62 |
+ if (iommu &&
|
|
|
016a62 |
+ object_dynamic_cast((Object *)iommu, TYPE_INTEL_IOMMU_DEVICE) &&
|
|
|
016a62 |
+ object_dynamic_cast((Object *)dev, "vfio-pci")) {
|
|
|
016a62 |
+ intel_iommu = INTEL_IOMMU_DEVICE(iommu);
|
|
|
016a62 |
+ if (!intel_iommu->caching_mode) {
|
|
|
016a62 |
+ error_setg(errp, "Device assignment is not allowed without "
|
|
|
016a62 |
+ "enabling caching-mode=on for Intel IOMMU.");
|
|
|
016a62 |
+ return false;
|
|
|
016a62 |
+ }
|
|
|
016a62 |
+ }
|
|
|
016a62 |
+
|
|
|
016a62 |
+ return true;
|
|
|
016a62 |
+}
|
|
|
016a62 |
+
|
|
|
016a62 |
static void pc_machine_class_init(ObjectClass *oc, void *data)
|
|
|
016a62 |
{
|
|
|
016a62 |
MachineClass *mc = MACHINE_CLASS(oc);
|
|
|
016a62 |
@@ -2369,6 +2389,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
|
|
|
016a62 |
*/
|
|
|
016a62 |
mc->async_pf_vmexit_disable = true;
|
|
|
016a62 |
mc->get_hotplug_handler = pc_get_hotpug_handler;
|
|
|
016a62 |
+ mc->hotplug_allowed = pc_hotplug_allowed;
|
|
|
016a62 |
mc->cpu_index_to_instance_props = pc_cpu_index_to_props;
|
|
|
016a62 |
mc->get_default_cpu_node_id = pc_get_default_cpu_node_id;
|
|
|
016a62 |
mc->possible_cpu_arch_ids = pc_possible_cpu_arch_ids;
|
|
|
016a62 |
--
|
|
|
016a62 |
1.8.3.1
|
|
|
016a62 |
|