Qemu update to version 6.2.0-59
- arm/virt: Fix vcpu hotplug idx_from_topo_ids - Revert patches related to the vSVA - sync some bugfix patches from upstream - add generic vDPA device support Signed-off-by: yezengruan <yezengruan@huawei.com> (cherry picked from commit b99dbfd9847104300672fb4f559f1c2abba8aa33)
This commit is contained in:
parent
78e641f44e
commit
dec64939c6
140
Fix-several-typos-in-documentation-found-by-codespel.patch
Normal file
140
Fix-several-typos-in-documentation-found-by-codespel.patch
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
From 961450f0cf1e2e3a092dd723d7c63a310a881e93 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 14:37:06 +0800
|
||||||
|
Subject: [PATCH 10/29] Fix several typos in documentation (found by codespell)
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Those typos are in files which are used to generate the QEMU manual.
|
||||||
|
|
||||||
|
Signed-off-by: Stefan Weil <sw@weilnetz.de>
|
||||||
|
Message-Id: <20221110190825.879620-1-sw@weilnetz.de>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||||
|
Reviewed-by: Ani Sinha <ani@anisinha.ca>
|
||||||
|
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
||||||
|
[thuth: update sentence in can.rst as suggested by Peter]
|
||||||
|
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||||
|
Signed-off-by: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/scsi/esp.c | 6 +++---
|
||||||
|
include/exec/memory.h | 6 +++---
|
||||||
|
qemu-options.hx | 4 ++--
|
||||||
|
tests/qtest/libqos/qgraph.h | 2 +-
|
||||||
|
tests/qtest/libqos/virtio-9p.c | 2 +-
|
||||||
|
5 files changed, 10 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
|
||||||
|
index 58d0edbd56..f38231f8cd 100644
|
||||||
|
--- a/hw/scsi/esp.c
|
||||||
|
+++ b/hw/scsi/esp.c
|
||||||
|
@@ -510,7 +510,7 @@ static void do_dma_pdma_cb(ESPState *s)
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Extra message out bytes received: update cmdfifo_cdb_offset
|
||||||
|
- * and then switch to commmand phase
|
||||||
|
+ * and then switch to command phase
|
||||||
|
*/
|
||||||
|
s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
|
||||||
|
s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
|
||||||
|
@@ -622,7 +622,7 @@ static void esp_do_dma(ESPState *s)
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Extra message out bytes received: update cmdfifo_cdb_offset
|
||||||
|
- * and then switch to commmand phase
|
||||||
|
+ * and then switch to command phase
|
||||||
|
*/
|
||||||
|
s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
|
||||||
|
s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
|
||||||
|
@@ -733,7 +733,7 @@ static void esp_do_nodma(ESPState *s)
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Extra message out bytes received: update cmdfifo_cdb_offset
|
||||||
|
- * and then switch to commmand phase
|
||||||
|
+ * and then switch to command phase
|
||||||
|
*/
|
||||||
|
s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
|
||||||
|
s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
|
||||||
|
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
||||||
|
index 4b5b431e45..abb838f194 100644
|
||||||
|
--- a/include/exec/memory.h
|
||||||
|
+++ b/include/exec/memory.h
|
||||||
|
@@ -561,7 +561,7 @@ typedef void (*ReplayRamDiscard)(MemoryRegionSection *section, void *opaque);
|
||||||
|
* A #RamDiscardManager coordinates which parts of specific RAM #MemoryRegion
|
||||||
|
* regions are currently populated to be used/accessed by the VM, notifying
|
||||||
|
* after parts were discarded (freeing up memory) and before parts will be
|
||||||
|
- * populated (consuming memory), to be used/acessed by the VM.
|
||||||
|
+ * populated (consuming memory), to be used/accessed by the VM.
|
||||||
|
*
|
||||||
|
* A #RamDiscardManager can only be set for a RAM #MemoryRegion while the
|
||||||
|
* #MemoryRegion isn't mapped yet; it cannot change while the #MemoryRegion is
|
||||||
|
@@ -585,7 +585,7 @@ typedef void (*ReplayRamDiscard)(MemoryRegionSection *section, void *opaque);
|
||||||
|
* Listeners are called in multiples of the minimum granularity (unless it
|
||||||
|
* would exceed the registered range) and changes are aligned to the minimum
|
||||||
|
* granularity within the #MemoryRegion. Listeners have to prepare for memory
|
||||||
|
- * becomming discarded in a different granularity than it was populated and the
|
||||||
|
+ * becoming discarded in a different granularity than it was populated and the
|
||||||
|
* other way around.
|
||||||
|
*/
|
||||||
|
struct RamDiscardManagerClass {
|
||||||
|
@@ -1242,7 +1242,7 @@ void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
|
||||||
|
Error **errp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
- * memory_region_init_resizeable_ram: Initialize memory region with resizeable
|
||||||
|
+ * memory_region_init_resizeable_ram: Initialize memory region with resizable
|
||||||
|
* RAM. Accesses into the region will
|
||||||
|
* modify memory directly. Only an initial
|
||||||
|
* portion of this RAM is actually used.
|
||||||
|
diff --git a/qemu-options.hx b/qemu-options.hx
|
||||||
|
index 1aaf38c613..047d28a357 100644
|
||||||
|
--- a/qemu-options.hx
|
||||||
|
+++ b/qemu-options.hx
|
||||||
|
@@ -318,7 +318,7 @@ SRST
|
||||||
|
\
|
||||||
|
``-numa cpu,node-id=node[,socket-id=x][,core-id=y][,thread-id=z]``
|
||||||
|
\
|
||||||
|
-``-numa hmat-lb,initiator=node,target=node,hierarchy=hierarchy,data-type=tpye[,latency=lat][,bandwidth=bw]``
|
||||||
|
+``-numa hmat-lb,initiator=node,target=node,hierarchy=hierarchy,data-type=type[,latency=lat][,bandwidth=bw]``
|
||||||
|
\
|
||||||
|
``-numa hmat-cache,node-id=node,size=size,level=level[,associativity=str][,policy=str][,line=size]``
|
||||||
|
Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA
|
||||||
|
@@ -1717,7 +1717,7 @@ SRST
|
||||||
|
directory on host is made directly accessible by guest as a pass-through
|
||||||
|
file system by using the 9P network protocol for communication between
|
||||||
|
host and guests, if desired even accessible, shared by several guests
|
||||||
|
- simultaniously.
|
||||||
|
+ simultaneously.
|
||||||
|
|
||||||
|
Note that ``-virtfs`` is actually just a convenience shortcut for its
|
||||||
|
generalized form ``-fsdev -device virtio-9p-pci``.
|
||||||
|
diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h
|
||||||
|
index 871740c0dc..33d609a06a 100644
|
||||||
|
--- a/tests/qtest/libqos/qgraph.h
|
||||||
|
+++ b/tests/qtest/libqos/qgraph.h
|
||||||
|
@@ -381,7 +381,7 @@ QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent,
|
||||||
|
* mind: only tests with a path down from the actual test case node (leaf) up
|
||||||
|
* to the graph's root node are actually executed by the qtest framework. And
|
||||||
|
* the qtest framework uses QMP to automatically check which QEMU drivers are
|
||||||
|
- * actually currently available, and accordingly qos marks certain pathes as
|
||||||
|
+ * actually currently available, and accordingly qos marks certain paths as
|
||||||
|
* 'unavailable' in such cases (e.g. when QEMU was compiled without support for
|
||||||
|
* a certain feature).
|
||||||
|
*/
|
||||||
|
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
|
||||||
|
index b4e1143288..2941d3cdc6 100644
|
||||||
|
--- a/tests/qtest/libqos/virtio-9p.c
|
||||||
|
+++ b/tests/qtest/libqos/virtio-9p.c
|
||||||
|
@@ -31,7 +31,7 @@
|
||||||
|
static QGuestAllocator *alloc;
|
||||||
|
static char *local_test_path;
|
||||||
|
|
||||||
|
-/* Concatenates the passed 2 pathes. Returned result must be freed. */
|
||||||
|
+/* Concatenates the passed 2 paths. Returned result must be freed. */
|
||||||
|
static char *concat_path(const char* a, const char* b)
|
||||||
|
{
|
||||||
|
return g_build_filename(a, b, NULL);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
28
Revert-hw-arm-smmu-common-Allow-domain-invalidation-.patch
Normal file
28
Revert-hw-arm-smmu-common-Allow-domain-invalidation-.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From c57d05a6ba11075b6998b98a204017c44f81759f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:55 +0800
|
||||||
|
Subject: [PATCH 32/36] Revert "hw/arm/smmu-common: Allow domain invalidation
|
||||||
|
for NH_ALL/NSNH_ALL"
|
||||||
|
|
||||||
|
This reverts commit 876d18c962f0ead31d8458cd7ac19178be78455c.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmu-common.c | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
|
||||||
|
index f253a27e1a..730dd20db1 100644
|
||||||
|
--- a/hw/arm/smmu-common.c
|
||||||
|
+++ b/hw/arm/smmu-common.c
|
||||||
|
@@ -478,7 +478,6 @@ static void smmu_unmap_notifier_range(IOMMUNotifier *n)
|
||||||
|
event.entry.iova = n->start;
|
||||||
|
event.entry.perm = IOMMU_NONE;
|
||||||
|
event.entry.addr_mask = n->end - n->start;
|
||||||
|
- event.entry.granularity = IOMMU_INV_GRAN_DOMAIN;
|
||||||
|
|
||||||
|
memory_region_notify_iommu_one(n, &event);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
30
Revert-hw-arm-smmuv3-Advertise-MSI_TRANSLATE-attribu.patch
Normal file
30
Revert-hw-arm-smmuv3-Advertise-MSI_TRANSLATE-attribu.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From 6ce1e1161c833d59b659a9f50062439a24ce6995 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:36 +0800
|
||||||
|
Subject: [PATCH 17/36] Revert "hw/arm/smmuv3: Advertise MSI_TRANSLATE
|
||||||
|
attribute"
|
||||||
|
|
||||||
|
This reverts commit 5a759ab19d508361053e388694546216705d173b.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 3 ---
|
||||||
|
1 file changed, 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index 275f1db430..5a092506d3 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -1600,9 +1600,6 @@ static int smmuv3_get_attr(IOMMUMemoryRegion *iommu,
|
||||||
|
if (attr == IOMMU_ATTR_VFIO_NESTED) {
|
||||||
|
*(bool *) data = true;
|
||||||
|
return 0;
|
||||||
|
- } else if (attr == IOMMU_ATTR_MSI_TRANSLATE) {
|
||||||
|
- *(bool *) data = true;
|
||||||
|
- return 0;
|
||||||
|
}
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
34
Revert-hw-arm-smmuv3-Allow-MAP-notifiers.patch
Normal file
34
Revert-hw-arm-smmuv3-Allow-MAP-notifiers.patch
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
From 27fb5c981f920fe6ee1345d35d5c3b6cff1b1ce6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:29 +0800
|
||||||
|
Subject: [PATCH 11/36] Revert "hw/arm/smmuv3: Allow MAP notifiers"
|
||||||
|
|
||||||
|
This reverts commit dc126664134989975ce9ab9e7d5d2c8916628bf6.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 8 ++++++++
|
||||||
|
1 file changed, 8 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index 55e78db65d..ed932d3340 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -1632,6 +1632,14 @@ static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (new & IOMMU_NOTIFIER_MAP) {
|
||||||
|
+ error_setg(errp,
|
||||||
|
+ "device %02x.%02x.%x requires iommu MAP notifier which is "
|
||||||
|
+ "not currently supported", pci_bus_num(sdev->bus),
|
||||||
|
+ PCI_SLOT(sdev->devfn), PCI_FUNC(sdev->devfn));
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (old == IOMMU_NOTIFIER_NONE) {
|
||||||
|
trace_smmuv3_notify_flag_add(iommu->parent_obj.name);
|
||||||
|
QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
29
Revert-hw-arm-smmuv3-Fill-the-IOTLBEntry-arch_id-on-.patch
Normal file
29
Revert-hw-arm-smmuv3-Fill-the-IOTLBEntry-arch_id-on-.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From 868d85814a59b1b710b3edf34a0916f6849b72c0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:33 +0800
|
||||||
|
Subject: [PATCH 15/36] Revert "hw/arm/smmuv3: Fill the IOTLBEntry arch_id on
|
||||||
|
NH_VA invalidation"
|
||||||
|
|
||||||
|
This reverts commit dcda615b3d9b1acffee3d31d57974cc9e4bd0dee.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 2 --
|
||||||
|
1 file changed, 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index 3751fb3ea8..e09e54a9aa 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -837,8 +837,6 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
|
event.entry.iova = iova;
|
||||||
|
event.entry.addr_mask = num_pages * (1 << granule) - 1;
|
||||||
|
event.entry.perm = IOMMU_NONE;
|
||||||
|
- event.entry.flags = IOMMU_INV_FLAGS_ARCHID;
|
||||||
|
- event.entry.arch_id = asid;
|
||||||
|
|
||||||
|
memory_region_notify_iommu_one(n, &event);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
73
Revert-hw-arm-smmuv3-Fill-the-IOTLBEntry-leaf-field-.patch
Normal file
73
Revert-hw-arm-smmuv3-Fill-the-IOTLBEntry-leaf-field-.patch
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
From 62e581d9c6adfa3aebcefa8c5270aa6fc38ed541 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:32 +0800
|
||||||
|
Subject: [PATCH 14/36] Revert "hw/arm/smmuv3: Fill the IOTLBEntry leaf field
|
||||||
|
on NH_VA invalidation"
|
||||||
|
|
||||||
|
This reverts commit c219274b7b6a472d7340a4f72a052ba33ed19659.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 11 +++++------
|
||||||
|
1 file changed, 5 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index cceb3794d4..3751fb3ea8 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -804,7 +804,7 @@ epilogue:
|
||||||
|
static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
|
IOMMUNotifier *n,
|
||||||
|
int asid, dma_addr_t iova,
|
||||||
|
- uint8_t tg, uint64_t num_pages, bool leaf)
|
||||||
|
+ uint8_t tg, uint64_t num_pages)
|
||||||
|
{
|
||||||
|
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
|
||||||
|
IOMMUTLBEvent event = {};
|
||||||
|
@@ -839,7 +839,6 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
|
event.entry.perm = IOMMU_NONE;
|
||||||
|
event.entry.flags = IOMMU_INV_FLAGS_ARCHID;
|
||||||
|
event.entry.arch_id = asid;
|
||||||
|
- event.entry.leaf = leaf;
|
||||||
|
|
||||||
|
memory_region_notify_iommu_one(n, &event);
|
||||||
|
}
|
||||||
|
@@ -871,7 +870,7 @@ static void smmuv3_notify_asid(IOMMUMemoryRegion *mr,
|
||||||
|
|
||||||
|
/* invalidate an asid/iova range tuple in all mr's */
|
||||||
|
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
||||||
|
- uint8_t tg, uint64_t num_pages, bool leaf)
|
||||||
|
+ uint8_t tg, uint64_t num_pages)
|
||||||
|
{
|
||||||
|
SMMUDevice *sdev;
|
||||||
|
|
||||||
|
@@ -883,7 +882,7 @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
||||||
|
tg, num_pages);
|
||||||
|
|
||||||
|
IOMMU_NOTIFIER_FOREACH(n, mr) {
|
||||||
|
- smmuv3_notify_iova(mr, n, asid, iova, tg, num_pages, leaf);
|
||||||
|
+ smmuv3_notify_iova(mr, n, asid, iova, tg, num_pages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -908,7 +907,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
||||||
|
|
||||||
|
if (!tg) {
|
||||||
|
trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
|
||||||
|
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1, leaf);
|
||||||
|
+ smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
|
||||||
|
smmu_iotlb_inv_iova(s, asid, addr, tg, 1, ttl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@@ -926,7 +925,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
||||||
|
|
||||||
|
num_pages = (mask + 1) >> granule;
|
||||||
|
trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
|
||||||
|
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages, leaf);
|
||||||
|
+ smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
|
||||||
|
smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl);
|
||||||
|
addr += mask + 1;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
104
Revert-hw-arm-smmuv3-Implement-fault-injection.patch
Normal file
104
Revert-hw-arm-smmuv3-Implement-fault-injection.patch
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
From 822386d862324be3c334faff790c1f6a64c5455a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:30 +0800
|
||||||
|
Subject: [PATCH 12/36] Revert "hw/arm/smmuv3: Implement fault injection"
|
||||||
|
|
||||||
|
This reverts commit d31c754470b4b651d0e19c66738fbcc8fc6abf3c.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 71 -------------------------------------------------
|
||||||
|
1 file changed, 71 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index ed932d3340..514ce9d57d 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -1664,76 +1664,6 @@ static int smmuv3_get_attr(IOMMUMemoryRegion *iommu,
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
-struct iommu_fault;
|
||||||
|
-
|
||||||
|
-static inline int
|
||||||
|
-smmuv3_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
|
||||||
|
- struct iommu_fault *buf)
|
||||||
|
-{
|
||||||
|
-#ifdef __linux__
|
||||||
|
- SMMUDevice *sdev = container_of(iommu_mr, SMMUDevice, iommu);
|
||||||
|
- SMMUv3State *s3 = sdev->smmu;
|
||||||
|
- uint32_t sid = smmu_get_sid(sdev);
|
||||||
|
- int i;
|
||||||
|
-
|
||||||
|
- for (i = 0; i < count; i++) {
|
||||||
|
- SMMUEventInfo info = {};
|
||||||
|
- struct iommu_fault_unrecoverable *record;
|
||||||
|
-
|
||||||
|
- if (buf[i].type != IOMMU_FAULT_DMA_UNRECOV) {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- info.sid = sid;
|
||||||
|
- record = &buf[i].event;
|
||||||
|
-
|
||||||
|
- switch (record->reason) {
|
||||||
|
- case IOMMU_FAULT_REASON_PASID_INVALID:
|
||||||
|
- info.type = SMMU_EVT_C_BAD_SUBSTREAMID;
|
||||||
|
- /* TODO further fill info.u.c_bad_substream */
|
||||||
|
- break;
|
||||||
|
- case IOMMU_FAULT_REASON_PASID_FETCH:
|
||||||
|
- info.type = SMMU_EVT_F_CD_FETCH;
|
||||||
|
- break;
|
||||||
|
- case IOMMU_FAULT_REASON_BAD_PASID_ENTRY:
|
||||||
|
- info.type = SMMU_EVT_C_BAD_CD;
|
||||||
|
- /* TODO further fill info.u.c_bad_cd */
|
||||||
|
- break;
|
||||||
|
- case IOMMU_FAULT_REASON_WALK_EABT:
|
||||||
|
- info.type = SMMU_EVT_F_WALK_EABT;
|
||||||
|
- info.u.f_walk_eabt.addr = record->addr;
|
||||||
|
- info.u.f_walk_eabt.addr2 = record->fetch_addr;
|
||||||
|
- break;
|
||||||
|
- case IOMMU_FAULT_REASON_PTE_FETCH:
|
||||||
|
- info.type = SMMU_EVT_F_TRANSLATION;
|
||||||
|
- info.u.f_translation.addr = record->addr;
|
||||||
|
- break;
|
||||||
|
- case IOMMU_FAULT_REASON_OOR_ADDRESS:
|
||||||
|
- info.type = SMMU_EVT_F_ADDR_SIZE;
|
||||||
|
- info.u.f_addr_size.addr = record->addr;
|
||||||
|
- break;
|
||||||
|
- case IOMMU_FAULT_REASON_ACCESS:
|
||||||
|
- info.type = SMMU_EVT_F_ACCESS;
|
||||||
|
- info.u.f_access.addr = record->addr;
|
||||||
|
- break;
|
||||||
|
- case IOMMU_FAULT_REASON_PERMISSION:
|
||||||
|
- info.type = SMMU_EVT_F_PERMISSION;
|
||||||
|
- info.u.f_permission.addr = record->addr;
|
||||||
|
- break;
|
||||||
|
- default:
|
||||||
|
- warn_report("%s Unexpected fault reason received from host: %d",
|
||||||
|
- __func__, record->reason);
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- smmuv3_record_event(s3, &info);
|
||||||
|
- }
|
||||||
|
- return 0;
|
||||||
|
-#else
|
||||||
|
- return -1;
|
||||||
|
-#endif
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
@@ -1742,7 +1672,6 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
||||||
|
imrc->translate = smmuv3_translate;
|
||||||
|
imrc->notify_flag_changed = smmuv3_notify_flag_changed;
|
||||||
|
imrc->get_attr = smmuv3_get_attr;
|
||||||
|
- imrc->inject_faults = smmuv3_inject_faults;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const TypeInfo smmuv3_type_info = {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
98
Revert-hw-arm-smmuv3-Improve-stage1-ASID-invalidatio.patch
Normal file
98
Revert-hw-arm-smmuv3-Improve-stage1-ASID-invalidatio.patch
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
From 98ca0862f34c891a0e381bd382306398b88ac5bc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:56 +0800
|
||||||
|
Subject: [PATCH 33/36] Revert "hw/arm/smmuv3: Improve stage1 ASID
|
||||||
|
invalidation"
|
||||||
|
|
||||||
|
This reverts commit de53feaa37a267a21ed30a642e1e64c5fcfbc4a4.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 44 ++------------------------------------------
|
||||||
|
hw/arm/trace-events | 1 -
|
||||||
|
2 files changed, 2 insertions(+), 43 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index f4de66827d..0e8fe646aa 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -840,31 +840,6 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
|
memory_region_notify_iommu_one(n, &event);
|
||||||
|
}
|
||||||
|
|
||||||
|
-/**
|
||||||
|
- * smmuv3_notify_asid - call the notifier @n for a given asid
|
||||||
|
- *
|
||||||
|
- * @mr: IOMMU mr region handle
|
||||||
|
- * @n: notifier to be called
|
||||||
|
- * @asid: address space ID or negative value if we don't care
|
||||||
|
- */
|
||||||
|
-static void smmuv3_notify_asid(IOMMUMemoryRegion *mr,
|
||||||
|
- IOMMUNotifier *n, int asid)
|
||||||
|
-{
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
-
|
||||||
|
- event.type = IOMMU_NOTIFIER_UNMAP;
|
||||||
|
- event.entry.target_as = &address_space_memory;
|
||||||
|
- event.entry.perm = IOMMU_NONE;
|
||||||
|
- event.entry.granularity = IOMMU_INV_GRAN_PASID;
|
||||||
|
- event.entry.flags = IOMMU_INV_FLAGS_ARCHID;
|
||||||
|
- event.entry.arch_id = asid;
|
||||||
|
- event.entry.iova = n->start;
|
||||||
|
- event.entry.addr_mask = n->end - n->start;
|
||||||
|
-
|
||||||
|
- memory_region_notify_iommu_one(n, &event);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-
|
||||||
|
/* invalidate an asid/iova range tuple in all mr's */
|
||||||
|
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
||||||
|
uint8_t tg, uint64_t num_pages)
|
||||||
|
@@ -942,22 +917,6 @@ smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void smmuv3_s1_asid_inval(SMMUState *s, uint16_t asid)
|
||||||
|
-{
|
||||||
|
- SMMUDevice *sdev;
|
||||||
|
-
|
||||||
|
- trace_smmuv3_s1_asid_inval(asid);
|
||||||
|
- QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
|
||||||
|
- IOMMUMemoryRegion *mr = &sdev->iommu;
|
||||||
|
- IOMMUNotifier *n;
|
||||||
|
-
|
||||||
|
- IOMMU_NOTIFIER_FOREACH(n, mr) {
|
||||||
|
- smmuv3_notify_asid(mr, n, asid);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- smmu_iotlb_inv_asid(s, asid);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static int smmuv3_cmdq_consume(SMMUv3State *s)
|
||||||
|
{
|
||||||
|
SMMUState *bs = ARM_SMMU(s);
|
||||||
|
@@ -1072,7 +1031,8 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
|
||||||
|
uint16_t asid = CMD_ASID(&cmd);
|
||||||
|
|
||||||
|
trace_smmuv3_cmdq_tlbi_nh_asid(asid);
|
||||||
|
- smmuv3_s1_asid_inval(bs, asid);
|
||||||
|
+ smmu_inv_notifiers_all(&s->smmu_state);
|
||||||
|
+ smmu_iotlb_inv_asid(bs, asid);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMMU_CMD_TLBI_NH_ALL:
|
||||||
|
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
|
||||||
|
index 1447ad5a90..2dee296c8f 100644
|
||||||
|
--- a/hw/arm/trace-events
|
||||||
|
+++ b/hw/arm/trace-events
|
||||||
|
@@ -46,7 +46,6 @@ smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x"
|
||||||
|
smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
|
||||||
|
smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
|
||||||
|
smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d"
|
||||||
|
-smmuv3_s1_asid_inval(int asid) "asid=%d"
|
||||||
|
smmuv3_cmdq_tlbi_nh(void) ""
|
||||||
|
smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d"
|
||||||
|
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
157
Revert-hw-arm-smmuv3-Pass-stage-1-configurations-to-.patch
Normal file
157
Revert-hw-arm-smmuv3-Pass-stage-1-configurations-to-.patch
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
From 9682b8cd2454c00fbb4c4f7eb3e959187d9e6f1c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:31 +0800
|
||||||
|
Subject: [PATCH 13/36] Revert "hw/arm/smmuv3: Pass stage 1 configurations to
|
||||||
|
the host"
|
||||||
|
|
||||||
|
This reverts commit 2e5929ec2a35a7a227dc7ba70a557a84993a366d.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmu-internal.h | 1 -
|
||||||
|
hw/arm/smmuv3.c | 71 ++++++------------------------------------
|
||||||
|
hw/arm/trace-events | 1 -
|
||||||
|
3 files changed, 9 insertions(+), 64 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
|
||||||
|
index 5ef8c598c6..2d75b31953 100644
|
||||||
|
--- a/hw/arm/smmu-internal.h
|
||||||
|
+++ b/hw/arm/smmu-internal.h
|
||||||
|
@@ -105,7 +105,6 @@ typedef struct SMMUIOTLBPageInvInfo {
|
||||||
|
} SMMUIOTLBPageInvInfo;
|
||||||
|
|
||||||
|
typedef struct SMMUSIDRange {
|
||||||
|
- SMMUState *state;
|
||||||
|
uint32_t start;
|
||||||
|
uint32_t end;
|
||||||
|
} SMMUSIDRange;
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index 514ce9d57d..cceb3794d4 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -16,10 +16,6 @@
|
||||||
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-#ifdef __linux__
|
||||||
|
-#include "linux/iommu.h"
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/bitops.h"
|
||||||
|
#include "hw/irq.h"
|
||||||
|
@@ -936,61 +932,6 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
||||||
|
-{
|
||||||
|
-#ifdef __linux__
|
||||||
|
- IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid);
|
||||||
|
- SMMUEventInfo event = {.type = SMMU_EVT_NONE, .sid = sid,
|
||||||
|
- .inval_ste_allowed = true};
|
||||||
|
- IOMMUConfig iommu_config = {};
|
||||||
|
- SMMUTransCfg *cfg;
|
||||||
|
- SMMUDevice *sdev;
|
||||||
|
-
|
||||||
|
- if (!mr) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- sdev = container_of(mr, SMMUDevice, iommu);
|
||||||
|
-
|
||||||
|
- /* flush QEMU config cache */
|
||||||
|
- smmuv3_flush_config(sdev);
|
||||||
|
-
|
||||||
|
- if (!pci_device_is_pasid_ops_set(sdev->bus, sdev->devfn)) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- cfg = smmuv3_get_config(sdev, &event);
|
||||||
|
-
|
||||||
|
- if (!cfg) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- iommu_config.pasid_cfg.argsz = sizeof(struct iommu_pasid_table_config);
|
||||||
|
- iommu_config.pasid_cfg.version = PASID_TABLE_CFG_VERSION_1;
|
||||||
|
- iommu_config.pasid_cfg.format = IOMMU_PASID_FORMAT_SMMUV3;
|
||||||
|
- iommu_config.pasid_cfg.base_ptr = cfg->s1ctxptr;
|
||||||
|
- iommu_config.pasid_cfg.pasid_bits = 0;
|
||||||
|
- iommu_config.pasid_cfg.vendor_data.smmuv3.version = PASID_TABLE_SMMUV3_CFG_VERSION_1;
|
||||||
|
-
|
||||||
|
- if (cfg->disabled || cfg->bypassed) {
|
||||||
|
- iommu_config.pasid_cfg.config = IOMMU_PASID_CONFIG_BYPASS;
|
||||||
|
- } else if (cfg->aborted) {
|
||||||
|
- iommu_config.pasid_cfg.config = IOMMU_PASID_CONFIG_ABORT;
|
||||||
|
- } else {
|
||||||
|
- iommu_config.pasid_cfg.config = IOMMU_PASID_CONFIG_TRANSLATE;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- trace_smmuv3_notify_config_change(mr->parent_obj.name,
|
||||||
|
- iommu_config.pasid_cfg.config,
|
||||||
|
- iommu_config.pasid_cfg.base_ptr);
|
||||||
|
-
|
||||||
|
- if (pci_device_set_pasid_table(sdev->bus, sdev->devfn, &iommu_config)) {
|
||||||
|
- error_report("Failed to pass PASID table to host for iommu mr %s (%m)",
|
||||||
|
- mr->parent_obj.name);
|
||||||
|
- }
|
||||||
|
-#endif
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static gboolean
|
||||||
|
smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
|
||||||
|
{
|
||||||
|
@@ -1001,7 +942,6 @@ smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
|
||||||
|
if (sid < sid_range->start || sid > sid_range->end) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
- smmuv3_notify_config_change(sid_range->state, sid);
|
||||||
|
trace_smmuv3_config_cache_inv(sid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -1072,14 +1012,22 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
|
||||||
|
case SMMU_CMD_CFGI_STE:
|
||||||
|
{
|
||||||
|
uint32_t sid = CMD_SID(&cmd);
|
||||||
|
+ IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid);
|
||||||
|
+ SMMUDevice *sdev;
|
||||||
|
|
||||||
|
if (CMD_SSEC(&cmd)) {
|
||||||
|
cmd_error = SMMU_CERROR_ILL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (!mr) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
trace_smmuv3_cmdq_cfgi_ste(sid);
|
||||||
|
- smmuv3_notify_config_change(bs, sid);
|
||||||
|
+ sdev = container_of(mr, SMMUDevice, iommu);
|
||||||
|
+ smmuv3_flush_config(sdev);
|
||||||
|
+
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMMU_CMD_CFGI_STE_RANGE: /* same as SMMU_CMD_CFGI_ALL */
|
||||||
|
@@ -1094,7 +1042,6 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
|
||||||
|
}
|
||||||
|
|
||||||
|
mask = (1ULL << (range + 1)) - 1;
|
||||||
|
- sid_range.state = bs;
|
||||||
|
sid_range.start = sid & ~mask;
|
||||||
|
sid_range.end = sid_range.start + mask;
|
||||||
|
|
||||||
|
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
|
||||||
|
index d9851d663e..1447ad5a90 100644
|
||||||
|
--- a/hw/arm/trace-events
|
||||||
|
+++ b/hw/arm/trace-events
|
||||||
|
@@ -53,5 +53,4 @@ smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
|
||||||
|
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
|
||||||
|
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
|
||||||
|
smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
|
||||||
|
-smmuv3_notify_config_change(const char *name, uint8_t config, uint64_t s1ctxptr) "iommu mr=%s config=%d s1ctxptr=0x%"PRIx64
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
105
Revert-hw-arm-smmuv3-Post-load-stage-1-configuration.patch
Normal file
105
Revert-hw-arm-smmuv3-Post-load-stage-1-configuration.patch
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
From c3dab32ec9b111e036b7de9cb8cb5a987b1764f3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:16 +0800
|
||||||
|
Subject: [PATCH 03/36] Revert "hw/arm/smmuv3: Post-load stage 1 configurations
|
||||||
|
to the host"
|
||||||
|
|
||||||
|
This reverts commit 1b95c995f032c21bf6607dda8ede0f5856bb190a.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 33 +++++----------------------------
|
||||||
|
1 file changed, 5 insertions(+), 28 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index 2bd9f22055..55e78db65d 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -936,7 +936,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
||||||
|
+static void smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
||||||
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid);
|
||||||
|
@@ -945,10 +945,9 @@ static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
||||||
|
IOMMUConfig iommu_config = {};
|
||||||
|
SMMUTransCfg *cfg;
|
||||||
|
SMMUDevice *sdev;
|
||||||
|
- int ret;
|
||||||
|
|
||||||
|
if (!mr) {
|
||||||
|
- return 0;
|
||||||
|
+ return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdev = container_of(mr, SMMUDevice, iommu);
|
||||||
|
@@ -957,13 +956,13 @@ static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
||||||
|
smmuv3_flush_config(sdev);
|
||||||
|
|
||||||
|
if (!pci_device_is_pasid_ops_set(sdev->bus, sdev->devfn)) {
|
||||||
|
- return 0;
|
||||||
|
+ return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg = smmuv3_get_config(sdev, &event);
|
||||||
|
|
||||||
|
if (!cfg) {
|
||||||
|
- return 0;
|
||||||
|
+ return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iommu_config.pasid_cfg.argsz = sizeof(struct iommu_pasid_table_config);
|
||||||
|
@@ -985,13 +984,10 @@ static int smmuv3_notify_config_change(SMMUState *bs, uint32_t sid)
|
||||||
|
iommu_config.pasid_cfg.config,
|
||||||
|
iommu_config.pasid_cfg.base_ptr);
|
||||||
|
|
||||||
|
- ret = pci_device_set_pasid_table(sdev->bus, sdev->devfn, &iommu_config);
|
||||||
|
- if (ret) {
|
||||||
|
+ if (pci_device_set_pasid_table(sdev->bus, sdev->devfn, &iommu_config)) {
|
||||||
|
error_report("Failed to pass PASID table to host for iommu mr %s (%m)",
|
||||||
|
mr->parent_obj.name);
|
||||||
|
}
|
||||||
|
-
|
||||||
|
- return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1561,24 +1557,6 @@ static void smmu_realize(DeviceState *d, Error **errp)
|
||||||
|
smmu_init_irq(s, dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int smmuv3_post_load(void *opaque, int version_id)
|
||||||
|
-{
|
||||||
|
- SMMUv3State *s3 = opaque;
|
||||||
|
- SMMUState *s = &(s3->smmu_state);
|
||||||
|
- SMMUDevice *sdev;
|
||||||
|
- int ret = 0;
|
||||||
|
-
|
||||||
|
- QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
|
||||||
|
- uint32_t sid = smmu_get_sid(sdev);
|
||||||
|
- ret = smmuv3_notify_config_change(s, sid);
|
||||||
|
- if (ret) {
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return ret;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static const VMStateDescription vmstate_smmuv3_queue = {
|
||||||
|
.name = "smmuv3_queue",
|
||||||
|
.version_id = 1,
|
||||||
|
@@ -1597,7 +1575,6 @@ static const VMStateDescription vmstate_smmuv3 = {
|
||||||
|
.version_id = 1,
|
||||||
|
.minimum_version_id = 1,
|
||||||
|
.priority = MIG_PRI_IOMMU,
|
||||||
|
- .post_load = smmuv3_post_load,
|
||||||
|
.fields = (VMStateField[]) {
|
||||||
|
VMSTATE_UINT32(features, SMMUv3State),
|
||||||
|
VMSTATE_UINT8(sid_size, SMMUv3State),
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
41
Revert-hw-arm-smmuv3-Store-the-PASID-table-GPA-in-th.patch
Normal file
41
Revert-hw-arm-smmuv3-Store-the-PASID-table-GPA-in-th.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From 7d0023ef0c909bc569477e7676bc4c43734783a3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:35 +0800
|
||||||
|
Subject: [PATCH 16/36] Revert "hw/arm/smmuv3: Store the PASID table GPA in the
|
||||||
|
translation config"
|
||||||
|
|
||||||
|
This reverts commit f937ce4124d57eea27d516957a2efa0e7fbdf198.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 1 -
|
||||||
|
include/hw/arm/smmu-common.h | 1 -
|
||||||
|
2 files changed, 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index e09e54a9aa..275f1db430 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -362,7 +362,6 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
|
||||||
|
"SMMUv3 S1 stalling fault model not allowed yet\n");
|
||||||
|
goto bad_ste;
|
||||||
|
}
|
||||||
|
- cfg->s1ctxptr = STE_CTXPTR(ste);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
bad_ste:
|
||||||
|
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
|
||||||
|
index d578339935..706be3c6d0 100644
|
||||||
|
--- a/include/hw/arm/smmu-common.h
|
||||||
|
+++ b/include/hw/arm/smmu-common.h
|
||||||
|
@@ -76,7 +76,6 @@ typedef struct SMMUTransCfg {
|
||||||
|
uint8_t tbi; /* Top Byte Ignore */
|
||||||
|
uint16_t asid;
|
||||||
|
SMMUTransTableInfo tt[2];
|
||||||
|
- dma_addr_t s1ctxptr;
|
||||||
|
uint32_t iotlb_hits; /* counts IOTLB hits for this asid */
|
||||||
|
uint32_t iotlb_misses; /* counts IOTLB misses for this asid */
|
||||||
|
} SMMUTransCfg;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
50
Revert-iommu-Introduce-generic-header.patch
Normal file
50
Revert-iommu-Introduce-generic-header.patch
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
From 2916e0465befa35df9cce14b761177be55ccce4d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:50 +0800
|
||||||
|
Subject: [PATCH 28/36] Revert "iommu: Introduce generic header"
|
||||||
|
|
||||||
|
This reverts commit 5e312f7b41ec48dc7dc9805af9f52aa8ed393bf9.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
include/hw/iommu/iommu.h | 28 ----------------------------
|
||||||
|
1 file changed, 28 deletions(-)
|
||||||
|
delete mode 100644 include/hw/iommu/iommu.h
|
||||||
|
|
||||||
|
diff --git a/include/hw/iommu/iommu.h b/include/hw/iommu/iommu.h
|
||||||
|
deleted file mode 100644
|
||||||
|
index 12092bda7b..0000000000
|
||||||
|
--- a/include/hw/iommu/iommu.h
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,28 +0,0 @@
|
||||||
|
-/*
|
||||||
|
- * common header for iommu devices
|
||||||
|
- *
|
||||||
|
- * Copyright Red Hat, Inc. 2019
|
||||||
|
- *
|
||||||
|
- * Authors:
|
||||||
|
- * Eric Auger <eric.auger@redhat.com>
|
||||||
|
- *
|
||||||
|
- * This work is licensed under the terms of the GNU GPL, version 2. See
|
||||||
|
- * the COPYING file in the top-level directory.
|
||||||
|
- */
|
||||||
|
-
|
||||||
|
-#ifndef QEMU_HW_IOMMU_IOMMU_H
|
||||||
|
-#define QEMU_HW_IOMMU_IOMMU_H
|
||||||
|
-#ifdef __linux__
|
||||||
|
-#include <linux/iommu.h>
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
-typedef struct IOMMUConfig {
|
||||||
|
- union {
|
||||||
|
-#ifdef __linux__
|
||||||
|
- struct iommu_pasid_table_config pasid_cfg;
|
||||||
|
-#endif
|
||||||
|
- };
|
||||||
|
-} IOMMUConfig;
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-#endif /* QEMU_HW_IOMMU_IOMMU_H */
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
28
Revert-memory-Add-IOMMU_ATTR_MSI_TRANSLATE-IOMMU-mem.patch
Normal file
28
Revert-memory-Add-IOMMU_ATTR_MSI_TRANSLATE-IOMMU-mem.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From eb4958875239ccfabc03f28738d520c75db638d5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:52 +0800
|
||||||
|
Subject: [PATCH 30/36] Revert "memory: Add IOMMU_ATTR_MSI_TRANSLATE IOMMU
|
||||||
|
memory region attribute"
|
||||||
|
|
||||||
|
This reverts commit 062923fd4e6d11e1b724f2dd059f8b0c6e65bf7a.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
include/exec/memory.h | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
||||||
|
index 67d9061766..229c9cf85b 100644
|
||||||
|
--- a/include/exec/memory.h
|
||||||
|
+++ b/include/exec/memory.h
|
||||||
|
@@ -326,7 +326,6 @@ typedef struct MemoryRegionClass {
|
||||||
|
enum IOMMUMemoryRegionAttr {
|
||||||
|
IOMMU_ATTR_SPAPR_TCE_FD,
|
||||||
|
IOMMU_ATTR_VFIO_NESTED,
|
||||||
|
- IOMMU_ATTR_MSI_TRANSLATE,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
61
Revert-memory-Add-IOMMU_ATTR_VFIO_NESTED-IOMMU-memor.patch
Normal file
61
Revert-memory-Add-IOMMU_ATTR_VFIO_NESTED-IOMMU-memor.patch
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
From 4c9e81175e15ca78c7ba7090ec20ea10c9e12751 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:53 +0800
|
||||||
|
Subject: [PATCH 31/36] Revert "memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory
|
||||||
|
region attribute"
|
||||||
|
|
||||||
|
This reverts commit b380e3e0c30fb68dbbfb1397f3c374adfff77ac4.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmuv3.c | 12 ------------
|
||||||
|
include/exec/memory.h | 3 +--
|
||||||
|
2 files changed, 1 insertion(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index 5a092506d3..f4de66827d 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -1593,17 +1593,6 @@ static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int smmuv3_get_attr(IOMMUMemoryRegion *iommu,
|
||||||
|
- enum IOMMUMemoryRegionAttr attr,
|
||||||
|
- void *data)
|
||||||
|
-{
|
||||||
|
- if (attr == IOMMU_ATTR_VFIO_NESTED) {
|
||||||
|
- *(bool *) data = true;
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- return -EINVAL;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
@@ -1611,7 +1600,6 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
||||||
|
|
||||||
|
imrc->translate = smmuv3_translate;
|
||||||
|
imrc->notify_flag_changed = smmuv3_notify_flag_changed;
|
||||||
|
- imrc->get_attr = smmuv3_get_attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const TypeInfo smmuv3_type_info = {
|
||||||
|
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
||||||
|
index 229c9cf85b..273f7f45d3 100644
|
||||||
|
--- a/include/exec/memory.h
|
||||||
|
+++ b/include/exec/memory.h
|
||||||
|
@@ -324,8 +324,7 @@ typedef struct MemoryRegionClass {
|
||||||
|
|
||||||
|
|
||||||
|
enum IOMMUMemoryRegionAttr {
|
||||||
|
- IOMMU_ATTR_SPAPR_TCE_FD,
|
||||||
|
- IOMMU_ATTR_VFIO_NESTED,
|
||||||
|
+ IOMMU_ATTR_SPAPR_TCE_FD
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
166
Revert-memory-Add-new-fields-in-IOTLBEntry.patch
Normal file
166
Revert-memory-Add-new-fields-in-IOTLBEntry.patch
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
From 8cc370faf56aeaa060e1b4d9a307075bae982563 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:57 +0800
|
||||||
|
Subject: [PATCH 34/36] Revert "memory: Add new fields in IOTLBEntry"
|
||||||
|
|
||||||
|
This reverts commit da97cef20d4ee5a8f3942953836b35e7f7dd974f.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/arm/smmu-common.c | 2 +-
|
||||||
|
hw/arm/smmuv3.c | 2 +-
|
||||||
|
hw/i386/intel_iommu.c | 6 +++---
|
||||||
|
hw/ppc/spapr_iommu.c | 2 +-
|
||||||
|
hw/virtio/virtio-iommu.c | 4 ++--
|
||||||
|
include/exec/memory.h | 36 +-----------------------------------
|
||||||
|
6 files changed, 9 insertions(+), 43 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
|
||||||
|
index 730dd20db1..e09b9c13b7 100644
|
||||||
|
--- a/hw/arm/smmu-common.c
|
||||||
|
+++ b/hw/arm/smmu-common.c
|
||||||
|
@@ -471,7 +471,7 @@ IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid)
|
||||||
|
/* Unmap the whole notifier's range */
|
||||||
|
static void smmu_unmap_notifier_range(IOMMUNotifier *n)
|
||||||
|
{
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
|
||||||
|
event.type = IOMMU_NOTIFIER_UNMAP;
|
||||||
|
event.entry.target_as = &address_space_memory;
|
||||||
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||||||
|
index 0e8fe646aa..3b43368be0 100644
|
||||||
|
--- a/hw/arm/smmuv3.c
|
||||||
|
+++ b/hw/arm/smmuv3.c
|
||||||
|
@@ -806,7 +806,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
|
uint8_t tg, uint64_t num_pages)
|
||||||
|
{
|
||||||
|
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
uint8_t granule;
|
||||||
|
|
||||||
|
if (!tg) {
|
||||||
|
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
|
||||||
|
index 6501d93f7e..5b865ac08c 100644
|
||||||
|
--- a/hw/i386/intel_iommu.c
|
||||||
|
+++ b/hw/i386/intel_iommu.c
|
||||||
|
@@ -1197,7 +1197,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,
|
||||||
|
uint32_t offset;
|
||||||
|
uint64_t slpte;
|
||||||
|
uint64_t subpage_size, subpage_mask;
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
uint64_t iova = start;
|
||||||
|
uint64_t iova_next;
|
||||||
|
int ret = 0;
|
||||||
|
@@ -2431,7 +2431,7 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s,
|
||||||
|
VTDInvDesc *inv_desc)
|
||||||
|
{
|
||||||
|
VTDAddressSpace *vtd_dev_as;
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
struct VTDBus *vtd_bus;
|
||||||
|
hwaddr addr;
|
||||||
|
uint64_t sz;
|
||||||
|
@@ -3487,7 +3487,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
|
||||||
|
size = remain = end - start + 1;
|
||||||
|
|
||||||
|
while (remain >= VTD_PAGE_SIZE) {
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
uint64_t mask = dma_aligned_pow2_mask(start, end, s->aw_bits);
|
||||||
|
uint64_t size = mask + 1;
|
||||||
|
|
||||||
|
diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
|
||||||
|
index 454df25d44..db01071858 100644
|
||||||
|
--- a/hw/ppc/spapr_iommu.c
|
||||||
|
+++ b/hw/ppc/spapr_iommu.c
|
||||||
|
@@ -449,7 +449,7 @@ static void spapr_tce_reset(DeviceState *dev)
|
||||||
|
static target_ulong put_tce_emu(SpaprTceTable *tcet, target_ulong ioba,
|
||||||
|
target_ulong tce)
|
||||||
|
{
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
hwaddr page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
||||||
|
unsigned long index = (ioba - tcet->bus_offset) >> tcet->page_shift;
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
|
||||||
|
index 83ed2b82e6..1b23e8e18c 100644
|
||||||
|
--- a/hw/virtio/virtio-iommu.c
|
||||||
|
+++ b/hw/virtio/virtio-iommu.c
|
||||||
|
@@ -129,7 +129,7 @@ static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
||||||
|
hwaddr virt_end, hwaddr paddr,
|
||||||
|
uint32_t flags)
|
||||||
|
{
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
IOMMUAccessFlags perm = IOMMU_ACCESS_FLAG(flags & VIRTIO_IOMMU_MAP_F_READ,
|
||||||
|
flags & VIRTIO_IOMMU_MAP_F_WRITE);
|
||||||
|
|
||||||
|
@@ -154,7 +154,7 @@ static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
||||||
|
static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
||||||
|
hwaddr virt_end)
|
||||||
|
{
|
||||||
|
- IOMMUTLBEvent event = {};
|
||||||
|
+ IOMMUTLBEvent event;
|
||||||
|
uint64_t delta = virt_end - virt_start;
|
||||||
|
|
||||||
|
if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) {
|
||||||
|
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
||||||
|
index 273f7f45d3..4b5b431e45 100644
|
||||||
|
--- a/include/exec/memory.h
|
||||||
|
+++ b/include/exec/memory.h
|
||||||
|
@@ -116,48 +116,14 @@ typedef enum {
|
||||||
|
IOMMU_RW = 3,
|
||||||
|
} IOMMUAccessFlags;
|
||||||
|
|
||||||
|
-/* Granularity of the cache invalidation */
|
||||||
|
-typedef enum {
|
||||||
|
- IOMMU_INV_GRAN_ADDR = 0,
|
||||||
|
- IOMMU_INV_GRAN_PASID,
|
||||||
|
- IOMMU_INV_GRAN_DOMAIN,
|
||||||
|
-} IOMMUInvGranularity;
|
||||||
|
-
|
||||||
|
#define IOMMU_ACCESS_FLAG(r, w) (((r) ? IOMMU_RO : 0) | ((w) ? IOMMU_WO : 0))
|
||||||
|
|
||||||
|
-/**
|
||||||
|
- * struct IOMMUTLBEntry - IOMMU TLB entry
|
||||||
|
- *
|
||||||
|
- * Structure used when performing a translation or when notifying MAP or
|
||||||
|
- * UNMAP (invalidation) events
|
||||||
|
- *
|
||||||
|
- * @target_as: target address space
|
||||||
|
- * @iova: IO virtual address (input)
|
||||||
|
- * @translated_addr: translated address (output)
|
||||||
|
- * @addr_mask: address mask (0xfff means 4K binding), must be multiple of 2
|
||||||
|
- * @perm: permission flag of the mapping (NONE encodes no mapping or
|
||||||
|
- * invalidation notification)
|
||||||
|
- * @granularity: granularity of the invalidation
|
||||||
|
- * @flags: informs whether the following fields are set
|
||||||
|
- * @arch_id: architecture specific ID tagging the TLB
|
||||||
|
- * @pasid: PASID tagging the TLB
|
||||||
|
- * @leaf: when @perm is NONE, indicates whether only caches for the last
|
||||||
|
- * level of translation need to be invalidated.
|
||||||
|
- */
|
||||||
|
struct IOMMUTLBEntry {
|
||||||
|
AddressSpace *target_as;
|
||||||
|
hwaddr iova;
|
||||||
|
hwaddr translated_addr;
|
||||||
|
- hwaddr addr_mask;
|
||||||
|
+ hwaddr addr_mask; /* 0xfff = 4k translation */
|
||||||
|
IOMMUAccessFlags perm;
|
||||||
|
- IOMMUInvGranularity granularity;
|
||||||
|
-#define IOMMU_INV_FLAGS_PASID (1 << 0)
|
||||||
|
-#define IOMMU_INV_FLAGS_ARCHID (1 << 1)
|
||||||
|
-#define IOMMU_INV_FLAGS_LEAF (1 << 2)
|
||||||
|
- uint32_t flags;
|
||||||
|
- uint32_t arch_id;
|
||||||
|
- uint32_t pasid;
|
||||||
|
- bool leaf;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
87
Revert-memory-Introduce-IOMMU-Memory-Region-inject_f.patch
Normal file
87
Revert-memory-Introduce-IOMMU-Memory-Region-inject_f.patch
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
From 3ab99dc1bf580607791aa402ad330720ce993ae2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:51 +0800
|
||||||
|
Subject: [PATCH 29/36] Revert "memory: Introduce IOMMU Memory Region
|
||||||
|
inject_faults API"
|
||||||
|
|
||||||
|
This reverts commit d2dce19165f133935ff72e209f19bc43ab4d1421.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
include/exec/memory.h | 24 ------------------------
|
||||||
|
softmmu/memory.c | 10 ----------
|
||||||
|
2 files changed, 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
||||||
|
index 7c3fe69d52..67d9061766 100644
|
||||||
|
--- a/include/exec/memory.h
|
||||||
|
+++ b/include/exec/memory.h
|
||||||
|
@@ -106,8 +106,6 @@ struct MemoryRegionSection {
|
||||||
|
bool nonvolatile;
|
||||||
|
};
|
||||||
|
|
||||||
|
-struct iommu_fault;
|
||||||
|
-
|
||||||
|
typedef struct IOMMUTLBEntry IOMMUTLBEntry;
|
||||||
|
|
||||||
|
/* See address_space_translate: bit 0 is read, bit 1 is write. */
|
||||||
|
@@ -528,19 +526,6 @@ struct IOMMUMemoryRegionClass {
|
||||||
|
int (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu,
|
||||||
|
uint64_t page_size_mask,
|
||||||
|
Error **errp);
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * Inject @count faults into the IOMMU memory region
|
||||||
|
- *
|
||||||
|
- * Optional method: if this method is not provided, then
|
||||||
|
- * memory_region_injection_faults() will return -ENOENT
|
||||||
|
- *
|
||||||
|
- * @iommu: the IOMMU memory region to inject the faults in
|
||||||
|
- * @count: number of faults to inject
|
||||||
|
- * @buf: fault buffer
|
||||||
|
- */
|
||||||
|
- int (*inject_faults)(IOMMUMemoryRegion *iommu, int count,
|
||||||
|
- struct iommu_fault *buf);
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct RamDiscardListener RamDiscardListener;
|
||||||
|
@@ -1837,15 +1822,6 @@ int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr);
|
||||||
|
int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr,
|
||||||
|
uint64_t page_size_mask,
|
||||||
|
Error **errp);
|
||||||
|
-/**
|
||||||
|
- * memory_region_inject_faults : inject @count faults stored in @buf
|
||||||
|
- *
|
||||||
|
- * @iommu_mr: the IOMMU memory region
|
||||||
|
- * @count: number of faults to be injected
|
||||||
|
- * @buf: buffer containing the faults
|
||||||
|
- */
|
||||||
|
-int memory_region_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
|
||||||
|
- struct iommu_fault *buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* memory_region_name: get a memory region's name
|
||||||
|
diff --git a/softmmu/memory.c b/softmmu/memory.c
|
||||||
|
index 9f98209ab2..7340e19ff5 100644
|
||||||
|
--- a/softmmu/memory.c
|
||||||
|
+++ b/softmmu/memory.c
|
||||||
|
@@ -2111,16 +2111,6 @@ void ram_discard_manager_unregister_listener(RamDiscardManager *rdm,
|
||||||
|
rdmc->unregister_listener(rdm, rdl);
|
||||||
|
}
|
||||||
|
|
||||||
|
-int memory_region_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
|
||||||
|
- struct iommu_fault *buf)
|
||||||
|
-{
|
||||||
|
- IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
|
||||||
|
- if (!imrc->inject_faults) {
|
||||||
|
- return -ENOENT;
|
||||||
|
- }
|
||||||
|
- return imrc->inject_faults(iommu_mr, count, buf);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)
|
||||||
|
{
|
||||||
|
uint8_t mask = 1 << client;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
84
Revert-pci-Add-return_page_response-pci-ops.patch
Normal file
84
Revert-pci-Add-return_page_response-pci-ops.patch
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
From 9f843b181db3d73e86df140a41975a7645adc071 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:27 +0800
|
||||||
|
Subject: [PATCH 10/36] Revert "pci: Add return_page_response pci ops"
|
||||||
|
|
||||||
|
This reverts commit 228345cfa59c764e725e2d3680a4bc3ecb237609.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/pci/pci.c | 16 ----------------
|
||||||
|
include/hw/iommu/iommu.h | 8 --------
|
||||||
|
include/hw/pci/pci.h | 4 ----
|
||||||
|
3 files changed, 28 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
|
||||||
|
index 0743dc7c42..71076fff48 100644
|
||||||
|
--- a/hw/pci/pci.c
|
||||||
|
+++ b/hw/pci/pci.c
|
||||||
|
@@ -2797,22 +2797,6 @@ int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn,
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
-int pci_device_return_page_response(PCIBus *bus, int32_t devfn,
|
||||||
|
- IOMMUPageResponse *resp)
|
||||||
|
-{
|
||||||
|
- PCIDevice *dev;
|
||||||
|
-
|
||||||
|
- if (!bus) {
|
||||||
|
- return -EINVAL;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- dev = bus->devices[devfn];
|
||||||
|
- if (dev && dev->pasid_ops && dev->pasid_ops->return_page_response) {
|
||||||
|
- return dev->pasid_ops->return_page_response(bus, devfn, resp);
|
||||||
|
- }
|
||||||
|
- return -ENOENT;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
|
||||||
|
{
|
||||||
|
Range *range = opaque;
|
||||||
|
diff --git a/include/hw/iommu/iommu.h b/include/hw/iommu/iommu.h
|
||||||
|
index 5890f095b1..12092bda7b 100644
|
||||||
|
--- a/include/hw/iommu/iommu.h
|
||||||
|
+++ b/include/hw/iommu/iommu.h
|
||||||
|
@@ -24,13 +24,5 @@ typedef struct IOMMUConfig {
|
||||||
|
};
|
||||||
|
} IOMMUConfig;
|
||||||
|
|
||||||
|
-typedef struct IOMMUPageResponse {
|
||||||
|
- union {
|
||||||
|
-#ifdef __linux__
|
||||||
|
- struct iommu_page_response resp;
|
||||||
|
-#endif
|
||||||
|
- };
|
||||||
|
-} IOMMUPageResponse;
|
||||||
|
-
|
||||||
|
|
||||||
|
#endif /* QEMU_HW_IOMMU_IOMMU_H */
|
||||||
|
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
|
||||||
|
index bfe3a6bca7..4cf3dc6b43 100644
|
||||||
|
--- a/include/hw/pci/pci.h
|
||||||
|
+++ b/include/hw/pci/pci.h
|
||||||
|
@@ -268,8 +268,6 @@ typedef struct PCIReqIDCache PCIReqIDCache;
|
||||||
|
|
||||||
|
struct PCIPASIDOps {
|
||||||
|
int (*set_pasid_table)(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
||||||
|
- int (*return_page_response)(PCIBus *bus, int32_t devfn,
|
||||||
|
- IOMMUPageResponse *resp);
|
||||||
|
};
|
||||||
|
typedef struct PCIPASIDOps PCIPASIDOps;
|
||||||
|
|
||||||
|
@@ -510,8 +508,6 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
|
||||||
|
void pci_setup_pasid_ops(PCIDevice *dev, PCIPASIDOps *ops);
|
||||||
|
bool pci_device_is_pasid_ops_set(PCIBus *bus, int32_t devfn);
|
||||||
|
int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
||||||
|
-int pci_device_return_page_response(PCIBus *bus, int32_t devfn,
|
||||||
|
- IOMMUPageResponse *resp);
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
pci_set_byte(uint8_t *config, uint8_t val)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
104
Revert-pci-introduce-PCIPASIDOps-to-PCIDevice.patch
Normal file
104
Revert-pci-introduce-PCIPASIDOps-to-PCIDevice.patch
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
From 87a125d3a175fd65f921dc7089450e13ce2ac457 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:49 +0800
|
||||||
|
Subject: [PATCH 27/36] Revert "pci: introduce PCIPASIDOps to PCIDevice"
|
||||||
|
|
||||||
|
This reverts commit c71485494970e7aa986be2b05bf7e2847017e264.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/pci/pci.c | 34 ----------------------------------
|
||||||
|
include/hw/pci/pci.h | 11 -----------
|
||||||
|
2 files changed, 45 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
|
||||||
|
index 71076fff48..40e2516d99 100644
|
||||||
|
--- a/hw/pci/pci.c
|
||||||
|
+++ b/hw/pci/pci.c
|
||||||
|
@@ -2763,40 +2763,6 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque)
|
||||||
|
bus->iommu_opaque = opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
-void pci_setup_pasid_ops(PCIDevice *dev, PCIPASIDOps *ops)
|
||||||
|
-{
|
||||||
|
- assert(ops && !dev->pasid_ops);
|
||||||
|
- dev->pasid_ops = ops;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-bool pci_device_is_pasid_ops_set(PCIBus *bus, int32_t devfn)
|
||||||
|
-{
|
||||||
|
- PCIDevice *dev;
|
||||||
|
-
|
||||||
|
- if (!bus) {
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- dev = bus->devices[devfn];
|
||||||
|
- return !!(dev && dev->pasid_ops);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn,
|
||||||
|
- IOMMUConfig *config)
|
||||||
|
-{
|
||||||
|
- PCIDevice *dev;
|
||||||
|
-
|
||||||
|
- if (!bus) {
|
||||||
|
- return -EINVAL;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- dev = bus->devices[devfn];
|
||||||
|
- if (dev && dev->pasid_ops && dev->pasid_ops->set_pasid_table) {
|
||||||
|
- return dev->pasid_ops->set_pasid_table(bus, devfn, config);
|
||||||
|
- }
|
||||||
|
- return -ENOENT;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
|
||||||
|
{
|
||||||
|
Range *range = opaque;
|
||||||
|
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
|
||||||
|
index 4cf3dc6b43..5b36334a28 100644
|
||||||
|
--- a/include/hw/pci/pci.h
|
||||||
|
+++ b/include/hw/pci/pci.h
|
||||||
|
@@ -9,7 +9,6 @@
|
||||||
|
|
||||||
|
#include "hw/pci/pcie.h"
|
||||||
|
#include "qom/object.h"
|
||||||
|
-#include "hw/iommu/iommu.h"
|
||||||
|
|
||||||
|
extern bool pci_available;
|
||||||
|
|
||||||
|
@@ -266,11 +265,6 @@ struct PCIReqIDCache {
|
||||||
|
};
|
||||||
|
typedef struct PCIReqIDCache PCIReqIDCache;
|
||||||
|
|
||||||
|
-struct PCIPASIDOps {
|
||||||
|
- int (*set_pasid_table)(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
||||||
|
-};
|
||||||
|
-typedef struct PCIPASIDOps PCIPASIDOps;
|
||||||
|
-
|
||||||
|
struct PCIDevice {
|
||||||
|
DeviceState qdev;
|
||||||
|
bool partially_hotplugged;
|
||||||
|
@@ -367,7 +361,6 @@ struct PCIDevice {
|
||||||
|
/* ID of standby device in net_failover pair */
|
||||||
|
char *failover_pair_id;
|
||||||
|
uint32_t acpi_index;
|
||||||
|
- PCIPASIDOps *pasid_ops;
|
||||||
|
};
|
||||||
|
|
||||||
|
void pci_register_bar(PCIDevice *pci_dev, int region_num,
|
||||||
|
@@ -505,10 +498,6 @@ typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *, int);
|
||||||
|
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
|
||||||
|
void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
|
||||||
|
|
||||||
|
-void pci_setup_pasid_ops(PCIDevice *dev, PCIPASIDOps *ops);
|
||||||
|
-bool pci_device_is_pasid_ops_set(PCIBus *bus, int32_t devfn);
|
||||||
|
-int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
|
||||||
|
-
|
||||||
|
static inline void
|
||||||
|
pci_set_byte(uint8_t *config, uint8_t val)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
28
Revert-update-linux-headers-Import-iommu.h.patch
Normal file
28
Revert-update-linux-headers-Import-iommu.h.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From 00e2515716eda5426bd999f812add9ff70204fc6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:23:00 +0800
|
||||||
|
Subject: [PATCH 36/36] Revert "update-linux-headers: Import iommu.h"
|
||||||
|
|
||||||
|
This reverts commit 694acf3c321908d26ce508842b7bd076664ffbc6.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
scripts/update-linux-headers.sh | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
|
||||||
|
index acde610733..fea4d6eb65 100755
|
||||||
|
--- a/scripts/update-linux-headers.sh
|
||||||
|
+++ b/scripts/update-linux-headers.sh
|
||||||
|
@@ -144,7 +144,7 @@ done
|
||||||
|
|
||||||
|
rm -rf "$output/linux-headers/linux"
|
||||||
|
mkdir -p "$output/linux-headers/linux"
|
||||||
|
-for header in kvm.h vfio.h vfio_ccw.h vfio_zdev.h vhost.h iommu.h \
|
||||||
|
+for header in kvm.h vfio.h vfio_ccw.h vfio_zdev.h vhost.h \
|
||||||
|
psci.h psp-sev.h userfaultfd.h mman.h; do
|
||||||
|
cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux"
|
||||||
|
done
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
65
Revert-vfio-Add-vfio_prereg_listener_global_log_star.patch
Normal file
65
Revert-vfio-Add-vfio_prereg_listener_global_log_star.patch
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
From 92c1c6d689d9f501a3f242b085cbbcb22ee931b4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:18 +0800
|
||||||
|
Subject: [PATCH 04/36] Revert "vfio: Add
|
||||||
|
vfio_prereg_listener_global_log_start/stop in nested stage"
|
||||||
|
|
||||||
|
This reverts commit 287c63ab540533f1f9642e753c091caa7e6e2511.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 24 ------------------------
|
||||||
|
1 file changed, 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 65f3979492..20c820aa74 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1501,17 +1501,6 @@ static void vfio_listener_log_global_start(MemoryListener *listener)
|
||||||
|
{
|
||||||
|
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
||||||
|
|
||||||
|
- /* For nested mode, vfio_prereg_listener is used to start dirty tracking */
|
||||||
|
- if (container->iommu_type != VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- vfio_set_dirty_page_tracking(container, true);
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static void vfio_prereg_listener_log_global_start(MemoryListener *listener)
|
||||||
|
-{
|
||||||
|
- VFIOContainer *container =
|
||||||
|
- container_of(listener, VFIOContainer, prereg_listener);
|
||||||
|
-
|
||||||
|
vfio_set_dirty_page_tracking(container, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1519,17 +1508,6 @@ static void vfio_listener_log_global_stop(MemoryListener *listener)
|
||||||
|
{
|
||||||
|
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
||||||
|
|
||||||
|
- /* For nested mode, vfio_prereg_listener is used to stop dirty tracking */
|
||||||
|
- if (container->iommu_type != VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- vfio_set_dirty_page_tracking(container, false);
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static void vfio_prereg_listener_log_global_stop(MemoryListener *listener)
|
||||||
|
-{
|
||||||
|
- VFIOContainer *container =
|
||||||
|
- container_of(listener, VFIOContainer, prereg_listener);
|
||||||
|
-
|
||||||
|
vfio_set_dirty_page_tracking(container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1944,8 +1922,6 @@ static const MemoryListener vfio_memory_listener = {
|
||||||
|
static MemoryListener vfio_memory_prereg_listener = {
|
||||||
|
.region_add = vfio_prereg_listener_region_add,
|
||||||
|
.region_del = vfio_prereg_listener_region_del,
|
||||||
|
- .log_global_start = vfio_prereg_listener_log_global_start,
|
||||||
|
- .log_global_stop = vfio_prereg_listener_log_global_stop,
|
||||||
|
.log_sync = vfio_prereg_listener_log_sync,
|
||||||
|
.log_clear = vfio_prereg_listener_log_clear,
|
||||||
|
};
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
81
Revert-vfio-Add-vfio_prereg_listener_log_clear-to-re.patch
Normal file
81
Revert-vfio-Add-vfio_prereg_listener_log_clear-to-re.patch
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
From 609b216873bfa9377f624dabcf709930e1722ca7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:20 +0800
|
||||||
|
Subject: [PATCH 05/36] Revert "vfio: Add vfio_prereg_listener_log_clear to
|
||||||
|
re-enable mark dirty pages"
|
||||||
|
|
||||||
|
This reverts commit 7086df6d90cd698a3e20cf4cf6e9a834f168cd8f.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 40 +---------------------------------------
|
||||||
|
1 file changed, 1 insertion(+), 39 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 20c820aa74..2506cd57ee 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1857,43 +1857,6 @@ static int vfio_physical_log_clear(VFIOContainer *container,
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void vfio_prereg_listener_log_clear(MemoryListener *listener,
|
||||||
|
- MemoryRegionSection *section)
|
||||||
|
-{
|
||||||
|
- VFIOContainer *container =
|
||||||
|
- container_of(listener, VFIOContainer, prereg_listener);
|
||||||
|
-
|
||||||
|
- if (!memory_region_is_ram(section->mr)) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- vfio_physical_log_clear(container, section);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static int vfio_clear_dirty_bitmap(VFIOContainer *container,
|
||||||
|
- MemoryRegionSection *section)
|
||||||
|
-{
|
||||||
|
- if (memory_region_is_iommu(section->mr)) {
|
||||||
|
- /*
|
||||||
|
- * In nested mode, stage 2 (gpa->hpa) and stage 1 (giova->gpa) are
|
||||||
|
- * set up separately. It is inappropriate to pass 'giova' to kernel
|
||||||
|
- * to get dirty pages. We only need to focus on stage 2 mapping when
|
||||||
|
- * marking dirty pages.
|
||||||
|
- */
|
||||||
|
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * TODO: x86. With the log_clear() interface added, x86 may inplement
|
||||||
|
- * its own method.
|
||||||
|
- */
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Here we assume that memory_region_is_ram(section->mr) == true */
|
||||||
|
- return vfio_physical_log_clear(container, section);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_listener_log_clear(MemoryListener *listener,
|
||||||
|
MemoryRegionSection *section)
|
||||||
|
{
|
||||||
|
@@ -1905,7 +1868,7 @@ static void vfio_listener_log_clear(MemoryListener *listener,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vfio_devices_all_dirty_tracking(container)) {
|
||||||
|
- vfio_clear_dirty_bitmap(container, section);
|
||||||
|
+ vfio_physical_log_clear(container, section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1923,7 +1886,6 @@ static MemoryListener vfio_memory_prereg_listener = {
|
||||||
|
.region_add = vfio_prereg_listener_region_add,
|
||||||
|
.region_del = vfio_prereg_listener_region_del,
|
||||||
|
.log_sync = vfio_prereg_listener_log_sync,
|
||||||
|
- .log_clear = vfio_prereg_listener_log_clear,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void vfio_listener_release(VFIOContainer *container)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
68
Revert-vfio-Add-vfio_prereg_listener_log_sync-in-nes.patch
Normal file
68
Revert-vfio-Add-vfio_prereg_listener_log_sync-in-nes.patch
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
From 13253899d93b287a7e8d78bdff48978f633eb279 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:22 +0800
|
||||||
|
Subject: [PATCH 06/36] Revert "vfio: Add vfio_prereg_listener_log_sync in
|
||||||
|
nested stage"
|
||||||
|
|
||||||
|
This reverts commit f4523389bf57593484308124e06d67855bb79315.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 27 ---------------------------
|
||||||
|
1 file changed, 27 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 2506cd57ee..6136b1ef61 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1579,22 +1579,6 @@ static int vfio_dma_sync_ram_section_dirty_bitmap(VFIOContainer *container,
|
||||||
|
int128_get64(section->size), ram_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void vfio_prereg_listener_log_sync(MemoryListener *listener,
|
||||||
|
- MemoryRegionSection *section)
|
||||||
|
-{
|
||||||
|
- VFIOContainer *container =
|
||||||
|
- container_of(listener, VFIOContainer, prereg_listener);
|
||||||
|
-
|
||||||
|
- if (!memory_region_is_ram(section->mr) ||
|
||||||
|
- !container->dirty_pages_supported) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (vfio_devices_all_dirty_tracking(container)) {
|
||||||
|
- vfio_dma_sync_ram_section_dirty_bitmap(container, section);
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
typedef struct {
|
||||||
|
IOMMUNotifier n;
|
||||||
|
VFIOGuestIOMMU *giommu;
|
||||||
|
@@ -1682,16 +1666,6 @@ static int vfio_sync_dirty_bitmap(VFIOContainer *container,
|
||||||
|
if (memory_region_is_iommu(section->mr)) {
|
||||||
|
VFIOGuestIOMMU *giommu;
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * In nested mode, stage 2 (gpa->hpa) and stage 1 (giova->gpa) are
|
||||||
|
- * set up separately. It is inappropriate to pass 'giova' to kernel
|
||||||
|
- * to get dirty pages. We only need to focus on stage 2 mapping when
|
||||||
|
- * marking dirty pages.
|
||||||
|
- */
|
||||||
|
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
QLIST_FOREACH(giommu, &container->giommu_list, giommu_next) {
|
||||||
|
if (MEMORY_REGION(giommu->iommu) == section->mr &&
|
||||||
|
giommu->n.start == section->offset_within_region) {
|
||||||
|
@@ -1885,7 +1859,6 @@ static const MemoryListener vfio_memory_listener = {
|
||||||
|
static MemoryListener vfio_memory_prereg_listener = {
|
||||||
|
.region_add = vfio_prereg_listener_region_add,
|
||||||
|
.region_del = vfio_prereg_listener_region_del,
|
||||||
|
- .log_sync = vfio_prereg_listener_log_sync,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void vfio_listener_release(VFIOContainer *container)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
97
Revert-vfio-Force-nested-if-iommu-requires-it.patch
Normal file
97
Revert-vfio-Force-nested-if-iommu-requires-it.patch
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
From bac64f79264fd95b349004dd20b4ef7e9944fcb7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:47 +0800
|
||||||
|
Subject: [PATCH 26/36] Revert "vfio: Force nested if iommu requires it"
|
||||||
|
|
||||||
|
This reverts commit e7eef5af743a53f0415267ebe9bba2e5f0e05816.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 36 ++++++++----------------------------
|
||||||
|
1 file changed, 8 insertions(+), 28 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index d7533637c9..6cb91e7ffd 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -2045,38 +2045,27 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
|
||||||
|
* vfio_get_iommu_type - selects the richest iommu_type (v2 first)
|
||||||
|
*/
|
||||||
|
static int vfio_get_iommu_type(VFIOContainer *container,
|
||||||
|
- bool want_nested,
|
||||||
|
Error **errp)
|
||||||
|
{
|
||||||
|
- int iommu_types[] = { VFIO_TYPE1_NESTING_IOMMU,
|
||||||
|
- VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
|
||||||
|
+ int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
|
||||||
|
VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
|
||||||
|
- int i, ret = -EINVAL;
|
||||||
|
+ int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
|
||||||
|
if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
|
||||||
|
- if (iommu_types[i] == VFIO_TYPE1_NESTING_IOMMU && !want_nested) {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- ret = iommu_types[i];
|
||||||
|
- break;
|
||||||
|
+ return iommu_types[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- if (ret < 0) {
|
||||||
|
- error_setg(errp, "No available IOMMU models");
|
||||||
|
- } else if (want_nested && ret != VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- error_setg(errp, "Nested mode requested but not supported");
|
||||||
|
- ret = -EINVAL;
|
||||||
|
- }
|
||||||
|
- return ret;
|
||||||
|
+ error_setg(errp, "No available IOMMU models");
|
||||||
|
+ return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vfio_init_container(VFIOContainer *container, int group_fd,
|
||||||
|
- bool want_nested, Error **errp)
|
||||||
|
+ Error **errp)
|
||||||
|
{
|
||||||
|
int iommu_type, dirty_log_manual_clear, ret;
|
||||||
|
|
||||||
|
- iommu_type = vfio_get_iommu_type(container, want_nested, errp);
|
||||||
|
+ iommu_type = vfio_get_iommu_type(container, errp);
|
||||||
|
if (iommu_type < 0) {
|
||||||
|
return iommu_type;
|
||||||
|
}
|
||||||
|
@@ -2188,14 +2177,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
|
VFIOContainer *container;
|
||||||
|
int ret, fd;
|
||||||
|
VFIOAddressSpace *space;
|
||||||
|
- IOMMUMemoryRegion *iommu_mr;
|
||||||
|
- bool nested = false;
|
||||||
|
-
|
||||||
|
- if (memory_region_is_iommu(as->root)) {
|
||||||
|
- iommu_mr = IOMMU_MEMORY_REGION(as->root);
|
||||||
|
- memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_VFIO_NESTED,
|
||||||
|
- (void *)&nested);
|
||||||
|
- }
|
||||||
|
|
||||||
|
space = vfio_get_address_space(as);
|
||||||
|
|
||||||
|
@@ -2276,7 +2257,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
|
QLIST_INIT(&container->vrdl_list);
|
||||||
|
QLIST_INIT(&container->dma_list);
|
||||||
|
|
||||||
|
- ret = vfio_init_container(container, group->fd, nested, errp);
|
||||||
|
+ ret = vfio_init_container(container, group->fd, errp);
|
||||||
|
if (ret) {
|
||||||
|
goto free_container_exit;
|
||||||
|
}
|
||||||
|
@@ -2288,7 +2269,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (container->iommu_type) {
|
||||||
|
- case VFIO_TYPE1_NESTING_IOMMU:
|
||||||
|
case VFIO_TYPE1v2_IOMMU:
|
||||||
|
case VFIO_TYPE1_IOMMU:
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
177
Revert-vfio-Helper-to-get-IRQ-info-including-capabil.patch
Normal file
177
Revert-vfio-Helper-to-get-IRQ-info-including-capabil.patch
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
From 1ab4bff7e5d82a16a0d004fd964819d092325776 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:41 +0800
|
||||||
|
Subject: [PATCH 21/36] Revert "vfio: Helper to get IRQ info including
|
||||||
|
capabilities"
|
||||||
|
|
||||||
|
This reverts commit a4336765c99a876743c0ead89997ad6f97d7b442.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 97 -----------------------------------
|
||||||
|
hw/vfio/trace-events | 1 -
|
||||||
|
include/hw/vfio/vfio-common.h | 7 ---
|
||||||
|
3 files changed, 105 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index d05a485808..1f78af121d 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1919,25 +1919,6 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
-struct vfio_info_cap_header *
|
||||||
|
-vfio_get_irq_info_cap(struct vfio_irq_info *info, uint16_t id)
|
||||||
|
-{
|
||||||
|
- struct vfio_info_cap_header *hdr;
|
||||||
|
- void *ptr = info;
|
||||||
|
-
|
||||||
|
- if (!(info->flags & VFIO_IRQ_INFO_FLAG_CAPS)) {
|
||||||
|
- return NULL;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- for (hdr = ptr + info->cap_offset; hdr != ptr; hdr = ptr + hdr->next) {
|
||||||
|
- if (hdr->id == id) {
|
||||||
|
- return hdr;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return NULL;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static int vfio_setup_region_sparse_mmaps(VFIORegion *region,
|
||||||
|
struct vfio_region_info *info)
|
||||||
|
{
|
||||||
|
@@ -2906,33 +2887,6 @@ retry:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-int vfio_get_irq_info(VFIODevice *vbasedev, int index,
|
||||||
|
- struct vfio_irq_info **info)
|
||||||
|
-{
|
||||||
|
- size_t argsz = sizeof(struct vfio_irq_info);
|
||||||
|
-
|
||||||
|
- *info = g_malloc0(argsz);
|
||||||
|
-
|
||||||
|
- (*info)->index = index;
|
||||||
|
-retry:
|
||||||
|
- (*info)->argsz = argsz;
|
||||||
|
-
|
||||||
|
- if (ioctl(vbasedev->fd, VFIO_DEVICE_GET_IRQ_INFO, *info)) {
|
||||||
|
- g_free(*info);
|
||||||
|
- *info = NULL;
|
||||||
|
- return -errno;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if ((*info)->argsz > argsz) {
|
||||||
|
- argsz = (*info)->argsz;
|
||||||
|
- *info = g_realloc(*info, argsz);
|
||||||
|
-
|
||||||
|
- goto retry;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
||||||
|
uint32_t subtype, struct vfio_region_info **info)
|
||||||
|
{
|
||||||
|
@@ -2968,42 +2922,6 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
-int vfio_get_dev_irq_info(VFIODevice *vbasedev, uint32_t type,
|
||||||
|
- uint32_t subtype, struct vfio_irq_info **info)
|
||||||
|
-{
|
||||||
|
- int i;
|
||||||
|
-
|
||||||
|
- for (i = 0; i < vbasedev->num_irqs; i++) {
|
||||||
|
- struct vfio_info_cap_header *hdr;
|
||||||
|
- struct vfio_irq_info_cap_type *cap_type;
|
||||||
|
-
|
||||||
|
- if (vfio_get_irq_info(vbasedev, i, info)) {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- hdr = vfio_get_irq_info_cap(*info, VFIO_IRQ_INFO_CAP_TYPE);
|
||||||
|
- if (!hdr) {
|
||||||
|
- g_free(*info);
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- cap_type = container_of(hdr, struct vfio_irq_info_cap_type, header);
|
||||||
|
-
|
||||||
|
- trace_vfio_get_dev_irq(vbasedev->name, i,
|
||||||
|
- cap_type->type, cap_type->subtype);
|
||||||
|
-
|
||||||
|
- if (cap_type->type == type && cap_type->subtype == subtype) {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- g_free(*info);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- *info = NULL;
|
||||||
|
- return -ENODEV;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-
|
||||||
|
bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type)
|
||||||
|
{
|
||||||
|
struct vfio_region_info *info = NULL;
|
||||||
|
@@ -3019,21 +2937,6 @@ bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
-bool vfio_has_irq_cap(VFIODevice *vbasedev, int region, uint16_t cap_type)
|
||||||
|
-{
|
||||||
|
- struct vfio_region_info *info = NULL;
|
||||||
|
- bool ret = false;
|
||||||
|
-
|
||||||
|
- if (!vfio_get_region_info(vbasedev, region, &info)) {
|
||||||
|
- if (vfio_get_region_info_cap(info, cap_type)) {
|
||||||
|
- ret = true;
|
||||||
|
- }
|
||||||
|
- g_free(info);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return ret;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
/*
|
||||||
|
* Interfaces for IBM EEH (Enhanced Error Handling)
|
||||||
|
*/
|
||||||
|
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
||||||
|
index f5fe201ab5..35bd415d6d 100644
|
||||||
|
--- a/hw/vfio/trace-events
|
||||||
|
+++ b/hw/vfio/trace-events
|
||||||
|
@@ -117,7 +117,6 @@ vfio_region_unmap(const char *name, unsigned long offset, unsigned long end) "Re
|
||||||
|
vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Device %s region %d: %d sparse mmap entries"
|
||||||
|
vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
|
||||||
|
vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
|
||||||
|
-vfio_get_dev_irq(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
|
||||||
|
vfio_dma_unmap_overflow_workaround(void) ""
|
||||||
|
vfio_iommu_addr_inv_iotlb(int asid, uint64_t addr, uint64_t size, uint64_t nb_granules, bool leaf) "nested IOTLB invalidate asid=%d, addr=0x%"PRIx64" granule_size=0x%"PRIx64" nb_granules=0x%"PRIx64" leaf=%d"
|
||||||
|
vfio_iommu_asid_inv_iotlb(int asid) "nested IOTLB invalidate asid=%d"
|
||||||
|
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
|
||||||
|
index 7fdca26fa0..a838a939e4 100644
|
||||||
|
--- a/include/hw/vfio/vfio-common.h
|
||||||
|
+++ b/include/hw/vfio/vfio-common.h
|
||||||
|
@@ -254,13 +254,6 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
||||||
|
unsigned int *avail);
|
||||||
|
struct vfio_info_cap_header *
|
||||||
|
vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id);
|
||||||
|
-int vfio_get_irq_info(VFIODevice *vbasedev, int index,
|
||||||
|
- struct vfio_irq_info **info);
|
||||||
|
-int vfio_get_dev_irq_info(VFIODevice *vbasedev, uint32_t type,
|
||||||
|
- uint32_t subtype, struct vfio_irq_info **info);
|
||||||
|
-bool vfio_has_irq_cap(VFIODevice *vbasedev, int irq, uint16_t cap_type);
|
||||||
|
-struct vfio_info_cap_header *
|
||||||
|
-vfio_get_irq_info_cap(struct vfio_irq_info *info, uint16_t id);
|
||||||
|
#endif
|
||||||
|
extern const MemoryListener vfio_prereg_listener;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
277
Revert-vfio-Introduce-helpers-to-DMA-map-unmap-a-RAM.patch
Normal file
277
Revert-vfio-Introduce-helpers-to-DMA-map-unmap-a-RAM.patch
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
From e73a30ce20cf0686e7a08e061f8afa5c8c385361 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:45 +0800
|
||||||
|
Subject: [PATCH 24/36] Revert "vfio: Introduce helpers to DMA map/unmap a RAM
|
||||||
|
section"
|
||||||
|
|
||||||
|
This reverts commit dab969657d8ff8b175856f91b035b74849cf69ba.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 206 ++++++++++++++++++-------------------------
|
||||||
|
hw/vfio/trace-events | 4 +-
|
||||||
|
2 files changed, 87 insertions(+), 123 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index b3dc090840..d358789f19 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -922,130 +922,13 @@ hostwin_from_range(VFIOContainer *container, hwaddr iova, hwaddr end)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int vfio_dma_map_ram_section(VFIOContainer *container,
|
||||||
|
- MemoryRegionSection *section, Error **err)
|
||||||
|
-{
|
||||||
|
- VFIOHostDMAWindow *hostwin;
|
||||||
|
- Int128 llend, llsize;
|
||||||
|
- hwaddr iova, end;
|
||||||
|
- void *vaddr;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- assert(memory_region_is_ram(section->mr));
|
||||||
|
-
|
||||||
|
- iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
|
||||||
|
- llend = int128_make64(section->offset_within_address_space);
|
||||||
|
- llend = int128_add(llend, section->size);
|
||||||
|
- llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
|
||||||
|
- end = int128_get64(int128_sub(llend, int128_one()));
|
||||||
|
-
|
||||||
|
- vaddr = memory_region_get_ram_ptr(section->mr) +
|
||||||
|
- section->offset_within_region +
|
||||||
|
- (iova - section->offset_within_address_space);
|
||||||
|
-
|
||||||
|
- hostwin = hostwin_from_range(container, iova, end);
|
||||||
|
- if (!hostwin) {
|
||||||
|
- error_setg(err, "Container %p can't map guest IOVA region"
|
||||||
|
- " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end);
|
||||||
|
- return -EFAULT;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- trace_vfio_dma_map_ram(iova, end, vaddr);
|
||||||
|
-
|
||||||
|
- llsize = int128_sub(llend, int128_make64(iova));
|
||||||
|
-
|
||||||
|
- if (memory_region_is_ram_device(section->mr)) {
|
||||||
|
- hwaddr pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
||||||
|
-
|
||||||
|
- if ((iova & pgmask) || (int128_get64(llsize) & pgmask)) {
|
||||||
|
- trace_vfio_listener_region_add_no_dma_map(
|
||||||
|
- memory_region_name(section->mr),
|
||||||
|
- section->offset_within_address_space,
|
||||||
|
- int128_getlo(section->size),
|
||||||
|
- pgmask + 1);
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ret = vfio_dma_map(container, iova, int128_get64(llsize),
|
||||||
|
- vaddr, section->readonly);
|
||||||
|
- if (ret) {
|
||||||
|
- error_setg(err, "vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
- "0x%"HWADDR_PRIx", %p) = %d (%m)",
|
||||||
|
- container, iova, int128_get64(llsize), vaddr, ret);
|
||||||
|
- if (memory_region_is_ram_device(section->mr)) {
|
||||||
|
- /* Allow unexpected mappings not to be fatal for RAM devices */
|
||||||
|
- error_report_err(*err);
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- return ret;
|
||||||
|
- }
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static void vfio_dma_unmap_ram_section(VFIOContainer *container,
|
||||||
|
- MemoryRegionSection *section)
|
||||||
|
-{
|
||||||
|
- Int128 llend, llsize;
|
||||||
|
- hwaddr iova, end;
|
||||||
|
- bool try_unmap = true;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
||||||
|
- llend = int128_make64(section->offset_within_address_space);
|
||||||
|
- llend = int128_add(llend, section->size);
|
||||||
|
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
||||||
|
-
|
||||||
|
- if (int128_ge(int128_make64(iova), llend)) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- end = int128_get64(int128_sub(llend, int128_one()));
|
||||||
|
-
|
||||||
|
- llsize = int128_sub(llend, int128_make64(iova));
|
||||||
|
-
|
||||||
|
- trace_vfio_dma_unmap_ram(iova, end);
|
||||||
|
-
|
||||||
|
- if (memory_region_is_ram_device(section->mr)) {
|
||||||
|
- hwaddr pgmask;
|
||||||
|
- VFIOHostDMAWindow *hostwin = hostwin_from_range(container, iova, end);
|
||||||
|
-
|
||||||
|
- assert(hostwin); /* or region_add() would have failed */
|
||||||
|
-
|
||||||
|
- pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
||||||
|
- try_unmap = !((iova & pgmask) || (int128_get64(llsize) & pgmask));
|
||||||
|
- } else if (memory_region_has_ram_discard_manager(section->mr)) {
|
||||||
|
- vfio_unregister_ram_discard_listener(container, section);
|
||||||
|
- /* Unregistering will trigger an unmap. */
|
||||||
|
- try_unmap = false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (try_unmap) {
|
||||||
|
- if (int128_eq(llsize, int128_2_64())) {
|
||||||
|
- /* The unmap ioctl doesn't accept a full 64-bit span. */
|
||||||
|
- llsize = int128_rshift(llsize, 1);
|
||||||
|
- ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
- "0x%"HWADDR_PRIx") = %d (%m)",
|
||||||
|
- container, iova, int128_get64(llsize), ret);
|
||||||
|
- }
|
||||||
|
- iova += int128_get64(llsize);
|
||||||
|
- }
|
||||||
|
- ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
- "0x%"HWADDR_PRIx") = %d (%m)",
|
||||||
|
- container, iova, int128_get64(llsize), ret);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
MemoryRegionSection *section)
|
||||||
|
{
|
||||||
|
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
||||||
|
hwaddr iova, end;
|
||||||
|
- Int128 llend;
|
||||||
|
+ Int128 llend, llsize;
|
||||||
|
+ void *vaddr;
|
||||||
|
int ret;
|
||||||
|
VFIOHostDMAWindow *hostwin;
|
||||||
|
Error *err = NULL;
|
||||||
|
@@ -1209,7 +1092,38 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (vfio_dma_map_ram_section(container, section, &err)) {
|
||||||
|
+ vaddr = memory_region_get_ram_ptr(section->mr) +
|
||||||
|
+ section->offset_within_region +
|
||||||
|
+ (iova - section->offset_within_address_space);
|
||||||
|
+
|
||||||
|
+ trace_vfio_listener_region_add_ram(iova, end, vaddr);
|
||||||
|
+
|
||||||
|
+ llsize = int128_sub(llend, int128_make64(iova));
|
||||||
|
+
|
||||||
|
+ if (memory_region_is_ram_device(section->mr)) {
|
||||||
|
+ hwaddr pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
||||||
|
+
|
||||||
|
+ if ((iova & pgmask) || (int128_get64(llsize) & pgmask)) {
|
||||||
|
+ trace_vfio_listener_region_add_no_dma_map(
|
||||||
|
+ memory_region_name(section->mr),
|
||||||
|
+ section->offset_within_address_space,
|
||||||
|
+ int128_getlo(section->size),
|
||||||
|
+ pgmask + 1);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = vfio_dma_map(container, iova, int128_get64(llsize),
|
||||||
|
+ vaddr, section->readonly);
|
||||||
|
+ if (ret) {
|
||||||
|
+ error_setg(&err, "vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
+ "0x%"HWADDR_PRIx", %p) = %d (%m)",
|
||||||
|
+ container, iova, int128_get64(llsize), vaddr, ret);
|
||||||
|
+ if (memory_region_is_ram_device(section->mr)) {
|
||||||
|
+ /* Allow unexpected mappings not to be fatal for RAM devices */
|
||||||
|
+ error_report_err(err);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1243,6 +1157,10 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
||||||
|
MemoryRegionSection *section)
|
||||||
|
{
|
||||||
|
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
||||||
|
+ hwaddr iova, end;
|
||||||
|
+ Int128 llend, llsize;
|
||||||
|
+ int ret;
|
||||||
|
+ bool try_unmap = true;
|
||||||
|
|
||||||
|
if (vfio_listener_skipped_section(section)) {
|
||||||
|
trace_vfio_listener_region_del_skip(
|
||||||
|
@@ -1282,7 +1200,53 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
- vfio_dma_unmap_ram_section(container, section);
|
||||||
|
+ iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
||||||
|
+ llend = int128_make64(section->offset_within_address_space);
|
||||||
|
+ llend = int128_add(llend, section->size);
|
||||||
|
+ llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
||||||
|
+
|
||||||
|
+ if (int128_ge(int128_make64(iova), llend)) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ end = int128_get64(int128_sub(llend, int128_one()));
|
||||||
|
+
|
||||||
|
+ llsize = int128_sub(llend, int128_make64(iova));
|
||||||
|
+
|
||||||
|
+ trace_vfio_listener_region_del(iova, end);
|
||||||
|
+
|
||||||
|
+ if (memory_region_is_ram_device(section->mr)) {
|
||||||
|
+ hwaddr pgmask;
|
||||||
|
+ VFIOHostDMAWindow *hostwin = hostwin_from_range(container, iova, end);
|
||||||
|
+
|
||||||
|
+ assert(hostwin); /* or region_add() would have failed */
|
||||||
|
+
|
||||||
|
+ pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
||||||
|
+ try_unmap = !((iova & pgmask) || (int128_get64(llsize) & pgmask));
|
||||||
|
+ } else if (memory_region_has_ram_discard_manager(section->mr)) {
|
||||||
|
+ vfio_unregister_ram_discard_listener(container, section);
|
||||||
|
+ /* Unregistering will trigger an unmap. */
|
||||||
|
+ try_unmap = false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (try_unmap) {
|
||||||
|
+ if (int128_eq(llsize, int128_2_64())) {
|
||||||
|
+ /* The unmap ioctl doesn't accept a full 64-bit span. */
|
||||||
|
+ llsize = int128_rshift(llsize, 1);
|
||||||
|
+ ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
||||||
|
+ if (ret) {
|
||||||
|
+ error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
+ "0x%"HWADDR_PRIx") = %d (%m)",
|
||||||
|
+ container, iova, int128_get64(llsize), ret);
|
||||||
|
+ }
|
||||||
|
+ iova += int128_get64(llsize);
|
||||||
|
+ }
|
||||||
|
+ ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
||||||
|
+ if (ret) {
|
||||||
|
+ error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
+ "0x%"HWADDR_PRIx") = %d (%m)",
|
||||||
|
+ container, iova, int128_get64(llsize), ret);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
memory_region_unref(section->mr);
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
||||||
|
index a37563a315..0ef1b5f4a6 100644
|
||||||
|
--- a/hw/vfio/trace-events
|
||||||
|
+++ b/hw/vfio/trace-events
|
||||||
|
@@ -99,10 +99,10 @@ vfio_iommu_map_notify(const char *op, uint64_t iova_start, uint64_t iova_end) "i
|
||||||
|
vfio_listener_region_add_skip(uint64_t start, uint64_t end) "SKIPPING region_add 0x%"PRIx64" - 0x%"PRIx64
|
||||||
|
vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d"
|
||||||
|
vfio_listener_region_add_iommu(uint64_t start, uint64_t end) "region_add [iommu] 0x%"PRIx64" - 0x%"PRIx64
|
||||||
|
-vfio_dma_map_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]"
|
||||||
|
+vfio_listener_region_add_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]"
|
||||||
|
vfio_listener_region_add_no_dma_map(const char *name, uint64_t iova, uint64_t size, uint64_t page_size) "Region \"%s\" 0x%"PRIx64" size=0x%"PRIx64" is not aligned to 0x%"PRIx64" and cannot be mapped for DMA"
|
||||||
|
vfio_listener_region_del_skip(uint64_t start, uint64_t end) "SKIPPING region_del 0x%"PRIx64" - 0x%"PRIx64
|
||||||
|
-vfio_dma_unmap_ram(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
|
||||||
|
+vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
|
||||||
|
vfio_disconnect_container(int fd) "close container->fd=%d"
|
||||||
|
vfio_put_group(int fd) "close group->fd=%d"
|
||||||
|
vfio_get_device(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u"
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
63
Revert-vfio-Introduce-helpers-to-mark-dirty-pages-of.patch
Normal file
63
Revert-vfio-Introduce-helpers-to-mark-dirty-pages-of.patch
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
From 9664a2d7b040a41d75067f4c58bf72c705e4a13b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:23 +0800
|
||||||
|
Subject: [PATCH 07/36] Revert "vfio: Introduce helpers to mark dirty pages of
|
||||||
|
a RAM section"
|
||||||
|
|
||||||
|
This reverts commit 1675d767aa9bd496178b4d74e01a40dbbd97eccb.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 22 ++++++++--------------
|
||||||
|
1 file changed, 8 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 6136b1ef61..bdfcc854fe 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1566,19 +1566,6 @@ err_out:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int vfio_dma_sync_ram_section_dirty_bitmap(VFIOContainer *container,
|
||||||
|
- MemoryRegionSection *section)
|
||||||
|
-{
|
||||||
|
- ram_addr_t ram_addr;
|
||||||
|
-
|
||||||
|
- ram_addr = memory_region_get_ram_addr(section->mr) +
|
||||||
|
- section->offset_within_region;
|
||||||
|
-
|
||||||
|
- return vfio_get_dirty_bitmap(container,
|
||||||
|
- REAL_HOST_PAGE_ALIGN(section->offset_within_address_space),
|
||||||
|
- int128_get64(section->size), ram_addr);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
typedef struct {
|
||||||
|
IOMMUNotifier n;
|
||||||
|
VFIOGuestIOMMU *giommu;
|
||||||
|
@@ -1663,6 +1650,8 @@ static int vfio_sync_ram_discard_listener_dirty_bitmap(VFIOContainer *container,
|
||||||
|
static int vfio_sync_dirty_bitmap(VFIOContainer *container,
|
||||||
|
MemoryRegionSection *section)
|
||||||
|
{
|
||||||
|
+ ram_addr_t ram_addr;
|
||||||
|
+
|
||||||
|
if (memory_region_is_iommu(section->mr)) {
|
||||||
|
VFIOGuestIOMMU *giommu;
|
||||||
|
|
||||||
|
@@ -1693,7 +1682,12 @@ static int vfio_sync_dirty_bitmap(VFIOContainer *container,
|
||||||
|
return vfio_sync_ram_discard_listener_dirty_bitmap(container, section);
|
||||||
|
}
|
||||||
|
|
||||||
|
- return vfio_dma_sync_ram_section_dirty_bitmap(container, section);
|
||||||
|
+ ram_addr = memory_region_get_ram_addr(section->mr) +
|
||||||
|
+ section->offset_within_region;
|
||||||
|
+
|
||||||
|
+ return vfio_get_dirty_bitmap(container,
|
||||||
|
+ REAL_HOST_PAGE_ALIGN(section->offset_within_address_space),
|
||||||
|
+ int128_get64(section->size), ram_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vfio_listener_log_sync(MemoryListener *listener,
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
84
Revert-vfio-Introduce-hostwin_from_range-helper.patch
Normal file
84
Revert-vfio-Introduce-hostwin_from_range-helper.patch
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
From 66fce3f7e9754345cf53afe3efd1b5bb5e322399 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:46 +0800
|
||||||
|
Subject: [PATCH 25/36] Revert "vfio: Introduce hostwin_from_range helper"
|
||||||
|
|
||||||
|
This reverts commit 85232739b4852f1a51dde58c9007ed0deb17c2f2.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 36 +++++++++++++++++++-----------------
|
||||||
|
1 file changed, 19 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index d358789f19..d7533637c9 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -909,19 +909,6 @@ static void vfio_unregister_ram_discard_listener(VFIOContainer *container,
|
||||||
|
g_free(vrdl);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static VFIOHostDMAWindow *
|
||||||
|
-hostwin_from_range(VFIOContainer *container, hwaddr iova, hwaddr end)
|
||||||
|
-{
|
||||||
|
- VFIOHostDMAWindow *hostwin;
|
||||||
|
-
|
||||||
|
- QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
|
||||||
|
- if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
|
||||||
|
- return hostwin;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- return NULL;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
MemoryRegionSection *section)
|
||||||
|
{
|
||||||
|
@@ -931,6 +918,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
void *vaddr;
|
||||||
|
int ret;
|
||||||
|
VFIOHostDMAWindow *hostwin;
|
||||||
|
+ bool hostwin_found;
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
|
if (vfio_listener_skipped_section(section)) {
|
||||||
|
@@ -1023,8 +1011,15 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
- hostwin = hostwin_from_range(container, iova, end);
|
||||||
|
- if (!hostwin) {
|
||||||
|
+ hostwin_found = false;
|
||||||
|
+ QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
|
||||||
|
+ if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
|
||||||
|
+ hostwin_found = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!hostwin_found) {
|
||||||
|
error_setg(&err, "Container %p can't map guest IOVA region"
|
||||||
|
" 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end);
|
||||||
|
goto fail;
|
||||||
|
@@ -1216,9 +1211,16 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
||||||
|
|
||||||
|
if (memory_region_is_ram_device(section->mr)) {
|
||||||
|
hwaddr pgmask;
|
||||||
|
- VFIOHostDMAWindow *hostwin = hostwin_from_range(container, iova, end);
|
||||||
|
+ VFIOHostDMAWindow *hostwin;
|
||||||
|
+ bool hostwin_found = false;
|
||||||
|
|
||||||
|
- assert(hostwin); /* or region_add() would have failed */
|
||||||
|
+ QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
|
||||||
|
+ if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
|
||||||
|
+ hostwin_found = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ assert(hostwin_found); /* or region_add() would have failed */
|
||||||
|
|
||||||
|
pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
|
||||||
|
try_unmap = !((iova & pgmask) || (int128_get64(llsize) & pgmask));
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
260
Revert-vfio-Pass-stage-1-MSI-bindings-to-the-host.patch
Normal file
260
Revert-vfio-Pass-stage-1-MSI-bindings-to-the-host.patch
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
From 17190414cd411d23f1fc14c3d44d7b9f210f12b0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:42 +0800
|
||||||
|
Subject: [PATCH 22/36] Revert "vfio: Pass stage 1 MSI bindings to the host"
|
||||||
|
|
||||||
|
This reverts commit 8b4fbe869f8a1f510896c86067d2e4fc3dc82eb9.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 59 ---------------------------
|
||||||
|
hw/vfio/pci.c | 76 +----------------------------------
|
||||||
|
hw/vfio/trace-events | 2 -
|
||||||
|
include/hw/vfio/vfio-common.h | 12 ------
|
||||||
|
4 files changed, 2 insertions(+), 147 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 1f78af121d..58f8a43a43 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -774,65 +774,6 @@ static void vfio_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-int vfio_iommu_set_msi_binding(VFIOContainer *container, int n,
|
||||||
|
- IOMMUTLBEntry *iotlb)
|
||||||
|
-{
|
||||||
|
- struct vfio_iommu_type1_set_msi_binding ustruct;
|
||||||
|
- VFIOMSIBinding *binding;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- QLIST_FOREACH(binding, &container->msibinding_list, next) {
|
||||||
|
- if (binding->index == n) {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ustruct.argsz = sizeof(struct vfio_iommu_type1_set_msi_binding);
|
||||||
|
- ustruct.iova = iotlb->iova;
|
||||||
|
- ustruct.flags = VFIO_IOMMU_BIND_MSI;
|
||||||
|
- ustruct.gpa = iotlb->translated_addr;
|
||||||
|
- ustruct.size = iotlb->addr_mask + 1;
|
||||||
|
- ret = ioctl(container->fd, VFIO_IOMMU_SET_MSI_BINDING , &ustruct);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("%s: failed to register the stage1 MSI binding (%m)",
|
||||||
|
- __func__);
|
||||||
|
- return ret;
|
||||||
|
- }
|
||||||
|
- binding = g_new0(VFIOMSIBinding, 1);
|
||||||
|
- binding->iova = ustruct.iova;
|
||||||
|
- binding->gpa = ustruct.gpa;
|
||||||
|
- binding->size = ustruct.size;
|
||||||
|
- binding->index = n;
|
||||||
|
-
|
||||||
|
- QLIST_INSERT_HEAD(&container->msibinding_list, binding, next);
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-int vfio_iommu_unset_msi_binding(VFIOContainer *container, int n)
|
||||||
|
-{
|
||||||
|
- struct vfio_iommu_type1_set_msi_binding ustruct;
|
||||||
|
- VFIOMSIBinding *binding, *tmp;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- ustruct.argsz = sizeof(struct vfio_iommu_type1_set_msi_binding);
|
||||||
|
- QLIST_FOREACH_SAFE(binding, &container->msibinding_list, next, tmp) {
|
||||||
|
- if (binding->index != n) {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- ustruct.flags = VFIO_IOMMU_UNBIND_MSI;
|
||||||
|
- ustruct.iova = binding->iova;
|
||||||
|
- ret = ioctl(container->fd, VFIO_IOMMU_SET_MSI_BINDING , &ustruct);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("Failed to unregister the stage1 MSI binding "
|
||||||
|
- "for iova=0x%"PRIx64" (%m)", binding->iova);
|
||||||
|
- }
|
||||||
|
- QLIST_REMOVE(binding, next);
|
||||||
|
- g_free(binding);
|
||||||
|
- return ret;
|
||||||
|
- }
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
||||||
|
{
|
||||||
|
VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
|
||||||
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||||||
|
index 99c52a0944..ae5e014e5d 100644
|
||||||
|
--- a/hw/vfio/pci.c
|
||||||
|
+++ b/hw/vfio/pci.c
|
||||||
|
@@ -365,65 +365,6 @@ static void vfio_msi_interrupt(void *opaque)
|
||||||
|
notify(&vdev->pdev, nr);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static bool vfio_iommu_require_msi_binding(IOMMUMemoryRegion *iommu_mr)
|
||||||
|
-{
|
||||||
|
- bool msi_translate = false, nested = false;
|
||||||
|
-
|
||||||
|
- memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_MSI_TRANSLATE,
|
||||||
|
- (void *)&msi_translate);
|
||||||
|
- memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_VFIO_NESTED,
|
||||||
|
- (void *)&nested);
|
||||||
|
- if (!nested || !msi_translate) {
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
- return true;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static int vfio_register_msi_binding(VFIOPCIDevice *vdev,
|
||||||
|
- int vector_n, bool set)
|
||||||
|
-{
|
||||||
|
- VFIOContainer *container = vdev->vbasedev.group->container;
|
||||||
|
- PCIDevice *dev = &vdev->pdev;
|
||||||
|
- AddressSpace *as = pci_device_iommu_address_space(dev);
|
||||||
|
- IOMMUMemoryRegionClass *imrc;
|
||||||
|
- IOMMUMemoryRegion *iommu_mr;
|
||||||
|
- IOMMUTLBEntry entry;
|
||||||
|
- MSIMessage msg;
|
||||||
|
-
|
||||||
|
- if (as == &address_space_memory) {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- iommu_mr = IOMMU_MEMORY_REGION(as->root);
|
||||||
|
- if (!vfio_iommu_require_msi_binding(iommu_mr)) {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* MSI doorbell address is translated by an IOMMU */
|
||||||
|
-
|
||||||
|
- if (!set) { /* unregister */
|
||||||
|
- trace_vfio_unregister_msi_binding(vdev->vbasedev.name, vector_n);
|
||||||
|
-
|
||||||
|
- return vfio_iommu_unset_msi_binding(container, vector_n);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- msg = pci_get_msi_message(dev, vector_n);
|
||||||
|
- imrc = memory_region_get_iommu_class_nocheck(iommu_mr);
|
||||||
|
-
|
||||||
|
- rcu_read_lock();
|
||||||
|
- entry = imrc->translate(iommu_mr, msg.address, IOMMU_WO, 0);
|
||||||
|
- rcu_read_unlock();
|
||||||
|
-
|
||||||
|
- if (entry.perm == IOMMU_NONE) {
|
||||||
|
- return -ENOENT;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- trace_vfio_register_msi_binding(vdev->vbasedev.name, vector_n,
|
||||||
|
- msg.address, entry.translated_addr);
|
||||||
|
-
|
||||||
|
- return vfio_iommu_set_msi_binding(container, vector_n, &entry);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
||||||
|
{
|
||||||
|
struct vfio_irq_set *irq_set;
|
||||||
|
@@ -441,7 +382,7 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
||||||
|
fds = (int32_t *)&irq_set->data;
|
||||||
|
|
||||||
|
for (i = 0; i < vdev->nr_vectors; i++) {
|
||||||
|
- int ret, fd = -1;
|
||||||
|
+ int fd = -1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MSI vs MSI-X - The guest has direct access to MSI mask and pending
|
||||||
|
@@ -450,12 +391,6 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
||||||
|
* KVM signaling path only when configured and unmasked.
|
||||||
|
*/
|
||||||
|
if (vdev->msi_vectors[i].use) {
|
||||||
|
- ret = vfio_register_msi_binding(vdev, i, true);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("%s failed to register S1 MSI binding "
|
||||||
|
- "for vector %d(%d)", vdev->vbasedev.name, i, ret);
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
if (vdev->msi_vectors[i].virq < 0 ||
|
||||||
|
(msix && msix_is_masked(&vdev->pdev, i))) {
|
||||||
|
fd = event_notifier_get_fd(&vdev->msi_vectors[i].interrupt);
|
||||||
|
@@ -469,7 +404,6 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
||||||
|
|
||||||
|
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
|
||||||
|
|
||||||
|
-out:
|
||||||
|
g_free(irq_set);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
@@ -784,8 +718,7 @@ static void vfio_msi_disable_common(VFIOPCIDevice *vdev)
|
||||||
|
|
||||||
|
static void vfio_msix_disable(VFIOPCIDevice *vdev)
|
||||||
|
{
|
||||||
|
- int ret, i;
|
||||||
|
-
|
||||||
|
+ int i;
|
||||||
|
|
||||||
|
msix_unset_vector_notifiers(&vdev->pdev);
|
||||||
|
|
||||||
|
@@ -797,11 +730,6 @@ static void vfio_msix_disable(VFIOPCIDevice *vdev)
|
||||||
|
if (vdev->msi_vectors[i].use) {
|
||||||
|
vfio_msix_vector_release(&vdev->pdev, i);
|
||||||
|
msix_vector_unuse(&vdev->pdev, i);
|
||||||
|
- ret = vfio_register_msi_binding(vdev, i, false);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("%s: failed to unregister S1 MSI binding "
|
||||||
|
- "for vector %d(%d)", vdev->vbasedev.name, i, ret);
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
||||||
|
index 35bd415d6d..20069935f5 100644
|
||||||
|
--- a/hw/vfio/trace-events
|
||||||
|
+++ b/hw/vfio/trace-events
|
||||||
|
@@ -120,8 +120,6 @@ vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype
|
||||||
|
vfio_dma_unmap_overflow_workaround(void) ""
|
||||||
|
vfio_iommu_addr_inv_iotlb(int asid, uint64_t addr, uint64_t size, uint64_t nb_granules, bool leaf) "nested IOTLB invalidate asid=%d, addr=0x%"PRIx64" granule_size=0x%"PRIx64" nb_granules=0x%"PRIx64" leaf=%d"
|
||||||
|
vfio_iommu_asid_inv_iotlb(int asid) "nested IOTLB invalidate asid=%d"
|
||||||
|
-vfio_register_msi_binding(const char *name, int vector, uint64_t giova, uint64_t gdb) "%s: register vector %d gIOVA=0x%"PRIx64 "-> gDB=0x%"PRIx64" stage 1 mapping"
|
||||||
|
-vfio_unregister_msi_binding(const char *name, int vector) "%s: unregister vector %d stage 1 mapping"
|
||||||
|
|
||||||
|
# platform.c
|
||||||
|
vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
|
||||||
|
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
|
||||||
|
index a838a939e4..0234f5e1b1 100644
|
||||||
|
--- a/include/hw/vfio/vfio-common.h
|
||||||
|
+++ b/include/hw/vfio/vfio-common.h
|
||||||
|
@@ -74,14 +74,6 @@ typedef struct VFIOAddressSpace {
|
||||||
|
QLIST_ENTRY(VFIOAddressSpace) list;
|
||||||
|
} VFIOAddressSpace;
|
||||||
|
|
||||||
|
-typedef struct VFIOMSIBinding {
|
||||||
|
- int index;
|
||||||
|
- hwaddr iova;
|
||||||
|
- hwaddr gpa;
|
||||||
|
- hwaddr size;
|
||||||
|
- QLIST_ENTRY(VFIOMSIBinding) next;
|
||||||
|
-} VFIOMSIBinding;
|
||||||
|
-
|
||||||
|
struct VFIOGroup;
|
||||||
|
|
||||||
|
typedef struct VFIODMARange {
|
||||||
|
@@ -111,7 +103,6 @@ typedef struct VFIOContainer {
|
||||||
|
QLIST_HEAD(, VFIOGroup) group_list;
|
||||||
|
QLIST_HEAD(, VFIORamDiscardListener) vrdl_list;
|
||||||
|
QLIST_HEAD(, VFIODMARange) dma_list;
|
||||||
|
- QLIST_HEAD(, VFIOMSIBinding) msibinding_list;
|
||||||
|
QLIST_ENTRY(VFIOContainer) next;
|
||||||
|
} VFIOContainer;
|
||||||
|
|
||||||
|
@@ -231,9 +222,6 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp);
|
||||||
|
void vfio_put_group(VFIOGroup *group);
|
||||||
|
int vfio_get_device(VFIOGroup *group, const char *name,
|
||||||
|
VFIODevice *vbasedev, Error **errp);
|
||||||
|
-int vfio_iommu_set_msi_binding(VFIOContainer *container, int n,
|
||||||
|
- IOMMUTLBEntry *entry);
|
||||||
|
-int vfio_iommu_unset_msi_binding(VFIOContainer *container, int n);
|
||||||
|
|
||||||
|
extern const MemoryRegionOps vfio_region_ops;
|
||||||
|
typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
266
Revert-vfio-Set-up-nested-stage-mappings.patch
Normal file
266
Revert-vfio-Set-up-nested-stage-mappings.patch
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
From 72b7903e406b7011ccba7a3ebbdfe790b421e9fc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:43 +0800
|
||||||
|
Subject: [PATCH 23/36] Revert "vfio: Set up nested stage mappings"
|
||||||
|
|
||||||
|
This reverts commit 96581a5ee46e89dbc9e1ebe247b00adefb1c7a41.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 139 ++-----------------------------------------
|
||||||
|
hw/vfio/pci.c | 21 -------
|
||||||
|
hw/vfio/trace-events | 2 -
|
||||||
|
3 files changed, 5 insertions(+), 157 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 58f8a43a43..b3dc090840 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -707,73 +707,6 @@ static bool vfio_get_xlat_addr(IOMMUTLBEntry *iotlb, void **vaddr,
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* Propagate a guest IOTLB invalidation to the host (nested mode) */
|
||||||
|
-static void vfio_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
||||||
|
-{
|
||||||
|
- VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
|
||||||
|
- struct vfio_iommu_type1_cache_invalidate ustruct = {};
|
||||||
|
- VFIOContainer *container = giommu->container;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- assert(iotlb->perm == IOMMU_NONE);
|
||||||
|
-
|
||||||
|
- ustruct.argsz = sizeof(ustruct);
|
||||||
|
- ustruct.flags = 0;
|
||||||
|
- ustruct.info.argsz = sizeof(struct iommu_cache_invalidate_info);
|
||||||
|
- ustruct.info.version = IOMMU_CACHE_INVALIDATE_INFO_VERSION_1;
|
||||||
|
- ustruct.info.cache = IOMMU_CACHE_INV_TYPE_IOTLB;
|
||||||
|
-
|
||||||
|
- switch (iotlb->granularity) {
|
||||||
|
- case IOMMU_INV_GRAN_DOMAIN:
|
||||||
|
- ustruct.info.granularity = IOMMU_INV_GRANU_DOMAIN;
|
||||||
|
- break;
|
||||||
|
- case IOMMU_INV_GRAN_PASID:
|
||||||
|
- {
|
||||||
|
- struct iommu_inv_pasid_info *pasid_info;
|
||||||
|
- int archid = -1;
|
||||||
|
-
|
||||||
|
- pasid_info = &ustruct.info.granu.pasid_info;
|
||||||
|
- ustruct.info.granularity = IOMMU_INV_GRANU_PASID;
|
||||||
|
- if (iotlb->flags & IOMMU_INV_FLAGS_ARCHID) {
|
||||||
|
- pasid_info->flags |= IOMMU_INV_ADDR_FLAGS_ARCHID;
|
||||||
|
- archid = iotlb->arch_id;
|
||||||
|
- }
|
||||||
|
- pasid_info->archid = archid;
|
||||||
|
- trace_vfio_iommu_asid_inv_iotlb(archid);
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
- case IOMMU_INV_GRAN_ADDR:
|
||||||
|
- {
|
||||||
|
- hwaddr start = iotlb->iova + giommu->iommu_offset;
|
||||||
|
- struct iommu_inv_addr_info *addr_info;
|
||||||
|
- size_t size = iotlb->addr_mask + 1;
|
||||||
|
- int archid = -1;
|
||||||
|
-
|
||||||
|
- addr_info = &ustruct.info.granu.addr_info;
|
||||||
|
- ustruct.info.granularity = IOMMU_INV_GRANU_ADDR;
|
||||||
|
- if (iotlb->leaf) {
|
||||||
|
- addr_info->flags |= IOMMU_INV_ADDR_FLAGS_LEAF;
|
||||||
|
- }
|
||||||
|
- if (iotlb->flags & IOMMU_INV_FLAGS_ARCHID) {
|
||||||
|
- addr_info->flags |= IOMMU_INV_ADDR_FLAGS_ARCHID;
|
||||||
|
- archid = iotlb->arch_id;
|
||||||
|
- }
|
||||||
|
- addr_info->archid = archid;
|
||||||
|
- addr_info->addr = start;
|
||||||
|
- addr_info->granule_size = size;
|
||||||
|
- addr_info->nb_granules = 1;
|
||||||
|
- trace_vfio_iommu_addr_inv_iotlb(archid, start, size,
|
||||||
|
- 1, iotlb->leaf);
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ret = ioctl(container->fd, VFIO_IOMMU_CACHE_INVALIDATE, &ustruct);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("%p: failed to invalidate CACHE (%d)", container, ret);
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
|
||||||
|
{
|
||||||
|
VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
|
||||||
|
@@ -1107,35 +1040,6 @@ static void vfio_dma_unmap_ram_section(VFIOContainer *container,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void vfio_prereg_listener_region_add(MemoryListener *listener,
|
||||||
|
- MemoryRegionSection *section)
|
||||||
|
-{
|
||||||
|
- VFIOContainer *container =
|
||||||
|
- container_of(listener, VFIOContainer, prereg_listener);
|
||||||
|
- Error *err = NULL;
|
||||||
|
-
|
||||||
|
- if (!memory_region_is_ram(section->mr)) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- vfio_dma_map_ram_section(container, section, &err);
|
||||||
|
- if (err) {
|
||||||
|
- error_report_err(err);
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-static void vfio_prereg_listener_region_del(MemoryListener *listener,
|
||||||
|
- MemoryRegionSection *section)
|
||||||
|
-{
|
||||||
|
- VFIOContainer *container =
|
||||||
|
- container_of(listener, VFIOContainer, prereg_listener);
|
||||||
|
-
|
||||||
|
- if (!memory_region_is_ram(section->mr)) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- vfio_dma_unmap_ram_section(container, section);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
MemoryRegionSection *section)
|
||||||
|
{
|
||||||
|
@@ -1246,10 +1150,9 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
memory_region_ref(section->mr);
|
||||||
|
|
||||||
|
if (memory_region_is_iommu(section->mr)) {
|
||||||
|
- IOMMUNotify notify;
|
||||||
|
VFIOGuestIOMMU *giommu;
|
||||||
|
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
|
||||||
|
- int iommu_idx, flags;
|
||||||
|
+ int iommu_idx;
|
||||||
|
|
||||||
|
trace_vfio_listener_region_add_iommu(iova, end);
|
||||||
|
/*
|
||||||
|
@@ -1268,18 +1171,8 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
llend = int128_sub(llend, int128_one());
|
||||||
|
iommu_idx = memory_region_iommu_attrs_to_index(iommu_mr,
|
||||||
|
MEMTXATTRS_UNSPECIFIED);
|
||||||
|
-
|
||||||
|
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- /* IOTLB unmap notifier to propagate guest IOTLB invalidations */
|
||||||
|
- flags = IOMMU_NOTIFIER_UNMAP;
|
||||||
|
- notify = vfio_iommu_unmap_notify;
|
||||||
|
- } else {
|
||||||
|
- /* MAP/UNMAP IOTLB notifier */
|
||||||
|
- flags = IOMMU_NOTIFIER_IOTLB_EVENTS;
|
||||||
|
- notify = vfio_iommu_map_notify;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- iommu_notifier_init(&giommu->n, notify, flags,
|
||||||
|
+ iommu_notifier_init(&giommu->n, vfio_iommu_map_notify,
|
||||||
|
+ IOMMU_NOTIFIER_IOTLB_EVENTS,
|
||||||
|
section->offset_within_region,
|
||||||
|
int128_get64(llend),
|
||||||
|
iommu_idx);
|
||||||
|
@@ -1299,9 +1192,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
|
||||||
|
- if (flags & IOMMU_NOTIFIER_MAP) {
|
||||||
|
- memory_region_iommu_replay(giommu->iommu, &giommu->n);
|
||||||
|
- }
|
||||||
|
+ memory_region_iommu_replay(giommu->iommu, &giommu->n);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@@ -1781,16 +1672,10 @@ static const MemoryListener vfio_memory_listener = {
|
||||||
|
.log_clear = vfio_listener_log_clear,
|
||||||
|
};
|
||||||
|
|
||||||
|
-static MemoryListener vfio_memory_prereg_listener = {
|
||||||
|
- .region_add = vfio_prereg_listener_region_add,
|
||||||
|
- .region_del = vfio_prereg_listener_region_del,
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
static void vfio_listener_release(VFIOContainer *container)
|
||||||
|
{
|
||||||
|
memory_listener_unregister(&container->listener);
|
||||||
|
- if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU ||
|
||||||
|
- container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
+ if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
|
||||||
|
memory_listener_unregister(&container->prereg_listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -2466,20 +2351,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
|
vfio_get_iommu_info_migration(container, info);
|
||||||
|
}
|
||||||
|
g_free(info);
|
||||||
|
-
|
||||||
|
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- container->prereg_listener = vfio_memory_prereg_listener;
|
||||||
|
- memory_listener_register(&container->prereg_listener,
|
||||||
|
- &address_space_memory);
|
||||||
|
- if (container->error) {
|
||||||
|
- memory_listener_unregister(&container->prereg_listener);
|
||||||
|
- ret = -1;
|
||||||
|
- error_propagate_prepend(errp, container->error,
|
||||||
|
- "RAM memory listener initialization failed "
|
||||||
|
- "for container");
|
||||||
|
- goto free_container_exit;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VFIO_SPAPR_TCE_v2_IOMMU:
|
||||||
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||||||
|
index ae5e014e5d..7b45353ce2 100644
|
||||||
|
--- a/hw/vfio/pci.c
|
||||||
|
+++ b/hw/vfio/pci.c
|
||||||
|
@@ -2797,25 +2797,6 @@ static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev)
|
||||||
|
vdev->req_enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int vfio_iommu_set_pasid_table(PCIBus *bus, int32_t devfn,
|
||||||
|
- IOMMUConfig *config)
|
||||||
|
-{
|
||||||
|
- PCIDevice *pdev = bus->devices[devfn];
|
||||||
|
- VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
||||||
|
- VFIOContainer *container = vdev->vbasedev.group->container;
|
||||||
|
- struct vfio_iommu_type1_set_pasid_table info;
|
||||||
|
-
|
||||||
|
- info.argsz = sizeof(info);
|
||||||
|
- info.flags = VFIO_PASID_TABLE_FLAG_SET;
|
||||||
|
- memcpy(&info.config, &config->pasid_cfg, sizeof(config->pasid_cfg));
|
||||||
|
-
|
||||||
|
- return ioctl(container->fd, VFIO_IOMMU_SET_PASID_TABLE, &info);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static PCIPASIDOps vfio_pci_pasid_ops = {
|
||||||
|
- .set_pasid_table = vfio_iommu_set_pasid_table,
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||||
|
{
|
||||||
|
VFIOPCIDevice *vdev = VFIO_PCI(pdev);
|
||||||
|
@@ -3127,8 +3108,6 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||||
|
vfio_register_req_notifier(vdev);
|
||||||
|
vfio_setup_resetfn_quirk(vdev);
|
||||||
|
|
||||||
|
- pci_setup_pasid_ops(pdev, &vfio_pci_pasid_ops);
|
||||||
|
-
|
||||||
|
return;
|
||||||
|
|
||||||
|
out_deregister:
|
||||||
|
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
|
||||||
|
index 20069935f5..a37563a315 100644
|
||||||
|
--- a/hw/vfio/trace-events
|
||||||
|
+++ b/hw/vfio/trace-events
|
||||||
|
@@ -118,8 +118,6 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
|
||||||
|
vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
|
||||||
|
vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
|
||||||
|
vfio_dma_unmap_overflow_workaround(void) ""
|
||||||
|
-vfio_iommu_addr_inv_iotlb(int asid, uint64_t addr, uint64_t size, uint64_t nb_granules, bool leaf) "nested IOTLB invalidate asid=%d, addr=0x%"PRIx64" granule_size=0x%"PRIx64" nb_granules=0x%"PRIx64" leaf=%d"
|
||||||
|
-vfio_iommu_asid_inv_iotlb(int asid) "nested IOTLB invalidate asid=%d"
|
||||||
|
|
||||||
|
# platform.c
|
||||||
|
vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
44
Revert-vfio-common-Add-address-alignment-check-in-vf.patch
Normal file
44
Revert-vfio-common-Add-address-alignment-check-in-vf.patch
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
From d0a16f250666ebd38c059ca86f161fade23640cf Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:09 +0800
|
||||||
|
Subject: [PATCH 01/36] Revert "vfio/common: Add address alignment check in
|
||||||
|
vfio_listener_region_del"
|
||||||
|
|
||||||
|
This reverts commit 00c553f53657bf4bc165d859187215dba7110246.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 10 ----------
|
||||||
|
1 file changed, 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 4d45c2b625..89c49f5508 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1411,8 +1411,6 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
||||||
|
MemoryRegionSection *section)
|
||||||
|
{
|
||||||
|
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
|
||||||
|
- hwaddr iova;
|
||||||
|
- Int128 llend;
|
||||||
|
|
||||||
|
if (vfio_listener_skipped_section(section)) {
|
||||||
|
trace_vfio_listener_region_del_skip(
|
||||||
|
@@ -1462,14 +1460,6 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
- iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
||||||
|
- llend = int128_make64(section->offset_within_address_space);
|
||||||
|
- llend = int128_add(llend, section->size);
|
||||||
|
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
||||||
|
- if (int128_ge(int128_make64(iova), llend)) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
vfio_dma_unmap_ram_section(container, section);
|
||||||
|
|
||||||
|
memory_region_unref(section->mr);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
37
Revert-vfio-common-Avoid-unmap-ram-section-at-vfio_l.patch
Normal file
37
Revert-vfio-common-Avoid-unmap-ram-section-at-vfio_l.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
From 2dc27b19fd8a17b23b112e84b9d7286d8c5f30ca Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:25 +0800
|
||||||
|
Subject: [PATCH 08/36] Revert "vfio/common: Avoid unmap ram section at
|
||||||
|
vfio_listener_region_del() in nested mode"
|
||||||
|
|
||||||
|
This reverts commit 9d7b782a0b2c5288e82f3064b4c5b7bf18887280.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 10 ----------
|
||||||
|
1 file changed, 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index bdfcc854fe..d05a485808 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1441,16 +1441,6 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * In nested mode, stage 2 (gpa->hpa) and the stage 1
|
||||||
|
- * (giova->gpa) are set separately. The ram section
|
||||||
|
- * will be unmapped in vfio_prereg_listener_region_del().
|
||||||
|
- * Hence it doesn't need to unmap ram section here.
|
||||||
|
- */
|
||||||
|
- if (container->iommu_type == VFIO_TYPE1_NESTING_IOMMU) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
/*
|
||||||
|
* FIXME: We assume the one big unmap below is adequate to
|
||||||
|
* remove any individual page mappings in the IOMMU which
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
33
Revert-vfio-common-Fix-incorrect-address-alignment-i.patch
Normal file
33
Revert-vfio-common-Fix-incorrect-address-alignment-i.patch
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
From b5cee7126a75ea0e1797760fd5d7dfd89028b8a8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:14 +0800
|
||||||
|
Subject: [PATCH 02/36] Revert "vfio/common: Fix incorrect address alignment in
|
||||||
|
vfio_dma_map_ram_section"
|
||||||
|
|
||||||
|
This reverts commit c2a4ce033db6ab74256e28da382c797a98047d4b.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/common.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||||||
|
index 89c49f5508..65f3979492 100644
|
||||||
|
--- a/hw/vfio/common.c
|
||||||
|
+++ b/hw/vfio/common.c
|
||||||
|
@@ -1059,10 +1059,10 @@ static int vfio_dma_map_ram_section(VFIOContainer *container,
|
||||||
|
|
||||||
|
assert(memory_region_is_ram(section->mr));
|
||||||
|
|
||||||
|
- iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
||||||
|
+ iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
|
||||||
|
llend = int128_make64(section->offset_within_address_space);
|
||||||
|
llend = int128_add(llend, section->size);
|
||||||
|
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
||||||
|
+ llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
|
||||||
|
end = int128_get64(int128_sub(llend, int128_one()));
|
||||||
|
|
||||||
|
vaddr = memory_region_get_ram_ptr(section->mr) +
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
194
Revert-vfio-pci-Implement-return_page_response-page-.patch
Normal file
194
Revert-vfio-pci-Implement-return_page_response-page-.patch
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
From 50e365a162cb7dd39d724fa1c5823e82d184af3a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:26 +0800
|
||||||
|
Subject: [PATCH 09/36] Revert "vfio/pci: Implement return_page_response page
|
||||||
|
response callback"
|
||||||
|
|
||||||
|
This reverts commit 6bbf810edebdb89a6958519ee3adfb1888520231.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/pci.c | 123 --------------------------------------------------
|
||||||
|
hw/vfio/pci.h | 2 -
|
||||||
|
2 files changed, 125 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||||||
|
index 8e24f9c7d1..c54e62fe8f 100644
|
||||||
|
--- a/hw/vfio/pci.c
|
||||||
|
+++ b/hw/vfio/pci.c
|
||||||
|
@@ -2693,61 +2693,6 @@ out:
|
||||||
|
g_free(fault_region_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void vfio_init_fault_response_regions(VFIOPCIDevice *vdev, Error **errp)
|
||||||
|
-{
|
||||||
|
- struct vfio_region_info *fault_region_info = NULL;
|
||||||
|
- struct vfio_region_info_cap_fault *cap_fault;
|
||||||
|
- VFIODevice *vbasedev = &vdev->vbasedev;
|
||||||
|
- struct vfio_info_cap_header *hdr;
|
||||||
|
- char *fault_region_name;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- ret = vfio_get_dev_region_info(&vdev->vbasedev,
|
||||||
|
- VFIO_REGION_TYPE_NESTED,
|
||||||
|
- VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT_RESPONSE,
|
||||||
|
- &fault_region_info);
|
||||||
|
- if (ret) {
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- hdr = vfio_get_region_info_cap(fault_region_info,
|
||||||
|
- VFIO_REGION_INFO_CAP_DMA_FAULT_RESPONSE);
|
||||||
|
- if (!hdr) {
|
||||||
|
- error_setg(errp, "failed to retrieve DMA FAULT RESPONSE capability");
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
- cap_fault = container_of(hdr, struct vfio_region_info_cap_fault,
|
||||||
|
- header);
|
||||||
|
- if (cap_fault->version != 1) {
|
||||||
|
- error_setg(errp, "Unsupported DMA FAULT RESPONSE API version %d",
|
||||||
|
- cap_fault->version);
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- fault_region_name = g_strdup_printf("%s DMA FAULT RESPONSE %d",
|
||||||
|
- vbasedev->name,
|
||||||
|
- fault_region_info->index);
|
||||||
|
-
|
||||||
|
- ret = vfio_region_setup(OBJECT(vdev), vbasedev,
|
||||||
|
- &vdev->dma_fault_response_region,
|
||||||
|
- fault_region_info->index,
|
||||||
|
- fault_region_name);
|
||||||
|
- g_free(fault_region_name);
|
||||||
|
- if (ret) {
|
||||||
|
- error_setg_errno(errp, -ret,
|
||||||
|
- "failed to set up the DMA FAULT RESPONSE region %d",
|
||||||
|
- fault_region_info->index);
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ret = vfio_region_mmap(&vdev->dma_fault_response_region);
|
||||||
|
- if (ret) {
|
||||||
|
- error_setg_errno(errp, -ret, "Failed to mmap the DMA FAULT RESPONSE queue");
|
||||||
|
- }
|
||||||
|
-out:
|
||||||
|
- g_free(fault_region_info);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
||||||
|
{
|
||||||
|
VFIODevice *vbasedev = &vdev->vbasedev;
|
||||||
|
@@ -2823,12 +2768,6 @@ static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
- vfio_init_fault_response_regions(vdev, &err);
|
||||||
|
- if (err) {
|
||||||
|
- error_propagate(errp, err);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
irq_info.index = VFIO_PCI_ERR_IRQ_INDEX;
|
||||||
|
|
||||||
|
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
|
||||||
|
@@ -3007,68 +2946,8 @@ static int vfio_iommu_set_pasid_table(PCIBus *bus, int32_t devfn,
|
||||||
|
return ioctl(container->fd, VFIO_IOMMU_SET_PASID_TABLE, &info);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int vfio_iommu_return_page_response(PCIBus *bus, int32_t devfn,
|
||||||
|
- IOMMUPageResponse *resp)
|
||||||
|
-{
|
||||||
|
- PCIDevice *pdev = bus->devices[devfn];
|
||||||
|
- VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
||||||
|
- struct iommu_page_response *response = &resp->resp;
|
||||||
|
- struct vfio_region_dma_fault_response header;
|
||||||
|
- struct iommu_page_response *queue;
|
||||||
|
- char *queue_buffer = NULL;
|
||||||
|
- ssize_t bytes;
|
||||||
|
-
|
||||||
|
- if (!vdev->dma_fault_response_region.mem) {
|
||||||
|
- return -EINVAL;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* read the header */
|
||||||
|
- bytes = pread(vdev->vbasedev.fd, &header, sizeof(header),
|
||||||
|
- vdev->dma_fault_response_region.fd_offset);
|
||||||
|
- if (bytes != sizeof(header)) {
|
||||||
|
- error_report("%s unable to read the fault region header (0x%lx)",
|
||||||
|
- __func__, bytes);
|
||||||
|
- return -1;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Normally the fault queue is mmapped */
|
||||||
|
- queue = (struct iommu_page_response *)vdev->dma_fault_response_region.mmaps[0].mmap;
|
||||||
|
- if (!queue) {
|
||||||
|
- size_t queue_size = header.nb_entries * header.entry_size;
|
||||||
|
-
|
||||||
|
- error_report("%s: fault queue not mmapped: slower fault handling",
|
||||||
|
- vdev->vbasedev.name);
|
||||||
|
-
|
||||||
|
- queue_buffer = g_malloc(queue_size);
|
||||||
|
- bytes = pread(vdev->vbasedev.fd, queue_buffer, queue_size,
|
||||||
|
- vdev->dma_fault_response_region.fd_offset + header.offset);
|
||||||
|
- if (bytes != queue_size) {
|
||||||
|
- error_report("%s unable to read the fault queue (0x%lx)",
|
||||||
|
- __func__, bytes);
|
||||||
|
- return -1;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- queue = (struct iommu_page_response *)queue_buffer;
|
||||||
|
- }
|
||||||
|
- /* deposit the new response in the queue and increment the head */
|
||||||
|
- memcpy(queue + header.head, response, header.entry_size);
|
||||||
|
-
|
||||||
|
- vdev->fault_response_head_index =
|
||||||
|
- (vdev->fault_response_head_index + 1) % header.nb_entries;
|
||||||
|
- bytes = pwrite(vdev->vbasedev.fd, &vdev->fault_response_head_index, 4,
|
||||||
|
- vdev->dma_fault_response_region.fd_offset);
|
||||||
|
- if (bytes != 4) {
|
||||||
|
- error_report("%s unable to write the fault response region head index (0x%lx)",
|
||||||
|
- __func__, bytes);
|
||||||
|
- }
|
||||||
|
- g_free(queue_buffer);
|
||||||
|
-
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static PCIPASIDOps vfio_pci_pasid_ops = {
|
||||||
|
.set_pasid_table = vfio_iommu_set_pasid_table,
|
||||||
|
- .return_page_response = vfio_iommu_return_page_response,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void vfio_dma_fault_notifier_handler(void *opaque)
|
||||||
|
@@ -3532,7 +3411,6 @@ static void vfio_instance_finalize(Object *obj)
|
||||||
|
vfio_display_finalize(vdev);
|
||||||
|
vfio_bars_finalize(vdev);
|
||||||
|
vfio_region_finalize(&vdev->dma_fault_region);
|
||||||
|
- vfio_region_finalize(&vdev->dma_fault_response_region);
|
||||||
|
g_free(vdev->emulated_config_bits);
|
||||||
|
g_free(vdev->rom);
|
||||||
|
/*
|
||||||
|
@@ -3554,7 +3432,6 @@ static void vfio_exitfn(PCIDevice *pdev)
|
||||||
|
vfio_unregister_err_notifier(vdev);
|
||||||
|
vfio_unregister_ext_irq_notifiers(vdev);
|
||||||
|
vfio_region_exit(&vdev->dma_fault_region);
|
||||||
|
- vfio_region_exit(&vdev->dma_fault_response_region);
|
||||||
|
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
|
||||||
|
if (vdev->irqchip_change_notifier.notify) {
|
||||||
|
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
||||||
|
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
||||||
|
index 61b3bf1303..03ac8919ef 100644
|
||||||
|
--- a/hw/vfio/pci.h
|
||||||
|
+++ b/hw/vfio/pci.h
|
||||||
|
@@ -147,8 +147,6 @@ struct VFIOPCIDevice {
|
||||||
|
VFIOPCIExtIRQ *ext_irqs;
|
||||||
|
VFIORegion dma_fault_region;
|
||||||
|
uint32_t fault_tail_index;
|
||||||
|
- VFIORegion dma_fault_response_region;
|
||||||
|
- uint32_t fault_response_head_index;
|
||||||
|
int (*resetfn)(struct VFIOPCIDevice *);
|
||||||
|
uint32_t vendor_id;
|
||||||
|
uint32_t device_id;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
93
Revert-vfio-pci-Implement-the-DMA-fault-handler.patch
Normal file
93
Revert-vfio-pci-Implement-the-DMA-fault-handler.patch
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
From 013220b686022a2e4ddb6a3d50af467275d25070 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:37 +0800
|
||||||
|
Subject: [PATCH 18/36] Revert "vfio/pci: Implement the DMA fault handler"
|
||||||
|
|
||||||
|
This reverts commit d33cc7eccb68c6a1488804c94ff5c1197ee0fc6e.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/pci.c | 50 --------------------------------------------------
|
||||||
|
hw/vfio/pci.h | 1 -
|
||||||
|
2 files changed, 51 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||||||
|
index c54e62fe8f..76bc9d3506 100644
|
||||||
|
--- a/hw/vfio/pci.c
|
||||||
|
+++ b/hw/vfio/pci.c
|
||||||
|
@@ -2953,60 +2953,10 @@ static PCIPASIDOps vfio_pci_pasid_ops = {
|
||||||
|
static void vfio_dma_fault_notifier_handler(void *opaque)
|
||||||
|
{
|
||||||
|
VFIOPCIExtIRQ *ext_irq = opaque;
|
||||||
|
- VFIOPCIDevice *vdev = ext_irq->vdev;
|
||||||
|
- PCIDevice *pdev = &vdev->pdev;
|
||||||
|
- AddressSpace *as = pci_device_iommu_address_space(pdev);
|
||||||
|
- IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(as->root);
|
||||||
|
- struct vfio_region_dma_fault header;
|
||||||
|
- struct iommu_fault *queue;
|
||||||
|
- char *queue_buffer = NULL;
|
||||||
|
- ssize_t bytes;
|
||||||
|
|
||||||
|
if (!event_notifier_test_and_clear(&ext_irq->notifier)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
-
|
||||||
|
- bytes = pread(vdev->vbasedev.fd, &header, sizeof(header),
|
||||||
|
- vdev->dma_fault_region.fd_offset);
|
||||||
|
- if (bytes != sizeof(header)) {
|
||||||
|
- error_report("%s unable to read the fault region header (0x%lx)",
|
||||||
|
- __func__, bytes);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Normally the fault queue is mmapped */
|
||||||
|
- queue = (struct iommu_fault *)vdev->dma_fault_region.mmaps[0].mmap;
|
||||||
|
- if (!queue) {
|
||||||
|
- size_t queue_size = header.nb_entries * header.entry_size;
|
||||||
|
-
|
||||||
|
- error_report("%s: fault queue not mmapped: slower fault handling",
|
||||||
|
- vdev->vbasedev.name);
|
||||||
|
-
|
||||||
|
- queue_buffer = g_malloc(queue_size);
|
||||||
|
- bytes = pread(vdev->vbasedev.fd, queue_buffer, queue_size,
|
||||||
|
- vdev->dma_fault_region.fd_offset + header.offset);
|
||||||
|
- if (bytes != queue_size) {
|
||||||
|
- error_report("%s unable to read the fault queue (0x%lx)",
|
||||||
|
- __func__, bytes);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- queue = (struct iommu_fault *)queue_buffer;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- while (vdev->fault_tail_index != header.head) {
|
||||||
|
- memory_region_inject_faults(iommu_mr, 1,
|
||||||
|
- &queue[vdev->fault_tail_index]);
|
||||||
|
- vdev->fault_tail_index =
|
||||||
|
- (vdev->fault_tail_index + 1) % header.nb_entries;
|
||||||
|
- }
|
||||||
|
- bytes = pwrite(vdev->vbasedev.fd, &vdev->fault_tail_index, 4,
|
||||||
|
- vdev->dma_fault_region.fd_offset);
|
||||||
|
- if (bytes != 4) {
|
||||||
|
- error_report("%s unable to write the fault region tail index (0x%lx)",
|
||||||
|
- __func__, bytes);
|
||||||
|
- }
|
||||||
|
- g_free(queue_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vfio_register_ext_irq_handler(VFIOPCIDevice *vdev,
|
||||||
|
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
||||||
|
index 03ac8919ef..eef91065f1 100644
|
||||||
|
--- a/hw/vfio/pci.h
|
||||||
|
+++ b/hw/vfio/pci.h
|
||||||
|
@@ -146,7 +146,6 @@ struct VFIOPCIDevice {
|
||||||
|
EventNotifier req_notifier;
|
||||||
|
VFIOPCIExtIRQ *ext_irqs;
|
||||||
|
VFIORegion dma_fault_region;
|
||||||
|
- uint32_t fault_tail_index;
|
||||||
|
int (*resetfn)(struct VFIOPCIDevice *);
|
||||||
|
uint32_t vendor_id;
|
||||||
|
uint32_t device_id;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
161
Revert-vfio-pci-Register-handler-for-iommu-fault.patch
Normal file
161
Revert-vfio-pci-Register-handler-for-iommu-fault.patch
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
From f32fc48313dadeb6469c00660bd96331e120030f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:40 +0800
|
||||||
|
Subject: [PATCH 20/36] Revert "vfio/pci: Register handler for iommu fault"
|
||||||
|
|
||||||
|
This reverts commit 574455d1363e818905e05cd23ef0948e83a16a51.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/pci.c | 81 +--------------------------------------------------
|
||||||
|
hw/vfio/pci.h | 7 -----
|
||||||
|
2 files changed, 1 insertion(+), 87 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||||||
|
index 37a70932c6..99c52a0944 100644
|
||||||
|
--- a/hw/vfio/pci.c
|
||||||
|
+++ b/hw/vfio/pci.c
|
||||||
|
@@ -2888,76 +2888,6 @@ static PCIPASIDOps vfio_pci_pasid_ops = {
|
||||||
|
.set_pasid_table = vfio_iommu_set_pasid_table,
|
||||||
|
};
|
||||||
|
|
||||||
|
-static void vfio_dma_fault_notifier_handler(void *opaque)
|
||||||
|
-{
|
||||||
|
- VFIOPCIExtIRQ *ext_irq = opaque;
|
||||||
|
-
|
||||||
|
- if (!event_notifier_test_and_clear(&ext_irq->notifier)) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static int vfio_register_ext_irq_handler(VFIOPCIDevice *vdev,
|
||||||
|
- uint32_t type, uint32_t subtype,
|
||||||
|
- IOHandler *handler)
|
||||||
|
-{
|
||||||
|
- int32_t fd, ext_irq_index, index;
|
||||||
|
- struct vfio_irq_info *irq_info;
|
||||||
|
- Error *err = NULL;
|
||||||
|
- EventNotifier *n;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- ret = vfio_get_dev_irq_info(&vdev->vbasedev, type, subtype, &irq_info);
|
||||||
|
- if (ret) {
|
||||||
|
- return ret;
|
||||||
|
- }
|
||||||
|
- index = irq_info->index;
|
||||||
|
- ext_irq_index = irq_info->index - VFIO_PCI_NUM_IRQS;
|
||||||
|
- g_free(irq_info);
|
||||||
|
-
|
||||||
|
- vdev->ext_irqs[ext_irq_index].vdev = vdev;
|
||||||
|
- vdev->ext_irqs[ext_irq_index].index = index;
|
||||||
|
- n = &vdev->ext_irqs[ext_irq_index].notifier;
|
||||||
|
-
|
||||||
|
- ret = event_notifier_init(n, 0);
|
||||||
|
- if (ret) {
|
||||||
|
- error_report("vfio: Unable to init event notifier for ext irq %d(%d)",
|
||||||
|
- ext_irq_index, ret);
|
||||||
|
- return ret;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- fd = event_notifier_get_fd(n);
|
||||||
|
- qemu_set_fd_handler(fd, vfio_dma_fault_notifier_handler, NULL,
|
||||||
|
- &vdev->ext_irqs[ext_irq_index]);
|
||||||
|
-
|
||||||
|
- ret = vfio_set_irq_signaling(&vdev->vbasedev, index, 0,
|
||||||
|
- VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err);
|
||||||
|
- if (ret) {
|
||||||
|
- error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
|
||||||
|
- qemu_set_fd_handler(fd, NULL, NULL, vdev);
|
||||||
|
- event_notifier_cleanup(n);
|
||||||
|
- }
|
||||||
|
- return ret;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static void vfio_unregister_ext_irq_notifiers(VFIOPCIDevice *vdev)
|
||||||
|
-{
|
||||||
|
- VFIODevice *vbasedev = &vdev->vbasedev;
|
||||||
|
- Error *err = NULL;
|
||||||
|
- int i;
|
||||||
|
-
|
||||||
|
- for (i = 0; i < vbasedev->num_irqs - VFIO_PCI_NUM_IRQS; i++) {
|
||||||
|
- if (vfio_set_irq_signaling(vbasedev, i + VFIO_PCI_NUM_IRQS , 0,
|
||||||
|
- VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
|
||||||
|
- error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
|
||||||
|
- }
|
||||||
|
- qemu_set_fd_handler(event_notifier_get_fd(&vdev->ext_irqs[i].notifier),
|
||||||
|
- NULL, NULL, vdev);
|
||||||
|
- event_notifier_cleanup(&vdev->ext_irqs[i].notifier);
|
||||||
|
- }
|
||||||
|
- g_free(vdev->ext_irqs);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||||
|
{
|
||||||
|
VFIOPCIDevice *vdev = VFIO_PCI(pdev);
|
||||||
|
@@ -2968,7 +2898,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||||
|
ssize_t len;
|
||||||
|
struct stat st;
|
||||||
|
int groupid;
|
||||||
|
- int i, ret, nb_ext_irqs;
|
||||||
|
+ int i, ret;
|
||||||
|
bool is_mdev;
|
||||||
|
|
||||||
|
if (!vdev->vbasedev.sysfsdev) {
|
||||||
|
@@ -3056,11 +2986,6 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
- nb_ext_irqs = vdev->vbasedev.num_irqs - VFIO_PCI_NUM_IRQS;
|
||||||
|
- if (nb_ext_irqs > 0) {
|
||||||
|
- vdev->ext_irqs = g_new0(VFIOPCIExtIRQ, nb_ext_irqs);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
vfio_populate_device(vdev, &err);
|
||||||
|
if (err) {
|
||||||
|
error_propagate(errp, err);
|
||||||
|
@@ -3272,9 +3197,6 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||||
|
|
||||||
|
vfio_register_err_notifier(vdev);
|
||||||
|
vfio_register_req_notifier(vdev);
|
||||||
|
- vfio_register_ext_irq_handler(vdev, VFIO_IRQ_TYPE_NESTED,
|
||||||
|
- VFIO_IRQ_SUBTYPE_DMA_FAULT,
|
||||||
|
- vfio_dma_fault_notifier_handler);
|
||||||
|
vfio_setup_resetfn_quirk(vdev);
|
||||||
|
|
||||||
|
pci_setup_pasid_ops(pdev, &vfio_pci_pasid_ops);
|
||||||
|
@@ -3317,7 +3239,6 @@ static void vfio_exitfn(PCIDevice *pdev)
|
||||||
|
|
||||||
|
vfio_unregister_req_notifier(vdev);
|
||||||
|
vfio_unregister_err_notifier(vdev);
|
||||||
|
- vfio_unregister_ext_irq_notifiers(vdev);
|
||||||
|
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
|
||||||
|
if (vdev->irqchip_change_notifier.notify) {
|
||||||
|
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
||||||
|
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
||||||
|
index a8b06737fb..64777516d1 100644
|
||||||
|
--- a/hw/vfio/pci.h
|
||||||
|
+++ b/hw/vfio/pci.h
|
||||||
|
@@ -114,12 +114,6 @@ typedef struct VFIOMSIXInfo {
|
||||||
|
unsigned long *pending;
|
||||||
|
} VFIOMSIXInfo;
|
||||||
|
|
||||||
|
-typedef struct VFIOPCIExtIRQ {
|
||||||
|
- struct VFIOPCIDevice *vdev;
|
||||||
|
- EventNotifier notifier;
|
||||||
|
- uint32_t index;
|
||||||
|
-} VFIOPCIExtIRQ;
|
||||||
|
-
|
||||||
|
#define TYPE_VFIO_PCI "vfio-pci"
|
||||||
|
OBJECT_DECLARE_SIMPLE_TYPE(VFIOPCIDevice, VFIO_PCI)
|
||||||
|
|
||||||
|
@@ -144,7 +138,6 @@ struct VFIOPCIDevice {
|
||||||
|
PCIHostDeviceAddress host;
|
||||||
|
EventNotifier err_notifier;
|
||||||
|
EventNotifier req_notifier;
|
||||||
|
- VFIOPCIExtIRQ *ext_irqs;
|
||||||
|
int (*resetfn)(struct VFIOPCIDevice *);
|
||||||
|
uint32_t vendor_id;
|
||||||
|
uint32_t device_id;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
129
Revert-vfio-pci-Set-up-the-DMA-FAULT-region.patch
Normal file
129
Revert-vfio-pci-Set-up-the-DMA-FAULT-region.patch
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
From 0e9cc7c0a60ace8baeab6e32f49770afbeec6f5d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:38 +0800
|
||||||
|
Subject: [PATCH 19/36] Revert "vfio/pci: Set up the DMA FAULT region"
|
||||||
|
|
||||||
|
This reverts commit e701d0fef4fbb7935d6aa7d22d82eb2dcfee2431.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
hw/vfio/pci.c | 64 ---------------------------------------------------
|
||||||
|
hw/vfio/pci.h | 1 -
|
||||||
|
2 files changed, 65 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||||||
|
index 76bc9d3506..37a70932c6 100644
|
||||||
|
--- a/hw/vfio/pci.c
|
||||||
|
+++ b/hw/vfio/pci.c
|
||||||
|
@@ -2638,67 +2638,11 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void vfio_init_fault_regions(VFIOPCIDevice *vdev, Error **errp)
|
||||||
|
-{
|
||||||
|
- struct vfio_region_info *fault_region_info = NULL;
|
||||||
|
- struct vfio_region_info_cap_fault *cap_fault;
|
||||||
|
- VFIODevice *vbasedev = &vdev->vbasedev;
|
||||||
|
- struct vfio_info_cap_header *hdr;
|
||||||
|
- char *fault_region_name;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- ret = vfio_get_dev_region_info(&vdev->vbasedev,
|
||||||
|
- VFIO_REGION_TYPE_NESTED,
|
||||||
|
- VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT,
|
||||||
|
- &fault_region_info);
|
||||||
|
- if (ret) {
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- hdr = vfio_get_region_info_cap(fault_region_info,
|
||||||
|
- VFIO_REGION_INFO_CAP_DMA_FAULT);
|
||||||
|
- if (!hdr) {
|
||||||
|
- error_setg(errp, "failed to retrieve DMA FAULT capability");
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
- cap_fault = container_of(hdr, struct vfio_region_info_cap_fault,
|
||||||
|
- header);
|
||||||
|
- if (cap_fault->version != 1) {
|
||||||
|
- error_setg(errp, "Unsupported DMA FAULT API version %d",
|
||||||
|
- cap_fault->version);
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- fault_region_name = g_strdup_printf("%s DMA FAULT %d",
|
||||||
|
- vbasedev->name,
|
||||||
|
- fault_region_info->index);
|
||||||
|
-
|
||||||
|
- ret = vfio_region_setup(OBJECT(vdev), vbasedev,
|
||||||
|
- &vdev->dma_fault_region,
|
||||||
|
- fault_region_info->index,
|
||||||
|
- fault_region_name);
|
||||||
|
- g_free(fault_region_name);
|
||||||
|
- if (ret) {
|
||||||
|
- error_setg_errno(errp, -ret,
|
||||||
|
- "failed to set up the DMA FAULT region %d",
|
||||||
|
- fault_region_info->index);
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ret = vfio_region_mmap(&vdev->dma_fault_region);
|
||||||
|
- if (ret) {
|
||||||
|
- error_setg_errno(errp, -ret, "Failed to mmap the DMA FAULT queue");
|
||||||
|
- }
|
||||||
|
-out:
|
||||||
|
- g_free(fault_region_info);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
||||||
|
{
|
||||||
|
VFIODevice *vbasedev = &vdev->vbasedev;
|
||||||
|
struct vfio_region_info *reg_info;
|
||||||
|
struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) };
|
||||||
|
- Error *err = NULL;
|
||||||
|
int i, ret = -1;
|
||||||
|
|
||||||
|
/* Sanity check device */
|
||||||
|
@@ -2762,12 +2706,6 @@ static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- vfio_init_fault_regions(vdev, &err);
|
||||||
|
- if (err) {
|
||||||
|
- error_propagate(errp, err);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
irq_info.index = VFIO_PCI_ERR_IRQ_INDEX;
|
||||||
|
|
||||||
|
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
|
||||||
|
@@ -3360,7 +3298,6 @@ static void vfio_instance_finalize(Object *obj)
|
||||||
|
|
||||||
|
vfio_display_finalize(vdev);
|
||||||
|
vfio_bars_finalize(vdev);
|
||||||
|
- vfio_region_finalize(&vdev->dma_fault_region);
|
||||||
|
g_free(vdev->emulated_config_bits);
|
||||||
|
g_free(vdev->rom);
|
||||||
|
/*
|
||||||
|
@@ -3381,7 +3318,6 @@ static void vfio_exitfn(PCIDevice *pdev)
|
||||||
|
vfio_unregister_req_notifier(vdev);
|
||||||
|
vfio_unregister_err_notifier(vdev);
|
||||||
|
vfio_unregister_ext_irq_notifiers(vdev);
|
||||||
|
- vfio_region_exit(&vdev->dma_fault_region);
|
||||||
|
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
|
||||||
|
if (vdev->irqchip_change_notifier.notify) {
|
||||||
|
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
||||||
|
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
|
||||||
|
index eef91065f1..a8b06737fb 100644
|
||||||
|
--- a/hw/vfio/pci.h
|
||||||
|
+++ b/hw/vfio/pci.h
|
||||||
|
@@ -145,7 +145,6 @@ struct VFIOPCIDevice {
|
||||||
|
EventNotifier err_notifier;
|
||||||
|
EventNotifier req_notifier;
|
||||||
|
VFIOPCIExtIRQ *ext_irqs;
|
||||||
|
- VFIORegion dma_fault_region;
|
||||||
|
int (*resetfn)(struct VFIOPCIDevice *);
|
||||||
|
uint32_t vendor_id;
|
||||||
|
uint32_t device_id;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
703
Revert-vfio.h-and-iommu.h-header-update-against-5.10.patch
Normal file
703
Revert-vfio.h-and-iommu.h-header-update-against-5.10.patch
Normal file
@ -0,0 +1,703 @@
|
|||||||
|
From d3b9b26c9bb53b00b1441b3edad446ffea1ad8ff Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Fri, 18 Nov 2022 15:22:58 +0800
|
||||||
|
Subject: [PATCH 35/36] Revert "vfio.h and iommu.h header update against 5.10"
|
||||||
|
|
||||||
|
This reverts commit 36b65d7312a343cb636e6963b8262dce9420ebc6.
|
||||||
|
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
---
|
||||||
|
linux-headers/linux/iommu.h | 395 ------------------------------------
|
||||||
|
linux-headers/linux/vfio.h | 220 +-------------------
|
||||||
|
2 files changed, 2 insertions(+), 613 deletions(-)
|
||||||
|
delete mode 100644 linux-headers/linux/iommu.h
|
||||||
|
|
||||||
|
diff --git a/linux-headers/linux/iommu.h b/linux-headers/linux/iommu.h
|
||||||
|
deleted file mode 100644
|
||||||
|
index 773b7dc2d6..0000000000
|
||||||
|
--- a/linux-headers/linux/iommu.h
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,395 +0,0 @@
|
||||||
|
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||||
|
-/*
|
||||||
|
- * IOMMU user API definitions
|
||||||
|
- */
|
||||||
|
-
|
||||||
|
-#ifndef IOMMU_H
|
||||||
|
-#define IOMMU_H
|
||||||
|
-
|
||||||
|
-#include <linux/types.h>
|
||||||
|
-
|
||||||
|
-#define IOMMU_FAULT_PERM_READ (1 << 0) /* read */
|
||||||
|
-#define IOMMU_FAULT_PERM_WRITE (1 << 1) /* write */
|
||||||
|
-#define IOMMU_FAULT_PERM_EXEC (1 << 2) /* exec */
|
||||||
|
-#define IOMMU_FAULT_PERM_PRIV (1 << 3) /* privileged */
|
||||||
|
-
|
||||||
|
-/* Generic fault types, can be expanded IRQ remapping fault */
|
||||||
|
-enum iommu_fault_type {
|
||||||
|
- IOMMU_FAULT_DMA_UNRECOV = 1, /* unrecoverable fault */
|
||||||
|
- IOMMU_FAULT_PAGE_REQ, /* page request fault */
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-enum iommu_fault_reason {
|
||||||
|
- IOMMU_FAULT_REASON_UNKNOWN = 0,
|
||||||
|
-
|
||||||
|
- /* Could not access the PASID table (fetch caused external abort) */
|
||||||
|
- IOMMU_FAULT_REASON_PASID_FETCH,
|
||||||
|
-
|
||||||
|
- /* PASID entry is invalid or has configuration errors */
|
||||||
|
- IOMMU_FAULT_REASON_BAD_PASID_ENTRY,
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * PASID is out of range (e.g. exceeds the maximum PASID
|
||||||
|
- * supported by the IOMMU) or disabled.
|
||||||
|
- */
|
||||||
|
- IOMMU_FAULT_REASON_PASID_INVALID,
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * An external abort occurred fetching (or updating) a translation
|
||||||
|
- * table descriptor
|
||||||
|
- */
|
||||||
|
- IOMMU_FAULT_REASON_WALK_EABT,
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * Could not access the page table entry (Bad address),
|
||||||
|
- * actual translation fault
|
||||||
|
- */
|
||||||
|
- IOMMU_FAULT_REASON_PTE_FETCH,
|
||||||
|
-
|
||||||
|
- /* Protection flag check failed */
|
||||||
|
- IOMMU_FAULT_REASON_PERMISSION,
|
||||||
|
-
|
||||||
|
- /* access flag check failed */
|
||||||
|
- IOMMU_FAULT_REASON_ACCESS,
|
||||||
|
-
|
||||||
|
- /* Output address of a translation stage caused Address Size fault */
|
||||||
|
- IOMMU_FAULT_REASON_OOR_ADDRESS,
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_fault_unrecoverable - Unrecoverable fault data
|
||||||
|
- * @reason: reason of the fault, from &enum iommu_fault_reason
|
||||||
|
- * @flags: parameters of this fault (IOMMU_FAULT_UNRECOV_* values)
|
||||||
|
- * @pasid: Process Address Space ID
|
||||||
|
- * @perm: requested permission access using by the incoming transaction
|
||||||
|
- * (IOMMU_FAULT_PERM_* values)
|
||||||
|
- * @addr: offending page address
|
||||||
|
- * @fetch_addr: address that caused a fetch abort, if any
|
||||||
|
- */
|
||||||
|
-struct iommu_fault_unrecoverable {
|
||||||
|
- __u32 reason;
|
||||||
|
-#define IOMMU_FAULT_UNRECOV_PASID_VALID (1 << 0)
|
||||||
|
-#define IOMMU_FAULT_UNRECOV_ADDR_VALID (1 << 1)
|
||||||
|
-#define IOMMU_FAULT_UNRECOV_FETCH_ADDR_VALID (1 << 2)
|
||||||
|
- __u32 flags;
|
||||||
|
- __u32 pasid;
|
||||||
|
- __u32 perm;
|
||||||
|
- __u64 addr;
|
||||||
|
- __u64 fetch_addr;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_fault_page_request - Page Request data
|
||||||
|
- * @flags: encodes whether the corresponding fields are valid and whether this
|
||||||
|
- * is the last page in group (IOMMU_FAULT_PAGE_REQUEST_* values).
|
||||||
|
- * When IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID is set, the page response
|
||||||
|
- * must have the same PASID value as the page request. When it is clear,
|
||||||
|
- * the page response should not have a PASID.
|
||||||
|
- * @pasid: Process Address Space ID
|
||||||
|
- * @grpid: Page Request Group Index
|
||||||
|
- * @perm: requested page permissions (IOMMU_FAULT_PERM_* values)
|
||||||
|
- * @addr: page address
|
||||||
|
- * @private_data: device-specific private information
|
||||||
|
- */
|
||||||
|
-struct iommu_fault_page_request {
|
||||||
|
-#define IOMMU_FAULT_PAGE_REQUEST_PASID_VALID (1 << 0)
|
||||||
|
-#define IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE (1 << 1)
|
||||||
|
-#define IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA (1 << 2)
|
||||||
|
-#define IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID (1 << 3)
|
||||||
|
- __u32 flags;
|
||||||
|
- __u32 pasid;
|
||||||
|
- __u32 grpid;
|
||||||
|
- __u32 perm;
|
||||||
|
- __u64 addr;
|
||||||
|
- __u64 private_data[2];
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_fault - Generic fault data
|
||||||
|
- * @type: fault type from &enum iommu_fault_type
|
||||||
|
- * @padding: reserved for future use (should be zero)
|
||||||
|
- * @event: fault event, when @type is %IOMMU_FAULT_DMA_UNRECOV
|
||||||
|
- * @prm: Page Request message, when @type is %IOMMU_FAULT_PAGE_REQ
|
||||||
|
- * @padding2: sets the fault size to allow for future extensions
|
||||||
|
- */
|
||||||
|
-struct iommu_fault {
|
||||||
|
- __u32 type;
|
||||||
|
- __u32 padding;
|
||||||
|
- union {
|
||||||
|
- struct iommu_fault_unrecoverable event;
|
||||||
|
- struct iommu_fault_page_request prm;
|
||||||
|
- __u8 padding2[56];
|
||||||
|
- };
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * enum iommu_page_response_code - Return status of fault handlers
|
||||||
|
- * @IOMMU_PAGE_RESP_SUCCESS: Fault has been handled and the page tables
|
||||||
|
- * populated, retry the access. This is "Success" in PCI PRI.
|
||||||
|
- * @IOMMU_PAGE_RESP_FAILURE: General error. Drop all subsequent faults from
|
||||||
|
- * this device if possible. This is "Response Failure" in PCI PRI.
|
||||||
|
- * @IOMMU_PAGE_RESP_INVALID: Could not handle this fault, don't retry the
|
||||||
|
- * access. This is "Invalid Request" in PCI PRI.
|
||||||
|
- */
|
||||||
|
-enum iommu_page_response_code {
|
||||||
|
- IOMMU_PAGE_RESP_SUCCESS = 0,
|
||||||
|
- IOMMU_PAGE_RESP_INVALID,
|
||||||
|
- IOMMU_PAGE_RESP_FAILURE,
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_page_response - Generic page response information
|
||||||
|
- * @argsz: User filled size of this data
|
||||||
|
- * @version: API version of this structure
|
||||||
|
- * @flags: encodes whether the corresponding fields are valid
|
||||||
|
- * (IOMMU_FAULT_PAGE_RESPONSE_* values)
|
||||||
|
- * @pasid: Process Address Space ID
|
||||||
|
- * @grpid: Page Request Group Index
|
||||||
|
- * @code: response code from &enum iommu_page_response_code
|
||||||
|
- */
|
||||||
|
-struct iommu_page_response {
|
||||||
|
- __u32 argsz;
|
||||||
|
-#define IOMMU_PAGE_RESP_VERSION_1 1
|
||||||
|
- __u32 version;
|
||||||
|
-#define IOMMU_PAGE_RESP_PASID_VALID (1 << 0)
|
||||||
|
- __u32 flags;
|
||||||
|
- __u32 pasid;
|
||||||
|
- __u32 grpid;
|
||||||
|
- __u32 code;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/* defines the granularity of the invalidation */
|
||||||
|
-enum iommu_inv_granularity {
|
||||||
|
- IOMMU_INV_GRANU_DOMAIN, /* domain-selective invalidation */
|
||||||
|
- IOMMU_INV_GRANU_PASID, /* PASID-selective invalidation */
|
||||||
|
- IOMMU_INV_GRANU_ADDR, /* page-selective invalidation */
|
||||||
|
- IOMMU_INV_GRANU_NR, /* number of invalidation granularities */
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_inv_addr_info - Address Selective Invalidation Structure
|
||||||
|
- *
|
||||||
|
- * @flags: indicates the granularity of the address-selective invalidation
|
||||||
|
- * - If the PASID bit is set, the @pasid field is populated and the invalidation
|
||||||
|
- * relates to cache entries tagged with this PASID and matching the address
|
||||||
|
- * range.
|
||||||
|
- * - If ARCHID bit is set, @archid is populated and the invalidation relates
|
||||||
|
- * to cache entries tagged with this architecture specific ID and matching
|
||||||
|
- * the address range.
|
||||||
|
- * - Both PASID and ARCHID can be set as they may tag different caches.
|
||||||
|
- * - If neither PASID or ARCHID is set, global addr invalidation applies.
|
||||||
|
- * - The LEAF flag indicates whether only the leaf PTE caching needs to be
|
||||||
|
- * invalidated and other paging structure caches can be preserved.
|
||||||
|
- * @pasid: process address space ID
|
||||||
|
- * @archid: architecture-specific ID
|
||||||
|
- * @addr: first stage/level input address
|
||||||
|
- * @granule_size: page/block size of the mapping in bytes
|
||||||
|
- * @nb_granules: number of contiguous granules to be invalidated
|
||||||
|
- */
|
||||||
|
-struct iommu_inv_addr_info {
|
||||||
|
-#define IOMMU_INV_ADDR_FLAGS_PASID (1 << 0)
|
||||||
|
-#define IOMMU_INV_ADDR_FLAGS_ARCHID (1 << 1)
|
||||||
|
-#define IOMMU_INV_ADDR_FLAGS_LEAF (1 << 2)
|
||||||
|
- __u32 flags;
|
||||||
|
- __u32 archid;
|
||||||
|
- __u64 pasid;
|
||||||
|
- __u64 addr;
|
||||||
|
- __u64 granule_size;
|
||||||
|
- __u64 nb_granules;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_inv_pasid_info - PASID Selective Invalidation Structure
|
||||||
|
- *
|
||||||
|
- * @flags: indicates the granularity of the PASID-selective invalidation
|
||||||
|
- * - If the PASID bit is set, the @pasid field is populated and the invalidation
|
||||||
|
- * relates to cache entries tagged with this PASID and matching the address
|
||||||
|
- * range.
|
||||||
|
- * - If the ARCHID bit is set, the @archid is populated and the invalidation
|
||||||
|
- * relates to cache entries tagged with this architecture specific ID and
|
||||||
|
- * matching the address range.
|
||||||
|
- * - Both PASID and ARCHID can be set as they may tag different caches.
|
||||||
|
- * - At least one of PASID or ARCHID must be set.
|
||||||
|
- * @pasid: process address space ID
|
||||||
|
- * @archid: architecture-specific ID
|
||||||
|
- */
|
||||||
|
-struct iommu_inv_pasid_info {
|
||||||
|
-#define IOMMU_INV_PASID_FLAGS_PASID (1 << 0)
|
||||||
|
-#define IOMMU_INV_PASID_FLAGS_ARCHID (1 << 1)
|
||||||
|
- __u32 flags;
|
||||||
|
- __u32 archid;
|
||||||
|
- __u64 pasid;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_cache_invalidate_info - First level/stage invalidation
|
||||||
|
- * information
|
||||||
|
- * @argsz: User filled size of this data
|
||||||
|
- * @version: API version of this structure
|
||||||
|
- * @cache: bitfield that allows to select which caches to invalidate
|
||||||
|
- * @granularity: defines the lowest granularity used for the invalidation:
|
||||||
|
- * domain > PASID > addr
|
||||||
|
- * @padding: reserved for future use (should be zero)
|
||||||
|
- * @pasid_info: invalidation data when @granularity is %IOMMU_INV_GRANU_PASID
|
||||||
|
- * @addr_info: invalidation data when @granularity is %IOMMU_INV_GRANU_ADDR
|
||||||
|
- *
|
||||||
|
- * Not all the combinations of cache/granularity are valid:
|
||||||
|
- *
|
||||||
|
- * +--------------+---------------+---------------+---------------+
|
||||||
|
- * | type / | DEV_IOTLB | IOTLB | PASID |
|
||||||
|
- * | granularity | | | cache |
|
||||||
|
- * +==============+===============+===============+===============+
|
||||||
|
- * | DOMAIN | N/A | Y | Y |
|
||||||
|
- * +--------------+---------------+---------------+---------------+
|
||||||
|
- * | PASID | Y | Y | Y |
|
||||||
|
- * +--------------+---------------+---------------+---------------+
|
||||||
|
- * | ADDR | Y | Y | N/A |
|
||||||
|
- * +--------------+---------------+---------------+---------------+
|
||||||
|
- *
|
||||||
|
- * Invalidations by %IOMMU_INV_GRANU_DOMAIN don't take any argument other than
|
||||||
|
- * @version and @cache.
|
||||||
|
- *
|
||||||
|
- * If multiple cache types are invalidated simultaneously, they all
|
||||||
|
- * must support the used granularity.
|
||||||
|
- */
|
||||||
|
-struct iommu_cache_invalidate_info {
|
||||||
|
- __u32 argsz;
|
||||||
|
-#define IOMMU_CACHE_INVALIDATE_INFO_VERSION_1 1
|
||||||
|
- __u32 version;
|
||||||
|
-/* IOMMU paging structure cache */
|
||||||
|
-#define IOMMU_CACHE_INV_TYPE_IOTLB (1 << 0) /* IOMMU IOTLB */
|
||||||
|
-#define IOMMU_CACHE_INV_TYPE_DEV_IOTLB (1 << 1) /* Device IOTLB */
|
||||||
|
-#define IOMMU_CACHE_INV_TYPE_PASID (1 << 2) /* PASID cache */
|
||||||
|
-#define IOMMU_CACHE_INV_TYPE_NR (3)
|
||||||
|
- __u8 cache;
|
||||||
|
- __u8 granularity;
|
||||||
|
- __u8 padding[6];
|
||||||
|
- union {
|
||||||
|
- struct iommu_inv_pasid_info pasid_info;
|
||||||
|
- struct iommu_inv_addr_info addr_info;
|
||||||
|
- } granu;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_gpasid_bind_data_vtd - Intel VT-d specific data on device and guest
|
||||||
|
- * SVA binding.
|
||||||
|
- *
|
||||||
|
- * @flags: VT-d PASID table entry attributes
|
||||||
|
- * @pat: Page attribute table data to compute effective memory type
|
||||||
|
- * @emt: Extended memory type
|
||||||
|
- *
|
||||||
|
- * Only guest vIOMMU selectable and effective options are passed down to
|
||||||
|
- * the host IOMMU.
|
||||||
|
- */
|
||||||
|
-struct iommu_gpasid_bind_data_vtd {
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_SRE (1 << 0) /* supervisor request */
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_EAFE (1 << 1) /* extended access enable */
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_PCD (1 << 2) /* page-level cache disable */
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_PWT (1 << 3) /* page-level write through */
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_EMTE (1 << 4) /* extended mem type enable */
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_CD (1 << 5) /* PASID-level cache disable */
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_LAST (1 << 6)
|
||||||
|
- __u64 flags;
|
||||||
|
- __u32 pat;
|
||||||
|
- __u32 emt;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-#define IOMMU_SVA_VTD_GPASID_MTS_MASK (IOMMU_SVA_VTD_GPASID_CD | \
|
||||||
|
- IOMMU_SVA_VTD_GPASID_EMTE | \
|
||||||
|
- IOMMU_SVA_VTD_GPASID_PCD | \
|
||||||
|
- IOMMU_SVA_VTD_GPASID_PWT)
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_gpasid_bind_data - Information about device and guest PASID binding
|
||||||
|
- * @argsz: User filled size of this data
|
||||||
|
- * @version: Version of this data structure
|
||||||
|
- * @format: PASID table entry format
|
||||||
|
- * @flags: Additional information on guest bind request
|
||||||
|
- * @gpgd: Guest page directory base of the guest mm to bind
|
||||||
|
- * @hpasid: Process address space ID used for the guest mm in host IOMMU
|
||||||
|
- * @gpasid: Process address space ID used for the guest mm in guest IOMMU
|
||||||
|
- * @addr_width: Guest virtual address width
|
||||||
|
- * @padding: Reserved for future use (should be zero)
|
||||||
|
- * @vtd: Intel VT-d specific data
|
||||||
|
- *
|
||||||
|
- * Guest to host PASID mapping can be an identity or non-identity, where guest
|
||||||
|
- * has its own PASID space. For non-identify mapping, guest to host PASID lookup
|
||||||
|
- * is needed when VM programs guest PASID into an assigned device. VMM may
|
||||||
|
- * trap such PASID programming then request host IOMMU driver to convert guest
|
||||||
|
- * PASID to host PASID based on this bind data.
|
||||||
|
- */
|
||||||
|
-struct iommu_gpasid_bind_data {
|
||||||
|
- __u32 argsz;
|
||||||
|
-#define IOMMU_GPASID_BIND_VERSION_1 1
|
||||||
|
- __u32 version;
|
||||||
|
-#define IOMMU_PASID_FORMAT_INTEL_VTD 1
|
||||||
|
-#define IOMMU_PASID_FORMAT_LAST 2
|
||||||
|
- __u32 format;
|
||||||
|
- __u32 addr_width;
|
||||||
|
-#define IOMMU_SVA_GPASID_VAL (1 << 0) /* guest PASID valid */
|
||||||
|
- __u64 flags;
|
||||||
|
- __u64 gpgd;
|
||||||
|
- __u64 hpasid;
|
||||||
|
- __u64 gpasid;
|
||||||
|
- __u8 padding[8];
|
||||||
|
- /* Vendor specific data */
|
||||||
|
- union {
|
||||||
|
- struct iommu_gpasid_bind_data_vtd vtd;
|
||||||
|
- } vendor;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_pasid_smmuv3 - ARM SMMUv3 Stream Table Entry stage 1 related
|
||||||
|
- * information
|
||||||
|
- * @version: API version of this structure
|
||||||
|
- * @s1fmt: STE s1fmt (format of the CD table: single CD, linear table
|
||||||
|
- * or 2-level table)
|
||||||
|
- * @s1dss: STE s1dss (specifies the behavior when @pasid_bits != 0
|
||||||
|
- * and no PASID is passed along with the incoming transaction)
|
||||||
|
- * @padding: reserved for future use (should be zero)
|
||||||
|
- *
|
||||||
|
- * The PASID table is referred to as the Context Descriptor (CD) table on ARM
|
||||||
|
- * SMMUv3. Please refer to the ARM SMMU 3.x spec (ARM IHI 0070A) for full
|
||||||
|
- * details.
|
||||||
|
- */
|
||||||
|
-struct iommu_pasid_smmuv3 {
|
||||||
|
-#define PASID_TABLE_SMMUV3_CFG_VERSION_1 1
|
||||||
|
- __u32 version;
|
||||||
|
- __u8 s1fmt;
|
||||||
|
- __u8 s1dss;
|
||||||
|
- __u8 padding[2];
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * struct iommu_pasid_table_config - PASID table data used to bind guest PASID
|
||||||
|
- * table to the host IOMMU
|
||||||
|
- * @argsz: User filled size of this data
|
||||||
|
- * @version: API version to prepare for future extensions
|
||||||
|
- * @base_ptr: guest physical address of the PASID table
|
||||||
|
- * @format: format of the PASID table
|
||||||
|
- * @pasid_bits: number of PASID bits used in the PASID table
|
||||||
|
- * @config: indicates whether the guest translation stage must
|
||||||
|
- * be translated, bypassed or aborted.
|
||||||
|
- * @padding: reserved for future use (should be zero)
|
||||||
|
- * @vendor_data.smmuv3: table information when @format is
|
||||||
|
- * %IOMMU_PASID_FORMAT_SMMUV3
|
||||||
|
- */
|
||||||
|
-struct iommu_pasid_table_config {
|
||||||
|
- __u32 argsz;
|
||||||
|
-#define PASID_TABLE_CFG_VERSION_1 1
|
||||||
|
- __u32 version;
|
||||||
|
- __u64 base_ptr;
|
||||||
|
-#define IOMMU_PASID_FORMAT_SMMUV3 1
|
||||||
|
- __u32 format;
|
||||||
|
- __u8 pasid_bits;
|
||||||
|
-#define IOMMU_PASID_CONFIG_TRANSLATE 1
|
||||||
|
-#define IOMMU_PASID_CONFIG_BYPASS 2
|
||||||
|
-#define IOMMU_PASID_CONFIG_ABORT 3
|
||||||
|
- __u8 config;
|
||||||
|
- __u8 padding[2];
|
||||||
|
- union {
|
||||||
|
- struct iommu_pasid_smmuv3 smmuv3;
|
||||||
|
- } vendor_data;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-#endif /* _UAPI_IOMMU_H */
|
||||||
|
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
|
||||||
|
index cf8e208fac..f4ff038e8c 100644
|
||||||
|
--- a/linux-headers/linux/vfio.h
|
||||||
|
+++ b/linux-headers/linux/vfio.h
|
||||||
|
@@ -14,7 +14,6 @@
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include <linux/ioctl.h>
|
||||||
|
-#include <linux/iommu.h>
|
||||||
|
|
||||||
|
#define VFIO_API_VERSION 0
|
||||||
|
|
||||||
|
@@ -335,7 +334,6 @@ struct vfio_region_info_cap_type {
|
||||||
|
#define VFIO_REGION_TYPE_GFX (1)
|
||||||
|
#define VFIO_REGION_TYPE_CCW (2)
|
||||||
|
#define VFIO_REGION_TYPE_MIGRATION (3)
|
||||||
|
-#define VFIO_REGION_TYPE_NESTED (4)
|
||||||
|
|
||||||
|
/* sub-types for VFIO_REGION_TYPE_PCI_* */
|
||||||
|
|
||||||
|
@@ -364,10 +362,6 @@ struct vfio_region_info_cap_type {
|
||||||
|
/* sub-types for VFIO_REGION_TYPE_GFX */
|
||||||
|
#define VFIO_REGION_SUBTYPE_GFX_EDID (1)
|
||||||
|
|
||||||
|
-/* sub-types for VFIO_REGION_TYPE_NESTED */
|
||||||
|
-#define VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT (1)
|
||||||
|
-#define VFIO_REGION_SUBTYPE_NESTED_DMA_FAULT_RESPONSE (2)
|
||||||
|
-
|
||||||
|
/**
|
||||||
|
* struct vfio_region_gfx_edid - EDID region layout.
|
||||||
|
*
|
||||||
|
@@ -727,30 +721,11 @@ struct vfio_irq_info {
|
||||||
|
#define VFIO_IRQ_INFO_MASKABLE (1 << 1)
|
||||||
|
#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)
|
||||||
|
#define VFIO_IRQ_INFO_NORESIZE (1 << 3)
|
||||||
|
-#define VFIO_IRQ_INFO_FLAG_CAPS (1 << 4) /* Info supports caps */
|
||||||
|
__u32 index; /* IRQ index */
|
||||||
|
__u32 count; /* Number of IRQs within this index */
|
||||||
|
- __u32 cap_offset; /* Offset within info struct of first cap */
|
||||||
|
};
|
||||||
|
#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9)
|
||||||
|
|
||||||
|
-/*
|
||||||
|
- * The irq type capability allows IRQs unique to a specific device or
|
||||||
|
- * class of devices to be exposed.
|
||||||
|
- *
|
||||||
|
- * The structures below define version 1 of this capability.
|
||||||
|
- */
|
||||||
|
-#define VFIO_IRQ_INFO_CAP_TYPE 3
|
||||||
|
-
|
||||||
|
-struct vfio_irq_info_cap_type {
|
||||||
|
- struct vfio_info_cap_header header;
|
||||||
|
- __u32 type; /* global per bus driver */
|
||||||
|
- __u32 subtype; /* type specific */
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-#define VFIO_IRQ_TYPE_NESTED (1)
|
||||||
|
-#define VFIO_IRQ_SUBTYPE_DMA_FAULT (1)
|
||||||
|
-
|
||||||
|
/**
|
||||||
|
* VFIO_DEVICE_SET_IRQS - _IOW(VFIO_TYPE, VFIO_BASE + 10, struct vfio_irq_set)
|
||||||
|
*
|
||||||
|
@@ -852,8 +827,7 @@ enum {
|
||||||
|
VFIO_PCI_MSIX_IRQ_INDEX,
|
||||||
|
VFIO_PCI_ERR_IRQ_INDEX,
|
||||||
|
VFIO_PCI_REQ_IRQ_INDEX,
|
||||||
|
- VFIO_PCI_NUM_IRQS = 5 /* Fixed user ABI, IRQ indexes >=5 use */
|
||||||
|
- /* device specific cap to define content */
|
||||||
|
+ VFIO_PCI_NUM_IRQS
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -1038,68 +1012,6 @@ struct vfio_device_feature {
|
||||||
|
*/
|
||||||
|
#define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
|
||||||
|
|
||||||
|
-/*
|
||||||
|
- * Capability exposed by the DMA fault region
|
||||||
|
- * @version: ABI version
|
||||||
|
- */
|
||||||
|
-#define VFIO_REGION_INFO_CAP_DMA_FAULT 6
|
||||||
|
-
|
||||||
|
-struct vfio_region_info_cap_fault {
|
||||||
|
- struct vfio_info_cap_header header;
|
||||||
|
- __u32 version;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * Capability exposed by the DMA fault response region
|
||||||
|
- * @version: ABI version
|
||||||
|
- */
|
||||||
|
-#define VFIO_REGION_INFO_CAP_DMA_FAULT_RESPONSE 7
|
||||||
|
-
|
||||||
|
-struct vfio_region_info_cap_fault_response {
|
||||||
|
- struct vfio_info_cap_header header;
|
||||||
|
- __u32 version;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * DMA Fault Region Layout
|
||||||
|
- * @tail: index relative to the start of the ring buffer at which the
|
||||||
|
- * consumer finds the next item in the buffer
|
||||||
|
- * @entry_size: fault ring buffer entry size in bytes
|
||||||
|
- * @nb_entries: max capacity of the fault ring buffer
|
||||||
|
- * @offset: ring buffer offset relative to the start of the region
|
||||||
|
- * @head: index relative to the start of the ring buffer at which the
|
||||||
|
- * producer (kernel) inserts items into the buffers
|
||||||
|
- */
|
||||||
|
-struct vfio_region_dma_fault {
|
||||||
|
- /* Write-Only */
|
||||||
|
- __u32 tail;
|
||||||
|
- /* Read-Only */
|
||||||
|
- __u32 entry_size;
|
||||||
|
- __u32 nb_entries;
|
||||||
|
- __u32 offset;
|
||||||
|
- __u32 head;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * DMA Fault Response Region Layout
|
||||||
|
- * @head: index relative to the start of the ring buffer at which the
|
||||||
|
- * producer (userspace) insert responses into the buffer
|
||||||
|
- * @entry_size: fault ring buffer entry size in bytes
|
||||||
|
- * @nb_entries: max capacity of the fault ring buffer
|
||||||
|
- * @offset: ring buffer offset relative to the start of the region
|
||||||
|
- * @tail: index relative to the start of the ring buffer at which the
|
||||||
|
- * consumer (kernel) finds the next item in the buffer
|
||||||
|
- */
|
||||||
|
-struct vfio_region_dma_fault_response {
|
||||||
|
- /* Write-Only */
|
||||||
|
- __u32 head;
|
||||||
|
- /* Read-Only */
|
||||||
|
- __u32 entry_size;
|
||||||
|
- __u32 nb_entries;
|
||||||
|
- __u32 offset;
|
||||||
|
- __u32 tail;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
/* -------- API for Type1 VFIO IOMMU -------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -1212,7 +1124,7 @@ struct vfio_iommu_type1_dma_map {
|
||||||
|
struct vfio_bitmap {
|
||||||
|
__u64 pgsize; /* page size for bitmap in bytes */
|
||||||
|
__u64 size; /* in bytes */
|
||||||
|
- __u64 *data; /* one bit per page */
|
||||||
|
+ __u64 *data; /* one bit per page */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -1338,134 +1250,6 @@ struct vfio_iommu_type1_dirty_bitmap_get {
|
||||||
|
|
||||||
|
#define VFIO_IOMMU_DIRTY_PAGES _IO(VFIO_TYPE, VFIO_BASE + 17)
|
||||||
|
|
||||||
|
-/*
|
||||||
|
- * VFIO_IOMMU_BIND_PROCESS
|
||||||
|
- *
|
||||||
|
- * Allocate a PASID for a process address space, and use it to attach this
|
||||||
|
- * process to all devices in the container. Devices can then tag their DMA
|
||||||
|
- * traffic with the returned @pasid to perform transactions on the associated
|
||||||
|
- * virtual address space. Mapping and unmapping buffers is performed by standard
|
||||||
|
- * functions such as mmap and malloc.
|
||||||
|
- *
|
||||||
|
- * If flag is VFIO_IOMMU_BIND_PID, @pid contains the pid of a foreign process to
|
||||||
|
- * bind. Otherwise the current task is bound. Given that the caller owns the
|
||||||
|
- * device, setting this flag grants the caller read and write permissions on the
|
||||||
|
- * entire address space of foreign process described by @pid. Therefore,
|
||||||
|
- * permission to perform the bind operation on a foreign process is governed by
|
||||||
|
- * the ptrace access mode PTRACE_MODE_ATTACH_REALCREDS check. See man ptrace(2)
|
||||||
|
- * for more information.
|
||||||
|
- *
|
||||||
|
- * On success, VFIO writes a Process Address Space ID (PASID) into @pasid. This
|
||||||
|
- * ID is unique to a process and can be used on all devices in the container.
|
||||||
|
- *
|
||||||
|
- * On fork, the child inherits the device fd and can use the bonds setup by its
|
||||||
|
- * parent. Consequently, the child has R/W access on the address spaces bound by
|
||||||
|
- * its parent. After an execv, the device fd is closed and the child doesn't
|
||||||
|
- * have access to the address space anymore.
|
||||||
|
- *
|
||||||
|
- * To remove a bond between process and container, VFIO_IOMMU_UNBIND ioctl is
|
||||||
|
- * issued with the same parameters. If a pid was specified in VFIO_IOMMU_BIND,
|
||||||
|
- * it should also be present for VFIO_IOMMU_UNBIND. Otherwise unbind the current
|
||||||
|
- * task from the container.
|
||||||
|
- */
|
||||||
|
-struct vfio_iommu_type1_bind_process {
|
||||||
|
- __u32 flags;
|
||||||
|
-#define VFIO_IOMMU_BIND_PID (1 << 0)
|
||||||
|
- __u32 pasid;
|
||||||
|
- __s32 pid;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * Only mode supported at the moment is VFIO_IOMMU_BIND_PROCESS, which takes
|
||||||
|
- * vfio_iommu_type1_bind_process in data.
|
||||||
|
- */
|
||||||
|
-struct vfio_iommu_type1_bind {
|
||||||
|
- __u32 argsz;
|
||||||
|
- __u32 flags;
|
||||||
|
-#define VFIO_IOMMU_BIND_PROCESS (1 << 0)
|
||||||
|
- __u8 data[];
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * VFIO_IOMMU_BIND - _IOWR(VFIO_TYPE, VFIO_BASE + 22, struct vfio_iommu_bind)
|
||||||
|
- *
|
||||||
|
- * Manage address spaces of devices in this container. Initially a TYPE1
|
||||||
|
- * container can only have one address space, managed with
|
||||||
|
- * VFIO_IOMMU_MAP/UNMAP_DMA.
|
||||||
|
- *
|
||||||
|
- * An IOMMU of type VFIO_TYPE1_NESTING_IOMMU can be managed by both MAP/UNMAP
|
||||||
|
- * and BIND ioctls at the same time. MAP/UNMAP acts on the stage-2 (host) page
|
||||||
|
- * tables, and BIND manages the stage-1 (guest) page tables. Other types of
|
||||||
|
- * IOMMU may allow MAP/UNMAP and BIND to coexist, where MAP/UNMAP controls
|
||||||
|
- * non-PASID traffic and BIND controls PASID traffic. But this depends on the
|
||||||
|
- * underlying IOMMU architecture and isn't guaranteed.
|
||||||
|
- *
|
||||||
|
- * Availability of this feature depends on the device, its bus, the underlying
|
||||||
|
- * IOMMU and the CPU architecture.
|
||||||
|
- *
|
||||||
|
- * returns: 0 on success, -errno on failure.
|
||||||
|
- */
|
||||||
|
-#define VFIO_IOMMU_BIND _IO(VFIO_TYPE, VFIO_BASE + 22)
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * VFIO_IOMMU_UNBIND - _IOWR(VFIO_TYPE, VFIO_BASE + 23, struct vfio_iommu_bind)
|
||||||
|
- *
|
||||||
|
- * Undo what was done by the corresponding VFIO_IOMMU_BIND ioctl.
|
||||||
|
- */
|
||||||
|
-#define VFIO_IOMMU_UNBIND _IO(VFIO_TYPE, VFIO_BASE + 23)
|
||||||
|
-
|
||||||
|
-/*
|
||||||
|
- * VFIO_IOMMU_SET_PASID_TABLE - _IOWR(VFIO_TYPE, VFIO_BASE + 18,
|
||||||
|
- * struct vfio_iommu_type1_set_pasid_table)
|
||||||
|
- *
|
||||||
|
- * The SET operation passes a PASID table to the host while the
|
||||||
|
- * UNSET operation detaches the one currently programmed. It is
|
||||||
|
- * allowed to "SET" the table several times without unsetting as
|
||||||
|
- * long as the table config does not stay IOMMU_PASID_CONFIG_TRANSLATE.
|
||||||
|
- */
|
||||||
|
-struct vfio_iommu_type1_set_pasid_table {
|
||||||
|
- __u32 argsz;
|
||||||
|
- __u32 flags;
|
||||||
|
-#define VFIO_PASID_TABLE_FLAG_SET (1 << 0)
|
||||||
|
-#define VFIO_PASID_TABLE_FLAG_UNSET (1 << 1)
|
||||||
|
- struct iommu_pasid_table_config config; /* used on SET */
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-#define VFIO_IOMMU_SET_PASID_TABLE _IO(VFIO_TYPE, VFIO_BASE + 18)
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * VFIO_IOMMU_CACHE_INVALIDATE - _IOWR(VFIO_TYPE, VFIO_BASE + 19,
|
||||||
|
- * struct vfio_iommu_type1_cache_invalidate)
|
||||||
|
- *
|
||||||
|
- * Propagate guest IOMMU cache invalidation to the host.
|
||||||
|
- */
|
||||||
|
-struct vfio_iommu_type1_cache_invalidate {
|
||||||
|
- __u32 argsz;
|
||||||
|
- __u32 flags;
|
||||||
|
- struct iommu_cache_invalidate_info info;
|
||||||
|
-};
|
||||||
|
-#define VFIO_IOMMU_CACHE_INVALIDATE _IO(VFIO_TYPE, VFIO_BASE + 19)
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * VFIO_IOMMU_SET_MSI_BINDING - _IOWR(VFIO_TYPE, VFIO_BASE + 20,
|
||||||
|
- * struct vfio_iommu_type1_set_msi_binding)
|
||||||
|
- *
|
||||||
|
- * Pass a stage 1 MSI doorbell mapping to the host so that this
|
||||||
|
- * latter can build a nested stage2 mapping. Or conversely tear
|
||||||
|
- * down a previously bound stage 1 MSI binding.
|
||||||
|
- */
|
||||||
|
-struct vfio_iommu_type1_set_msi_binding {
|
||||||
|
- __u32 argsz;
|
||||||
|
- __u32 flags;
|
||||||
|
-#define VFIO_IOMMU_BIND_MSI (1 << 0)
|
||||||
|
-#define VFIO_IOMMU_UNBIND_MSI (1 << 1)
|
||||||
|
- __u64 iova; /* MSI guest IOVA */
|
||||||
|
- /* Fields below are used on BIND */
|
||||||
|
- __u64 gpa; /* MSI guest physical address */
|
||||||
|
- __u64 size; /* size of stage1 mapping (bytes) */
|
||||||
|
-};
|
||||||
|
-#define VFIO_IOMMU_SET_MSI_BINDING _IO(VFIO_TYPE, VFIO_BASE + 20)
|
||||||
|
-
|
||||||
|
/* -------- Additional API for SPAPR TCE (Server POWERPC) IOMMU -------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
29
arm-virt-Fix-vcpu-hotplug-idx_from_topo_ids.patch
Normal file
29
arm-virt-Fix-vcpu-hotplug-idx_from_topo_ids.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From add7ed9bb57490e29371a542d47891b7c9210c43 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Keqian Zhu <zhukeqian1@huawei.com>
|
||||||
|
Date: Sun, 6 Nov 2022 06:36:15 +0800
|
||||||
|
Subject: [PATCH 1/3] arm/virt: Fix vcpu hotplug idx_from_topo_ids
|
||||||
|
|
||||||
|
Add missing "nr_threads" when compute cpu index.
|
||||||
|
|
||||||
|
Fixes: 5454c0090823 ("arm/virt: Add CPU topology support")
|
||||||
|
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
||||||
|
---
|
||||||
|
include/hw/arm/topology.h | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/include/hw/arm/topology.h b/include/hw/arm/topology.h
|
||||||
|
index d0dad1a9a3..33e4a0d552 100644
|
||||||
|
--- a/include/hw/arm/topology.h
|
||||||
|
+++ b/include/hw/arm/topology.h
|
||||||
|
@@ -39,7 +39,7 @@ static inline unsigned idx_from_topo_ids(unsigned nr_clusters,
|
||||||
|
assert(topo != NULL);
|
||||||
|
|
||||||
|
return topo->pkg_id * nr_clusters * nr_cores * nr_threads +
|
||||||
|
- topo->cluster_id * nr_cores +
|
||||||
|
+ topo->cluster_id * nr_cores * nr_threads +
|
||||||
|
topo->core_id * nr_threads +
|
||||||
|
topo->smt_id;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
40
configure-Add-.-on-front-of-glob-of-config-devices.m.patch
Normal file
40
configure-Add-.-on-front-of-glob-of-config-devices.m.patch
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
From 05facfc2f1442dc96b862fff97dde7f600a41491 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Thu, 24 Nov 2022 19:33:04 +0800
|
||||||
|
Subject: [PATCH 26/29] configure: Add './' on front of glob of
|
||||||
|
*/config-devices.mak.d
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Shellcheck warns that in
|
||||||
|
rm -f */config-devices.mak.d
|
||||||
|
the glob might expand to something with a '-' in it, which would
|
||||||
|
then be misinterpreted as an option to rm. Fix this by adding './'.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Message-id: 20220825150703.4074125-5-peter.maydell@linaro.org
|
||||||
|
|
||||||
|
Signed-off-by: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
configure | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 8cbf186296..7e81444ade 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -1479,7 +1479,7 @@ exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove old dependency files to make sure that they get properly regenerated
|
||||||
|
-rm -f */config-devices.mak.d
|
||||||
|
+rm -f ./*/config-devices.mak.d
|
||||||
|
|
||||||
|
if test -z "$python"
|
||||||
|
then
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
90
configure-Add-missing-quoting-for-some-easy-cases.patch
Normal file
90
configure-Add-missing-quoting-for-some-easy-cases.patch
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
From 6f1b97c06f116945553846cb0c5c3d949c953890 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Thu, 24 Nov 2022 19:29:07 +0800
|
||||||
|
Subject: [PATCH 19/29] configure: Add missing quoting for some easy cases
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
This commit adds quotes in some places which:
|
||||||
|
* are spotted by shellcheck
|
||||||
|
* are obviously incorrect
|
||||||
|
* are easy to fix just by adding the quotes
|
||||||
|
|
||||||
|
It doesn't attempt fix all of the places shellcheck finds errors,
|
||||||
|
or even all the ones which are easy to fix. It's just a random
|
||||||
|
sampling which is hopefully easy to review and which cuts
|
||||||
|
down the size of the problem for next time somebody wants to
|
||||||
|
try to look at shellcheck errors.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Message-id: 20220825150703.4074125-4-peter.maydell@linaro.org
|
||||||
|
|
||||||
|
Signed-off-by: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
configure | 12 ++++++------
|
||||||
|
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 8cbf186296..737572c8e6 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -57,7 +57,7 @@ GNUmakefile: ;
|
||||||
|
|
||||||
|
EOF
|
||||||
|
cd build
|
||||||
|
- exec $source_path/configure "$@"
|
||||||
|
+ exec "$source_path/configure" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Temporary directory used for files created while
|
||||||
|
@@ -728,7 +728,7 @@ fi
|
||||||
|
|
||||||
|
werror=""
|
||||||
|
|
||||||
|
-. $source_path/scripts/meson-buildoptions.sh
|
||||||
|
+. "$source_path/scripts/meson-buildoptions.sh"
|
||||||
|
|
||||||
|
meson_options=
|
||||||
|
meson_option_parse() {
|
||||||
|
@@ -745,7 +745,7 @@ for opt do
|
||||||
|
case "$opt" in
|
||||||
|
--help|-h) show_help=yes
|
||||||
|
;;
|
||||||
|
- --version|-V) exec cat $source_path/VERSION
|
||||||
|
+ --version|-V) exec cat "$source_path/VERSION"
|
||||||
|
;;
|
||||||
|
--prefix=*) prefix="$optarg"
|
||||||
|
;;
|
||||||
|
@@ -1503,7 +1503,7 @@ python="$python -B"
|
||||||
|
if test -z "$meson"; then
|
||||||
|
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
|
||||||
|
meson=meson
|
||||||
|
- elif test $git_submodules_action != 'ignore' ; then
|
||||||
|
+ elif test "$git_submodules_action" != 'ignore' ; then
|
||||||
|
meson=git
|
||||||
|
elif test -e "${source_path}/meson/meson.py" ; then
|
||||||
|
meson=internal
|
||||||
|
@@ -3352,7 +3352,7 @@ if test "$QEMU_GA_DISTRO" = ""; then
|
||||||
|
QEMU_GA_DISTRO=Linux
|
||||||
|
fi
|
||||||
|
if test "$QEMU_GA_VERSION" = ""; then
|
||||||
|
- QEMU_GA_VERSION=$(cat $source_path/VERSION)
|
||||||
|
+ QEMU_GA_VERSION=$(cat "$source_path"/VERSION)
|
||||||
|
fi
|
||||||
|
|
||||||
|
QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
|
||||||
|
@@ -3790,7 +3790,7 @@ fi
|
||||||
|
for target in $target_list; do
|
||||||
|
target_dir="$target"
|
||||||
|
target_name=$(echo $target | cut -d '-' -f 1)
|
||||||
|
- mkdir -p $target_dir
|
||||||
|
+ mkdir -p "$target_dir"
|
||||||
|
case $target in
|
||||||
|
*-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
|
||||||
|
*) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
39
configure-Check-mkdir-result-directly-not-via.patch
Normal file
39
configure-Check-mkdir-result-directly-not-via.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
From d5ad002a22aade5086722fd9aa2addf2f95e52c3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Thu, 24 Nov 2022 19:39:33 +0800
|
||||||
|
Subject: [PATCH 27/29] configure: Check mkdir result directly, not via $?
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Shellcheck warns that we have one place where we run a command and
|
||||||
|
then check if it failed using $?; this is better written to simply
|
||||||
|
check the command in the 'if' statement directly.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Message-id: 20220825150703.4074125-7-peter.maydell@linaro.org
|
||||||
|
|
||||||
|
Signed-off-by: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
configure | 3 +--
|
||||||
|
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 8cbf186296..561c86c913 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -67,8 +67,7 @@ fi
|
||||||
|
# it when configure exits.)
|
||||||
|
TMPDIR1="config-temp"
|
||||||
|
rm -rf "${TMPDIR1}"
|
||||||
|
-mkdir -p "${TMPDIR1}"
|
||||||
|
-if [ $? -ne 0 ]; then
|
||||||
|
+if ! mkdir -p "${TMPDIR1}"; then
|
||||||
|
echo "ERROR: failed to create temporary directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
37
configure-Remove-unused-meson_args-variable.patch
Normal file
37
configure-Remove-unused-meson_args-variable.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
From 280fca570579e659aa38def7f55151eea4f42712 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Thu, 24 Nov 2022 15:38:49 +0800
|
||||||
|
Subject: [PATCH 17/29] configure: Remove unused meson_args variable
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
The meson_args variable was added in commit 3b4da13293482134b, but
|
||||||
|
was not used in that commit and isn't used today. Delete the
|
||||||
|
unnecessary assignment.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Message-id: 20220825150703.4074125-3-peter.maydell@linaro.org
|
||||||
|
|
||||||
|
Signed-off-by: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
configure | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index e12ef3d842..8cbf186296 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -361,7 +361,6 @@ plugins="$default_feature"
|
||||||
|
rng_none="no"
|
||||||
|
secret_keyring="$default_feature"
|
||||||
|
meson=""
|
||||||
|
-meson_args=""
|
||||||
|
ninja=""
|
||||||
|
gio="$default_feature"
|
||||||
|
skip_meson=no
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
42
configure-Remove-unused-python_version-variable.patch
Normal file
42
configure-Remove-unused-python_version-variable.patch
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
From 6933c65bc3835f69f2c774c7d27c8ebcd05d55d6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Thu, 24 Nov 2022 14:54:20 +0800
|
||||||
|
Subject: [PATCH 16/29] configure: Remove unused python_version variable
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Shellcheck correctly reports that we set python_version and never use
|
||||||
|
it. This is a leftover from commit f9332757898a7: we used to use
|
||||||
|
python_version purely to as part of the summary information printed
|
||||||
|
at the end of a configure run, and that commit changed to printing
|
||||||
|
the information from meson (which looks up the python version
|
||||||
|
itself). Remove the unused variable.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Message-id: 20220825150703.4074125-2-peter.maydell@linaro.org
|
||||||
|
|
||||||
|
Signed-off-by: wangjinlei <wangjinlei_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
configure | 3 ---
|
||||||
|
1 file changed, 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 0ae7bcf065..e12ef3d842 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -1498,9 +1498,6 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
|
||||||
|
"Use --python=/path/to/python to specify a supported Python."
|
||||||
|
fi
|
||||||
|
|
||||||
|
-# Preserve python version since some functionality is dependent on it
|
||||||
|
-python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
|
||||||
|
-
|
||||||
|
# Suppress writing compiled files
|
||||||
|
python="$python -B"
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
76
docs-Add-generic-vhost-vdpa-device-documentation.patch
Normal file
76
docs-Add-generic-vhost-vdpa-device-documentation.patch
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
From 8e62b2af62ea165f6bb7dbd1128ed1542a63eb6b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Longpeng <longpeng2@huawei.com>
|
||||||
|
Date: Sat, 12 Nov 2022 22:40:13 +0800
|
||||||
|
Subject: [PATCH 6/7] docs: Add generic vhost-vdpa device documentation
|
||||||
|
|
||||||
|
Signed-off-by: Longpeng <longpeng2@huawei.com>
|
||||||
|
---
|
||||||
|
docs/system/device-emulation.rst | 1 +
|
||||||
|
.../devices/vhost-vdpa-generic-device.rst | 46 +++++++++++++++++++
|
||||||
|
2 files changed, 47 insertions(+)
|
||||||
|
create mode 100644 docs/system/devices/vhost-vdpa-generic-device.rst
|
||||||
|
|
||||||
|
diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst
|
||||||
|
index 19944f526c..ef299a2fcd 100644
|
||||||
|
--- a/docs/system/device-emulation.rst
|
||||||
|
+++ b/docs/system/device-emulation.rst
|
||||||
|
@@ -89,3 +89,4 @@ Emulated Devices
|
||||||
|
devices/vhost-user.rst
|
||||||
|
devices/virtio-pmem.rst
|
||||||
|
devices/vhost-user-rng.rst
|
||||||
|
+ devices/vhost-vdpa-generic-device.rst
|
||||||
|
diff --git a/docs/system/devices/vhost-vdpa-generic-device.rst b/docs/system/devices/vhost-vdpa-generic-device.rst
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..25fbcac60e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/docs/system/devices/vhost-vdpa-generic-device.rst
|
||||||
|
@@ -0,0 +1,46 @@
|
||||||
|
+
|
||||||
|
+=========================
|
||||||
|
+vhost-vDPA generic device
|
||||||
|
+=========================
|
||||||
|
+
|
||||||
|
+This document explains the usage of the vhost-vDPA generic device.
|
||||||
|
+
|
||||||
|
+Description
|
||||||
|
+-----------
|
||||||
|
+
|
||||||
|
+vDPA(virtio data path acceleration) device is a device that uses a datapath
|
||||||
|
+which complies with the virtio specifications with vendor specific control
|
||||||
|
+path.
|
||||||
|
+
|
||||||
|
+QEMU provides two types of vhost-vDPA devices to enable the vDPA device, one
|
||||||
|
+is type sensitive which means QEMU needs to know the actual device type
|
||||||
|
+(e.g. net, blk, scsi) and another is called "vhost-vDPA generic device" which
|
||||||
|
+is type insensitive
|
||||||
|
+
|
||||||
|
+The vhost-vDPA generic device builds on the vhost-vdpa subsystem and virtio
|
||||||
|
+subsystem. It is quite small, but it can support any type of virtio device.
|
||||||
|
+
|
||||||
|
+Examples
|
||||||
|
+--------
|
||||||
|
+
|
||||||
|
+Prepare the vhost-vDPA backends first:
|
||||||
|
+
|
||||||
|
+::
|
||||||
|
+ host# ls -l /dev/vhost-vdpa-*
|
||||||
|
+ crw------- 1 root root 236, 0 Nov 2 00:49 /dev/vhost-vdpa-0
|
||||||
|
+
|
||||||
|
+Start QEMU with virtio-mmio bus:
|
||||||
|
+
|
||||||
|
+::
|
||||||
|
+ host# qemu-system \
|
||||||
|
+ -M microvm -m 512 -smp 2 -kernel ... -initrd ... \
|
||||||
|
+ -device vhost-vdpa-device,vhostdev=/dev/vhost-vdpa-0 \
|
||||||
|
+ ...
|
||||||
|
+
|
||||||
|
+Start QEMU with virtio-pci bus:
|
||||||
|
+
|
||||||
|
+::
|
||||||
|
+ host# qemu-system \
|
||||||
|
+ -M pc -m 512 -smp 2 \
|
||||||
|
+ -device vhost-vdpa-device-pci,vhostdev=/dev/vhost-vdpa-0 \
|
||||||
|
+ ...\
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
49
gdb-xml-Fix-size-of-EFER-register-on-i386-architectu.patch
Normal file
49
gdb-xml-Fix-size-of-EFER-register-on-i386-architectu.patch
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
From 9fd0035ff518ab3d2d4ee2578176fb562f9eb161 Mon Sep 17 00:00:00 2001
|
||||||
|
From: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 06:05:06 +0000
|
||||||
|
Subject: [PATCH 06/29] gdb-xml: Fix size of EFER register on i386 architecture
|
||||||
|
when debugged by GDB mainline inclusion from mainline-v7.2.0-rc2 commit
|
||||||
|
75ac231c67cdb13f0609943fab5499963858b587 category: bugfix
|
||||||
|
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
Before this commit, there were contradictory descriptions about size of EFER
|
||||||
|
register.
|
||||||
|
Line 113 says the size is 8 bytes.
|
||||||
|
Line 129 says the size is 4 bytes.
|
||||||
|
|
||||||
|
As a result, when GDB is debugging an OS running on QEMU, the GDB cannot
|
||||||
|
read 'g' packets correctly. This 'g' packet transmits values of each
|
||||||
|
registers of machine emulated by QEMU to GDB. QEMU, the packet sender,
|
||||||
|
assign 4 bytes for EFER in 'g' packet based on the line 113.
|
||||||
|
GDB, the packet receiver, extract 8 bytes for EFER in 'g' packet based on
|
||||||
|
the line 129. Therefore, all registers located behind EFER in 'g' packet
|
||||||
|
has been shifted 4 bytes in GDB.
|
||||||
|
|
||||||
|
After this commit, GDB can read 'g' packets correctly.
|
||||||
|
|
||||||
|
Signed-off-by: TaiseiIto <taisei1212@outlook.jp>
|
||||||
|
Message-Id: <TY0PR0101MB4285F637209075C9F65FCDA6A4479@TY0PR0101MB4285.apcprd01.prod.exchangelabs.com>
|
||||||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||||
|
|
||||||
|
Signed-off-by: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
gdb-xml/i386-32bit.xml | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/gdb-xml/i386-32bit.xml b/gdb-xml/i386-32bit.xml
|
||||||
|
index 872fcea9c2..7a66a02b67 100644
|
||||||
|
--- a/gdb-xml/i386-32bit.xml
|
||||||
|
+++ b/gdb-xml/i386-32bit.xml
|
||||||
|
@@ -110,7 +110,7 @@
|
||||||
|
<field name="PKE" start="22" end="22"/>
|
||||||
|
</flags>
|
||||||
|
|
||||||
|
- <flags id="i386_efer" size="8">
|
||||||
|
+ <flags id="i386_efer" size="4">
|
||||||
|
<field name="TCE" start="15" end="15"/>
|
||||||
|
<field name="FFXSR" start="14" end="14"/>
|
||||||
|
<field name="LMSLE" start="13" end="13"/>
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
45
hostmem-default-the-amount-of-prealloc-threads-to-sm.patch
Normal file
45
hostmem-default-the-amount-of-prealloc-threads-to-sm.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From 1a1ea4307536f142aff5ea17b9dc73ffe3a35c79 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jaroslav Jindrak <dzejrou@gmail.com>
|
||||||
|
Date: Tue, 17 May 2022 14:38:58 +0200
|
||||||
|
Subject: [PATCH 3/3] hostmem: default the amount of prealloc-threads to
|
||||||
|
smp-cpus
|
||||||
|
|
||||||
|
Prior to the introduction of the prealloc-threads property, the amount
|
||||||
|
of threads used to preallocate memory was derived from the value of
|
||||||
|
smp-cpus passed to qemu, the amount of physical cpus of the host
|
||||||
|
and a hardcoded maximum value. When the prealloc-threads property
|
||||||
|
was introduced, it included a default of 1 in backends/hostmem.c and
|
||||||
|
a default of smp-cpus using the sugar API for the property itself. The
|
||||||
|
latter default is not used when the property is not specified on qemu's
|
||||||
|
command line, so guests that were not adjusted for this change suddenly
|
||||||
|
started to use the default of 1 thread to preallocate memory, which
|
||||||
|
resulted in observable slowdowns in guest boots for guests with large
|
||||||
|
memory (e.g. when using libvirt <8.2.0 or managing guests manually).
|
||||||
|
|
||||||
|
This commit restores the original behavior for these cases while not
|
||||||
|
impacting guests started with the prealloc-threads property in any way.
|
||||||
|
|
||||||
|
Fixes: 220c1fd864e9d ("hostmem: introduce "prealloc-threads" property")
|
||||||
|
Signed-off-by: Jaroslav Jindrak <dzejrou@gmail.com>
|
||||||
|
Message-Id: <20220517123858.7933-1-dzejrou@gmail.com>
|
||||||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||||
|
---
|
||||||
|
backends/hostmem.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/backends/hostmem.c b/backends/hostmem.c
|
||||||
|
index 4c05862ed5..c9ddaec849 100644
|
||||||
|
--- a/backends/hostmem.c
|
||||||
|
+++ b/backends/hostmem.c
|
||||||
|
@@ -273,7 +273,7 @@ static void host_memory_backend_init(Object *obj)
|
||||||
|
backend->merge = machine_mem_merge(machine);
|
||||||
|
backend->dump = machine_dump_guest_core(machine);
|
||||||
|
backend->reserve = true;
|
||||||
|
- backend->prealloc_threads = 1;
|
||||||
|
+ backend->prealloc_threads = machine->smp.cpus;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void host_memory_backend_post_init(Object *obj)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
62
hw-arm-virt-Fix-devicetree-warnings-about-the-virtio.patch
Normal file
62
hw-arm-virt-Fix-devicetree-warnings-about-the-virtio.patch
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
From 9fdae653dc60c96fad416abb1b5294f767fcb3c5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 08:10:00 +0000
|
||||||
|
Subject: [PATCH 11/29] hw/arm/virt: Fix devicetree warnings about the
|
||||||
|
virtio-iommu node mainline inclusion from mainline-v7.2.0-rc1 commit
|
||||||
|
7cd5d384bb298ce3c595a3774213b5b478881ac8 category: bugfix
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
The "PCI Bus Binding to: IEEE Std 1275-1994" defines the compatible
|
||||||
|
string for a PCIe bus or endpoint as "pci<vendorid>,<deviceid>" or
|
||||||
|
similar. Since the initial binding for PCI virtio-iommu didn't follow
|
||||||
|
this rule, it was modified to accept both strings and ensure backward
|
||||||
|
compatibility. Also, the unit-name for the node should be
|
||||||
|
"device,function".
|
||||||
|
|
||||||
|
Fix corresponding dt-validate and dtc warnings:
|
||||||
|
|
||||||
|
pcie@10000000: virtio_iommu@16:compatible: ['virtio,pci-iommu'] does not contain items matching the given schema
|
||||||
|
pcie@10000000: Unevaluated properties are not allowed (... 'virtio_iommu@16' were unexpected)
|
||||||
|
From schema: linux/Documentation/devicetree/bindings/pci/host-generic-pci.yaml
|
||||||
|
virtio_iommu@16: compatible: 'oneOf' conditional failed, one must be fixed:
|
||||||
|
['virtio,pci-iommu'] is too short
|
||||||
|
'pci1af4,1057' was expected
|
||||||
|
From schema: dtschema/schemas/pci/pci-bus.yaml
|
||||||
|
|
||||||
|
Warning (pci_device_reg): /pcie@10000000/virtio_iommu@16: PCI unit address format error, expected "2,0"
|
||||||
|
|
||||||
|
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
|
||||||
|
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
|
||||||
|
Signed-off-by: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/arm/virt.c | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
|
||||||
|
index b81d22d68f..4716f9baaa 100644
|
||||||
|
--- a/hw/arm/virt.c
|
||||||
|
+++ b/hw/arm/virt.c
|
||||||
|
@@ -1470,14 +1470,15 @@ static void create_smmu(const VirtMachineState *vms,
|
||||||
|
|
||||||
|
static void create_virtio_iommu_dt_bindings(VirtMachineState *vms)
|
||||||
|
{
|
||||||
|
- const char compat[] = "virtio,pci-iommu";
|
||||||
|
+ const char compat[] = "virtio,pci-iommu\0pci1af4,1057";
|
||||||
|
uint16_t bdf = vms->virtio_iommu_bdf;
|
||||||
|
MachineState *ms = MACHINE(vms);
|
||||||
|
char *node;
|
||||||
|
|
||||||
|
vms->iommu_phandle = qemu_fdt_alloc_phandle(ms->fdt);
|
||||||
|
|
||||||
|
- node = g_strdup_printf("%s/virtio_iommu@%d", vms->pciehb_nodename, bdf);
|
||||||
|
+ node = g_strdup_printf("%s/virtio_iommu@%x,%x", vms->pciehb_nodename,
|
||||||
|
+ PCI_SLOT(bdf), PCI_FUNC(bdf));
|
||||||
|
qemu_fdt_add_subnode(ms->fdt, node);
|
||||||
|
qemu_fdt_setprop(ms->fdt, node, "compatible", compat, sizeof(compat));
|
||||||
|
qemu_fdt_setprop_sized_cells(ms->fdt, node, "reg",
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
39
hw-char-pl011-fix-baud-rate-calculation.patch
Normal file
39
hw-char-pl011-fix-baud-rate-calculation.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
From 07639839666f134834b060a63d6b172812092366 Mon Sep 17 00:00:00 2001
|
||||||
|
From: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
Date: Mon, 28 Nov 2022 02:50:07 +0000
|
||||||
|
Subject: [PATCH 28/29] hw/char/pl011: fix baud rate calculation mainline
|
||||||
|
inclusion from mainline-v7.2.0-rc2 commit
|
||||||
|
31cb769c317e0623cbe2a3e8da437b6cd7ddef9b category: bugfix
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
The PL011 TRM says that "UARTIBRD = 0 is invalid and UARTFBRD is ignored
|
||||||
|
when this is the case". But the code looks at FBRD for the invalid case.
|
||||||
|
Fix this.
|
||||||
|
|
||||||
|
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
|
||||||
|
Message-id: 1408f62a2e45665816527d4845ffde650957d5ab.1665051588.git.baruchs-c@neureality.ai
|
||||||
|
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
|
||||||
|
Signed-off-by: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/char/pl011.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
|
||||||
|
index 8ca2a4ed68..b24ccfeac7 100644
|
||||||
|
--- a/hw/char/pl011.c
|
||||||
|
+++ b/hw/char/pl011.c
|
||||||
|
@@ -176,7 +176,7 @@ static unsigned int pl011_get_baudrate(const PL011State *s)
|
||||||
|
{
|
||||||
|
uint64_t clk;
|
||||||
|
|
||||||
|
- if (s->fbrd == 0) {
|
||||||
|
+ if (s->ibrd == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
82
hw-core-resettable-fix-reset-level-counting.patch
Normal file
82
hw-core-resettable-fix-reset-level-counting.patch
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
From a6943e9033df97862b3ec0438ec85ff0abfb59c0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Fri, 25 Nov 2022 09:44:11 +0800
|
||||||
|
Subject: [PATCH 20/29] hw/core/resettable: fix reset level counting
|
||||||
|
|
||||||
|
The code for handling the reset level count in the Resettable code
|
||||||
|
has two issues:
|
||||||
|
The reset count is only decremented for the 1->0 case. This means
|
||||||
|
that if there's ever a nested reset that takes the count to 2 then it
|
||||||
|
will never again be decremented. Eventually the count will exceed
|
||||||
|
the '50' limit in resettable_phase_enter() and QEMU will trip over
|
||||||
|
the assertion failure. The repro case in issue 1266 is an example of
|
||||||
|
this that happens now the SCSI subsystem uses three-phase reset.
|
||||||
|
Secondly, the count is decremented only after the exit phase handler
|
||||||
|
is called. Moving the reset count decrement from "just after" to
|
||||||
|
"just before" calling the exit phase handler allows
|
||||||
|
resettable_is_in_reset() to return false during the handler
|
||||||
|
execution.
|
||||||
|
This simplifies reset handling in resettable devices. Typically, a
|
||||||
|
function that updates the device state will just need to read the
|
||||||
|
current reset state and not anymore treat the "in a reset-exit
|
||||||
|
transition" as a special case.
|
||||||
|
Note that the semantics change to the *_is_in_reset() functions
|
||||||
|
will have no effect on the current codebase, because only two
|
||||||
|
devices (hw/char/cadence_uart.c and hw/misc/zynq_sclr.c) currently
|
||||||
|
call those functions, and in neither case do they do it from the
|
||||||
|
device's exit phase methed.
|
||||||
|
|
||||||
|
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1266
|
||||||
|
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
|
||||||
|
Buglink: https://bugs.launchpad.net/qemu/+bug/1905297
|
||||||
|
Reported-by: Michael Peter <michael.peter@hensoldt-cyber.com>
|
||||||
|
[PMM: adjust the docs paragraph changed to get the name of the
|
||||||
|
'enter' phase right and to clarify exactly when the count is
|
||||||
|
adjusted; rewrite the commit message]
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
docs/devel/reset.rst | 8 +++++---
|
||||||
|
hw/core/resettable.c | 3 +--
|
||||||
|
2 files changed, 6 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
|
||||||
|
index abea1102dc..7cc6a6b314 100644
|
||||||
|
--- a/docs/devel/reset.rst
|
||||||
|
+++ b/docs/devel/reset.rst
|
||||||
|
@@ -210,9 +210,11 @@ Polling the reset state
|
||||||
|
Resettable interface provides the ``resettable_is_in_reset()`` function.
|
||||||
|
This function returns true if the object parameter is currently under reset.
|
||||||
|
|
||||||
|
-An object is under reset from the beginning of the *init* phase to the end of
|
||||||
|
-the *exit* phase. During all three phases, the function will return that the
|
||||||
|
-object is in reset.
|
||||||
|
+An object is under reset from the beginning of the *enter* phase (before
|
||||||
|
+either its children or its own enter method is called) to the *exit*
|
||||||
|
+phase. During *enter* and *hold* phase only, the function will return that the
|
||||||
|
+object is in reset. The state is changed after the *exit* is propagated to
|
||||||
|
+its children and just before calling the object's own *exit* method.
|
||||||
|
|
||||||
|
This function may be used if the object behavior has to be adapted
|
||||||
|
while in reset state. For example if a device has an irq input,
|
||||||
|
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
|
||||||
|
index 96a99ce39e..c3df75c6ba 100644
|
||||||
|
--- a/hw/core/resettable.c
|
||||||
|
+++ b/hw/core/resettable.c
|
||||||
|
@@ -201,12 +201,11 @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
|
||||||
|
resettable_child_foreach(rc, obj, resettable_phase_exit, NULL, type);
|
||||||
|
|
||||||
|
assert(s->count > 0);
|
||||||
|
- if (s->count == 1) {
|
||||||
|
+ if (--s->count == 0) {
|
||||||
|
trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
|
||||||
|
if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
|
||||||
|
rc->phases.exit(obj);
|
||||||
|
}
|
||||||
|
- s->count = 0;
|
||||||
|
}
|
||||||
|
s->exit_phase_in_progress = false;
|
||||||
|
trace_resettable_phase_exit_end(obj, obj_typename, s->count);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
36
hw-hyperv-hyperv.c-Use-device_cold_reset-instead-of-.patch
Normal file
36
hw-hyperv-hyperv.c-Use-device_cold_reset-instead-of-.patch
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
From 9ba48faf402e5964e1ab74decd8eddbc496082c9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Fri, 25 Nov 2022 11:05:17 +0800
|
||||||
|
Subject: [PATCH 25/29] hw/hyperv/hyperv.c: Use device_cold_reset() instead of
|
||||||
|
device_legacy_reset()
|
||||||
|
|
||||||
|
The semantic difference between the deprecated device_legacy_reset()
|
||||||
|
function and the newer device_cold_reset() function is that the new
|
||||||
|
function resets both the device itself and any qbuses it owns,
|
||||||
|
whereas the legacy function resets just the device itself and nothing
|
||||||
|
else. In hyperv_synic_reset() we reset a SynICState, which has no
|
||||||
|
qbuses, so for this purpose the two functions behave identically and
|
||||||
|
we can stop using the deprecated one.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/hyperv/hyperv.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
|
||||||
|
index cb1074f234..220481a1ca 100644
|
||||||
|
--- a/hw/hyperv/hyperv.c
|
||||||
|
+++ b/hw/hyperv/hyperv.c
|
||||||
|
@@ -150,7 +150,7 @@ void hyperv_synic_reset(CPUState *cs)
|
||||||
|
SynICState *synic = get_synic(cs);
|
||||||
|
|
||||||
|
if (synic) {
|
||||||
|
- device_legacy_reset(DEVICE(synic));
|
||||||
|
+ device_cold_reset(DEVICE(synic));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
51
hw-i386-Use-device_cold_reset-to-reset-the-APIC.patch
Normal file
51
hw-i386-Use-device_cold_reset-to-reset-the-APIC.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From b65da0b1f73a47754a5056b89948d06d9eeaf596 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Fri, 25 Nov 2022 11:00:24 +0800
|
||||||
|
Subject: [PATCH 24/29] hw/i386: Use device_cold_reset() to reset the APIC
|
||||||
|
|
||||||
|
The semantic difference between the deprecated device_legacy_reset()
|
||||||
|
function and the newer device_cold_reset() function is that the new
|
||||||
|
function resets both the device itself and any qbuses it owns,
|
||||||
|
whereas the legacy function resets just the device itself and nothing
|
||||||
|
else.
|
||||||
|
The pc_machine_reset() and microvm_machine_reset() functions use
|
||||||
|
device_legacy_reset() to reset the APIC; this is an APICCommonState
|
||||||
|
and does not have any qbuses, so for this purpose the two functions
|
||||||
|
behave identically and we can stop using the deprecated one.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/i386/microvm.c | 2 +-
|
||||||
|
hw/i386/pc.c | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
|
||||||
|
index 4b3b1dd262..3ee95f9b4d 100644
|
||||||
|
--- a/hw/i386/microvm.c
|
||||||
|
+++ b/hw/i386/microvm.c
|
||||||
|
@@ -486,7 +486,7 @@ static void microvm_machine_reset(MachineState *machine)
|
||||||
|
cpu = X86_CPU(cs);
|
||||||
|
|
||||||
|
if (cpu->apic_state) {
|
||||||
|
- device_legacy_reset(cpu->apic_state);
|
||||||
|
+ device_cold_reset(cpu->apic_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
|
||||||
|
index a2ef40ecbc..4870ce0f96 100644
|
||||||
|
--- a/hw/i386/pc.c
|
||||||
|
+++ b/hw/i386/pc.c
|
||||||
|
@@ -1642,7 +1642,7 @@ static void pc_machine_reset(MachineState *machine)
|
||||||
|
cpu = X86_CPU(cs);
|
||||||
|
|
||||||
|
if (cpu->apic_state) {
|
||||||
|
- device_legacy_reset(cpu->apic_state);
|
||||||
|
+ device_cold_reset(cpu->apic_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
77
hw-ide-microdrive-Use-device_cold_reset-for-self-res.patch
Normal file
77
hw-ide-microdrive-Use-device_cold_reset-for-self-res.patch
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
From a9269ae78f478e70ba58df388b8110c7e9c81035 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Fri, 25 Nov 2022 10:53:29 +0800
|
||||||
|
Subject: [PATCH 23/29] hw/ide/microdrive: Use device_cold_reset() for
|
||||||
|
self-resets
|
||||||
|
|
||||||
|
Currently the microdrive code uses device_legacy_reset() to reset
|
||||||
|
itself, and has its reset method call reset on the IDE bus as the
|
||||||
|
last thing it does. Switch to using device_cold_reset().
|
||||||
|
The only concrete microdrive device is the TYPE_DSCM1XXXX; it is not
|
||||||
|
command-line pluggable, so it is used only by the old pxa2xx Arm
|
||||||
|
boards 'akita', 'borzoi', 'spitz', 'terrier' and 'tosa'.
|
||||||
|
You might think that this would result in the IDE bus being
|
||||||
|
reset automatically, but it does not, because the IDEBus type
|
||||||
|
does not set the BusClass::reset method. Instead the controller
|
||||||
|
must explicitly call ide_bus_reset(). We therefore leave that
|
||||||
|
call in md_reset().
|
||||||
|
Note also that because the PCMCIA card device is a direct subclass of
|
||||||
|
TYPE_DEVICE and we don't model the PCMCIA controller-to-card
|
||||||
|
interface as a qbus, PCMCIA cards are not on any qbus and so they
|
||||||
|
don't get reset when the system is reset. The reset only happens via
|
||||||
|
the dscm1xxxx_attach() and dscm1xxxx_detach() functions during
|
||||||
|
machine creation.
|
||||||
|
Because our aim here is merely to try to get rid of calls to the
|
||||||
|
device_legacy_reset() function, we leave these other dubious
|
||||||
|
reset-related issues alone. (They all stem from this code being
|
||||||
|
absolutely ancient.)
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/ide/microdrive.c | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
|
||||||
|
index 6df9b4cbbe..56c5be3655 100644
|
||||||
|
--- a/hw/ide/microdrive.c
|
||||||
|
+++ b/hw/ide/microdrive.c
|
||||||
|
@@ -175,7 +175,7 @@ static void md_attr_write(PCMCIACardState *card, uint32_t at, uint8_t value)
|
||||||
|
case 0x00: /* Configuration Option Register */
|
||||||
|
s->opt = value & 0xcf;
|
||||||
|
if (value & OPT_SRESET) {
|
||||||
|
- device_legacy_reset(DEVICE(s));
|
||||||
|
+ device_cold_reset(DEVICE(s));
|
||||||
|
}
|
||||||
|
md_interrupt_update(s);
|
||||||
|
break;
|
||||||
|
@@ -318,7 +318,7 @@ static void md_common_write(PCMCIACardState *card, uint32_t at, uint16_t value)
|
||||||
|
case 0xe: /* Device Control */
|
||||||
|
s->ctrl = value;
|
||||||
|
if (value & CTRL_SRST) {
|
||||||
|
- device_legacy_reset(DEVICE(s));
|
||||||
|
+ device_cold_reset(DEVICE(s));
|
||||||
|
}
|
||||||
|
md_interrupt_update(s);
|
||||||
|
break;
|
||||||
|
@@ -543,7 +543,7 @@ static int dscm1xxxx_attach(PCMCIACardState *card)
|
||||||
|
md->attr_base = pcc->cis[0x74] | (pcc->cis[0x76] << 8);
|
||||||
|
md->io_base = 0x0;
|
||||||
|
|
||||||
|
- device_legacy_reset(DEVICE(md));
|
||||||
|
+ device_cold_reset(DEVICE(md));
|
||||||
|
md_interrupt_update(md);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
@@ -553,7 +553,7 @@ static int dscm1xxxx_detach(PCMCIACardState *card)
|
||||||
|
{
|
||||||
|
MicroDriveState *md = MICRODRIVE(card);
|
||||||
|
|
||||||
|
- device_legacy_reset(DEVICE(md));
|
||||||
|
+ device_cold_reset(DEVICE(md));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
41
hw-mem-nvdimm-fix-error-message-for-unarmed-flag.patch
Normal file
41
hw-mem-nvdimm-fix-error-message-for-unarmed-flag.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From b1201fb95d14f5564d4df28ab53d16676d335934 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 10:57:07 +0800
|
||||||
|
Subject: [PATCH 05/29] hw/mem/nvdimm: fix error message for 'unarmed' flag
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
In the ACPI specification [1], the 'unarmed' bit is set when a device
|
||||||
|
cannot accept a persistent write. This means that when a memdev is
|
||||||
|
read-only, the 'unarmed' flag must be turned on. The logic is correct,
|
||||||
|
just changing the error message.
|
||||||
|
[1] ACPI NFIT NVDIMM Region Mapping Structure "NVDIMM State Flags" Bit 3
|
||||||
|
|
||||||
|
Fixes: dbd730e859 ("nvdimm: check -object memory-backend-file, readonly=on option")
|
||||||
|
Signed-off-by: Julia Suvorova <jusual@redhat.com>
|
||||||
|
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||||
|
Acked-by: David Hildenbrand <david@redhat.com>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/mem/nvdimm.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
|
||||||
|
index 7397b67156..8df1d7e088 100644
|
||||||
|
--- a/hw/mem/nvdimm.c
|
||||||
|
+++ b/hw/mem/nvdimm.c
|
||||||
|
@@ -149,7 +149,7 @@ static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **errp)
|
||||||
|
if (!nvdimm->unarmed && memory_region_is_rom(mr)) {
|
||||||
|
HostMemoryBackend *hostmem = dimm->hostmem;
|
||||||
|
|
||||||
|
- error_setg(errp, "'unarmed' property must be off since memdev %s "
|
||||||
|
+ error_setg(errp, "'unarmed' property must be 'on' since memdev %s "
|
||||||
|
"is read-only",
|
||||||
|
object_get_canonical_path_component(OBJECT(hostmem)));
|
||||||
|
return;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
34
hw-ppc-spapr_pci.c-Use-device_cold_reset-rather-than.patch
Normal file
34
hw-ppc-spapr_pci.c-Use-device_cold_reset-rather-than.patch
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
From 77c0eacba702ad1799b71b00315313e1f9de2e1a Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Fri, 25 Nov 2022 10:44:28 +0800
|
||||||
|
Subject: [PATCH 22/29] hw/ppc/spapr_pci.c: Use device_cold_reset() rather than
|
||||||
|
device_legacy_reset()
|
||||||
|
|
||||||
|
In spapr_phb_children_reset() we call device_legacy_reset() to reset any
|
||||||
|
QOM children of the SPAPR PCI host bridge device. This will not reset
|
||||||
|
any qbus such a child might own. Switch to device_cold_reset(), which will
|
||||||
|
reset both the device and its buses. (If the child has no qbuses then
|
||||||
|
there will be no change in behaviour.)
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/ppc/spapr_pci.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
|
||||||
|
index 5bfd4aa9e5..d3367e8578 100644
|
||||||
|
--- a/hw/ppc/spapr_pci.c
|
||||||
|
+++ b/hw/ppc/spapr_pci.c
|
||||||
|
@@ -2044,7 +2044,7 @@ static int spapr_phb_children_reset(Object *child, void *opaque)
|
||||||
|
DeviceState *dev = (DeviceState *) object_dynamic_cast(child, TYPE_DEVICE);
|
||||||
|
|
||||||
|
if (dev) {
|
||||||
|
- device_legacy_reset(dev);
|
||||||
|
+ device_cold_reset(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
52
hw-usb-hcd-xhci-Reset-the-XHCIState-with-device_cold.patch
Normal file
52
hw-usb-hcd-xhci-Reset-the-XHCIState-with-device_cold.patch
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
From 5f738b6b95efbdd8d9398b45e038287c5dd3c413 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Fri, 25 Nov 2022 10:00:58 +0800
|
||||||
|
Subject: [PATCH 21/29] hw/usb/hcd-xhci: Reset the XHCIState with
|
||||||
|
device_cold_reset()
|
||||||
|
|
||||||
|
Currently the hcd-xhci-pci and hcd-xhci-sysbus devices, which are
|
||||||
|
mostly wrappers around the TYPE_XHCI device, which is a direct
|
||||||
|
subclass of TYPE_DEVICE. Since TYPE_DEVICE devices are not on any
|
||||||
|
qbus and do not get automatically reset, the wrapper devices both
|
||||||
|
reset the TYPE_XHCI device in their own reset functions. However,
|
||||||
|
they do this using device_legacy_reset(), which will reset the device
|
||||||
|
itself but not any bus it has.
|
||||||
|
Switch to device_cold_reset(), which avoids using a deprecated
|
||||||
|
function and also propagates reset along any child buses.
|
||||||
|
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/usb/hcd-xhci-pci.c | 2 +-
|
||||||
|
hw/usb/hcd-xhci-sysbus.c | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
|
||||||
|
index e934b1a5b1..643d4643e4 100644
|
||||||
|
--- a/hw/usb/hcd-xhci-pci.c
|
||||||
|
+++ b/hw/usb/hcd-xhci-pci.c
|
||||||
|
@@ -85,7 +85,7 @@ static void xhci_pci_reset(DeviceState *dev)
|
||||||
|
{
|
||||||
|
XHCIPciState *s = XHCI_PCI(dev);
|
||||||
|
|
||||||
|
- device_legacy_reset(DEVICE(&s->xhci));
|
||||||
|
+ device_cold_reset(DEVICE(&s->xhci));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int xhci_pci_vmstate_post_load(void *opaque, int version_id)
|
||||||
|
diff --git a/hw/usb/hcd-xhci-sysbus.c b/hw/usb/hcd-xhci-sysbus.c
|
||||||
|
index a14e438196..faf57b4797 100644
|
||||||
|
--- a/hw/usb/hcd-xhci-sysbus.c
|
||||||
|
+++ b/hw/usb/hcd-xhci-sysbus.c
|
||||||
|
@@ -29,7 +29,7 @@ void xhci_sysbus_reset(DeviceState *dev)
|
||||||
|
{
|
||||||
|
XHCISysbusState *s = XHCI_SYSBUS(dev);
|
||||||
|
|
||||||
|
- device_legacy_reset(DEVICE(&s->xhci));
|
||||||
|
+ device_cold_reset(DEVICE(&s->xhci));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xhci_sysbus_realize(DeviceState *dev, Error **errp)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
31
linux-headers-Update-headers-to-Linux-5.18-rc6.patch
Normal file
31
linux-headers-Update-headers-to-Linux-5.18-rc6.patch
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
From f639ed71c4baa5e40281ff9baa3ef312f37cf985 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Longpeng <longpeng2@huawei.com>
|
||||||
|
Date: Sat, 14 May 2022 12:11:04 +0800
|
||||||
|
Subject: [PATCH 1/7] linux-headers: Update headers to Linux 5.18-rc6
|
||||||
|
|
||||||
|
Update headers to 5.18-rc6. I need latest vhost changes.
|
||||||
|
|
||||||
|
Signed-off-by: Longpeng <longpeng2@huawei.com>
|
||||||
|
---
|
||||||
|
linux-headers/linux/vhost.h | 7 +++++++
|
||||||
|
1 file changed, 7 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
|
||||||
|
index c998860d7b..5d99e7c242 100644
|
||||||
|
--- a/linux-headers/linux/vhost.h
|
||||||
|
+++ b/linux-headers/linux/vhost.h
|
||||||
|
@@ -150,4 +150,11 @@
|
||||||
|
/* Get the valid iova range */
|
||||||
|
#define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \
|
||||||
|
struct vhost_vdpa_iova_range)
|
||||||
|
+
|
||||||
|
+/* Get the config size */
|
||||||
|
+#define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32)
|
||||||
|
+
|
||||||
|
+/* Get the count of all virtqueues */
|
||||||
|
+#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32)
|
||||||
|
+
|
||||||
|
#endif
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
36
linux-user-always-translate-cmsg-when-recvmsg.patch
Normal file
36
linux-user-always-translate-cmsg-when-recvmsg.patch
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
From eb2a5f2f73e4cfaf20246fb3d3fb1b8bd5716606 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Tue, 22 Nov 2022 17:10:35 +0800
|
||||||
|
Subject: [PATCH 03/29] linux-user: always translate cmsg when recvmsg
|
||||||
|
|
||||||
|
It's possible that a message contains both normal payload and ancillary
|
||||||
|
data in the same message, and even if no ancillary data is available
|
||||||
|
this information should be passed to the target, otherwise the target
|
||||||
|
cmsghdr will be left uninitialized and the target is going to access
|
||||||
|
uninitialized memory if it expects cmsg.
|
||||||
|
Always call the function that translate cmsg when recvmsg, because that
|
||||||
|
function should be empty-cmsg-safe(it creates an empty cmsg in the target).
|
||||||
|
|
||||||
|
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
linux-user/syscall.c | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
|
||||||
|
index f1cfcc8104..fce2c03259 100644
|
||||||
|
--- a/linux-user/syscall.c
|
||||||
|
+++ b/linux-user/syscall.c
|
||||||
|
@@ -3296,7 +3296,8 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
|
||||||
|
if (fd_trans_host_to_target_data(fd)) {
|
||||||
|
ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base,
|
||||||
|
MIN(msg.msg_iov->iov_len, len));
|
||||||
|
- } else {
|
||||||
|
+ }
|
||||||
|
+ if (!is_error(ret)) {
|
||||||
|
ret = host_to_target_cmsg(msgp, &msg);
|
||||||
|
}
|
||||||
|
if (!is_error(ret)) {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
62
memory-Fix-wrong-end-address-dump.patch
Normal file
62
memory-Fix-wrong-end-address-dump.patch
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
From de10e9df6bcb2d56dcfd2017e66593e6e62dbb22 Mon Sep 17 00:00:00 2001
|
||||||
|
From: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
Date: Tue, 22 Nov 2022 09:56:55 +0000
|
||||||
|
Subject: [PATCH 01/29] memory: Fix wrong end address dump mainline inclusion
|
||||||
|
from mainline-v7.2.0-rc1 commit f9c307c3f9dfda64355fd2c6d73b002913d6752c
|
||||||
|
category: bugfix
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
The end address of memory region section isn't correctly calculated
|
||||||
|
which leads to overflowed mtree dump:
|
||||||
|
|
||||||
|
Dispatch
|
||||||
|
Physical sections
|
||||||
|
......
|
||||||
|
#70 @0000000000002000..0000000000011fff io [ROOT]
|
||||||
|
#71 @0000000000005000..0000000000005fff (noname)
|
||||||
|
#72 @0000000000005000..0000000000014fff io [ROOT]
|
||||||
|
#73 @0000000000005658..0000000000005658 vmport
|
||||||
|
#74 @0000000000005659..0000000000015658 io [ROOT]
|
||||||
|
#75 @0000000000006000..0000000000015fff io [ROOT]
|
||||||
|
|
||||||
|
After fix:
|
||||||
|
#70 @0000000000002000..0000000000004fff io [ROOT]
|
||||||
|
#71 @0000000000005000..0000000000005fff (noname)
|
||||||
|
#72 @0000000000005000..0000000000005657 io [ROOT]
|
||||||
|
#73 @0000000000005658..0000000000005658 vmport
|
||||||
|
#74 @0000000000005659..0000000000005fff io [ROOT]
|
||||||
|
#75 @0000000000006000..000000000000ffff io [ROOT]
|
||||||
|
|
||||||
|
Fixes: 5e8fd94 ("memory: Rework "info mtree" to print flat views and dispatch trees")
|
||||||
|
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||||||
|
Reviewed-by: David Hildenbrand <david@redhat.com>
|
||||||
|
Reviewed-by: Peter Xu <peterx@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||||
|
Message-Id: <20220622095912.3430583-1-zhenzhong.duan@intel.com>
|
||||||
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||||
|
|
||||||
|
Signed-off-by: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
softmmu/physmem.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
|
||||||
|
index 0e709ae384..e5c3557d54 100644
|
||||||
|
--- a/softmmu/physmem.c
|
||||||
|
+++ b/softmmu/physmem.c
|
||||||
|
@@ -3719,7 +3719,7 @@ void mtree_print_dispatch(AddressSpaceDispatch *d, MemoryRegion *root)
|
||||||
|
" %s%s%s%s%s",
|
||||||
|
i,
|
||||||
|
s->offset_within_address_space,
|
||||||
|
- s->offset_within_address_space + MR_SIZE(s->mr->size),
|
||||||
|
+ s->offset_within_address_space + MR_SIZE(s->size),
|
||||||
|
s->mr->name ? s->mr->name : "(noname)",
|
||||||
|
i < ARRAY_SIZE(names) ? names[i] : "",
|
||||||
|
s->mr == root ? " [ROOT]" : "",
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
40
qemu-binfmt-conf.sh-fix-F-option.patch
Normal file
40
qemu-binfmt-conf.sh-fix-F-option.patch
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
From f87df2b0761b55b24a9317f7694e2225a29c981d Mon Sep 17 00:00:00 2001
|
||||||
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 06:33:44 +0000
|
||||||
|
Subject: [PATCH 09/29] qemu-binfmt-conf.sh: fix -F option mainline inclusion
|
||||||
|
commit 719fab3afad22f34f0c812a8956adc88ab3242ce category: bugfix
|
||||||
|
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
qemu-binfmt-conf.sh should use "-F" as short option for "--qemu-suffix".
|
||||||
|
Fix the getopt call to make this work.
|
||||||
|
|
||||||
|
Fixes: 7155be7cda5c ("qemu-binfmt-conf.sh: allow to provide a suffix to the interpreter name")
|
||||||
|
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
||||||
|
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
|
||||||
|
Message-Id: <20211129135100.3934-1-mwilck@suse.com>
|
||||||
|
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
|
||||||
|
|
||||||
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
scripts/qemu-binfmt-conf.sh | 4 +++-
|
||||||
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
|
||||||
|
index 7de996d536..e9bfeb94d3 100755
|
||||||
|
--- a/scripts/qemu-binfmt-conf.sh
|
||||||
|
+++ b/scripts/qemu-binfmt-conf.sh
|
||||||
|
@@ -340,7 +340,9 @@ PERSISTENT=no
|
||||||
|
PRESERVE_ARG0=no
|
||||||
|
QEMU_SUFFIX=""
|
||||||
|
|
||||||
|
-options=$(getopt -o ds:Q:S:e:hc:p:g: -l debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,persistent:,preserve-argv0: -- "$@")
|
||||||
|
+_longopts="debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,\
|
||||||
|
+persistent:,preserve-argv0:"
|
||||||
|
+options=$(getopt -o ds:Q:S:e:hc:p:g:F: -l ${_longopts} -- "$@")
|
||||||
|
eval set -- "$options"
|
||||||
|
|
||||||
|
while true ; do
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
85
qemu.spec
85
qemu.spec
@ -1,6 +1,6 @@
|
|||||||
Name: qemu
|
Name: qemu
|
||||||
Version: 6.2.0
|
Version: 6.2.0
|
||||||
Release: 58
|
Release: 59
|
||||||
Epoch: 10
|
Epoch: 10
|
||||||
Summary: QEMU is a generic and open source machine emulator and virtualizer
|
Summary: QEMU is a generic and open source machine emulator and virtualizer
|
||||||
License: GPLv2 and BSD and MIT and CC-BY-SA-4.0
|
License: GPLv2 and BSD and MIT and CC-BY-SA-4.0
|
||||||
@ -32,7 +32,7 @@ Patch0018: migration-Add-compress_level-sanity-check.patch
|
|||||||
Patch0019: doc-Update-multi-thread-compression-doc.patch
|
Patch0019: doc-Update-multi-thread-compression-doc.patch
|
||||||
Patch0020: Revert-cpu-parse-feature-to-avoid-failure.patch
|
Patch0020: Revert-cpu-parse-feature-to-avoid-failure.patch
|
||||||
Patch0021: Revert-cpu-add-Cortex-A72-processor-kvm-target-suppo.patch
|
Patch0021: Revert-cpu-add-Cortex-A72-processor-kvm-target-suppo.patch
|
||||||
Patch0022: 0003-cpu-add-Cortex-A72-processor-kvm-target-support.patch
|
Patch0022: cpu-add-Cortex-A72-processor-kvm-target-support-v2.patch
|
||||||
Patch0023: hugepages-hugepages-files-maybe-leftover.patch
|
Patch0023: hugepages-hugepages-files-maybe-leftover.patch
|
||||||
Patch0024: target-i386-Modify-the-VM-s-physical-bits-value-set-.patch
|
Patch0024: target-i386-Modify-the-VM-s-physical-bits-value-set-.patch
|
||||||
Patch0025: vfio-pci-Ascend310-need-4Bytes-quirk-in-bar4.patch
|
Patch0025: vfio-pci-Ascend310-need-4Bytes-quirk-in-bar4.patch
|
||||||
@ -341,6 +341,81 @@ Patch0328: target-i386-kvm-do-not-access-uninitialized-variable.patch
|
|||||||
Patch0329: KVM-x86-workaround-invalid-CPUID-0xD-9-info-on-some-.patch
|
Patch0329: KVM-x86-workaround-invalid-CPUID-0xD-9-info-on-some-.patch
|
||||||
Patch0330: fix-compilation-errors-of-sw64-architecture-on-x86-p.patch
|
Patch0330: fix-compilation-errors-of-sw64-architecture-on-x86-p.patch
|
||||||
Patch0331: fixed-the-error-that-no-bios-file-soft-link-was-crea.patch
|
Patch0331: fixed-the-error-that-no-bios-file-soft-link-was-crea.patch
|
||||||
|
Patch0332: arm-virt-Fix-vcpu-hotplug-idx_from_topo_ids.patch
|
||||||
|
Patch0333: vfio-migration-Fix-incorrect-initialization-value-fo.patch
|
||||||
|
Patch0334: hostmem-default-the-amount-of-prealloc-threads-to-sm.patch
|
||||||
|
Patch0335: Revert-vfio-common-Add-address-alignment-check-in-vf.patch
|
||||||
|
Patch0336: Revert-vfio-common-Fix-incorrect-address-alignment-i.patch
|
||||||
|
Patch0337: Revert-hw-arm-smmuv3-Post-load-stage-1-configuration.patch
|
||||||
|
Patch0338: Revert-vfio-Add-vfio_prereg_listener_global_log_star.patch
|
||||||
|
Patch0339: Revert-vfio-Add-vfio_prereg_listener_log_clear-to-re.patch
|
||||||
|
Patch0340: Revert-vfio-Add-vfio_prereg_listener_log_sync-in-nes.patch
|
||||||
|
Patch0341: Revert-vfio-Introduce-helpers-to-mark-dirty-pages-of.patch
|
||||||
|
Patch0342: Revert-vfio-common-Avoid-unmap-ram-section-at-vfio_l.patch
|
||||||
|
Patch0343: Revert-vfio-pci-Implement-return_page_response-page-.patch
|
||||||
|
Patch0344: Revert-pci-Add-return_page_response-pci-ops.patch
|
||||||
|
Patch0345: Revert-hw-arm-smmuv3-Allow-MAP-notifiers.patch
|
||||||
|
Patch0346: Revert-hw-arm-smmuv3-Implement-fault-injection.patch
|
||||||
|
Patch0347: Revert-hw-arm-smmuv3-Pass-stage-1-configurations-to-.patch
|
||||||
|
Patch0348: Revert-hw-arm-smmuv3-Fill-the-IOTLBEntry-leaf-field-.patch
|
||||||
|
Patch0349: Revert-hw-arm-smmuv3-Fill-the-IOTLBEntry-arch_id-on-.patch
|
||||||
|
Patch0350: Revert-hw-arm-smmuv3-Store-the-PASID-table-GPA-in-th.patch
|
||||||
|
Patch0351: Revert-hw-arm-smmuv3-Advertise-MSI_TRANSLATE-attribu.patch
|
||||||
|
Patch0352: Revert-vfio-pci-Implement-the-DMA-fault-handler.patch
|
||||||
|
Patch0353: Revert-vfio-pci-Set-up-the-DMA-FAULT-region.patch
|
||||||
|
Patch0354: Revert-vfio-pci-Register-handler-for-iommu-fault.patch
|
||||||
|
Patch0355: Revert-vfio-Helper-to-get-IRQ-info-including-capabil.patch
|
||||||
|
Patch0356: Revert-vfio-Pass-stage-1-MSI-bindings-to-the-host.patch
|
||||||
|
Patch0357: Revert-vfio-Set-up-nested-stage-mappings.patch
|
||||||
|
Patch0359: Revert-vfio-Introduce-helpers-to-DMA-map-unmap-a-RAM.patch
|
||||||
|
Patch0360: Revert-vfio-Introduce-hostwin_from_range-helper.patch
|
||||||
|
Patch0361: Revert-vfio-Force-nested-if-iommu-requires-it.patch
|
||||||
|
Patch0362: Revert-pci-introduce-PCIPASIDOps-to-PCIDevice.patch
|
||||||
|
Patch0363: Revert-iommu-Introduce-generic-header.patch
|
||||||
|
Patch0364: Revert-memory-Introduce-IOMMU-Memory-Region-inject_f.patch
|
||||||
|
Patch0365: Revert-memory-Add-IOMMU_ATTR_MSI_TRANSLATE-IOMMU-mem.patch
|
||||||
|
Patch0366: Revert-memory-Add-IOMMU_ATTR_VFIO_NESTED-IOMMU-memor.patch
|
||||||
|
Patch0367: Revert-hw-arm-smmu-common-Allow-domain-invalidation-.patch
|
||||||
|
Patch0368: Revert-hw-arm-smmuv3-Improve-stage1-ASID-invalidatio.patch
|
||||||
|
Patch0369: Revert-memory-Add-new-fields-in-IOTLBEntry.patch
|
||||||
|
Patch0370: Revert-vfio.h-and-iommu.h-header-update-against-5.10.patch
|
||||||
|
Patch0371: Revert-update-linux-headers-Import-iommu.h.patch
|
||||||
|
Patch0372: memory-Fix-wrong-end-address-dump.patch
|
||||||
|
Patch0373: tests-vm-use-o-IdentitiesOnly-yes-for-ssh.patch
|
||||||
|
Patch0374: linux-user-always-translate-cmsg-when-recvmsg.patch
|
||||||
|
Patch0375: target-arm-Copy-the-entire-vector-in-DO_ZIP.patch
|
||||||
|
Patch0376: hw-mem-nvdimm-fix-error-message-for-unarmed-flag.patch
|
||||||
|
Patch0377: gdb-xml-Fix-size-of-EFER-register-on-i386-architectu.patch
|
||||||
|
Patch0378: tcg-tci-fix-logic-error-when-registering-helpers-via.patch
|
||||||
|
Patch0379: virtio-mem-Don-t-skip-alignment-checks-when-warning-.patch
|
||||||
|
Patch0380: qemu-binfmt-conf.sh-fix-F-option.patch
|
||||||
|
Patch0381: Fix-several-typos-in-documentation-found-by-codespel.patch
|
||||||
|
Patch0382: hw-arm-virt-Fix-devicetree-warnings-about-the-virtio.patch
|
||||||
|
Patch0383: target-hppa-Fix-deposit-assert-from-trans_shrpw_imm.patch
|
||||||
|
Patch0384: tcg-optimize-Fix-folding-of-vector-ops.patch
|
||||||
|
Patch0385: target-arm-Add-missing-FEAT_TLBIOS-instructions.patch
|
||||||
|
Patch0386: target-riscv-pmp-fix-no-pmp-illegal-intrs.patch
|
||||||
|
Patch0387: configure-Remove-unused-python_version-variable.patch
|
||||||
|
Patch0388: configure-Remove-unused-meson_args-variable.patch
|
||||||
|
Patch0389: target-imx-reload-cmp-timer-outside-of-the-reload-pt.patch
|
||||||
|
Patch0390: configure-Add-missing-quoting-for-some-easy-cases.patch
|
||||||
|
Patch0391: hw-core-resettable-fix-reset-level-counting.patch
|
||||||
|
Patch0392: hw-usb-hcd-xhci-Reset-the-XHCIState-with-device_cold.patch
|
||||||
|
Patch0393: hw-ppc-spapr_pci.c-Use-device_cold_reset-rather-than.patch
|
||||||
|
Patch0394: hw-ide-microdrive-Use-device_cold_reset-for-self-res.patch
|
||||||
|
Patch0395: hw-i386-Use-device_cold_reset-to-reset-the-APIC.patch
|
||||||
|
Patch0396: hw-hyperv-hyperv.c-Use-device_cold_reset-instead-of-.patch
|
||||||
|
Patch0397: configure-Add-.-on-front-of-glob-of-config-devices.m.patch
|
||||||
|
Patch0398: configure-Check-mkdir-result-directly-not-via.patch
|
||||||
|
Patch0399: hw-char-pl011-fix-baud-rate-calculation.patch
|
||||||
|
Patch0400: target-i386-kvm-fix-kvmclock_current_nsec-Assertion-.patch
|
||||||
|
Patch0401: linux-headers-Update-headers-to-Linux-5.18-rc6.patch
|
||||||
|
Patch0402: virtio-get-class_id-and-pci-device-id-by-the-virtio-.patch
|
||||||
|
Patch0403: vdpa-add-vdpa-dev-support.patch
|
||||||
|
Patch0404: vdpa-add-vdpa-dev-pci-support.patch
|
||||||
|
Patch0405: vdpa-dev-mark-the-device-as-unmigratable.patch
|
||||||
|
Patch0406: docs-Add-generic-vhost-vdpa-device-documentation.patch
|
||||||
|
Patch0407: vhost-vdpa-add-memslot-getter-setter-for-vhost-vdpa.patch
|
||||||
|
|
||||||
BuildRequires: flex
|
BuildRequires: flex
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
@ -859,6 +934,12 @@ getent passwd qemu >/dev/null || \
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 22 2022 yezengruan <yezengruan@huawei.com> - 10:6.2.0-59
|
||||||
|
- arm/virt: Fix vcpu hotplug idx_from_topo_ids
|
||||||
|
- Revert patches related to the vSVA
|
||||||
|
- sync some bugfix patches from upstream
|
||||||
|
- add generic vDPA device support
|
||||||
|
|
||||||
* Mon Nov 14 2022 weishaokun <weishaokun@kylinos.cn> - 10:6.2.0-58
|
* Mon Nov 14 2022 weishaokun <weishaokun@kylinos.cn> - 10:6.2.0-58
|
||||||
- support io-uring by adding --enable-io-uring compilation option
|
- support io-uring by adding --enable-io-uring compilation option
|
||||||
|
|
||||||
|
|||||||
90
target-arm-Add-missing-FEAT_TLBIOS-instructions.patch
Normal file
90
target-arm-Add-missing-FEAT_TLBIOS-instructions.patch
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
From 1ac38ad4f16bf8fe4cabf1e41036f36ad08cf14f Mon Sep 17 00:00:00 2001
|
||||||
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 15:07:57 +0000
|
||||||
|
Subject: [PATCH 14/29] target/arm: Add missing FEAT_TLBIOS instructions
|
||||||
|
|
||||||
|
mainline inclusion
|
||||||
|
commit b7469ef92a8034b32031ba22b84fb14046f9770e
|
||||||
|
category: bugfix
|
||||||
|
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
Some of the instructions added by the FEAT_TLBIOS extension were forgotten
|
||||||
|
when the extension was originally added to QEMU.
|
||||||
|
|
||||||
|
Fixes: 7113d618505b ("target/arm: Add support for FEAT_TLBIOS")
|
||||||
|
Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com>
|
||||||
|
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
||||||
|
Message-id: 20211231103928.1455657-1-idan.horowitz@gmail.com
|
||||||
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||||
|
|
||||||
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
target/arm/helper.c | 32 ++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 32 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/target/arm/helper.c b/target/arm/helper.c
|
||||||
|
index 80737a8d7b..1854c65863 100644
|
||||||
|
--- a/target/arm/helper.c
|
||||||
|
+++ b/target/arm/helper.c
|
||||||
|
@@ -6998,18 +6998,42 @@ static const ARMCPRegInfo tlbios_reginfo[] = {
|
||||||
|
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 0,
|
||||||
|
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||||
|
.writefn = tlbi_aa64_vmalle1is_write },
|
||||||
|
+ { .name = "TLBI_VAE1OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 1,
|
||||||
|
+ .access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae1is_write },
|
||||||
|
{ .name = "TLBI_ASIDE1OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 2,
|
||||||
|
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||||
|
.writefn = tlbi_aa64_vmalle1is_write },
|
||||||
|
+ { .name = "TLBI_VAAE1OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 3,
|
||||||
|
+ .access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae1is_write },
|
||||||
|
+ { .name = "TLBI_VALE1OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 5,
|
||||||
|
+ .access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae1is_write },
|
||||||
|
+ { .name = "TLBI_VAALE1OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 7,
|
||||||
|
+ .access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae1is_write },
|
||||||
|
{ .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0,
|
||||||
|
.access = PL2_W, .type = ARM_CP_NO_RAW,
|
||||||
|
.writefn = tlbi_aa64_alle2is_write },
|
||||||
|
+ { .name = "TLBI_VAE2OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 1,
|
||||||
|
+ .access = PL2_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae2is_write },
|
||||||
|
{ .name = "TLBI_ALLE1OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 4,
|
||||||
|
.access = PL2_W, .type = ARM_CP_NO_RAW,
|
||||||
|
.writefn = tlbi_aa64_alle1is_write },
|
||||||
|
+ { .name = "TLBI_VALE2OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 5,
|
||||||
|
+ .access = PL2_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae2is_write },
|
||||||
|
{ .name = "TLBI_VMALLS12E1OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 6,
|
||||||
|
.access = PL2_W, .type = ARM_CP_NO_RAW,
|
||||||
|
@@ -7030,6 +7054,14 @@ static const ARMCPRegInfo tlbios_reginfo[] = {
|
||||||
|
.opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 0,
|
||||||
|
.access = PL3_W, .type = ARM_CP_NO_RAW,
|
||||||
|
.writefn = tlbi_aa64_alle3is_write },
|
||||||
|
+ { .name = "TLBI_VAE3OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 1,
|
||||||
|
+ .access = PL3_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae3is_write },
|
||||||
|
+ { .name = "TLBI_VALE3OS", .state = ARM_CP_STATE_AA64,
|
||||||
|
+ .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 5,
|
||||||
|
+ .access = PL3_W, .type = ARM_CP_NO_RAW,
|
||||||
|
+ .writefn = tlbi_aa64_vae3is_write },
|
||||||
|
REGINFO_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
35
target-arm-Copy-the-entire-vector-in-DO_ZIP.patch
Normal file
35
target-arm-Copy-the-entire-vector-in-DO_ZIP.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
From 5386c69970911a73c705068b72048437b1c27df0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Tue, 22 Nov 2022 17:52:53 +0800
|
||||||
|
Subject: [PATCH 04/29] target/arm: Copy the entire vector in DO_ZIP
|
||||||
|
|
||||||
|
With odd_ofs set, we weren't copying enough data.
|
||||||
|
Fixes: 09eb6d7025d1 ("target/arm: Move sve zip high_ofs into simd_data")
|
||||||
|
|
||||||
|
Reported-by: Idan Horowitz <idan.horowitz@gmail.com>
|
||||||
|
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
target/arm/sve_helper.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
|
||||||
|
index 07be55b7e1..03d58cabc8 100644
|
||||||
|
--- a/target/arm/sve_helper.c
|
||||||
|
+++ b/target/arm/sve_helper.c
|
||||||
|
@@ -3387,10 +3387,10 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \
|
||||||
|
/* We produce output faster than we consume input. \
|
||||||
|
Therefore we must be mindful of possible overlap. */ \
|
||||||
|
if (unlikely((vn - vd) < (uintptr_t)oprsz)) { \
|
||||||
|
- vn = memcpy(&tmp_n, vn, oprsz_2); \
|
||||||
|
+ vn = memcpy(&tmp_n, vn, oprsz); \
|
||||||
|
} \
|
||||||
|
if (unlikely((vm - vd) < (uintptr_t)oprsz)) { \
|
||||||
|
- vm = memcpy(&tmp_m, vm, oprsz_2); \
|
||||||
|
+ vm = memcpy(&tmp_m, vm, oprsz); \
|
||||||
|
} \
|
||||||
|
for (i = 0; i < oprsz_2; i += sizeof(TYPE)) { \
|
||||||
|
*(TYPE *)(vd + H(2 * i + 0)) = *(TYPE *)(vn + H(i)); \
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
88
target-hppa-Fix-deposit-assert-from-trans_shrpw_imm.patch
Normal file
88
target-hppa-Fix-deposit-assert-from-trans_shrpw_imm.patch
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
From 8964f3516cab9ed0183407136aa9f0dae87c49e3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 15:38:38 -0800
|
||||||
|
Subject: [PATCH 12/29] target/hppa: Fix deposit assert from trans_shrpw_imm
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
mainline inclusion
|
||||||
|
commit 05bfd4db08608bc4c22de729780c1f74612fbc0e
|
||||||
|
category: bugfix
|
||||||
|
|
||||||
|
----------------------------------------------
|
||||||
|
|
||||||
|
Because sa may be 0,
|
||||||
|
|
||||||
|
tcg_gen_deposit_reg(dest, t0, cpu_gr[a->r1], 32 - sa, sa);
|
||||||
|
|
||||||
|
may attempt a zero-width deposit at bit 32, which will assert
|
||||||
|
for TARGET_REGISTER_BITS == 32.
|
||||||
|
|
||||||
|
Use the newer extract2 when possible, which itself includes the
|
||||||
|
rotri special case; otherwise mirror the code from trans_shrpw_sar,
|
||||||
|
using concat and shri.
|
||||||
|
|
||||||
|
Cc: qemu-stable@nongnu.org
|
||||||
|
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/635
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||||
|
|
||||||
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
target/hppa/translate.c | 19 ++++++++++++-------
|
||||||
|
1 file changed, 12 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
|
||||||
|
index 3b9744deb4..952027a28e 100644
|
||||||
|
--- a/target/hppa/translate.c
|
||||||
|
+++ b/target/hppa/translate.c
|
||||||
|
@@ -140,6 +140,7 @@
|
||||||
|
#define tcg_gen_deposit_z_reg tcg_gen_deposit_z_i64
|
||||||
|
#define tcg_gen_extract_reg tcg_gen_extract_i64
|
||||||
|
#define tcg_gen_sextract_reg tcg_gen_sextract_i64
|
||||||
|
+#define tcg_gen_extract2_reg tcg_gen_extract2_i64
|
||||||
|
#define tcg_const_reg tcg_const_i64
|
||||||
|
#define tcg_const_local_reg tcg_const_local_i64
|
||||||
|
#define tcg_constant_reg tcg_constant_i64
|
||||||
|
@@ -234,6 +235,7 @@
|
||||||
|
#define tcg_gen_deposit_z_reg tcg_gen_deposit_z_i32
|
||||||
|
#define tcg_gen_extract_reg tcg_gen_extract_i32
|
||||||
|
#define tcg_gen_sextract_reg tcg_gen_sextract_i32
|
||||||
|
+#define tcg_gen_extract2_reg tcg_gen_extract2_i32
|
||||||
|
#define tcg_const_reg tcg_const_i32
|
||||||
|
#define tcg_const_local_reg tcg_const_local_i32
|
||||||
|
#define tcg_constant_reg tcg_constant_i32
|
||||||
|
@@ -3204,19 +3206,22 @@ static bool trans_shrpw_imm(DisasContext *ctx, arg_shrpw_imm *a)
|
||||||
|
|
||||||
|
dest = dest_gpr(ctx, a->t);
|
||||||
|
t2 = load_gpr(ctx, a->r2);
|
||||||
|
- if (a->r1 == a->r2) {
|
||||||
|
+ if (a->r1 == 0) {
|
||||||
|
+ tcg_gen_extract_reg(dest, t2, sa, 32 - sa);
|
||||||
|
+ } else if (TARGET_REGISTER_BITS == 32) {
|
||||||
|
+ tcg_gen_extract2_reg(dest, t2, cpu_gr[a->r1], sa);
|
||||||
|
+ } else if (a->r1 == a->r2) {
|
||||||
|
TCGv_i32 t32 = tcg_temp_new_i32();
|
||||||
|
tcg_gen_trunc_reg_i32(t32, t2);
|
||||||
|
tcg_gen_rotri_i32(t32, t32, sa);
|
||||||
|
tcg_gen_extu_i32_reg(dest, t32);
|
||||||
|
tcg_temp_free_i32(t32);
|
||||||
|
- } else if (a->r1 == 0) {
|
||||||
|
- tcg_gen_extract_reg(dest, t2, sa, 32 - sa);
|
||||||
|
} else {
|
||||||
|
- TCGv_reg t0 = tcg_temp_new();
|
||||||
|
- tcg_gen_extract_reg(t0, t2, sa, 32 - sa);
|
||||||
|
- tcg_gen_deposit_reg(dest, t0, cpu_gr[a->r1], 32 - sa, sa);
|
||||||
|
- tcg_temp_free(t0);
|
||||||
|
+ TCGv_i64 t64 = tcg_temp_new_i64();
|
||||||
|
+ tcg_gen_concat_reg_i64(t64, t2, cpu_gr[a->r1]);
|
||||||
|
+ tcg_gen_shri_i64(t64, t64, sa);
|
||||||
|
+ tcg_gen_trunc_i64_reg(dest, t64);
|
||||||
|
+ tcg_temp_free_i64(t64);
|
||||||
|
}
|
||||||
|
save_gpr(ctx, a->t, dest);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
49
target-i386-kvm-fix-kvmclock_current_nsec-Assertion-.patch
Normal file
49
target-i386-kvm-fix-kvmclock_current_nsec-Assertion-.patch
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
From f53c352a12a0785ff4e83aaeaec7245384538d6a Mon Sep 17 00:00:00 2001
|
||||||
|
From: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
Date: Mon, 28 Nov 2022 03:10:06 +0000
|
||||||
|
Subject: [PATCH 29/29] target/i386/kvm: fix kvmclock_current_nsec: Assertion
|
||||||
|
`time.tsc_timestamp <= migration_tsc' failed mainline inclusion from
|
||||||
|
mainline-v7.2.0-rc2 commit c4ef867f2949bf2a2ae18a4e27cf1a34bbc8aecb category:
|
||||||
|
bugfix
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
New KVM_CLOCK flags were added in the kernel.(c68dc1b577eabd5605c6c7c08f3e07ae18d30d5d)
|
||||||
|
```
|
||||||
|
+ #define KVM_CLOCK_VALID_FLAGS \
|
||||||
|
+ (KVM_CLOCK_TSC_STABLE | KVM_CLOCK_REALTIME | KVM_CLOCK_HOST_TSC)
|
||||||
|
|
||||||
|
case KVM_CAP_ADJUST_CLOCK:
|
||||||
|
- r = KVM_CLOCK_TSC_STABLE;
|
||||||
|
+ r = KVM_CLOCK_VALID_FLAGS;
|
||||||
|
```
|
||||||
|
|
||||||
|
kvm_has_adjust_clock_stable needs to handle additional flags,
|
||||||
|
so that s->clock_is_reliable can be true and kvmclock_current_nsec doesn't need to be called.
|
||||||
|
|
||||||
|
Signed-off-by: Ray Zhang <zhanglei002@gmail.com>
|
||||||
|
Message-Id: <20220922100523.2362205-1-zhanglei002@gmail.com>
|
||||||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||||
|
|
||||||
|
|
||||||
|
Signed-off-by: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
target/i386/kvm/kvm.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
||||||
|
index 20e418463d..5b15e0430b 100644
|
||||||
|
--- a/target/i386/kvm/kvm.c
|
||||||
|
+++ b/target/i386/kvm/kvm.c
|
||||||
|
@@ -151,7 +151,7 @@ bool kvm_has_adjust_clock_stable(void)
|
||||||
|
{
|
||||||
|
int ret = kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK);
|
||||||
|
|
||||||
|
- return (ret == KVM_CLOCK_TSC_STABLE);
|
||||||
|
+ return (ret & KVM_CLOCK_TSC_STABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool kvm_has_adjust_clock(void)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
43
target-imx-reload-cmp-timer-outside-of-the-reload-pt.patch
Normal file
43
target-imx-reload-cmp-timer-outside-of-the-reload-pt.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
From bdd1741cf18959e70cdfc6f46bb41d9209e86315 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Thu, 24 Nov 2022 17:18:00 +0800
|
||||||
|
Subject: [PATCH 18/29] target/imx: reload cmp timer outside of the reload
|
||||||
|
ptimer transaction
|
||||||
|
|
||||||
|
When running seL4 tests (https://docs.sel4.systems/projects/sel4test)
|
||||||
|
on the sabrelight platform, the timer tests fail. The arm/imx6 EPIT
|
||||||
|
timer interrupt does not fire properly, instead of a e.g. second in
|
||||||
|
can take up to a minute to finally see the interrupt.
|
||||||
|
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1263
|
||||||
|
|
||||||
|
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/timer/imx_epit.c | 9 +++++++--
|
||||||
|
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
|
||||||
|
index ebd58254d1..a78b625d15 100644
|
||||||
|
--- a/hw/timer/imx_epit.c
|
||||||
|
+++ b/hw/timer/imx_epit.c
|
||||||
|
@@ -275,10 +275,15 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
|
||||||
|
/* If IOVW bit is set then set the timer value */
|
||||||
|
ptimer_set_count(s->timer_reload, s->lr);
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+ /*
|
||||||
|
+ * Commit the change to s->timer_reload, so it can propagate. Otherwise
|
||||||
|
+ * the timer interrupt may not fire properly. The commit must happen
|
||||||
|
+ * before calling imx_epit_reload_compare_timer(), which reads
|
||||||
|
+ * s->timer_reload internally again.
|
||||||
|
+ */
|
||||||
|
+ ptimer_transaction_commit(s->timer_reload);
|
||||||
|
imx_epit_reload_compare_timer(s);
|
||||||
|
ptimer_transaction_commit(s->timer_cmp);
|
||||||
|
- ptimer_transaction_commit(s->timer_reload);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: /* CMP */
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
43
target-riscv-pmp-fix-no-pmp-illegal-intrs.patch
Normal file
43
target-riscv-pmp-fix-no-pmp-illegal-intrs.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
From 5489264cd9583855d45fd0c21f18387b649f6e44 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 15:26:59 +0300
|
||||||
|
Subject: [PATCH 15/29] target/riscv/pmp: fix no pmp illegal intrs
|
||||||
|
|
||||||
|
mainline inclusion
|
||||||
|
commit 0fbb5d2d3c9ded9fbd3f6f993974cc5e88e28912
|
||||||
|
category: bugfix
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
As per the privilege specification, any access from S/U mode should fail
|
||||||
|
if no pmp region is configured and pmp is present, othwerwise access
|
||||||
|
should succeed.
|
||||||
|
|
||||||
|
Fixes: d102f19a208 (target/riscv/pmp: Raise exception if no PMP entry is configured)
|
||||||
|
Signed-off-by: Nikita Shubin <n.shubin@yadro.com>
|
||||||
|
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
||||||
|
Message-id: 20211214092659.15709-1-nikita.shubin@maquefel.me
|
||||||
|
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
||||||
|
|
||||||
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
target/riscv/op_helper.c | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
|
||||||
|
index ee7c24efe7..58d992e98a 100644
|
||||||
|
--- a/target/riscv/op_helper.c
|
||||||
|
+++ b/target/riscv/op_helper.c
|
||||||
|
@@ -146,7 +146,8 @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb)
|
||||||
|
uint64_t mstatus = env->mstatus;
|
||||||
|
target_ulong prev_priv = get_field(mstatus, MSTATUS_MPP);
|
||||||
|
|
||||||
|
- if (!pmp_get_num_rules(env) && (prev_priv != PRV_M)) {
|
||||||
|
+ if (riscv_feature(env, RISCV_FEATURE_PMP) &&
|
||||||
|
+ !pmp_get_num_rules(env) && (prev_priv != PRV_M)) {
|
||||||
|
riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC());
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
157
tcg-optimize-Fix-folding-of-vector-ops.patch
Normal file
157
tcg-optimize-Fix-folding-of-vector-ops.patch
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
From 8eef73d0714c8bb5a4fc5a8b6ae007752d0061b2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 15:35:25 -0800
|
||||||
|
Subject: [PATCH 13/29] tcg/optimize: Fix folding of vector ops
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
mainline inclusion
|
||||||
|
commit c578ff18584666499c3141b2d770b9e36b5e9d7e
|
||||||
|
category: bugfix
|
||||||
|
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
Bitwise operations are easy to fold, because the operation is
|
||||||
|
identical regardless of element size. But add and sub need
|
||||||
|
extra element size info that is not currently propagated.
|
||||||
|
|
||||||
|
Fixes: 2f9f08ba43d
|
||||||
|
Cc: qemu-stable@nongnu.org
|
||||||
|
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/799
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||||
|
|
||||||
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
tcg/optimize.c | 49 ++++++++++++++++++++++++++++++++++++++-----------
|
||||||
|
1 file changed, 38 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tcg/optimize.c b/tcg/optimize.c
|
||||||
|
index 2397f2cf93..e573000951 100644
|
||||||
|
--- a/tcg/optimize.c
|
||||||
|
+++ b/tcg/optimize.c
|
||||||
|
@@ -308,13 +308,13 @@ static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y)
|
||||||
|
CASE_OP_32_64(mul):
|
||||||
|
return x * y;
|
||||||
|
|
||||||
|
- CASE_OP_32_64(and):
|
||||||
|
+ CASE_OP_32_64_VEC(and):
|
||||||
|
return x & y;
|
||||||
|
|
||||||
|
- CASE_OP_32_64(or):
|
||||||
|
+ CASE_OP_32_64_VEC(or):
|
||||||
|
return x | y;
|
||||||
|
|
||||||
|
- CASE_OP_32_64(xor):
|
||||||
|
+ CASE_OP_32_64_VEC(xor):
|
||||||
|
return x ^ y;
|
||||||
|
|
||||||
|
case INDEX_op_shl_i32:
|
||||||
|
@@ -347,16 +347,16 @@ static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y)
|
||||||
|
case INDEX_op_rotl_i64:
|
||||||
|
return rol64(x, y & 63);
|
||||||
|
|
||||||
|
- CASE_OP_32_64(not):
|
||||||
|
+ CASE_OP_32_64_VEC(not):
|
||||||
|
return ~x;
|
||||||
|
|
||||||
|
CASE_OP_32_64(neg):
|
||||||
|
return -x;
|
||||||
|
|
||||||
|
- CASE_OP_32_64(andc):
|
||||||
|
+ CASE_OP_32_64_VEC(andc):
|
||||||
|
return x & ~y;
|
||||||
|
|
||||||
|
- CASE_OP_32_64(orc):
|
||||||
|
+ CASE_OP_32_64_VEC(orc):
|
||||||
|
return x | ~y;
|
||||||
|
|
||||||
|
CASE_OP_32_64(eqv):
|
||||||
|
@@ -751,6 +751,12 @@ static bool fold_const2(OptContext *ctx, TCGOp *op)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static bool fold_commutative(OptContext *ctx, TCGOp *op)
|
||||||
|
+{
|
||||||
|
+ swap_commutative(op->args[0], &op->args[1], &op->args[2]);
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static bool fold_const2_commutative(OptContext *ctx, TCGOp *op)
|
||||||
|
{
|
||||||
|
swap_commutative(op->args[0], &op->args[1], &op->args[2]);
|
||||||
|
@@ -905,6 +911,16 @@ static bool fold_add(OptContext *ctx, TCGOp *op)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* We cannot as yet do_constant_folding with vectors. */
|
||||||
|
+static bool fold_add_vec(OptContext *ctx, TCGOp *op)
|
||||||
|
+{
|
||||||
|
+ if (fold_commutative(ctx, op) ||
|
||||||
|
+ fold_xi_to_x(ctx, op, 0)) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add)
|
||||||
|
{
|
||||||
|
if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) &&
|
||||||
|
@@ -1938,10 +1954,10 @@ static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static bool fold_sub(OptContext *ctx, TCGOp *op)
|
||||||
|
+/* We cannot as yet do_constant_folding with vectors. */
|
||||||
|
+static bool fold_sub_vec(OptContext *ctx, TCGOp *op)
|
||||||
|
{
|
||||||
|
- if (fold_const2(ctx, op) ||
|
||||||
|
- fold_xx_to_i(ctx, op, 0) ||
|
||||||
|
+ if (fold_xx_to_i(ctx, op, 0) ||
|
||||||
|
fold_xi_to_x(ctx, op, 0) ||
|
||||||
|
fold_sub_to_neg(ctx, op)) {
|
||||||
|
return true;
|
||||||
|
@@ -1949,6 +1965,11 @@ static bool fold_sub(OptContext *ctx, TCGOp *op)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static bool fold_sub(OptContext *ctx, TCGOp *op)
|
||||||
|
+{
|
||||||
|
+ return fold_const2(ctx, op) || fold_sub_vec(ctx, op);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static bool fold_sub2(OptContext *ctx, TCGOp *op)
|
||||||
|
{
|
||||||
|
return fold_addsub2(ctx, op, false);
|
||||||
|
@@ -2052,9 +2073,12 @@ void tcg_optimize(TCGContext *s)
|
||||||
|
* Sorted alphabetically by opcode as much as possible.
|
||||||
|
*/
|
||||||
|
switch (opc) {
|
||||||
|
- CASE_OP_32_64_VEC(add):
|
||||||
|
+ CASE_OP_32_64(add):
|
||||||
|
done = fold_add(&ctx, op);
|
||||||
|
break;
|
||||||
|
+ case INDEX_op_add_vec:
|
||||||
|
+ done = fold_add_vec(&ctx, op);
|
||||||
|
+ break;
|
||||||
|
CASE_OP_32_64(add2):
|
||||||
|
done = fold_add2(&ctx, op);
|
||||||
|
break;
|
||||||
|
@@ -2193,9 +2217,12 @@ void tcg_optimize(TCGContext *s)
|
||||||
|
CASE_OP_32_64(sextract):
|
||||||
|
done = fold_sextract(&ctx, op);
|
||||||
|
break;
|
||||||
|
- CASE_OP_32_64_VEC(sub):
|
||||||
|
+ CASE_OP_32_64(sub):
|
||||||
|
done = fold_sub(&ctx, op);
|
||||||
|
break;
|
||||||
|
+ case INDEX_op_sub_vec:
|
||||||
|
+ done = fold_sub_vec(&ctx, op);
|
||||||
|
+ break;
|
||||||
|
CASE_OP_32_64(sub2):
|
||||||
|
done = fold_sub2(&ctx, op);
|
||||||
|
break;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
53
tcg-tci-fix-logic-error-when-registering-helpers-via.patch
Normal file
53
tcg-tci-fix-logic-error-when-registering-helpers-via.patch
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
From 32533b4b6ea73b69f654ae2d337b3262da36830a Mon Sep 17 00:00:00 2001
|
||||||
|
From: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 06:23:16 +0000
|
||||||
|
Subject: [PATCH 07/29] tcg/tci: fix logic error when registering helpers via
|
||||||
|
FFI mainline inclusion from mainline-v7.2.0-rc1 commit
|
||||||
|
9dd1d56e570e5119fef2b28fda811d6891e597a8 category: bugfix
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
When registering helpers via FFI for TCI, the inner loop that iterates
|
||||||
|
parameters of the helper reuses (and thus pollutes) the same variable
|
||||||
|
used by the outer loop that iterates all helpers, thus made some helpers
|
||||||
|
unregistered.
|
||||||
|
|
||||||
|
Fix this logic error by using a dedicated temporary variable for the
|
||||||
|
inner loop.
|
||||||
|
|
||||||
|
Fixes: 22f1557 ("tcg: Build ffi data structures for helpers")
|
||||||
|
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||||
|
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
|
||||||
|
Message-Id: <20221028072145.1593205-1-uwu@icenowy.me>
|
||||||
|
[rth: Move declaration of j to the for loop itself]
|
||||||
|
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||||
|
|
||||||
|
Signed-off-by: cmss_dx <dingxiang@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
tcg/tcg.c | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tcg/tcg.c b/tcg/tcg.c
|
||||||
|
index 934aa8510b..635555001b 100644
|
||||||
|
--- a/tcg/tcg.c
|
||||||
|
+++ b/tcg/tcg.c
|
||||||
|
@@ -632,9 +632,9 @@ static void tcg_context_init(unsigned max_cpus)
|
||||||
|
|
||||||
|
if (nargs != 0) {
|
||||||
|
ca->cif.arg_types = ca->args;
|
||||||
|
- for (i = 0; i < nargs; ++i) {
|
||||||
|
- int typecode = extract32(typemask, (i + 1) * 3, 3);
|
||||||
|
- ca->args[i] = typecode_to_ffi[typecode];
|
||||||
|
+ for (int j = 0; j < nargs; ++j) {
|
||||||
|
+ int typecode = extract32(typemask, (j + 1) * 3, 3);
|
||||||
|
+ ca->args[j] = typecode_to_ffi[typecode];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
35
tests-vm-use-o-IdentitiesOnly-yes-for-ssh.patch
Normal file
35
tests-vm-use-o-IdentitiesOnly-yes-for-ssh.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
From 09ebd704c71b855a1c5732d4e4816aa9aed3fe13 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Tue, 22 Nov 2022 16:47:27 +0800
|
||||||
|
Subject: [PATCH 02/29] tests/vm: use -o IdentitiesOnly=yes for ssh
|
||||||
|
|
||||||
|
When one has a lot of keys in ~/.ssh directory, the ssh command will
|
||||||
|
try all of them before the one specified on the command line, and this
|
||||||
|
may cause the remote ssh server to reject the connection due to too
|
||||||
|
many failed authentication attempts.
|
||||||
|
Fix by adding -o IdentitiesOnly=yes, which makes the ssh client
|
||||||
|
consider only the keys specified on the command line.
|
||||||
|
|
||||||
|
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
|
||||||
|
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
tests/vm/basevm.py | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
|
||||||
|
index 254e11c932..4003bc5fef 100644
|
||||||
|
--- a/tests/vm/basevm.py
|
||||||
|
+++ b/tests/vm/basevm.py
|
||||||
|
@@ -228,7 +228,8 @@ def _ssh_do(self, user, cmd, check):
|
||||||
|
"-o", "UserKnownHostsFile=" + os.devnull,
|
||||||
|
"-o",
|
||||||
|
"ConnectTimeout={}".format(self._config["ssh_timeout"]),
|
||||||
|
- "-p", str(self.ssh_port), "-i", self._ssh_tmp_key_file]
|
||||||
|
+ "-p", str(self.ssh_port), "-i", self._ssh_tmp_key_file,
|
||||||
|
+ "-o", "IdentitiesOnly=yes"]
|
||||||
|
# If not in debug mode, set ssh to quiet mode to
|
||||||
|
# avoid printing the results of commands.
|
||||||
|
if not self.debug:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
141
vdpa-add-vdpa-dev-pci-support.patch
Normal file
141
vdpa-add-vdpa-dev-pci-support.patch
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
From e422f956fa13298c25ac645d9d822d3ca92f8e31 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Longpeng <longpeng2@huawei.com>
|
||||||
|
Date: Sat, 12 Nov 2022 22:40:11 +0800
|
||||||
|
Subject: [PATCH 4/7] vdpa: add vdpa-dev-pci support
|
||||||
|
|
||||||
|
Supports vdpa-dev-pci, we can use the device as follow:
|
||||||
|
|
||||||
|
-device vhost-vdpa-device-pci,vhostdev=/dev/vhost-vdpa-X
|
||||||
|
|
||||||
|
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||||
|
Signed-off-by: Longpeng <longpeng2@huawei.com>
|
||||||
|
---
|
||||||
|
hw/virtio/meson.build | 1 +
|
||||||
|
hw/virtio/vdpa-dev-pci.c | 102 +++++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 103 insertions(+)
|
||||||
|
create mode 100644 hw/virtio/vdpa-dev-pci.c
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
|
||||||
|
index 289e955478..8e8943e20b 100644
|
||||||
|
--- a/hw/virtio/meson.build
|
||||||
|
+++ b/hw/virtio/meson.build
|
||||||
|
@@ -50,6 +50,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: files('virtio-serial-pc
|
||||||
|
virtio_pci_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: files('virtio-pmem-pci.c'))
|
||||||
|
virtio_pci_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu-pci.c'))
|
||||||
|
virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pci.c'))
|
||||||
|
+virtio_pci_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev-pci.c'))
|
||||||
|
|
||||||
|
virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/vdpa-dev-pci.c b/hw/virtio/vdpa-dev-pci.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..5446e6b393
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/hw/virtio/vdpa-dev-pci.c
|
||||||
|
@@ -0,0 +1,102 @@
|
||||||
|
+/*
|
||||||
|
+ * Vhost Vdpa Device PCI Bindings
|
||||||
|
+ *
|
||||||
|
+ * Copyright (c) Huawei Technologies Co., Ltd. 2022. All Rights Reserved.
|
||||||
|
+ *
|
||||||
|
+ * Authors:
|
||||||
|
+ * Longpeng <longpeng2@huawei.com>
|
||||||
|
+ *
|
||||||
|
+ * Largely based on the "vhost-user-blk-pci.c" and "vhost-user-blk.c"
|
||||||
|
+ * implemented by:
|
||||||
|
+ * Changpeng Liu <changpeng.liu@intel.com>
|
||||||
|
+ *
|
||||||
|
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
||||||
|
+ * See the COPYING.LIB file in the top-level directory.
|
||||||
|
+ */
|
||||||
|
+#include "qemu/osdep.h"
|
||||||
|
+#include <sys/ioctl.h>
|
||||||
|
+#include <linux/vhost.h>
|
||||||
|
+#include "hw/virtio/virtio.h"
|
||||||
|
+#include "hw/virtio/vdpa-dev.h"
|
||||||
|
+#include "hw/pci/pci.h"
|
||||||
|
+#include "hw/qdev-properties.h"
|
||||||
|
+#include "qapi/error.h"
|
||||||
|
+#include "qemu/error-report.h"
|
||||||
|
+#include "qemu/module.h"
|
||||||
|
+#include "hw/virtio/virtio-pci.h"
|
||||||
|
+#include "qom/object.h"
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+typedef struct VhostVdpaDevicePCI VhostVdpaDevicePCI;
|
||||||
|
+
|
||||||
|
+#define TYPE_VHOST_VDPA_DEVICE_PCI "vhost-vdpa-device-pci-base"
|
||||||
|
+DECLARE_INSTANCE_CHECKER(VhostVdpaDevicePCI, VHOST_VDPA_DEVICE_PCI,
|
||||||
|
+ TYPE_VHOST_VDPA_DEVICE_PCI)
|
||||||
|
+
|
||||||
|
+struct VhostVdpaDevicePCI {
|
||||||
|
+ VirtIOPCIProxy parent_obj;
|
||||||
|
+ VhostVdpaDevice vdev;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_pci_instance_init(Object *obj)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevicePCI *dev = VHOST_VDPA_DEVICE_PCI(obj);
|
||||||
|
+
|
||||||
|
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
|
||||||
|
+ TYPE_VHOST_VDPA_DEVICE);
|
||||||
|
+ object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
|
||||||
|
+ "bootindex");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static Property vhost_vdpa_device_pci_properties[] = {
|
||||||
|
+ DEFINE_PROP_END_OF_LIST(),
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static int vhost_vdpa_device_pci_post_init(VhostVdpaDevice *v, Error **errp)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevicePCI *dev = container_of(v, VhostVdpaDevicePCI, vdev);
|
||||||
|
+ VirtIOPCIProxy *vpci_dev = &dev->parent_obj;
|
||||||
|
+
|
||||||
|
+ vpci_dev->class_code = virtio_pci_get_class_id(v->vdev_id);
|
||||||
|
+ vpci_dev->trans_devid = virtio_pci_get_trans_devid(v->vdev_id);
|
||||||
|
+ /* one for config vector */
|
||||||
|
+ vpci_dev->nvectors = v->num_queues + 1;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+vhost_vdpa_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevicePCI *dev = VHOST_VDPA_DEVICE_PCI(vpci_dev);
|
||||||
|
+
|
||||||
|
+ dev->vdev.post_init = vhost_vdpa_device_pci_post_init;
|
||||||
|
+ qdev_realize(DEVICE(&dev->vdev), BUS(&vpci_dev->bus), errp);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_pci_class_init(ObjectClass *klass, void *data)
|
||||||
|
+{
|
||||||
|
+ DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
+ VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
|
||||||
|
+
|
||||||
|
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||||
|
+ device_class_set_props(dc, vhost_vdpa_device_pci_properties);
|
||||||
|
+ k->realize = vhost_vdpa_device_pci_realize;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static const VirtioPCIDeviceTypeInfo vhost_vdpa_device_pci_info = {
|
||||||
|
+ .base_name = TYPE_VHOST_VDPA_DEVICE_PCI,
|
||||||
|
+ .generic_name = "vhost-vdpa-device-pci",
|
||||||
|
+ .transitional_name = "vhost-vdpa-device-pci-transitional",
|
||||||
|
+ .non_transitional_name = "vhost-vdpa-device-pci-non-transitional",
|
||||||
|
+ .instance_size = sizeof(VhostVdpaDevicePCI),
|
||||||
|
+ .instance_init = vhost_vdpa_device_pci_instance_init,
|
||||||
|
+ .class_init = vhost_vdpa_device_pci_class_init,
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_pci_register(void)
|
||||||
|
+{
|
||||||
|
+ virtio_pci_types_register(&vhost_vdpa_device_pci_info);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+type_init(vhost_vdpa_device_pci_register);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
481
vdpa-add-vdpa-dev-support.patch
Normal file
481
vdpa-add-vdpa-dev-support.patch
Normal file
@ -0,0 +1,481 @@
|
|||||||
|
From 813ab05c3e508a702457236abd40e8256312a499 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Longpeng <longpeng2@huawei.com>
|
||||||
|
Date: Sat, 12 Nov 2022 22:40:10 +0800
|
||||||
|
Subject: [PATCH 3/7] vdpa: add vdpa-dev support
|
||||||
|
|
||||||
|
Supports vdpa-dev, we can use the deivce directly:
|
||||||
|
|
||||||
|
-M microvm -m 512m -smp 2 -kernel ... -initrd ... -device \
|
||||||
|
vhost-vdpa-device,vhostdev=/dev/vhost-vdpa-x
|
||||||
|
|
||||||
|
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||||
|
Signed-off-by: Longpeng <longpeng2@huawei.com>
|
||||||
|
---
|
||||||
|
hw/virtio/Kconfig | 5 +
|
||||||
|
hw/virtio/meson.build | 1 +
|
||||||
|
hw/virtio/vdpa-dev.c | 376 +++++++++++++++++++++++++++++++++++
|
||||||
|
include/hw/virtio/vdpa-dev.h | 43 ++++
|
||||||
|
4 files changed, 425 insertions(+)
|
||||||
|
create mode 100644 hw/virtio/vdpa-dev.c
|
||||||
|
create mode 100644 include/hw/virtio/vdpa-dev.h
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig
|
||||||
|
index c144d42f9b..724eb58a32 100644
|
||||||
|
--- a/hw/virtio/Kconfig
|
||||||
|
+++ b/hw/virtio/Kconfig
|
||||||
|
@@ -68,3 +68,8 @@ config VHOST_USER_RNG
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
depends on VIRTIO && VHOST_USER
|
||||||
|
+
|
||||||
|
+config VHOST_VDPA_DEV
|
||||||
|
+ bool
|
||||||
|
+ default y
|
||||||
|
+ depends on VIRTIO && VHOST_VDPA && LINUX
|
||||||
|
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
|
||||||
|
index 521f7d64a8..289e955478 100644
|
||||||
|
--- a/hw/virtio/meson.build
|
||||||
|
+++ b/hw/virtio/meson.build
|
||||||
|
@@ -29,6 +29,7 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
|
||||||
|
virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2C'], if_true: files('vhost-user-i2c-pci.c'))
|
||||||
|
virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
|
||||||
|
virtio_ss.add(when: ['CONFIG_VHOST_USER_RNG', 'CONFIG_VIRTIO_PCI'], if_true: files('vhost-user-rng-pci.c'))
|
||||||
|
+virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c'))
|
||||||
|
|
||||||
|
virtio_pci_ss = ss.source_set()
|
||||||
|
virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
|
||||||
|
diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..42ab74c255
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/hw/virtio/vdpa-dev.c
|
||||||
|
@@ -0,0 +1,376 @@
|
||||||
|
+/*
|
||||||
|
+ * Vhost Vdpa Device
|
||||||
|
+ *
|
||||||
|
+ * Copyright (c) Huawei Technologies Co., Ltd. 2022. All Rights Reserved.
|
||||||
|
+ *
|
||||||
|
+ * Authors:
|
||||||
|
+ * Longpeng <longpeng2@huawei.com>
|
||||||
|
+ *
|
||||||
|
+ * Largely based on the "vhost-user-blk-pci.c" and "vhost-user-blk.c"
|
||||||
|
+ * implemented by:
|
||||||
|
+ * Changpeng Liu <changpeng.liu@intel.com>
|
||||||
|
+ *
|
||||||
|
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
||||||
|
+ * See the COPYING.LIB file in the top-level directory.
|
||||||
|
+ */
|
||||||
|
+#include "qemu/osdep.h"
|
||||||
|
+#include <sys/ioctl.h>
|
||||||
|
+#include <linux/vhost.h>
|
||||||
|
+#include "qapi/error.h"
|
||||||
|
+#include "qemu/error-report.h"
|
||||||
|
+#include "qemu/cutils.h"
|
||||||
|
+#include "hw/qdev-core.h"
|
||||||
|
+#include "hw/qdev-properties.h"
|
||||||
|
+#include "hw/qdev-properties-system.h"
|
||||||
|
+#include "hw/virtio/vhost.h"
|
||||||
|
+#include "hw/virtio/virtio.h"
|
||||||
|
+#include "hw/virtio/virtio-bus.h"
|
||||||
|
+#include "hw/virtio/virtio-access.h"
|
||||||
|
+#include "hw/virtio/vdpa-dev.h"
|
||||||
|
+#include "sysemu/sysemu.h"
|
||||||
|
+#include "sysemu/runstate.h"
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+vhost_vdpa_device_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
|
+{
|
||||||
|
+ /* Nothing to do */
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static uint32_t
|
||||||
|
+vhost_vdpa_device_get_u32(int fd, unsigned long int cmd, Error **errp)
|
||||||
|
+{
|
||||||
|
+ uint32_t val = (uint32_t)-1;
|
||||||
|
+
|
||||||
|
+ if (ioctl(fd, cmd, &val) < 0) {
|
||||||
|
+ error_setg(errp, "vhost-vdpa-device: cmd 0x%lx failed: %s",
|
||||||
|
+ cmd, strerror(errno));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return val;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_realize(DeviceState *dev, Error **errp)
|
||||||
|
+{
|
||||||
|
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||||||
|
+ VhostVdpaDevice *v = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+ uint16_t max_queue_size;
|
||||||
|
+ struct vhost_virtqueue *vqs;
|
||||||
|
+ int i, ret;
|
||||||
|
+
|
||||||
|
+ if (!v->vhostdev) {
|
||||||
|
+ error_setg(errp, "vhost-vdpa-device: vhostdev are missing");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ v->vhostfd = qemu_open(v->vhostdev, O_RDWR, errp);
|
||||||
|
+ if (*errp) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ v->vdpa.device_fd = v->vhostfd;
|
||||||
|
+
|
||||||
|
+ v->vdev_id = vhost_vdpa_device_get_u32(v->vhostfd,
|
||||||
|
+ VHOST_VDPA_GET_DEVICE_ID, errp);
|
||||||
|
+ if (*errp) {
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ max_queue_size = vhost_vdpa_device_get_u32(v->vhostfd,
|
||||||
|
+ VHOST_VDPA_GET_VRING_NUM, errp);
|
||||||
|
+ if (*errp) {
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (v->queue_size > max_queue_size) {
|
||||||
|
+ error_setg(errp, "vhost-vdpa-device: invalid queue_size: %u (max:%u)",
|
||||||
|
+ v->queue_size, max_queue_size);
|
||||||
|
+ goto out;
|
||||||
|
+ } else if (!v->queue_size) {
|
||||||
|
+ v->queue_size = max_queue_size;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ v->num_queues = vhost_vdpa_device_get_u32(v->vhostfd,
|
||||||
|
+ VHOST_VDPA_GET_VQS_COUNT, errp);
|
||||||
|
+ if (*errp) {
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!v->num_queues || v->num_queues > VIRTIO_QUEUE_MAX) {
|
||||||
|
+ error_setg(errp, "invalid number of virtqueues: %u (max:%u)",
|
||||||
|
+ v->num_queues, VIRTIO_QUEUE_MAX);
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ v->dev.nvqs = v->num_queues;
|
||||||
|
+ vqs = g_new0(struct vhost_virtqueue, v->dev.nvqs);
|
||||||
|
+ v->dev.vqs = vqs;
|
||||||
|
+ v->dev.vq_index = 0;
|
||||||
|
+ v->dev.vq_index_end = v->dev.nvqs;
|
||||||
|
+ v->dev.backend_features = 0;
|
||||||
|
+ v->started = false;
|
||||||
|
+
|
||||||
|
+ ret = vhost_dev_init(&v->dev, &v->vdpa, VHOST_BACKEND_TYPE_VDPA, 0, NULL);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ error_setg(errp, "vhost-vdpa-device: vhost initialization failed: %s",
|
||||||
|
+ strerror(-ret));
|
||||||
|
+ goto free_vqs;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ v->config_size = vhost_vdpa_device_get_u32(v->vhostfd,
|
||||||
|
+ VHOST_VDPA_GET_CONFIG_SIZE,
|
||||||
|
+ errp);
|
||||||
|
+ if (*errp) {
|
||||||
|
+ goto vhost_cleanup;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Invoke .post_init() to initialize the transport-specific fields
|
||||||
|
+ * before calling virtio_init().
|
||||||
|
+ */
|
||||||
|
+ if (v->post_init && v->post_init(v, errp) < 0) {
|
||||||
|
+ goto vhost_cleanup;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ v->config = g_malloc0(v->config_size);
|
||||||
|
+
|
||||||
|
+ ret = vhost_dev_get_config(&v->dev, v->config, v->config_size, NULL);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ error_setg(errp, "vhost-vdpa-device: get config failed");
|
||||||
|
+ goto free_config;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ virtio_init(vdev, "vhost-vdpa", v->vdev_id, v->config_size);
|
||||||
|
+
|
||||||
|
+ v->virtqs = g_new0(VirtQueue *, v->dev.nvqs);
|
||||||
|
+ for (i = 0; i < v->dev.nvqs; i++) {
|
||||||
|
+ v->virtqs[i] = virtio_add_queue(vdev, v->queue_size,
|
||||||
|
+ vhost_vdpa_device_dummy_handle_output);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+free_config:
|
||||||
|
+ g_free(v->config);
|
||||||
|
+vhost_cleanup:
|
||||||
|
+ vhost_dev_cleanup(&v->dev);
|
||||||
|
+free_vqs:
|
||||||
|
+ g_free(vqs);
|
||||||
|
+out:
|
||||||
|
+ qemu_close(v->vhostfd);
|
||||||
|
+ v->vhostfd = -1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_unrealize(DeviceState *dev)
|
||||||
|
+{
|
||||||
|
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ virtio_set_status(vdev, 0);
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < s->num_queues; i++) {
|
||||||
|
+ virtio_delete_queue(s->virtqs[i]);
|
||||||
|
+ }
|
||||||
|
+ g_free(s->virtqs);
|
||||||
|
+ virtio_cleanup(vdev);
|
||||||
|
+
|
||||||
|
+ g_free(s->config);
|
||||||
|
+ g_free(s->dev.vqs);
|
||||||
|
+ vhost_dev_cleanup(&s->dev);
|
||||||
|
+ qemu_close(s->vhostfd);
|
||||||
|
+ s->vhostfd = -1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+vhost_vdpa_device_get_config(VirtIODevice *vdev, uint8_t *config)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+
|
||||||
|
+ memcpy(config, s->config, s->config_size);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+vhost_vdpa_device_set_config(VirtIODevice *vdev, const uint8_t *config)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ ret = vhost_dev_set_config(&s->dev, s->config, 0, s->config_size,
|
||||||
|
+ VHOST_SET_CONFIG_TYPE_MASTER);
|
||||||
|
+ if (ret) {
|
||||||
|
+ error_report("set device config space failed");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static uint64_t vhost_vdpa_device_get_features(VirtIODevice *vdev,
|
||||||
|
+ uint64_t features,
|
||||||
|
+ Error **errp)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+ uint64_t backend_features = s->dev.features;
|
||||||
|
+
|
||||||
|
+ if (!virtio_has_feature(features, VIRTIO_F_IOMMU_PLATFORM)) {
|
||||||
|
+ virtio_clear_feature(&backend_features, VIRTIO_F_IOMMU_PLATFORM);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return backend_features;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int vhost_vdpa_device_start(VirtIODevice *vdev, Error **errp)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+ BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
||||||
|
+ VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
||||||
|
+ int i, ret;
|
||||||
|
+
|
||||||
|
+ if (!k->set_guest_notifiers) {
|
||||||
|
+ error_setg(errp, "binding does not support guest notifiers");
|
||||||
|
+ return -ENOSYS;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = vhost_dev_enable_notifiers(&s->dev, vdev);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ error_setg_errno(errp, -ret, "Error enabling host notifiers");
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, true);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ error_setg_errno(errp, -ret, "Error binding guest notifier");
|
||||||
|
+ goto err_host_notifiers;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ s->dev.acked_features = vdev->guest_features;
|
||||||
|
+
|
||||||
|
+ ret = vhost_dev_start(&s->dev, vdev);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ error_setg_errno(errp, -ret, "Error starting vhost");
|
||||||
|
+ goto err_guest_notifiers;
|
||||||
|
+ }
|
||||||
|
+ s->started = true;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * guest_notifier_mask/pending not used yet, so just unmask
|
||||||
|
+ * everything here. virtio-pci will do the right thing by
|
||||||
|
+ * enabling/disabling irqfd.
|
||||||
|
+ */
|
||||||
|
+ for (i = 0; i < s->dev.nvqs; i++) {
|
||||||
|
+ vhost_virtqueue_mask(&s->dev, vdev, i, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+err_guest_notifiers:
|
||||||
|
+ k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
|
||||||
|
+err_host_notifiers:
|
||||||
|
+ vhost_dev_disable_notifiers(&s->dev, vdev);
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_stop(VirtIODevice *vdev)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+ BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
||||||
|
+ VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ if (!s->started) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ s->started = false;
|
||||||
|
+
|
||||||
|
+ if (!k->set_guest_notifiers) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ vhost_dev_stop(&s->dev, vdev);
|
||||||
|
+
|
||||||
|
+ ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ error_report("vhost guest notifier cleanup failed: %d", ret);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ vhost_dev_disable_notifiers(&s->dev, vdev);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
|
||||||
|
+ bool should_start = virtio_device_started(vdev, status);
|
||||||
|
+ Error *local_err = NULL;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ if (!vdev->vm_running) {
|
||||||
|
+ should_start = false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (s->started == should_start) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (should_start) {
|
||||||
|
+ ret = vhost_vdpa_device_start(vdev, &local_err);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ error_reportf_err(local_err, "vhost-vdpa-device: start failed: ");
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ vhost_vdpa_device_stop(vdev);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static Property vhost_vdpa_device_properties[] = {
|
||||||
|
+ DEFINE_PROP_STRING("vhostdev", VhostVdpaDevice, vhostdev),
|
||||||
|
+ DEFINE_PROP_UINT16("queue-size", VhostVdpaDevice, queue_size, 0),
|
||||||
|
+ DEFINE_PROP_END_OF_LIST(),
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static const VMStateDescription vmstate_vhost_vdpa_device = {
|
||||||
|
+ .name = "vhost-vdpa-device",
|
||||||
|
+ .minimum_version_id = 1,
|
||||||
|
+ .version_id = 1,
|
||||||
|
+ .fields = (VMStateField[]) {
|
||||||
|
+ VMSTATE_VIRTIO_DEVICE,
|
||||||
|
+ VMSTATE_END_OF_LIST()
|
||||||
|
+ },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_class_init(ObjectClass *klass, void *data)
|
||||||
|
+{
|
||||||
|
+ DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
|
||||||
|
+
|
||||||
|
+ device_class_set_props(dc, vhost_vdpa_device_properties);
|
||||||
|
+ dc->desc = "VDPA-based generic device assignment";
|
||||||
|
+ dc->vmsd = &vmstate_vhost_vdpa_device;
|
||||||
|
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||||
|
+ vdc->realize = vhost_vdpa_device_realize;
|
||||||
|
+ vdc->unrealize = vhost_vdpa_device_unrealize;
|
||||||
|
+ vdc->get_config = vhost_vdpa_device_get_config;
|
||||||
|
+ vdc->set_config = vhost_vdpa_device_set_config;
|
||||||
|
+ vdc->get_features = vhost_vdpa_device_get_features;
|
||||||
|
+ vdc->set_status = vhost_vdpa_device_set_status;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void vhost_vdpa_device_instance_init(Object *obj)
|
||||||
|
+{
|
||||||
|
+ VhostVdpaDevice *s = VHOST_VDPA_DEVICE(obj);
|
||||||
|
+
|
||||||
|
+ device_add_bootindex_property(obj, &s->bootindex, "bootindex",
|
||||||
|
+ NULL, DEVICE(obj));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static const TypeInfo vhost_vdpa_device_info = {
|
||||||
|
+ .name = TYPE_VHOST_VDPA_DEVICE,
|
||||||
|
+ .parent = TYPE_VIRTIO_DEVICE,
|
||||||
|
+ .instance_size = sizeof(VhostVdpaDevice),
|
||||||
|
+ .class_init = vhost_vdpa_device_class_init,
|
||||||
|
+ .instance_init = vhost_vdpa_device_instance_init,
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void register_vhost_vdpa_device_type(void)
|
||||||
|
+{
|
||||||
|
+ type_register_static(&vhost_vdpa_device_info);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+type_init(register_vhost_vdpa_device_type);
|
||||||
|
diff --git a/include/hw/virtio/vdpa-dev.h b/include/hw/virtio/vdpa-dev.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..4dbf98195c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/include/hw/virtio/vdpa-dev.h
|
||||||
|
@@ -0,0 +1,43 @@
|
||||||
|
+/*
|
||||||
|
+ * Vhost Vdpa Device
|
||||||
|
+ *
|
||||||
|
+ * Copyright (c) Huawei Technologies Co., Ltd. 2022. All Rights Reserved.
|
||||||
|
+ *
|
||||||
|
+ * Authors:
|
||||||
|
+ * Longpeng <longpeng2@huawei.com>
|
||||||
|
+ *
|
||||||
|
+ * Largely based on the "vhost-user-blk.h" implemented by:
|
||||||
|
+ * Changpeng Liu <changpeng.liu@intel.com>
|
||||||
|
+ *
|
||||||
|
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
||||||
|
+ * See the COPYING.LIB file in the top-level directory.
|
||||||
|
+ */
|
||||||
|
+#ifndef _VHOST_VDPA_DEVICE_H
|
||||||
|
+#define _VHOST_VDPA_DEVICE_H
|
||||||
|
+
|
||||||
|
+#include "hw/virtio/vhost.h"
|
||||||
|
+#include "hw/virtio/vhost-vdpa.h"
|
||||||
|
+#include "qom/object.h"
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+#define TYPE_VHOST_VDPA_DEVICE "vhost-vdpa-device"
|
||||||
|
+OBJECT_DECLARE_SIMPLE_TYPE(VhostVdpaDevice, VHOST_VDPA_DEVICE)
|
||||||
|
+
|
||||||
|
+struct VhostVdpaDevice {
|
||||||
|
+ VirtIODevice parent_obj;
|
||||||
|
+ char *vhostdev;
|
||||||
|
+ int vhostfd;
|
||||||
|
+ int32_t bootindex;
|
||||||
|
+ uint32_t vdev_id;
|
||||||
|
+ uint32_t num_queues;
|
||||||
|
+ struct vhost_dev dev;
|
||||||
|
+ struct vhost_vdpa vdpa;
|
||||||
|
+ VirtQueue **virtqs;
|
||||||
|
+ uint8_t *config;
|
||||||
|
+ int config_size;
|
||||||
|
+ uint16_t queue_size;
|
||||||
|
+ bool started;
|
||||||
|
+ int (*post_init)(VhostVdpaDevice *v, Error **errp);
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+#endif
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
30
vdpa-dev-mark-the-device-as-unmigratable.patch
Normal file
30
vdpa-dev-mark-the-device-as-unmigratable.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From 90615553b0062b0c971cd1ce5b90aad4a9ea9b6a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Longpeng <longpeng2@huawei.com>
|
||||||
|
Date: Sat, 12 Nov 2022 22:40:12 +0800
|
||||||
|
Subject: [PATCH 5/7] vdpa-dev: mark the device as unmigratable
|
||||||
|
|
||||||
|
The generic vDPA device doesn't support migration currently, so
|
||||||
|
mark it as unmigratable temporarily.
|
||||||
|
|
||||||
|
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||||
|
Signed-off-by: Longpeng <longpeng2@huawei.com>
|
||||||
|
---
|
||||||
|
hw/virtio/vdpa-dev.c | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
|
||||||
|
index 42ab74c255..1840f0e450 100644
|
||||||
|
--- a/hw/virtio/vdpa-dev.c
|
||||||
|
+++ b/hw/virtio/vdpa-dev.c
|
||||||
|
@@ -327,6 +327,7 @@ static Property vhost_vdpa_device_properties[] = {
|
||||||
|
|
||||||
|
static const VMStateDescription vmstate_vhost_vdpa_device = {
|
||||||
|
.name = "vhost-vdpa-device",
|
||||||
|
+ .unmigratable = 1,
|
||||||
|
.minimum_version_id = 1,
|
||||||
|
.version_id = 1,
|
||||||
|
.fields = (VMStateField[]) {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
37
vfio-migration-Fix-incorrect-initialization-value-fo.patch
Normal file
37
vfio-migration-Fix-incorrect-initialization-value-fo.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
From d57f2527fd747d2b51ad18dc38fa9d0c25ebc8a7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Date: Mon, 11 Jul 2022 09:46:51 +0800
|
||||||
|
Subject: [PATCH 2/3] vfio/migration: Fix incorrect initialization value for
|
||||||
|
parameters in VFIOMigration
|
||||||
|
|
||||||
|
The structure VFIOMigration of a VFIODevice is allocated and initialized
|
||||||
|
in vfio_migration_init(). "device_state" and "vm_running" are initialized
|
||||||
|
to 0, indicating that VFIO device is_STOP and VM is not-running. The
|
||||||
|
initialization value is incorrect. According to the agreement, default
|
||||||
|
state of VFIO device is _RUNNING. And if a VFIO device is hot-plugged
|
||||||
|
while the VM is running, "vm_running" should be 1. This patch fixes it.
|
||||||
|
|
||||||
|
Fixes: 02a7e71b1e5b ("vfio: Add VM state change handler to know state of VM")
|
||||||
|
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
|
||||||
|
Link: https://lore.kernel.org/r/20220711014651.1327-1-jiangkunkun@huawei.com
|
||||||
|
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
|
||||||
|
---
|
||||||
|
hw/vfio/migration.c | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
|
||||||
|
index ff6b45de6b..e69b5f2e42 100644
|
||||||
|
--- a/hw/vfio/migration.c
|
||||||
|
+++ b/hw/vfio/migration.c
|
||||||
|
@@ -805,6 +805,8 @@ static int vfio_migration_init(VFIODevice *vbasedev,
|
||||||
|
}
|
||||||
|
|
||||||
|
vbasedev->migration = g_new0(VFIOMigration, 1);
|
||||||
|
+ vbasedev->migration->device_state = VFIO_DEVICE_STATE_RUNNING;
|
||||||
|
+ vbasedev->migration->vm_running = runstate_is_running();
|
||||||
|
|
||||||
|
ret = vfio_region_setup(obj, vbasedev, &vbasedev->migration->region,
|
||||||
|
info->index, "migration");
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
70
vhost-vdpa-add-memslot-getter-setter-for-vhost-vdpa.patch
Normal file
70
vhost-vdpa-add-memslot-getter-setter-for-vhost-vdpa.patch
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
From f32dbb81662b5c74d1a929ff8a58fec6a920a34a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pengyuan <zhaopengyuan@hisilicon.com>
|
||||||
|
Date: Mon, 7 Nov 2022 10:11:06 +0800
|
||||||
|
Subject: [PATCH 7/7] vhost-vdpa: add memslot getter/setter for vhost-vdpa
|
||||||
|
|
||||||
|
When vhost-vdpa is used as the virtio-net-pci backend on
|
||||||
|
the ARM64 platform, a null pointer access is triggered.
|
||||||
|
|
||||||
|
#0 0x0000000000000000 in ()
|
||||||
|
#1 0x0000aaaaab63bdcc in vhost_dev_used_memslots_is_exceeded (hdev=0xaaaaac632420) at ../hw/virtio/vhost.c:1341
|
||||||
|
#2 0x0000aaaaab63c420 in vhost_dev_init (hdev=0xaaaaac632420, opaque=0xfffff4321190, backend_type=VHOST_BACKEND_TYPE_VDPA, busyloop_timeout=0, errp=0xfffffffff210) at ../hw/virtio/vhost.c:1461
|
||||||
|
#3 0x0000aaaaab0d6ad8 in vhost_net_init (options=0xfffffffff290) at ../hw/net/vhost_net.c:247
|
||||||
|
#4 0x0000aaaaaaf05f40 in vhost_vdpa_add (ncs=0xfffff4321010, be=0xfffff4321190, queue_pair_index=0, nvqs=2) at ../net/vhost-vdpa.c:109
|
||||||
|
#5 0x0000aaaaaaf06358 in net_vhost_vdpa_init (peer=0x0, device=0xaaaaaba47140 "vhost-vdpa", name=0xaaaaac63a640 "vhost-vdpa0", vdpa_device_fd=12, queue_pair_index=0, nvqs=2, is_datapath=true) at ../net/vhost-vdpa.c:214
|
||||||
|
#6 0x0000aaaaaaf066ac in net_init_vhost_vdpa (netdev=0xaaaaac6322a0, name=0xaaaaac63a640 "vhost-vdpa0", peer=0x0, errp=0xaaaaac26ea20 <error_fatal>) at ../net/vhost-vdpa.c:291
|
||||||
|
#7 0x0000aaaaaaef7f94 in net_client_init1 (netdev=0xaaaaac6322a0, is_netdev=true, errp=0xaaaaac26ea20 <error_fatal>) at ../net/net.c:1064
|
||||||
|
#8 0x0000aaaaaaef8334 in net_client_init (opts=0xaaaaac32bf80, is_netdev=true, errp=0xaaaaac26ea20 <error_fatal>) at ../net/net.c:1162
|
||||||
|
#9 0x0000aaaaaaef90a4 in net_init_netdev (dummy=0x0, opts=0xaaaaac32bf80, errp=0xaaaaac26ea20 <error_fatal>) at ../net/net.c:1494
|
||||||
|
#10 0x0000aaaaab97aee0 in qemu_opts_foreach (list=0xaaaaac1038c0 <qemu_netdev_opts>, func=0xaaaaaaef9040 <net_init_netdev>, opaque=0x0, errp=0xaaaaac26ea20 <error_fatal>) at ../util/qemu-option.c:1135
|
||||||
|
#11 0x0000aaaaaaef93a4 in net_init_clients (errp=0xaaaaac26ea20 <error_fatal>) at ../net/net.c:1567
|
||||||
|
#12 0x0000aaaaab586f8c in qemu_create_late_backends () at ../softmmu/vl.c:2000
|
||||||
|
#13 0x0000aaaaab58b234 in qemu_init (argc=37, argv=0xfffffffff848, envp=0xfffffffff978) at ../softmmu/vl.c:3763
|
||||||
|
#14 0x0000aaaaaae1f7f8 in main (argc=37, argv=0xfffffffff848, envp=0xfffffffff978) at ../softmmu/main.c:50
|
||||||
|
|
||||||
|
Fixes: 185d7efe768 ("vhost-user: add separate memslot counter for vhost-user")
|
||||||
|
Signed-off-by:Pengyuan Zhao <zhaopengyuan@hisilicon.com>
|
||||||
|
---
|
||||||
|
hw/virtio/vhost-vdpa.c | 14 ++++++++++++++
|
||||||
|
1 file changed, 14 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
|
||||||
|
index bcaf00e09f..f285edb786 100644
|
||||||
|
--- a/hw/virtio/vhost-vdpa.c
|
||||||
|
+++ b/hw/virtio/vhost-vdpa.c
|
||||||
|
@@ -24,6 +24,8 @@
|
||||||
|
#include "trace.h"
|
||||||
|
#include "qemu-common.h"
|
||||||
|
|
||||||
|
+static unsigned int vhost_vdpa_used_memslots;
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Return one past the end of the end of section. Be careful with uint64_t
|
||||||
|
* conversions!
|
||||||
|
@@ -763,6 +765,16 @@ static bool vhost_vdpa_force_iommu(struct vhost_dev *dev)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void vhost_vdpa_set_used_memslots(struct vhost_dev *dev)
|
||||||
|
+{
|
||||||
|
+ vhost_vdpa_used_memslots = dev->mem->nregions;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static unsigned int vhost_vdpa_get_used_memslots(void)
|
||||||
|
+{
|
||||||
|
+ return vhost_vdpa_used_memslots;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
const VhostOps vdpa_ops = {
|
||||||
|
.backend_type = VHOST_BACKEND_TYPE_VDPA,
|
||||||
|
.vhost_backend_init = vhost_vdpa_init,
|
||||||
|
@@ -795,4 +807,6 @@ const VhostOps vdpa_ops = {
|
||||||
|
.vhost_get_device_id = vhost_vdpa_get_device_id,
|
||||||
|
.vhost_vq_get_addr = vhost_vdpa_vq_get_addr,
|
||||||
|
.vhost_force_iommu = vhost_vdpa_force_iommu,
|
||||||
|
+ .vhost_set_used_memslots = vhost_vdpa_set_used_memslots,
|
||||||
|
+ .vhost_get_used_memslots = vhost_vdpa_get_used_memslots,
|
||||||
|
};
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
156
virtio-get-class_id-and-pci-device-id-by-the-virtio-.patch
Normal file
156
virtio-get-class_id-and-pci-device-id-by-the-virtio-.patch
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
From 78f66113a2c3a01f0290a982f6901ba57516f47f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Longpeng <longpeng2@huawei.com>
|
||||||
|
Date: Sat, 12 Nov 2022 22:40:09 +0800
|
||||||
|
Subject: [PATCH 2/7] virtio: get class_id and pci device id by the virtio id
|
||||||
|
|
||||||
|
Add helpers to get the "Transitional PCI Device ID" and "class_id"
|
||||||
|
of the device specified by the "Virtio Device ID".
|
||||||
|
|
||||||
|
These helpers will be used to build the generic vDPA device later.
|
||||||
|
|
||||||
|
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||||
|
Signed-off-by: Longpeng <longpeng2@huawei.com>
|
||||||
|
---
|
||||||
|
hw/virtio/virtio-pci.c | 88 ++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
hw/virtio/virtio-pci.h | 5 +++
|
||||||
|
2 files changed, 93 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
|
||||||
|
index 38a5dc1ba8..21c0ec3b1b 100644
|
||||||
|
--- a/hw/virtio/virtio-pci.c
|
||||||
|
+++ b/hw/virtio/virtio-pci.c
|
||||||
|
@@ -19,6 +19,7 @@
|
||||||
|
|
||||||
|
#include "exec/memop.h"
|
||||||
|
#include "standard-headers/linux/virtio_pci.h"
|
||||||
|
+#include "standard-headers/linux/virtio_ids.h"
|
||||||
|
#include "hw/boards.h"
|
||||||
|
#include "hw/virtio/virtio.h"
|
||||||
|
#include "migration/qemu-file-types.h"
|
||||||
|
@@ -213,6 +214,90 @@ static int virtio_pci_load_queue(DeviceState *d, int n, QEMUFile *f)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+typedef struct VirtIOPCIIDInfo {
|
||||||
|
+ /* virtio id */
|
||||||
|
+ uint16_t vdev_id;
|
||||||
|
+ /* pci device id for the transitional device */
|
||||||
|
+ uint16_t trans_devid;
|
||||||
|
+ uint16_t class_id;
|
||||||
|
+} VirtIOPCIIDInfo;
|
||||||
|
+
|
||||||
|
+static const VirtIOPCIIDInfo virtio_pci_id_info[] = {
|
||||||
|
+ {
|
||||||
|
+ .vdev_id = VIRTIO_ID_CRYPTO,
|
||||||
|
+ .class_id = PCI_CLASS_OTHERS,
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_FS,
|
||||||
|
+ .class_id = PCI_CLASS_STORAGE_OTHER,
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_NET,
|
||||||
|
+ .trans_devid = PCI_DEVICE_ID_VIRTIO_NET,
|
||||||
|
+ .class_id = PCI_CLASS_NETWORK_ETHERNET,
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_BLOCK,
|
||||||
|
+ .trans_devid = PCI_DEVICE_ID_VIRTIO_BLOCK,
|
||||||
|
+ .class_id = PCI_CLASS_STORAGE_SCSI,
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_CONSOLE,
|
||||||
|
+ .trans_devid = PCI_DEVICE_ID_VIRTIO_CONSOLE,
|
||||||
|
+ .class_id = PCI_CLASS_COMMUNICATION_OTHER,
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_SCSI,
|
||||||
|
+ .trans_devid = PCI_DEVICE_ID_VIRTIO_SCSI,
|
||||||
|
+ .class_id = PCI_CLASS_STORAGE_SCSI
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_9P,
|
||||||
|
+ .trans_devid = PCI_DEVICE_ID_VIRTIO_9P,
|
||||||
|
+ .class_id = PCI_BASE_CLASS_NETWORK,
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_BALLOON,
|
||||||
|
+ .trans_devid = PCI_DEVICE_ID_VIRTIO_BALLOON,
|
||||||
|
+ .class_id = PCI_CLASS_OTHERS,
|
||||||
|
+ }, {
|
||||||
|
+ .vdev_id = VIRTIO_ID_RNG,
|
||||||
|
+ .trans_devid = PCI_DEVICE_ID_VIRTIO_RNG,
|
||||||
|
+ .class_id = PCI_CLASS_OTHERS,
|
||||||
|
+ },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static const VirtIOPCIIDInfo *virtio_pci_get_id_info(uint16_t vdev_id)
|
||||||
|
+{
|
||||||
|
+ const VirtIOPCIIDInfo *info = NULL;
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < ARRAY_SIZE(virtio_pci_id_info); i++) {
|
||||||
|
+ if (virtio_pci_id_info[i].vdev_id == vdev_id) {
|
||||||
|
+ info = &virtio_pci_id_info[i];
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!info) {
|
||||||
|
+ /* The device id is invalid or not added to the id_info yet. */
|
||||||
|
+ error_report("Invalid virtio device(id %u)", vdev_id);
|
||||||
|
+ abort();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return info;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Get the Transitional Device ID for the specific device, return
|
||||||
|
+ * zero if the device is non-transitional.
|
||||||
|
+ */
|
||||||
|
+uint16_t virtio_pci_get_trans_devid(uint16_t device_id)
|
||||||
|
+{
|
||||||
|
+ return virtio_pci_get_id_info(device_id)->trans_devid;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Get the Class ID for the specific device.
|
||||||
|
+ */
|
||||||
|
+uint16_t virtio_pci_get_class_id(uint16_t device_id)
|
||||||
|
+{
|
||||||
|
+ return virtio_pci_get_id_info(device_id)->class_id;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static bool virtio_pci_ioeventfd_enabled(DeviceState *d)
|
||||||
|
{
|
||||||
|
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
|
||||||
|
@@ -1674,6 +1759,9 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
|
||||||
|
* is set to PCI_SUBVENDOR_ID_REDHAT_QUMRANET by default.
|
||||||
|
*/
|
||||||
|
pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus));
|
||||||
|
+ if (proxy->trans_devid) {
|
||||||
|
+ pci_config_set_device_id(config, proxy->trans_devid);
|
||||||
|
+ }
|
||||||
|
} else {
|
||||||
|
/* pure virtio-1.0 */
|
||||||
|
pci_set_word(config + PCI_VENDOR_ID,
|
||||||
|
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
|
||||||
|
index 2446dcd9ae..d95b1a13a5 100644
|
||||||
|
--- a/hw/virtio/virtio-pci.h
|
||||||
|
+++ b/hw/virtio/virtio-pci.h
|
||||||
|
@@ -146,6 +146,8 @@ struct VirtIOPCIProxy {
|
||||||
|
bool disable_modern;
|
||||||
|
bool ignore_backend_features;
|
||||||
|
OnOffAuto disable_legacy;
|
||||||
|
+ /* Transitional device id */
|
||||||
|
+ uint16_t trans_devid;
|
||||||
|
uint32_t class_code;
|
||||||
|
uint32_t nvectors;
|
||||||
|
uint32_t dfselect;
|
||||||
|
@@ -179,6 +181,9 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy)
|
||||||
|
proxy->disable_modern = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
+uint16_t virtio_pci_get_trans_devid(uint16_t device_id);
|
||||||
|
+uint16_t virtio_pci_get_class_id(uint16_t device_id);
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* virtio-input-pci: This extends VirtioPCIProxy.
|
||||||
|
*/
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
45
virtio-mem-Don-t-skip-alignment-checks-when-warning-.patch
Normal file
45
virtio-mem-Don-t-skip-alignment-checks-when-warning-.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From d319f43f223df53ed5c9c13c5b60caaa1b952c35 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Wed, 23 Nov 2022 06:26:18 +0000
|
||||||
|
Subject: [PATCH 08/29] virtio-mem: Don't skip alignment checks when warning
|
||||||
|
about block size mainline inclusion commit
|
||||||
|
7656d9ce09cb1d6d76eeb2081f164a920361d1d3 category: bugfix
|
||||||
|
|
||||||
|
---------------------------------------------------------------
|
||||||
|
|
||||||
|
If we warn about the block size being smaller than the default, we skip
|
||||||
|
some alignment checks.
|
||||||
|
|
||||||
|
This can currently only fail on x86-64, when specifying a block size of
|
||||||
|
1 MiB, however, we detect the THP size of 2 MiB.
|
||||||
|
|
||||||
|
Fixes: 228957fea3a9 ("virtio-mem: Probe THP size to determine default block size")
|
||||||
|
Cc: "Michael S. Tsirkin" <mst@redhat.com>
|
||||||
|
Signed-off-by: David Hildenbrand <david@redhat.com>
|
||||||
|
Message-Id: <20211011173305.13778-1-david@redhat.com>
|
||||||
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||||
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||||
|
|
||||||
|
|
||||||
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||||||
|
---
|
||||||
|
hw/virtio/virtio-mem.c | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
|
||||||
|
index d5a578142b..341c3fa2c1 100644
|
||||||
|
--- a/hw/virtio/virtio-mem.c
|
||||||
|
+++ b/hw/virtio/virtio-mem.c
|
||||||
|
@@ -733,7 +733,8 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
|
||||||
|
warn_report("'%s' property is smaller than the default block size (%"
|
||||||
|
PRIx64 " MiB)", VIRTIO_MEM_BLOCK_SIZE_PROP,
|
||||||
|
virtio_mem_default_block_size(rb) / MiB);
|
||||||
|
- } else if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
|
||||||
|
+ }
|
||||||
|
+ if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) {
|
||||||
|
error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" PRIx64
|
||||||
|
")", VIRTIO_MEM_REQUESTED_SIZE_PROP,
|
||||||
|
VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user