qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/2] s390x/pci: add support for guests that request direct


From: David Hildenbrand
Subject: Re: [PATCH v2 1/2] s390x/pci: add support for guests that request direct mapping
Date: Mon, 16 Dec 2024 16:42:51 +0100
User-agent: Mozilla Thunderbird

On 16.12.24 16:37, Philippe Mathieu-Daudé wrote:
Hi Matthew,

On 13/12/24 23:54, Matthew Rosato wrote:
When receiving a guest mpcifc(4) or mpcifc(6) instruction without the T
bit set, treat this as a request to perform direct mapping instead of
address translation.  In order to facilitate this, pin the entirety of
guest memory into the host iommu.

Subsequent guest DMA operations are all expected to be of the format
guest_phys+sdma, allowing them to be used as lookup into the host
iommu table.

Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
   hw/s390x/s390-pci-bus.c         | 34 +++++++++++++++++++++++++++++++--
   hw/s390x/s390-pci-inst.c        | 13 +++++++++++--
   hw/s390x/s390-virtio-ccw.c      |  5 +++++
   include/hw/s390x/s390-pci-bus.h |  4 ++++
   4 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 40b2567aa7..95dbe0c984 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -18,6 +18,7 @@
   #include "hw/s390x/s390-pci-inst.h"
   #include "hw/s390x/s390-pci-kvm.h"
   #include "hw/s390x/s390-pci-vfio.h"
+#include "hw/boards.h"
   #include "hw/pci/pci_bus.h"
   #include "hw/qdev-properties.h"
   #include "hw/pci/pci_bridge.h"
@@ -720,16 +721,43 @@ void s390_pci_iommu_enable(S390PCIIOMMU *iommu)
                                TYPE_S390_IOMMU_MEMORY_REGION, 
OBJECT(&iommu->mr),
                                name, iommu->pal + 1);
       iommu->enabled = true;
+    iommu->direct_map = false;
       memory_region_add_subregion(&iommu->mr, 0, 
MEMORY_REGION(&iommu->iommu_mr));
       g_free(name);
   }
+void s390_pci_iommu_dm_enable(S390PCIIOMMU *iommu)
+{
+    MachineState *ms = MACHINE(qdev_get_machine());
+
+    /*
+     * For direct-mapping we must map the entire guest address space.  Rather
+     * than using an iommu, create a memory region alias that maps GPA X to
+     * iova X + SDMA.  VFIO will handle pinning via its memory listener.
+     */
+    g_autofree char *name = g_strdup_printf("iommu-dm-s390-%04x",
+                                            iommu->pbdev->uid);
+    memory_region_init_alias(&iommu->dm_mr, OBJECT(&iommu->mr), name, ms->ram,
+                             0, ms->ram_size);

Is it a good idea to take the whole machine ram-size here?
Could it be better to pass it as qdev property?

I think we want all guest RAM, just like ordinary vfio on !s390x without a viommu would do.

Matthew, I assume to handle virtio-mem, we would actually pass in here the result from s390_get_memory_limit(), which will cover initial+device RAM, correct? Until then, this would map initial RAM only.

--
Cheers,

David / dhildenb




reply via email to

[Prev in Thread] Current Thread [Next in Thread]