Blame SOURCES/kvm-intel_iommu-fix-operator-in-vtd_switch_address_space.patch

ae23c9
From 94edd1b203f3a88065ce05d9e027b24a3e8eed2f Mon Sep 17 00:00:00 2001
ae23c9
From: Peter Xu <peterx@redhat.com>
ae23c9
Date: Tue, 2 Apr 2019 07:25:28 +0100
ae23c9
Subject: [PATCH 4/7] intel_iommu: fix operator in vtd_switch_address_space
ae23c9
ae23c9
RH-Author: Peter Xu <peterx@redhat.com>
ae23c9
Message-id: <20190402072531.23771-2-peterx@redhat.com>
ae23c9
Patchwork-id: 85298
ae23c9
O-Subject: [RHEL-8.1 qemu-kvm PATCH 1/4] intel_iommu: fix operator in vtd_switch_address_space
ae23c9
Bugzilla: 1662272
ae23c9
RH-Acked-by: Wei Huang <wei@redhat.com>
ae23c9
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
ae23c9
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
ae23c9
ae23c9
When calculating use_iommu, we wanted to first detect whether DMAR is
ae23c9
enabled, then check whether PT is enabled if DMAR is enabled.  However
ae23c9
in the current code we used "&" rather than "&&" so the ordering
ae23c9
requirement is lost (instead it'll be an "AND" operation).  This could
ae23c9
introduce errors dumped in QEMU console when rebooting a guest with
ae23c9
both assigned device and vIOMMU, like:
ae23c9
ae23c9
  qemu-system-x86_64: vtd_dev_to_context_entry: invalid root entry:
ae23c9
  rsvd=0xf000ff53f000e2c3, val=0xf000ff53f000ff53 (reserved nonzero)
ae23c9
ae23c9
Acked-by: Jason Wang <jasowang@redhat.com>
ae23c9
Signed-off-by: Peter Xu <peterx@redhat.com>
ae23c9
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ae23c9
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ae23c9
(cherry picked from commit 2a078b1080917dc6143783e1dd645e188d11dc8f)
ae23c9
Signed-off-by: Peter Xu <peterx@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 hw/i386/intel_iommu.c | 2 +-
ae23c9
 1 file changed, 1 insertion(+), 1 deletion(-)
ae23c9
ae23c9
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
ae23c9
index 12af410..7170266 100644
ae23c9
--- a/hw/i386/intel_iommu.c
ae23c9
+++ b/hw/i386/intel_iommu.c
ae23c9
@@ -1145,7 +1145,7 @@ static bool vtd_switch_address_space(VTDAddressSpace *as)
ae23c9
 
ae23c9
     assert(as);
ae23c9
 
ae23c9
-    use_iommu = as->iommu_state->dmar_enabled & !vtd_dev_pt_enabled(as);
ae23c9
+    use_iommu = as->iommu_state->dmar_enabled && !vtd_dev_pt_enabled(as);
ae23c9
 
ae23c9
     trace_vtd_switch_address_space(pci_bus_num(as->bus),
ae23c9
                                    VTD_PCI_SLOT(as->devfn),
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9