Pablo Greco e6a3ae
From 324a0ffc5140c4ece5b720708da2c673a8d1b9cc Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Date: Tue, 1 Oct 2019 06:02:58 +0100
Pablo Greco e6a3ae
Subject: [PATCH 12/22] s390: PCI: fix IOMMU region init
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Message-id: <20191001060258.28206-2-thuth@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 90929
Pablo Greco e6a3ae
O-Subject: [RHEL-8.2.0/RHEL-8.1.z qemu-kvm PATCH 1/1] s390: PCI: fix IOMMU region init
Pablo Greco e6a3ae
Bugzilla: 1754643
Pablo Greco e6a3ae
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: David Hildenbrand <david@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: Matthew Rosato <mjrosato@linux.ibm.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
The fix in dbe9cf606c shrinks the IOMMU memory region to a size
Pablo Greco e6a3ae
that seems reasonable on the surface, however is actually too
Pablo Greco e6a3ae
small as it is based against a 0-mapped address space.  This
Pablo Greco e6a3ae
causes breakage with small guests as they can overrun the IOMMU window.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Let's go back to the prior method of initializing iommu for now.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Fixes: dbe9cf606c ("s390x/pci: Set the iommu region size mpcifc request")
Pablo Greco e6a3ae
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Pablo Greco e6a3ae
Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Pablo Greco e6a3ae
Tested-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Pablo Greco e6a3ae
Reported-by: Stefan Zimmerman <stzi@linux.ibm.com>
Pablo Greco e6a3ae
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Pablo Greco e6a3ae
Message-Id: <1569507036-15314-1-git-send-email-mjrosato@linux.ibm.com>
Pablo Greco e6a3ae
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Pablo Greco e6a3ae
(cherry picked from commit 7df1dac5f1c85312474df9cb3a8fcae72303da62)
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 hw/s390x/s390-pci-bus.c | 7 ++++++-
Pablo Greco e6a3ae
 1 file changed, 6 insertions(+), 1 deletion(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
Pablo Greco e6a3ae
index 383b3e7..069e152 100644
Pablo Greco e6a3ae
--- a/hw/s390x/s390-pci-bus.c
Pablo Greco e6a3ae
+++ b/hw/s390x/s390-pci-bus.c
Pablo Greco e6a3ae
@@ -691,10 +691,15 @@ static const MemoryRegionOps s390_msi_ctrl_ops = {
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 void s390_pci_iommu_enable(S390PCIIOMMU *iommu)
Pablo Greco e6a3ae
 {
Pablo Greco e6a3ae
+    /*
Pablo Greco e6a3ae
+     * The iommu region is initialized against a 0-mapped address space,
Pablo Greco e6a3ae
+     * so the smallest IOMMU region we can define runs from 0 to the end
Pablo Greco e6a3ae
+     * of the PCI address space.
Pablo Greco e6a3ae
+     */
Pablo Greco e6a3ae
     char *name = g_strdup_printf("iommu-s390-%04x", iommu->pbdev->uid);
Pablo Greco e6a3ae
     memory_region_init_iommu(&iommu->iommu_mr, sizeof(iommu->iommu_mr),
Pablo Greco e6a3ae
                              TYPE_S390_IOMMU_MEMORY_REGION, OBJECT(&iommu->mr),
Pablo Greco e6a3ae
-                             name, iommu->pal - iommu->pba + 1);
Pablo Greco e6a3ae
+                             name, iommu->pal + 1);
Pablo Greco e6a3ae
     iommu->enabled = true;
Pablo Greco e6a3ae
     memory_region_add_subregion(&iommu->mr, 0, MEMORY_REGION(&iommu->iommu_mr));
Pablo Greco e6a3ae
     g_free(name);
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae