]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0020-intel-iommu-fail-DEVIOTLB_UNMAP-without-dt-mode.patch
add more stable fixes
[pve-qemu.git] / debian / patches / extra / 0020-intel-iommu-fail-DEVIOTLB_UNMAP-without-dt-mode.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Jason Wang <jasowang@redhat.com>
3 Date: Thu, 23 Feb 2023 14:59:21 +0800
4 Subject: [PATCH] intel-iommu: fail DEVIOTLB_UNMAP without dt mode
5
6 Without dt mode, device IOTLB notifier won't work since guest won't
7 send device IOTLB invalidation descriptor in this case. Let's fail
8 early instead of misbehaving silently.
9
10 Reviewed-by: Laurent Vivier <lvivier@redhat.com>
11 Tested-by: Laurent Vivier <lvivier@redhat.com>
12 Tested-by: Viktor Prutyanov <viktor@daynix.com>
13 Buglink: https://bugzilla.redhat.com/2156876
14 Signed-off-by: Jason Wang <jasowang@redhat.com>
15 Message-Id: <20230223065924.42503-3-jasowang@redhat.com>
16 Reviewed-by: Peter Xu <peterx@redhat.com>
17 Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
18 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
19 (cherry-picked from commit 09adb0e021207b60a0c51a68939b4539d98d3ef3)
20 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
21 ---
22 hw/i386/intel_iommu.c | 8 ++++++++
23 1 file changed, 8 insertions(+)
24
25 diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
26 index 9143376677..d025ef2873 100644
27 --- a/hw/i386/intel_iommu.c
28 +++ b/hw/i386/intel_iommu.c
29 @@ -3179,6 +3179,7 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
30 {
31 VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
32 IntelIOMMUState *s = vtd_as->iommu_state;
33 + X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
34
35 /* TODO: add support for VFIO and vhost users */
36 if (s->snoop_control) {
37 @@ -3193,6 +3194,13 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
38 PCI_FUNC(vtd_as->devfn));
39 return -ENOTSUP;
40 }
41 + if (!x86_iommu->dt_supported && (new & IOMMU_NOTIFIER_DEVIOTLB_UNMAP)) {
42 + error_setg_errno(errp, ENOTSUP,
43 + "device %02x.%02x.%x requires device IOTLB mode",
44 + pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
45 + PCI_FUNC(vtd_as->devfn));
46 + return -ENOTSUP;
47 + }
48
49 /* Update per-address-space notifier flags */
50 vtd_as->notifier_flags = new;