Skip to contentSkip to conversation

pc,pci,virtio: features, fixes, tests

GIT PULL Applied Michael S. Tsirkin 4 participants 48 messages Oct 20, 2021 – Oct 26, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit 50352cce138ef3b30c1cda28a4df68fff5da3202:

Merge remote-tracking branch 'remotes/juanquintela/tags/migration.next-pull-request' into staging (2021-10-19 07:41:04 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a8339e07f94a47f99560baef59d65a9e039aaf45:

tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test (2021-10-20 06:18:17 -0400)

----------------------------------------------------------------
pc,pci,virtio: features, fixes, tests

vhost user rng
vdpa multiqueue
Fixes, cleanups, new tests all over the place.

----------------------------------------------------------------
Ani Sinha (3):
tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35 tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test

David Hildenbrand (1):
libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr

Eric Auger (2):
virtio-iommu: Remove the non transitional name
virtio-iommu: Drop base_name and change generic_name

Eugenio Pérez (3):
vdpa: Skip protected ram IOMMU mappings
vdpa: Add vhost_vdpa_section_end
vdpa: Check for iova range at mappings changes

Igor Mammedov (15):
tests: acpi: dump table with failed checksum
tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator
tests: acpi: whitelist expected tables for acpi/q35/xapic testcase
tests: acpi: q35: test for x2APIC entries in SRAT
tests: acpi: update expected tables blobs
tests: acpi: whitelist new expected table tests/data/acpi/q35/DMAR.dmar
tests: acpi: add testcase for intel_iommu (DMAR table)
tests: acpi: add expected blob for DMAR table
tests: acpi: whitelist expected blobs for new acpi/q35/ivrs testcase
tests: acpi: add testcase for amd-iommu (IVRS table)
tests: acpi: update expected blobs
tests: acpi: arm/virt: drop redundant test_acpi_one() in test_acpi_virt_tcg()
tests: arm-cpu-features: use qtest_has_kvm() API
tests: migration-test: use qtest_has_accel() API
tests: bios-tables-test: use qtest_has_accel() API to register TCG only tests

Jason Wang (10):
vhost-vdpa: open device fd in net_init_vhost_vdpa()
vhost-vdpa: classify one time request
vhost-vdpa: prepare for the multiqueue support
vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState *
net: introduce control client
vhost-net: control virtqueue support
virtio-net: use "queue_pairs" instead of "queues" when possible
vhost: record the last virtqueue index for the virtio device
virtio-net: vhost control virtqueue support
vhost-vdpa: multiqueue support

Laurent Vivier (2):
failover: fix a regression introduced by JSON'ification of -device qdev/qbus: remove failover specific code

Mathieu Poirier (3):
vhost-user-rng: Add vhost-user-rng implementation
vhost-user-rng-pci: Add vhost-user-rng-pci implementation
docs: Add documentation for vhost based RNG implementation

Michael S. Tsirkin (3):
rebuild-expected-aml.sh: allow partial target list
bios-tables-test: don't disassemble empty files
pci: fix PCI resource reserve capability on BE

Stefan Hajnoczi (1):
vhost-user-blk-test: pass vhost-user socket fds to QSD

Xueming Li (1):
vhost-user: fix duplicated notifier MR init

 include/hw/virtio/vhost-user-rng.h        |  33 ++++
 include/hw/virtio/vhost-vdpa.h            |   3 +
 include/hw/virtio/vhost.h                 |   2 +
 include/hw/virtio/virtio-iommu.h          |   2 +-
 include/hw/virtio/virtio-net.h            |   5 +-
 include/net/net.h                         |   5 +
 include/net/vhost_net.h                   |   6 +-
 tests/qtest/libqos/libqtest.h             |   8 +
 hw/net/vhost_net-stub.c                   |   4 +-
 hw/net/vhost_net.c                        |  55 ++++--
 hw/net/virtio-net.c                       | 201 ++++++++++++---------
 hw/pci/pci_bridge.c                       |  10 +-
 hw/virtio/vhost-user-rng-pci.c            |  79 ++++++++
 hw/virtio/vhost-user-rng.c                | 289 ++++++++++++++++++++++++++++++
 hw/virtio/vhost-user.c                    |   5 +-
 hw/virtio/vhost-vdpa.c                    | 140 ++++++++++++---
 hw/virtio/virtio-iommu-pci.c              |   4 +-
 net/net.c                                 |  24 ++-
 net/vhost-vdpa.c                          | 127 +++++++++++--
 softmmu/qdev-monitor.c                    |  18 +-
 subprojects/libvhost-user/libvhost-user.c |   1 +
 tests/qtest/acpi-utils.c                  |  14 ++
 tests/qtest/arm-cpu-features.c            |  29 +--
 tests/qtest/bios-tables-test.c            | 122 ++++++++++---
 tests/qtest/libqtest.c                    |  27 +++
 tests/qtest/migration-test.c              |  15 +-
 tests/qtest/vhost-user-blk-test.c         |   4 +-
 docs/system/device-emulation.rst          |   1 +
 docs/system/devices/vhost-user-rng.rst    |  39 ++++
 hw/virtio/Kconfig                         |   5 +
 hw/virtio/meson.build                     |   2 +
 hw/virtio/trace-events                    |   1 +
 meson.build                               |   6 +
 tests/data/acpi/q35/APIC.xapic            | Bin 0 -> 2686 bytes
 tests/data/acpi/q35/DMAR.dmar             | Bin 0 -> 120 bytes
 tests/data/acpi/q35/DSDT.ivrs             | Bin 0 -> 8306 bytes
 tests/data/acpi/q35/DSDT.multi-bridge     | Bin 0 -> 8583 bytes
 tests/data/acpi/q35/DSDT.xapic            | Bin 0 -> 35652 bytes
 tests/data/acpi/q35/FACP.xapic            | Bin 0 -> 244 bytes
 tests/data/acpi/q35/IVRS.ivrs             | Bin 0 -> 104 bytes
 tests/data/acpi/q35/SRAT.xapic            | Bin 0 -> 5080 bytes
 tests/data/acpi/rebuild-expected-aml.sh   |  22 ++-
 42 files changed, 1075 insertions(+), 233 deletions(-)
 create mode 100644 include/hw/virtio/vhost-user-rng.h
 create mode 100644 hw/virtio/vhost-user-rng-pci.c
 create mode 100644 hw/virtio/vhost-user-rng.c
 create mode 100644 docs/system/devices/vhost-user-rng.rst
 create mode 100644 tests/data/acpi/q35/APIC.xapic
 create mode 100644 tests/data/acpi/q35/DMAR.dmar
 create mode 100644 tests/data/acpi/q35/DSDT.ivrs
 create mode 100644 tests/data/acpi/q35/DSDT.multi-bridge
 create mode 100644 tests/data/acpi/q35/DSDT.xapic
 create mode 100644 tests/data/acpi/q35/FACP.xapic
 create mode 100644 tests/data/acpi/q35/IVRS.ivrs
 create mode 100644 tests/data/acpi/q35/SRAT.xapic
#1 lore raw

[PULL v2 01/44] tests: acpi: dump table with failed checksum

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/acpi-utils.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tests/qtest/acpi-utils.c +14 -0
index d2a202efca..766c48e3a6 100644
@@ -98,6 +98,20 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
         ACPI_ASSERT_CMP(**aml, sig);
     }
     if (verify_checksum) {
+        if (acpi_calc_checksum(*aml, *aml_len)) {
+            gint fd, ret;
+            char *fname = NULL;
+            GError *error = NULL;
+
+            fprintf(stderr, "Invalid '%.4s'(%d)\n", *aml, *aml_len);
+            fd = g_file_open_tmp("malformed-XXXXXX.dat", &fname, &error);
+            g_assert_no_error(error);
+            fprintf(stderr, "Dumping invalid table into '%s'\n", fname);
+            ret = qemu_write_full(fd, *aml, *aml_len);
+            g_assert(ret == *aml_len);
+            close(fd);
+            g_free(fname);
+        }
         g_assert(!acpi_calc_checksum(*aml, *aml_len));
     }
 }
Signature · 1 line
MST
#2 lore raw

[PULL v2 05/44] tests: acpi: update expected tables blobs

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Update adds CPU entries to MADT/SRAT/FACP and DSDT to cover 288 CPUs. Notable changes are that CPUs with APIC ID 255 and higher use 'Processor Local x2APIC Affinity' structure in SRAT and "Device" element in DSDT.

FACP:
- Use APIC Cluster Model (V4) : 0
+ Use APIC Cluster Model (V4) : 1

SRAT:
...
+[1010h 4112 1] Subtable Type : 00 [Processor Local APIC/SAPIC Affinity]
+[1011h 4113 1] Length : 10
+

+[1012h 4114   1]      Proximity Domain Low(8) : 00
+[1013h 4115   1]                      Apic ID : FE
+[1014h 4116   4]        Flags (decoded below) : 00000001
+                                     Enabled : 1
+[1018h 4120   1]              Local Sapic EID : 00
+[1019h 4121   3]    Proximity Domain High(24) : 000000
+[101Ch 4124   4]                 Clock Domain : 00000000

+
+[1020h 4128 1] Subtable Type : 02 [Processor Local x2APIC Affinity]
+[1021h 4129 1] Length : 18
+

+[1022h 4130   2]                    Reserved1 : 0000
+[1024h 4132   4]             Proximity Domain : 00000001
+[1028h 4136   4]                      Apic ID : 000000FF
+[102Ch 4140   4]        Flags (decoded below) : 00000001

+ Enabled : 1
+[1030h 4144 4] Clock Domain : 00000000
+[1034h 4148 4] Reserved2 : 00000000

...

+[1320h 4896 1] Subtable Type : 02 [Processor Local x2APIC Affinity]
+[1321h 4897 1] Length : 18
+

+[1322h 4898   2]                    Reserved1 : 0000
+[1324h 4900   4]             Proximity Domain : 00000001
+[1328h 4904   4]                      Apic ID : 0000011F
+[132Ch 4908   4]        Flags (decoded below) : 00000001

+ Enabled : 1
+[1330h 4912 4] Clock Domain : 00000000
+[1334h 4916 4] Reserved2 : 00000000

DSDT:

...
+ Processor (C0FE, 0xFE, 0x00000000, 0x00)
+ {
...
+ }
+
+ Device (C0FF)
+ {
+ Name (_HID, "ACPI0007" /* Processor Device */) // _HID: Hardware ID
+ Name (_UID, 0xFF) // _UID: Unique ID
...
+ }

+ Device (C11F)
+ {
+ Name (_HID, "ACPI0007" /* Processor Device */) // _HID: Hardware ID
+ Name (_UID, 0x011F) // _UID: Unique ID
...
+ }

APIC:

+[034h 0052   1]                Subtable Type : 00 [Processor Local APIC]
+[035h 0053   1]                       Length : 08
+[036h 0054   1]                 Processor ID : 01
+[037h 0055   1]                Local Apic ID : 01
+[038h 0056   4]        Flags (decoded below) : 00000000

+ Processor Enabled : 0

...

+[81Ch 2076   1]                Subtable Type : 00 [Processor Local APIC]
+[81Dh 2077   1]                       Length : 08
+[81Eh 2078   1]                 Processor ID : FE
+[81Fh 2079   1]                Local Apic ID : FE
+[820h 2080   4]        Flags (decoded below) : 00000000
+                           Processor Enabled : 0
+
+[824h 2084   1]                Subtable Type : 09 [Processor Local x2APIC]
+[825h 2085   1]                       Length : 10
+[826h 2086   2]                     Reserved : 0000
+[828h 2088   4]          Processor x2Apic ID : 000000FF
+[82Ch 2092   4]        Flags (decoded below) : 00000000

+ Processor Enabled : 0
+[830h 2096 4] Processor UID : 000000FF

...

+[A24h 2596   1]                Subtable Type : 09 [Processor Local x2APIC]
+[A25h 2597   1]                       Length : 10
+[A26h 2598   2]                     Reserved : 0000
+[A28h 2600   4]          Processor x2Apic ID : 0000011F
+[A2Ch 2604   4]        Flags (decoded below) : 00000000
+                           Processor Enabled : 0
+[A30h 2608   4]                Processor UID : 0000011F
+
+[A34h 2612   1]                Subtable Type : 01 [I/O APIC]
+[A35h 2613   1]                       Length : 0C
+[A36h 2614   1]                  I/O Apic ID : 00
+[A37h 2615   1]                     Reserved : 00
+[A38h 2616   4]                      Address : FEC00000
+[A3Ch 2620   4]                    Interrupt : 00000000
+
+[A40h 2624   1]                Subtable Type : 02 [Interrupt Source Override]
+[A41h 2625   1]                       Length : 0A
+[A42h 2626   1]                          Bus : 00
+[A43h 2627   1]                       Source : 00
+[A44h 2628   4]                    Interrupt : 00000002
+[A48h 2632   2]        Flags (decoded below) : 0000

Polarity : 0
Trigger Mode : 0

-[04Ah 0074   1]                Subtable Type : 02 [Interrupt Source Override]
-[04Bh 0075   1]                       Length : 0A
-[04Ch 0076   1]                          Bus : 00
-[04Dh 0077   1]                       Source : 05
-[04Eh 0078   4]                    Interrupt : 00000005
-[052h 0082   2]        Flags (decoded below) : 000D
+[A4Ah 2634   1]                Subtable Type : 02 [Interrupt Source Override]
+[A4Bh 2635   1]                       Length : 0A
+[A4Ch 2636   1]                          Bus : 00
+[A4Dh 2637   1]                       Source : 05
+[A4Eh 2638   4]                    Interrupt : 00000005
+[A52h 2642   2]        Flags (decoded below) : 000D

Polarity : 1
Trigger Mode : 3

-[054h 0084   1]                Subtable Type : 02 [Interrupt Source Override]
-[055h 0085   1]                       Length : 0A
-[056h 0086   1]                          Bus : 00
-[057h 0087   1]                       Source : 09
-[058h 0088   4]                    Interrupt : 00000009
-[05Ch 0092   2]        Flags (decoded below) : 000D
+[A54h 2644   1]                Subtable Type : 02 [Interrupt Source Override]
+[A55h 2645   1]                       Length : 0A
+[A56h 2646   1]                          Bus : 00
+[A57h 2647   1]                       Source : 09
+[A58h 2648   4]                    Interrupt : 00000009
+[A5Ch 2652   2]        Flags (decoded below) : 000D

Polarity : 1
Trigger Mode : 3

-[05Eh 0094   1]                Subtable Type : 02 [Interrupt Source Override]
-[05Fh 0095   1]                       Length : 0A
-[060h 0096   1]                          Bus : 00
-[061h 0097   1]                       Source : 0A
-[062h 0098   4]                    Interrupt : 0000000A
-[066h 0102   2]        Flags (decoded below) : 000D
+[A5Eh 2654   1]                Subtable Type : 02 [Interrupt Source Override]
+[A5Fh 2655   1]                       Length : 0A
+[A60h 2656   1]                          Bus : 00
+[A61h 2657   1]                       Source : 0A
+[A62h 2658   4]                    Interrupt : 0000000A
+[A66h 2662   2]        Flags (decoded below) : 000D

Polarity : 1
Trigger Mode : 3

-[068h 0104   1]                Subtable Type : 02 [Interrupt Source Override]
-[069h 0105   1]                       Length : 0A
-[06Ah 0106   1]                          Bus : 00
-[06Bh 0107   1]                       Source : 0B
-[06Ch 0108   4]                    Interrupt : 0000000B
-[070h 0112   2]        Flags (decoded below) : 000D
+[A68h 2664   1]                Subtable Type : 02 [Interrupt Source Override]
+[A69h 2665   1]                       Length : 0A
+[A6Ah 2666   1]                          Bus : 00
+[A6Bh 2667   1]                       Source : 0B
+[A6Ch 2668   4]                    Interrupt : 0000000B
+[A70h 2672   2]        Flags (decoded below) : 000D

Polarity : 1
Trigger Mode : 3

-[072h 0114   1]                Subtable Type : 04 [Local APIC NMI]
-[073h 0115   1]                       Length : 06
-[074h 0116   1]                 Processor ID : FF
-[075h 0117   2]        Flags (decoded below) : 0000
+[A72h 2674   1]                Subtable Type : 0A [Local x2APIC NMI]
+[A73h 2675   1]                       Length : 0C
+[A74h 2676   2]        Flags (decoded below) : 0000
                                     Polarity : 0
                                 Trigger Mode : 0
-[077h 0119   1]         Interrupt Input LINT : 01
+[A76h 2678   4]                Processor UID : FFFFFFFF
+[A7Ah 2682   1]         Interrupt Input LINT : 01
+[A7Bh 2683   3]                     Reserved : 000000

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h |   4 ----
 tests/data/acpi/q35/APIC.xapic              | Bin 0 -> 2686 bytes
 tests/data/acpi/q35/DSDT.xapic              | Bin 0 -> 35652 bytes
 tests/data/acpi/q35/FACP.xapic              | Bin 0 -> 244 bytes
 tests/data/acpi/q35/SRAT.xapic              | Bin 0 -> 5080 bytes
 5 files changed, 4 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
index 344eee3acc..dfb8523c8b 100644
@@ -1,5 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.xapic",
-"tests/data/acpi/q35/SRAT.xapic",
-"tests/data/acpi/q35/FACP.xapic",
-"tests/data/acpi/q35/APIC.xapic",
tests/data/acpi/q35/APIC.xapic binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c1969c35aa12b61d25e0134bbb8d2187ba42d663 100644
GIT binary patch
tests/data/acpi/q35/DSDT.xapic binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..119fc90f1f8a7b6934df6fd95609446e627ce15d 100644
GIT binary patch
tests/data/acpi/q35/FACP.xapic binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2d3659c9c6753d07c3d48742343cb8e8cc034de7 100644
GIT binary patch
tests/data/acpi/q35/SRAT.xapic binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1a91cfa65fdbebe1756d63d80022c2af767e5d3f 100644
GIT binary patch
Signature · 1 line
MST
#3 lore raw

[PULL v2 04/44] tests: acpi: q35: test for x2APIC entries in SRAT

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Set -smp 1,maxcpus=288 to test for ACPI code that deal with CPUs with large APIC ID (>255).

PS:
Test requires KVM and in-kernel irqchip support, so skip test if KVM is not available.

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tests/qtest/bios-tables-test.c +17 -0
index 4f11d03055..87a94a59fa 100644
@@ -1033,6 +1033,19 @@ static void test_acpi_q35_tcg_numamem(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_kvm_xapic(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_Q35;
+    data.variant = ".xapic";
+    test_acpi_one(" -object memory-backend-ram,id=ram0,size=128M"
+                  " -numa node -numa node,memdev=ram0"
+                  " -machine kernel-irqchip=on -smp 1,maxcpus=288", &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_q35_tcg_nosmm(void)
 {
     test_data data;
@@ -1509,6 +1522,7 @@ static void test_acpi_oem_fields_virt(void)
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
+    const bool has_kvm = qtest_has_accel("kvm");
     int ret;
 
     g_test_init(&argc, &argv, NULL);
@@ -1567,6 +1581,9 @@ int main(int argc, char *argv[])
         if (strcmp(arch, "x86_64") == 0) {
             qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie_tcg);
         }
+        if (has_kvm) {
+            qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xapic);
+        }
     } else if (strcmp(arch, "aarch64") == 0) {
         qtest_add_func("acpi/virt", test_acpi_virt_tcg);
         qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
Signature · 1 line
MST
#4 lore raw

[PULL v2 02/44] tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Currently it is not possible to create tests that have KVM as a hard requirement on a host that doesn't support KVM for tested target binary (modulo going through the trouble of compiling out the offending test case).

Following scenario makes test fail when it's run on non x86 host:
qemu-system-x86_64 -enable-kvm -M q35,kernel-irqchip=on -smp 1,maxcpus=288

This patch introduces qtest_has_accel() to let users check if accel is available in advance and avoid executing non run-able test-cases.

It implements detection of TCG and KVM only, the rest could be added later on, when we actually start testing them in qtest.

Message-Id: <[email protected]>

---
 tests/qtest/libqos/libqtest.h |  8 ++++++++
 tests/qtest/libqtest.c        | 27 +++++++++++++++++++++++++++
 meson.build                   |  6 ++++++
 3 files changed, 41 insertions(+)
tests/qtest/libqos/libqtest.h +8 -0
index a68dcd79d4..59e9271195 100644
@@ -588,6 +588,14 @@ bool qtest_big_endian(QTestState *s);
  */
 const char *qtest_get_arch(void);
 
+/**
+ * qtest_has_accel:
+ * @accel_name: Accelerator name to check for.
+ *
+ * Returns: true if the accelerator is built in.
+ */
+bool qtest_has_accel(const char *accel_name);
+
 /**
  * qtest_add_func:
  * @str: Test case path.
tests/qtest/libqtest.c +27 -0
index 73f6b977a6..25aeea385b 100644
@@ -922,6 +922,33 @@ const char *qtest_get_arch(void)
     return end + 1;
 }
 
+bool qtest_has_accel(const char *accel_name)
+{
+    if (g_str_equal(accel_name, "tcg")) {
+#if defined(CONFIG_TCG)
+        return true;
+#else
+        return false;
+#endif
+    } else if (g_str_equal(accel_name, "kvm")) {
+        int i;
+        const char *arch = qtest_get_arch();
+        const char *targets[] = { CONFIG_KVM_TARGETS };
+
+        for (i = 0; i < ARRAY_SIZE(targets); i++) {
+            if (!strncmp(targets[i], arch, strlen(arch))) {
+                if (!access("/dev/kvm", R_OK | W_OK)) {
+                    return true;
+                }
+            }
+        }
+    } else {
+        /* not implemented */
+        g_assert_not_reached();
+    }
+    return false;
+}
+
 bool qtest_get_irq(QTestState *s, int num)
 {
     /* dummy operation in order to make sure irq is up to date */
meson.build +6 -0
index 9ed9a993e2..2c5b53cbe2 100644
@@ -75,6 +75,12 @@ else
   kvm_targets = []
 endif
 
+kvm_targets_c = ''
+if not get_option('kvm').disabled() and targetos == 'linux'
+  kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
+endif
+config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
+
 accelerator_targets = { 'CONFIG_KVM': kvm_targets }
 
 if cpu in ['aarch64']
Signature · 1 line
MST
#5 lore raw

Re: [PULL v2 02/44] tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator

Quoted 58 lines · Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Currently it is not possible to create tests that have KVM as a hard requirement on a host that doesn't support KVM for tested target binary (modulo going through the trouble of compiling out the offending test case).

Following scenario makes test fail when it's run on non x86 host:
qemu-system-x86_64 -enable-kvm -M q35,kernel-irqchip=on -smp 1,maxcpus=288

This patch introduces qtest_has_accel() to let users check if accel is available in advance and avoid executing non run-able test-cases.

It implements detection of TCG and KVM only, the rest could be added later on, when we actually start testing them in qtest.

Message-Id: <[email protected]>

---
 tests/qtest/libqos/libqtest.h |  8 ++++++++
 tests/qtest/libqtest.c        | 27 +++++++++++++++++++++++++++
 meson.build                   |  6 ++++++
 3 files changed, 41 insertions(+)
tests/qtest/libqos/libqtest.h +8 -0
index a68dcd79d4..59e9271195 100644
@@ -588,6 +588,14 @@ bool qtest_big_endian(QTestState *s);
  */
 const char *qtest_get_arch(void);
 
+/**
+ * qtest_has_accel:
+ * @accel_name: Accelerator name to check for.
+ *
+ * Returns: true if the accelerator is built in.
+ */
+bool qtest_has_accel(const char *accel_name);
+
 /**
  * qtest_add_func:
  * @str: Test case path.
tests/qtest/libqtest.c +4 -0
index 73f6b977a6..25aeea385b 100644
@@ -922,6 +922,33 @@ const char *qtest_get_arch(void)
     return end + 1;
 }
 
+bool qtest_has_accel(const char *accel_name)
+{
+    if (g_str_equal(accel_name, "tcg")) {
+#if defined(CONFIG_TCG)

tests/qtest/libqtest.c const char *qtest_get_arch(void) · line 938

Quoted 10 lines
tests/qtest/libqtest.c +10 -0
+        return true;
+#else
+        return false;
+#endif
+    } else if (g_str_equal(accel_name, "kvm")) {
+        int i;
+        const char *arch = qtest_get_arch();
+        const char *targets[] = { CONFIG_KVM_TARGETS };
+
+        for (i = 0; i < ARRAY_SIZE(targets); i++) {

A xen osstest build fails with:
../qemu-xen-dir-remote/tests/qtest/libqtest.c: In function 'qtest_has_accel':
../qemu-xen-dir-remote/tests/qtest/libqtest.c:938:23: error:
comparison of unsigned expression < 0 is always false [-Werror=type-limits]

         for (i = 0; i < ARRAY_SIZE(targets); i++) {
                       ^

Super long osstest log here:http://logs.test-lab.xenproject.org/osstest/logs/165703/build-i386-xsm/6.ts-xen-build.log

It was configured like:
$source/configure --enable-xen --target-list=i386-softmmu \
--enable-debug \
--enable-trace-backend=log \
--prefix=/usr/local \
--libdir=/usr/local/lib/xen/lib \
--includedir=/usr/local/lib/xen/include \
--extra-cflags="-DXC_WANT_COMPAT_EVTCHN_API=1 \
-DXC_WANT_COMPAT_GNTTAB_API=1 \
-DXC_WANT_COMPAT_MAP_FOREIGN_API=1 \
-DXC_WANT_COMPAT_DEVICEMODEL_API=1 \
" \
--extra-ldflags="-Wl,-rpath,/usr/local/lib/xen/lib" \
--bindir=/usr/local/lib/xen/bin \
--datadir=/usr/local/share/qemu-xen \
--localstatedir=/var \
--docdir=/usr/local/lib/xen/share/doc \
--mandir=/usr/local/lib/xen/share/man \
--libexecdir=/usr/local/lib/xen/libexec \
--firmwarepath=/usr/local/lib/xen/share/qemu-firmware \
--disable-kvm \
--disable-docs \
--disable-guest-agent \
--python=python3 \
--cpu=i386 ;

--cpu=i386 may be important? osstest is building in a 32bit debian environment. My 64bit fedora workstation fails to configure with --cpu=i386, and it builds successfully without it.

Maybe add #if defined(CONFIG_KVM) around the code like CONFIG_TCG above?

Regards,
Jason

#6 lore raw

Re: [PULL v2 02/44] tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator

Quoted 107 lines · On Fri, 22 Oct 2021 09:04:43 -0400 Jason Andryuk <[email protected]> wrote:
Quoted 58 lines · Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Currently it is not possible to create tests that have KVM as a hard requirement on a host that doesn't support KVM for tested target binary (modulo going through the trouble of compiling out the offending test case).

Following scenario makes test fail when it's run on non x86 host:
qemu-system-x86_64 -enable-kvm -M q35,kernel-irqchip=on -smp 1,maxcpus=288

This patch introduces qtest_has_accel() to let users check if accel is available in advance and avoid executing non run-able test-cases.

It implements detection of TCG and KVM only, the rest could be added later on, when we actually start testing them in qtest.

Message-Id: <[email protected]>

---
 tests/qtest/libqos/libqtest.h |  8 ++++++++
 tests/qtest/libqtest.c        | 27 +++++++++++++++++++++++++++
 meson.build                   |  6 ++++++
 3 files changed, 41 insertions(+)
tests/qtest/libqos/libqtest.h +8 -0
index a68dcd79d4..59e9271195 100644
@@ -588,6 +588,14 @@ bool qtest_big_endian(QTestState *s);
  */
 const char *qtest_get_arch(void);
 
+/**
+ * qtest_has_accel:
+ * @accel_name: Accelerator name to check for.
+ *
+ * Returns: true if the accelerator is built in.
+ */
+bool qtest_has_accel(const char *accel_name);
+
 /**
  * qtest_add_func:
  * @str: Test case path.
tests/qtest/libqtest.c +4 -0
index 73f6b977a6..25aeea385b 100644
@@ -922,6 +922,33 @@ const char *qtest_get_arch(void)
     return end + 1;
 }
 
+bool qtest_has_accel(const char *accel_name)
+{
+    if (g_str_equal(accel_name, "tcg")) {
+#if defined(CONFIG_TCG)

tests/qtest/libqtest.c const char *qtest_get_arch(void) · line 938

Quoted 10 lines
tests/qtest/libqtest.c +10 -0
+        return true;
+#else
+        return false;
+#endif
+    } else if (g_str_equal(accel_name, "kvm")) {
+        int i;
+        const char *arch = qtest_get_arch();
+        const char *targets[] = { CONFIG_KVM_TARGETS };
+
+        for (i = 0; i < ARRAY_SIZE(targets); i++) {  

A xen osstest build fails with:
../qemu-xen-dir-remote/tests/qtest/libqtest.c: In function 'qtest_has_accel':
../qemu-xen-dir-remote/tests/qtest/libqtest.c:938:23: error:
comparison of unsigned expression < 0 is always false [-Werror=type-limits]

         for (i = 0; i < ARRAY_SIZE(targets); i++) {
                       ^

Super long osstest log here:http://logs.test-lab.xenproject.org/osstest/logs/165703/build-i386-xsm/6.ts-xen-build.log

It was configured like:
$source/configure --enable-xen --target-list=i386-softmmu \
--enable-debug \
--enable-trace-backend=log \
--prefix=/usr/local \
--libdir=/usr/local/lib/xen/lib \
--includedir=/usr/local/lib/xen/include \
--extra-cflags="-DXC_WANT_COMPAT_EVTCHN_API=1 \

(quoted diff) +0 -3
-DXC_WANT_COMPAT_GNTTAB_API=1 \
-DXC_WANT_COMPAT_MAP_FOREIGN_API=1 \
-DXC_WANT_COMPAT_DEVICEMODEL_API=1 \

" \
--extra-ldflags="-Wl,-rpath,/usr/local/lib/xen/lib" \
--bindir=/usr/local/lib/xen/bin \
--datadir=/usr/local/share/qemu-xen \
--localstatedir=/var \
--docdir=/usr/local/lib/xen/share/doc \
--mandir=/usr/local/lib/xen/share/man \
--libexecdir=/usr/local/lib/xen/libexec \
--firmwarepath=/usr/local/lib/xen/share/qemu-firmware \
--disable-kvm \
--disable-docs \
--disable-guest-agent \
--python=python3 \
--cpu=i386 ;

Quoted 5 lines

--cpu=i386 may be important? osstest is building in a 32bit debian environment. My 64bit fedora workstation fails to configure with --cpu=i386, and it builds successfully without it.

Maybe add #if defined(CONFIG_KVM) around the code like CONFIG_TCG above?

Thanks for reporting, I'll post fix in a moment.

Quoted 3 lines

Regards,
Jason

#7 lore raw

[PULL v2 03/44] tests: acpi: whitelist expected tables for acpi/q35/xapic testcase

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++
 tests/data/acpi/q35/APIC.xapic              | 0
 tests/data/acpi/q35/DSDT.xapic              | 0
 tests/data/acpi/q35/FACP.xapic              | 0
 tests/data/acpi/q35/SRAT.xapic              | 0
 5 files changed, 4 insertions(+)
 create mode 100644 tests/data/acpi/q35/APIC.xapic
 create mode 100644 tests/data/acpi/q35/DSDT.xapic
 create mode 100644 tests/data/acpi/q35/FACP.xapic
 create mode 100644 tests/data/acpi/q35/SRAT.xapic
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
index dfb8523c8b..344eee3acc 100644
@@ -1 +1,5 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.xapic",
+"tests/data/acpi/q35/SRAT.xapic",
+"tests/data/acpi/q35/FACP.xapic",
+"tests/data/acpi/q35/APIC.xapic",
tests/data/acpi/q35/APIC.xapic new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/data/acpi/q35/DSDT.xapic new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/data/acpi/q35/FACP.xapic new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/data/acpi/q35/SRAT.xapic new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
MST
#8 lore raw

[PULL v2 14/44] tests: migration-test: use qtest_has_accel() API

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/migration-test.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
tests/qtest/migration-test.c +4 -11
index cc5e83d98a..7b42f6fd90 100644
@@ -1420,6 +1420,7 @@ static bool kvm_dirty_ring_supported(void)
 int main(int argc, char **argv)
 {
     char template[] = "/tmp/migration-test-XXXXXX";
+    const bool has_kvm = qtest_has_accel("kvm");
     int ret;
 
     g_test_init(&argc, &argv, NULL);
@@ -1434,8 +1435,7 @@ int main(int argc, char **argv)
      * some reason)
      */
     if (g_str_equal(qtest_get_arch(), "ppc64") &&
-        (access("/sys/module/kvm_hv", F_OK) ||
-         access("/dev/kvm", R_OK | W_OK))) {
+        (!has_kvm || access("/sys/module/kvm_hv", F_OK))) {
         g_test_message("Skipping test: kvm_hv not available");
         return g_test_run();
     }
@@ -1444,16 +1444,9 @@ int main(int argc, char **argv)
      * Similar to ppc64, s390x seems to be touchy with TCG, so disable it
      * there until the problems are resolved
      */
-    if (g_str_equal(qtest_get_arch(), "s390x")) {
-#if defined(HOST_S390X)
-        if (access("/dev/kvm", R_OK | W_OK)) {
-            g_test_message("Skipping test: kvm not available");
-            return g_test_run();
-        }
-#else
-        g_test_message("Skipping test: Need s390x host to work properly");
+    if (g_str_equal(qtest_get_arch(), "s390x") && !has_kvm) {
+        g_test_message("Skipping test: s390x host with KVM is required");
         return g_test_run();
-#endif
     }
 
     tmpfs = mkdtemp(template);
Signature · 1 line
MST
#9 lore raw

[PULL v2 06/44] tests: acpi: whitelist new expected table tests/data/acpi/q35/DMAR.dmar

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 tests/data/acpi/q35/DMAR.dmar               | 0
 2 files changed, 1 insertion(+)
 create mode 100644 tests/data/acpi/q35/DMAR.dmar
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..a2843335c8 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DMAR.dmar",
tests/data/acpi/q35/DMAR.dmar new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
MST
#10 lore raw

[PULL v2 08/44] tests: acpi: add expected blob for DMAR table

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

[000h 0000   4]                    Signature : "DMAR"    [DMA Remapping table]
[004h 0004   4]                 Table Length : 00000078
[008h 0008   1]                     Revision : 01
[009h 0009   1]                     Checksum : 15
[00Ah 0010   6]                       Oem ID : "BOCHS "
[010h 0016   8]                 Oem Table ID : "BXPC    "
[018h 0024   4]                 Oem Revision : 00000001
[01Ch 0028   4]              Asl Compiler ID : "BXPC"
[020h 0032   4]        Asl Compiler Revision : 00000001

[024h 0036 1] Host Address Width : 26
[025h 0037 1] Flags : 01
[026h 0038 10] Reserved : 00 00 00 00 00 00 00 00 00 00

[030h 0048 2] Subtable Type : 0000 [Hardware Unit Definition]
[032h 0050 2] Length : 0040

[034h 0052   1]                        Flags : 00
[035h 0053   1]                     Reserved : 00
[036h 0054   2]           PCI Segment Number : 0000
[038h 0056   8]        Register Base Address : 00000000FED90000
[040h 0064   1]            Device Scope Type : 03 [IOAPIC Device]
[041h 0065   1]                 Entry Length : 08
[042h 0066   2]                     Reserved : 0000
[044h 0068   1]               Enumeration ID : 00
[045h 0069   1]               PCI Bus Number : FF

[046h 0070 2] PCI Path : 00,00

[048h 0072   1]            Device Scope Type : 01 [PCI Endpoint Device]
[049h 0073   1]                 Entry Length : 08
[04Ah 0074   2]                     Reserved : 0000
[04Ch 0076   1]               Enumeration ID : 00
[04Dh 0077   1]               PCI Bus Number : 00

[04Eh 0078 2] PCI Path : 00,00

[050h 0080   1]            Device Scope Type : 01 [PCI Endpoint Device]
[051h 0081   1]                 Entry Length : 08
[052h 0082   2]                     Reserved : 0000
[054h 0084   1]               Enumeration ID : 00
[055h 0085   1]               PCI Bus Number : 00

[056h 0086 2] PCI Path : 01,00

[058h 0088   1]            Device Scope Type : 01 [PCI Endpoint Device]
[059h 0089   1]                 Entry Length : 08
[05Ah 0090   2]                     Reserved : 0000
[05Ch 0092   1]               Enumeration ID : 00
[05Dh 0093   1]               PCI Bus Number : 00

[05Eh 0094 2] PCI Path : 1F,00

[060h 0096   1]            Device Scope Type : 01 [PCI Endpoint Device]
[061h 0097   1]                 Entry Length : 08
[062h 0098   2]                     Reserved : 0000
[064h 0100   1]               Enumeration ID : 00
[065h 0101   1]               PCI Bus Number : 00

[066h 0102 2] PCI Path : 1F,02

[068h 0104   1]            Device Scope Type : 01 [PCI Endpoint Device]
[069h 0105   1]                 Entry Length : 08
[06Ah 0106   2]                     Reserved : 0000
[06Ch 0108   1]               Enumeration ID : 00
[06Dh 0109   1]               PCI Bus Number : 00

[06Eh 0110 2] PCI Path : 1F,03

[070h 0112 2] Subtable Type : 0002 [Root Port ATS Capability]
[072h 0114 2] Length : 0008

[074h 0116   1]                        Flags : 01
[075h 0117   1]                     Reserved : 00
[076h 0118   2]           PCI Segment Number : 0000

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 tests/data/acpi/q35/DMAR.dmar               | Bin 0 -> 120 bytes
 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index a2843335c8..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DMAR.dmar",
tests/data/acpi/q35/DMAR.dmar binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0dca6e68ad8a8ca5b981bcfbc745385a63e9f216 100644
GIT binary patch
Signature · 1 line
MST
#11 lore raw

[PULL v2 17/44] vdpa: Add vhost_vdpa_section_end

In reply to Michael S. Tsirkin

From: Eugenio Pérez <[email protected]>

Abstract this operation, that will be reused when validating the region against the iova range that the device supports.

Message-Id: <[email protected]>

---
 hw/virtio/vhost-vdpa.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
hw/virtio/vhost-vdpa.c +15 -7
index ea1aa71ad8..be7c63b4ba 100644
@@ -24,6 +24,19 @@
 #include "trace.h"
 #include "qemu-common.h"
 
+/*
+ * Return one past the end of the end of section. Be careful with uint64_t
+ * conversions!
+ */
+static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section)
+{
+    Int128 llend = int128_make64(section->offset_within_address_space);
+    llend = int128_add(llend, section->size);
+    llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
+
+    return llend;
+}
+
 static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
 {
     return (!memory_region_is_ram(section->mr) &&
@@ -160,10 +173,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener,
     }
 
     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));
-
+    llend = vhost_vdpa_section_end(section);
     if (int128_ge(int128_make64(iova), llend)) {
         return;
     }
@@ -221,9 +231,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
     }
 
     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));
+    llend = vhost_vdpa_section_end(section);
 
     trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(llend));
 
Signature · 1 line
MST
#12 lore raw

[PULL v2 07/44] tests: acpi: add testcase for intel_iommu (DMAR table)

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/qtest/bios-tables-test.c +13 -0
index 87a94a59fa..0361c84c5e 100644
@@ -1090,6 +1090,18 @@ static void test_acpi_q35_tcg_nohpet(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_kvm_dmar(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_Q35;
+    data.variant = ".dmar";
+    test_acpi_one("-machine kernel-irqchip=split -accel kvm"
+                  " -device intel-iommu,intremap=on,device-iotlb=on", &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_piix4_tcg_numamem(void)
 {
     test_data data;
@@ -1583,6 +1595,7 @@ int main(int argc, char *argv[])
         }
         if (has_kvm) {
             qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xapic);
+            qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar);
         }
     } else if (strcmp(arch, "aarch64") == 0) {
         qtest_add_func("acpi/virt", test_acpi_virt_tcg);
Signature · 1 line
MST
#13 lore raw

[PULL v2 13/44] tests: arm-cpu-features: use qtest_has_kvm() API

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

and drop custom function that were doing the job

Message-Id: <[email protected]>

---
 tests/qtest/arm-cpu-features.c | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)
tests/qtest/arm-cpu-features.c +5 -24
index 90a87f0ea9..f76652143a 100644
@@ -26,21 +26,6 @@
                     "  'arguments': { 'type': 'full', "
 #define QUERY_TAIL  "}}"
 
-static bool kvm_enabled(QTestState *qts)
-{
-    QDict *resp, *qdict;
-    bool enabled;
-
-    resp = qtest_qmp(qts, "{ 'execute': 'query-kvm' }");
-    g_assert(qdict_haskey(resp, "return"));
-    qdict = qdict_get_qdict(resp, "return");
-    g_assert(qdict_haskey(qdict, "enabled"));
-    enabled = qdict_get_bool(qdict, "enabled");
-    qobject_unref(resp);
-
-    return enabled;
-}
-
 static QDict *do_query_no_props(QTestState *qts, const char *cpu_type)
 {
     return qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s }"
@@ -506,14 +491,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
 
     qts = qtest_init(MACHINE_KVM "-cpu max");
 
-    /*
-     * These tests target the 'host' CPU type, so KVM must be enabled.
-     */
-    if (!kvm_enabled(qts)) {
-        qtest_quit(qts);
-        return;
-    }
-
     /* Enabling and disabling kvm-no-adjvtime should always work. */
     assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");
     assert_set_feature(qts, "host", "kvm-no-adjvtime", true);
@@ -637,7 +614,11 @@ int main(int argc, char **argv)
      * order avoid attempting to run an AArch32 QEMU with KVM on
      * AArch64 hosts. That won't work and isn't easy to detect.
      */
-    if (g_str_equal(qtest_get_arch(), "aarch64")) {
+    if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) {
+        /*
+         * This tests target the 'host' CPU type, so register it only if
+         * KVM is available.
+         */
         qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
                             NULL, test_query_cpu_model_expansion_kvm);
     }
Signature · 1 line
MST
#14 lore raw

[PULL v2 09/44] tests: acpi: whitelist expected blobs for new acpi/q35/ivrs testcase

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h | 2 ++
 tests/data/acpi/q35/DSDT.ivrs               | 0
 tests/data/acpi/q35/IVRS.ivrs               | 0
 3 files changed, 2 insertions(+)
 create mode 100644 tests/data/acpi/q35/DSDT.ivrs
 create mode 100644 tests/data/acpi/q35/IVRS.ivrs
tests/qtest/bios-tables-test-allowed-diff.h +2 -0
index dfb8523c8b..4fe8e8272a 100644
@@ -1 +1,3 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.ivrs",
+"tests/data/acpi/q35/IVRS.ivrs",
tests/data/acpi/q35/DSDT.ivrs new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
tests/data/acpi/q35/IVRS.ivrs new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
MST
#15 lore raw

[PULL v2 28/44] qdev/qbus: remove failover specific code

In reply to Michael S. Tsirkin

From: Laurent Vivier <[email protected]>

Commit f3a850565693 ("qdev/qbus: add hidden device support") has introduced a generic way to hide a device but it has modified qdev_device_add() to check a specific option of the failover device, "failover_pair_id", before calling the generic mechanism.

It's not needed (and not generic) to do that in qdev_device_add() because this is also checked by the failover_hide_primary_device() function that uses the generic mechanism to hide the device.

Message-Id: <[email protected]>

---
 hw/net/virtio-net.c    | 12 +++++++++++-
 softmmu/qdev-monitor.c | 18 ++++++------------
 2 files changed, 17 insertions(+), 13 deletions(-)
hw/net/virtio-net.c +11 -1
index 83642c85b2..3dd2896ff9 100644
@@ -3299,7 +3299,17 @@ static bool failover_hide_primary_device(DeviceListener *listener,
     if (!device_opts) {
         return false;
     }
-    standby_id = qdict_get_try_str(device_opts, "failover_pair_id");
+
+    if (!qdict_haskey(device_opts, "failover_pair_id")) {
+        return false;
+    }
+
+    if (!qdict_haskey(device_opts, "id")) {
+        error_setg(errp, "Device with failover_pair_id needs to have id");
+        return false;
+    }
+
+    standby_id = qdict_get_str(device_opts, "failover_pair_id");
     if (g_strcmp0(standby_id, n->netclient_name) != 0) {
         return false;
     }
softmmu/qdev-monitor.c +6 -12
index 89c473cb22..4851de51a5 100644
@@ -639,19 +639,13 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
         }
     }
 
-    if (qdict_haskey(opts, "failover_pair_id")) {
-        if (!qdict_haskey(opts, "id")) {
-            error_setg(errp, "Device with failover_pair_id don't have id");
-            return NULL;
-        }
-        if (qdev_should_hide_device(opts, from_json, errp)) {
-            if (bus && !qbus_is_hotpluggable(bus)) {
-                error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
-            }
-            return NULL;
-        } else if (*errp) {
-            return NULL;
+    if (qdev_should_hide_device(opts, from_json, errp)) {
+        if (bus && !qbus_is_hotpluggable(bus)) {
+            error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
         }
+        return NULL;
+    } else if (*errp) {
+        return NULL;
     }
 
     if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(bus)) {
Signature · 1 line
MST
#16 lore raw

[PULL v2 10/44] tests: acpi: add testcase for amd-iommu (IVRS table)

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/qtest/bios-tables-test.c +13 -0
index 0361c84c5e..ef28bb41f3 100644
@@ -1102,6 +1102,18 @@ static void test_acpi_q35_kvm_dmar(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_tcg_ivrs(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_Q35;
+    data.variant = ".ivrs";
+    data.tcg_only = true,
+    test_acpi_one(" -device amd-iommu", &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_piix4_tcg_numamem(void)
 {
     test_data data;
@@ -1581,6 +1593,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/smm-compat-nosmm",
                        test_acpi_q35_tcg_smm_compat_nosmm);
         qtest_add_func("acpi/q35/nohpet", test_acpi_q35_tcg_nohpet);
+        qtest_add_func("acpi/q35/ivrs", test_acpi_q35_tcg_ivrs);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
         qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hmat);
Signature · 1 line
MST
#17 lore raw

[PULL v2 15/44] tests: bios-tables-test: use qtest_has_accel() API to register TCG only tests

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

.. only if TCG is available

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)
tests/qtest/bios-tables-test.c +13 -15
index 873eb9c037..6e21a650d2 100644
@@ -722,13 +722,6 @@ static void test_acpi_one(const char *params, test_data *data)
     char *args;
     bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
 
-#ifndef CONFIG_TCG
-    if (data->tcg_only) {
-        g_test_skip("TCG disabled, skipping ACPI tcg_only test");
-        return;
-    }
-#endif /* CONFIG_TCG */
-
     args = test_acpi_create_args(data, params, use_uefi);
     data->qts = qtest_init(args);
     test_acpi_load_tables(data, use_uefi);
@@ -1544,6 +1537,7 @@ int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
     const bool has_kvm = qtest_has_accel("kvm");
+    const bool has_tcg = qtest_has_accel("tcg");
     int ret;
 
     g_test_init(&argc, &argv, NULL);
@@ -1590,7 +1584,6 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/smm-compat-nosmm",
                        test_acpi_q35_tcg_smm_compat_nosmm);
         qtest_add_func("acpi/q35/nohpet", test_acpi_q35_tcg_nohpet);
-        qtest_add_func("acpi/q35/ivrs", test_acpi_q35_tcg_ivrs);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
         qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hmat);
@@ -1600,19 +1593,24 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc_tcg);
         qtest_add_func("acpi/microvm/ioapic2", test_acpi_microvm_ioapic2_tcg);
         qtest_add_func("acpi/microvm/oem-fields", test_acpi_oem_fields_microvm);
-        if (strcmp(arch, "x86_64") == 0) {
-            qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie_tcg);
+        if (has_tcg) {
+            qtest_add_func("acpi/q35/ivrs", test_acpi_q35_tcg_ivrs);
+            if (strcmp(arch, "x86_64") == 0) {
+                qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie_tcg);
+            }
         }
         if (has_kvm) {
             qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xapic);
             qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar);
         }
     } else if (strcmp(arch, "aarch64") == 0) {
-        qtest_add_func("acpi/virt", test_acpi_virt_tcg);
-        qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
-        qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp);
-        qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb);
-        qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt);
+        if (has_tcg) {
+            qtest_add_func("acpi/virt", test_acpi_virt_tcg);
+            qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
+            qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp);
+            qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb);
+            qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt);
+        }
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
Signature · 1 line
MST
#18 lore raw

[PULL v2 11/44] tests: acpi: update expected blobs

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

DSDT:
+ Device (S10)
+ {
+ Name (_ADR, 0x00020000) // _ADR: Address
+ }

New IVRS table:

[000h 0000   4]                    Signature : "IVRS"    [I/O Virtualization Reporting Structure]
[004h 0004   4]                 Table Length : 00000068
[008h 0008   1]                     Revision : 01
[009h 0009   1]                     Checksum : 43
[00Ah 0010   6]                       Oem ID : "BOCHS "
[010h 0016   8]                 Oem Table ID : "BXPC    "
[018h 0024   4]                 Oem Revision : 00000001
[01Ch 0028   4]              Asl Compiler ID : "BXPC"
[020h 0032   4]        Asl Compiler Revision : 00000001

[024h 0036 4] Virtualization Info : 00002800
[028h 0040 8] Reserved : 0000000000000000

[030h 0048   1]                Subtable Type : 10 [Hardware Definition Block]
[031h 0049   1]                        Flags : D1
[032h 0050   2]                       Length : 0038
[034h 0052   2]                     DeviceId : 0010
[036h 0054   2]            Capability Offset : 0040
[038h 0056   8]                 Base Address : 00000000FED80000
[040h 0064   2]            PCI Segment Group : 0000
[042h 0066   2]          Virtualization Info : 0000
[044h 0068   4]                     Reserved : 00000044
[048h 0072   1]                   Entry Type : 02
[049h 0073   2]                    Device ID : 0000
[04Bh 0075   1]                 Data Setting : 00
[04Ch 0076   1]                   Entry Type : 02
[04Dh 0077   2]                    Device ID : 0008
[04Fh 0079   1]                 Data Setting : 00
[050h 0080   1]                   Entry Type : 02
[051h 0081   2]                    Device ID : 0010
[053h 0083   1]                 Data Setting : 00
[054h 0084   1]                   Entry Type : 02
[055h 0085   2]                    Device ID : 00F8
[057h 0087   1]                 Data Setting : 00
[058h 0088   1]                   Entry Type : 02
[059h 0089   2]                    Device ID : 00FA
[05Bh 0091   1]                 Data Setting : 00
[05Ch 0092   1]                   Entry Type : 02
[05Dh 0093   2]                    Device ID : 00FB
[05Fh 0095   1]                 Data Setting : 00
[060h 0096   1]                   Entry Type : 48
[061h 0097   2]                    Device ID : 0000
[063h 0099   1]                 Data Setting : 00
[064h 0100   1]                       Handle : 00
[065h 0101   2]        Source Used Device ID : 00A0
[067h 0103   1]                      Variety : 01

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h |   2 --
 tests/data/acpi/q35/DSDT.ivrs               | Bin 0 -> 8306 bytes
 tests/data/acpi/q35/IVRS.ivrs               | Bin 0 -> 104 bytes
 3 files changed, 2 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
index 4fe8e8272a..dfb8523c8b 100644
@@ -1,3 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.ivrs",
-"tests/data/acpi/q35/IVRS.ivrs",
tests/data/acpi/q35/DSDT.ivrs binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b0eafe90e5832935557ec5e6802c0147c88f379c 100644
GIT binary patch
tests/data/acpi/q35/IVRS.ivrs binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..17611202e53a32f7da8e4925d6955b384670b8b1 100644
GIT binary patch
Signature · 1 line
MST
#19 lore raw

[PULL v2 32/44] vhost-vdpa: classify one time request

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

Vhost-vdpa uses one device multiqueue queue (pairs) model. So we need to classify the one time request (e.g SET_OWNER) and make sure those request were only called once per device.

This is used for multiqueue support.

Message-Id: <[email protected]>

---
 include/hw/virtio/vhost-vdpa.h |  1 +
 hw/virtio/vhost-vdpa.c         | 53 ++++++++++++++++++++++++++++++----
 2 files changed, 48 insertions(+), 6 deletions(-)
include/hw/virtio/vhost-vdpa.h +1 -0
index c288cf7ecb..3ce79a646d 100644
@@ -22,6 +22,7 @@ typedef struct VhostVDPAHostNotifier {
 
 typedef struct vhost_vdpa {
     int device_fd;
+    int index;
     uint32_t msg_type;
     bool iotlb_batch_begin_sent;
     MemoryListener listener;
hw/virtio/vhost-vdpa.c +47 -6

110 lines not on this page · raw message

Signature · 1 line
MST
#20 lore raw

[PULL v2 16/44] vdpa: Skip protected ram IOMMU mappings

In reply to Michael S. Tsirkin

From: Eugenio Pérez <[email protected]>

Following the logic of commit 56918a126ae ("memory: Add RAM_PROTECTED flag to skip IOMMU mappings") with VFIO, skip memory sections inaccessible via normal mechanisms, including DMA.

Message-Id: <[email protected]>

---
 hw/virtio/vhost-vdpa.c | 1 +
 1 file changed, 1 insertion(+)
hw/virtio/vhost-vdpa.c +1 -0
index 47d7a5a23d..ea1aa71ad8 100644
@@ -28,6 +28,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
 {
     return (!memory_region_is_ram(section->mr) &&
             !memory_region_is_iommu(section->mr)) ||
+            memory_region_is_protected(section->mr) ||
            /* vhost-vDPA doesn't allow MMIO to be mapped  */
             memory_region_is_ram_device(section->mr) ||
            /*
Signature · 1 line
MST
#21 lore raw

[PULL v2 39/44] virtio-net: vhost control virtqueue support

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

This patch implements the control virtqueue support for vhost. This requires virtio-net to figure out the datapath queue pairs and control virtqueue via is_datapath and pass the number of those two types of virtqueues to vhost_net_start()/vhost_net_stop().

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio-net.h |  1 +
 hw/net/vhost_net.c             |  2 +-
 hw/net/virtio-net.c            | 23 +++++++++++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)
include/hw/virtio/virtio-net.h +1 -0
index 2903b79a92..eb87032627 100644
@@ -196,6 +196,7 @@ struct VirtIONet {
     int multiqueue;
     uint16_t max_queue_pairs;
     uint16_t curr_queue_pairs;
+    uint16_t max_ncs;
     size_t config_size;
     char *netclient_name;
     char *netclient_type;
hw/net/vhost_net.c +1 -1
index 3aabab06ea..0d888f29a6 100644
@@ -326,7 +326,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
     VirtIONet *n = VIRTIO_NET(dev);
     int nvhosts = data_queue_pairs + cvq;
     struct vhost_net *net;
-    int r, e, i, last_index = data_qps * 2;
+    int r, e, i, last_index = data_queue_pairs * 2;
     NetClientState *peer;
 
     if (!cvq) {
hw/net/virtio-net.c +19 -4
index 7594f7ea92..f2014d5ea0 100644
@@ -244,6 +244,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
     NetClientState *nc = qemu_get_queue(n->nic);
     int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;
+    int cvq = n->max_ncs - n->max_queue_pairs;
 
     if (!get_vhost_net(nc->peer)) {
         return;
@@ -285,14 +286,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
         }
 
         n->vhost_started = 1;
-        r = vhost_net_start(vdev, n->nic->ncs, queue_pairs, 0);
+        r = vhost_net_start(vdev, n->nic->ncs, queue_pairs, cvq);
         if (r < 0) {
             error_report("unable to start vhost net: %d: "
                          "falling back on userspace virtio", -r);
             n->vhost_started = 0;
         }
     } else {
-        vhost_net_stop(vdev, n->nic->ncs, queue_pairs, 0);
+        vhost_net_stop(vdev, n->nic->ncs, queue_pairs, cvq);
         n->vhost_started = 0;
     }
 }
@@ -3411,9 +3412,23 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    n->max_queue_pairs = MAX(n->nic_conf.peers.queues, 1);
+    n->max_ncs = MAX(n->nic_conf.peers.queues, 1);
+
+    /*
+     * Figure out the datapath queue pairs since the backend could
+     * provide control queue via peers as well.
+     */
+    if (n->nic_conf.peers.queues) {
+        for (i = 0; i < n->max_ncs; i++) {
+            if (n->nic_conf.peers.ncs[i]->is_datapath) {
+                ++n->max_queue_pairs;
+            }
+        }
+    }
+    n->max_queue_pairs = MAX(n->max_queue_pairs, 1);
+
     if (n->max_queue_pairs * 2 + 1 > VIRTIO_QUEUE_MAX) {
-        error_setg(errp, "Invalid number of queue_pairs (= %" PRIu32 "), "
+        error_setg(errp, "Invalid number of queue pairs (= %" PRIu32 "), "
                    "must be a positive integer less than %d.",
                    n->max_queue_pairs, (VIRTIO_QUEUE_MAX - 1) / 2);
         virtio_cleanup(vdev);
Signature · 1 line
MST
#22 lore raw

[PULL v2 23/44] vhost-user-rng-pci: Add vhost-user-rng-pci implementation

In reply to Michael S. Tsirkin

From: Mathieu Poirier <[email protected]>

This patch provides a PCI bus interface to the vhost-user-rng backend.

Message-Id: <[email protected]>

---
 hw/virtio/vhost-user-rng-pci.c | 79 ++++++++++++++++++++++++++++++++++
 hw/virtio/meson.build          |  1 +
 2 files changed, 80 insertions(+)
 create mode 100644 hw/virtio/vhost-user-rng-pci.c
hw/virtio/vhost-user-rng-pci.c new file +79 -0
new file mode 100644
index 0000000000..c83dc86813
@@ -0,0 +1,79 @@
+/*
+ * Vhost-user RNG virtio device PCI glue
+ *
+ * Copyright (c) 2021 Mathieu Poirier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev-properties.h"
+#include "hw/virtio/vhost-user-rng.h"
+#include "virtio-pci.h"
+
+struct VHostUserRNGPCI {
+    VirtIOPCIProxy parent_obj;
+    VHostUserRNG vdev;
+};
+
+typedef struct VHostUserRNGPCI VHostUserRNGPCI;
+
+#define TYPE_VHOST_USER_RNG_PCI "vhost-user-rng-pci-base"
+
+DECLARE_INSTANCE_CHECKER(VHostUserRNGPCI, VHOST_USER_RNG_PCI,
+                         TYPE_VHOST_USER_RNG_PCI)
+
+static Property vhost_user_rng_pci_properties[] = {
+    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
+                       DEV_NVECTORS_UNSPECIFIED),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vhost_user_rng_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+    VHostUserRNGPCI *dev = VHOST_USER_RNG_PCI(vpci_dev);
+    DeviceState *vdev = DEVICE(&dev->vdev);
+
+    if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
+        vpci_dev->nvectors = 1;
+    }
+
+    qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
+}
+
+static void vhost_user_rng_pci_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+    PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+    k->realize = vhost_user_rng_pci_realize;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
+    device_class_set_props(dc, vhost_user_rng_pci_properties);
+    pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+    pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */
+    pcidev_k->revision = 0x00;
+    pcidev_k->class_id = PCI_CLASS_OTHERS;
+}
+
+static void vhost_user_rng_pci_instance_init(Object *obj)
+{
+    VHostUserRNGPCI *dev = VHOST_USER_RNG_PCI(obj);
+
+    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+                                TYPE_VHOST_USER_RNG);
+}
+
+static const VirtioPCIDeviceTypeInfo vhost_user_rng_pci_info = {
+    .base_name = TYPE_VHOST_USER_RNG_PCI,
+    .non_transitional_name = "vhost-user-rng-pci",
+    .instance_size = sizeof(VHostUserRNGPCI),
+    .instance_init = vhost_user_rng_pci_instance_init,
+    .class_init = vhost_user_rng_pci_class_init,
+};
+
+static void vhost_user_rng_pci_register(void)
+{
+    virtio_pci_types_register(&vhost_user_rng_pci_info);
+}
+
+type_init(vhost_user_rng_pci_register);
hw/virtio/meson.build +1 -0
index ae6b2cde10..521f7d64a8 100644
@@ -28,6 +28,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
 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_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
Signature · 1 line
MST
#23 lore raw

[PULL v2 19/44] virtio-iommu: Remove the non transitional name

In reply to Michael S. Tsirkin

From: Eric Auger <[email protected]>

Remove the non transitional name for virtio iommu. Like other devices introduced after 1.0 spec, the virtio-iommu does not need it.

Message-Id: <[email protected]>

---
 hw/virtio/virtio-iommu-pci.c | 1 -
 1 file changed, 1 deletion(-)
hw/virtio/virtio-iommu-pci.c +0 -1
index 770c286be7..86fa4e6c28 100644
@@ -100,7 +100,6 @@ static void virtio_iommu_pci_instance_init(Object *obj)
 static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = {
     .base_name             = TYPE_VIRTIO_IOMMU_PCI,
     .generic_name          = "virtio-iommu-pci",
-    .non_transitional_name = "virtio-iommu-pci-non-transitional",
     .instance_size = sizeof(VirtIOIOMMUPCI),
     .instance_init = virtio_iommu_pci_instance_init,
     .class_init    = virtio_iommu_pci_class_init,
Signature · 1 line
MST
#24 lore raw

[PULL v2 40/44] vhost-vdpa: multiqueue support

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

This patch implements the multiqueue support for vhost-vdpa. This is done simply by reading the number of queue pairs from the config space and initialize the datapath and control path net client.

Message-Id: <[email protected]>

---
 hw/virtio/vhost-vdpa.c |   2 +-
 net/vhost-vdpa.c       | 105 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 97 insertions(+), 10 deletions(-)
hw/virtio/vhost-vdpa.c +1 -1
index 8948fd316b..12661fd5b1 100644
@@ -632,7 +632,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
         vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
     }
 
-    if (vhost_vdpa_one_time_request(dev)) {
+    if (dev->vq_index + dev->nvqs != dev->last_index) {
         return 0;
     }
 
net/vhost-vdpa.c +96 -9

163 lines not on this page · raw message

Signature · 1 line
MST
#25 lore raw

[PULL v2 25/44] vhost-user: fix duplicated notifier MR init

In reply to Michael S. Tsirkin

From: Xueming Li <[email protected]>

In case of device resume after suspend, VQ notifier MR still valid. Duplicated registrations explode memory block list and slow down device resume.

Fixes 44866521bd6e ("vhost-user: support registering external host notifiers")
Cc Yuwei Zhang <[email protected]>

Message-Id: <[email protected]>

---
 hw/virtio/vhost-user.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/virtio/vhost-user.c +3 -2
index 2c8556237f..bf6e50223c 100644
@@ -1526,8 +1526,9 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
 
     name = g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]",
                            user, queue_idx);
-    memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
-                                      page_size, addr);
+    if (!n->mr.ram) /* Don't init again after suspend. */
+        memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
+                                          page_size, addr);
     g_free(name);
 
     if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) {
Signature · 1 line
MST
#26 lore raw

[PULL v2 12/44] tests: acpi: arm/virt: drop redundant test_acpi_one() in test_acpi_virt_tcg()

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

follow up call with smbios options generates the same ACPI tables, so there is no need to run smbios-less variant at all.

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test.c | 3 ---
 1 file changed, 3 deletions(-)
tests/qtest/bios-tables-test.c +0 -3
index ef28bb41f3..873eb9c037 100644
@@ -1430,9 +1430,6 @@ static void test_acpi_virt_tcg(void)
         .scan_len = 128ULL * 1024 * 1024,
     };
 
-    test_acpi_one("-cpu cortex-a57", &data);
-    free_test_data(&data);
-
     data.smbios_cpu_max_speed = 2900;
     data.smbios_cpu_curr_speed = 2700;
     test_acpi_one("-cpu cortex-a57 "
Signature · 1 line
MST
#27 lore raw

[PULL v2 26/44] failover: fix a regression introduced by JSON'ification of -device

In reply to Michael S. Tsirkin

From: Laurent Vivier <[email protected]>

The hide_device helper can be called several times for the same devices as it shouldn't change any state and should only return an information.

But not to rely anymore on QemuOpts we have introduced a new field to store the parameters of the device and don't allow to update it once it is done.

And as the function is called several times, we ends with:

warning: Cannot attach more than one primary device to 'virtio0'

That is not only a warning as it prevents to hide the device and breaks failover.

Fix that by checking the device id.

Now, we fail only if the virtio-net device is really used by two different devices, for instance:

   -device virtio-net-pci,id=virtio0,failover=on,... \
   -device vfio-pci,id=hostdev0,failover_pair_id=virtio0,... \
   -device e1000e,id=e1000e0,failover_pair_id=virtio0,... \

will exit with:

Cannot attach more than one primary device to 'virtio0': 'hostdev0' and 'e1000e0'

Fixes 259a10dbcb4f ("virtio-net: Store failover primary opts pointer locally")

Message-Id: <[email protected]>

---
 hw/net/virtio-net.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
hw/net/virtio-net.c +18 -6
index 09e173a558..83642c85b2 100644
@@ -3304,15 +3304,27 @@ static bool failover_hide_primary_device(DeviceListener *listener,
         return false;
     }
 
+    /*
+     * The hide helper can be called several times for a given device.
+     * Check there is only one primary for a virtio-net device but
+     * don't duplicate the qdict several times if it's called for the same
+     * device.
+     */
     if (n->primary_opts) {
-        error_setg(errp, "Cannot attach more than one primary device to '%s'",
-                   n->netclient_name);
-        return false;
+        const char *old, *new;
+        /* devices with failover_pair_id always have an id */
+        old = qdict_get_str(n->primary_opts, "id");
+        new = qdict_get_str(device_opts, "id");
+        if (strcmp(old, new) != 0) {
+            error_setg(errp, "Cannot attach more than one primary device to "
+                       "'%s': '%s' and '%s'", n->netclient_name, old, new);
+            return false;
+        }
+    } else {
+        n->primary_opts = qdict_clone_shallow(device_opts);
+        n->primary_opts_from_json = from_json;
     }
 
-    n->primary_opts = qdict_clone_shallow(device_opts);
-    n->primary_opts_from_json = from_json;
-
     /* failover_primary_hidden is set during feature negotiation */
     return qatomic_read(&n->failover_primary_hidden);
 }
Signature · 1 line
MST
#28 lore raw

[PULL v2 42/44] tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob

In reply to Michael S. Tsirkin

From: Ani Sinha <[email protected]>

We are adding a new unit test to cover the acpi hotplug support in q35 for multi-function bridges. This test uses a new table DSDT.multi-bridge. We need to allow changes in DSDT acpi table for addition of this new unit test.

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 tests/data/acpi/q35/DSDT.multi-bridge       | 0
 2 files changed, 1 insertion(+)
 create mode 100644 tests/data/acpi/q35/DSDT.multi-bridge
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..dabc024f53 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/q35/DSDT.multi-bridge new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
MST
#29 lore raw

[PULL v2 29/44] rebuild-expected-aml.sh: allow partial target list

In reply to Michael S. Tsirkin

Only rebuild AML for configured targets.

---
 tests/data/acpi/rebuild-expected-aml.sh | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
tests/data/acpi/rebuild-expected-aml.sh +21 -1
index fc78770544..dcf2e2f221 100755
@@ -12,7 +12,7 @@
 # This work is licensed under the terms of the GNU GPLv2.
 # See the COPYING.LIB file in the top-level directory.
 
-qemu_bins="./qemu-system-x86_64 ./qemu-system-aarch64"
+qemu_arches="x86_64 aarch64"
 
 if [ ! -e "tests/qtest/bios-tables-test" ]; then
     echo "Test: bios-tables-test is required! Run make check before this script."
@@ -20,6 +20,26 @@ if [ ! -e "tests/qtest/bios-tables-test" ]; then
     exit 1;
 fi
 
+if grep TARGET_DIRS= config-host.mak; then
+    for arch in $qemu_arches; do
+        if  grep TARGET_DIRS= config-host.mak | grep "$arch"-softmmu;
+        then
+            qemu_bins="$qemu_bins ./qemu-system-$arch"
+        fi
+    done
+else
+    echo "config-host.mak missing!"
+    echo "Run this script from the build directory."
+    exit 1;
+fi
+
+if [ -z "$qemu_bins" ]; then
+    echo "Only the following architectures are currently supported: $qemu_arches"
+    echo "None of these configured!"
+    echo "To fix, run configure --target-list=x86_64-softmmu,aarch64-softmmu"
+    exit 1;
+fi
+
 for qemu in $qemu_bins; do
     if [ ! -e $qemu ]; then
         echo "Run 'make' to build the following QEMU executables: $qemu_bins"
Signature · 1 line
MST
#30 lore raw

[PULL v2 22/44] vhost-user-rng: Add vhost-user-rng implementation

In reply to Michael S. Tsirkin

From: Mathieu Poirier <[email protected]>

Introduce a random number generator (RNG) backend that communicates with a vhost-user server to retrieve entropy. That way other VMM that comply with the vhost user protocl can use the same vhost-user daemon without having to write yet another RNG driver.

Message-Id: <[email protected]>

---
 include/hw/virtio/vhost-user-rng.h |  33 ++++
 hw/virtio/vhost-user-rng.c         | 289 +++++++++++++++++++++++++++++
 hw/virtio/Kconfig                  |   5 +
 hw/virtio/meson.build              |   1 +
 4 files changed, 328 insertions(+)
 create mode 100644 include/hw/virtio/vhost-user-rng.h
 create mode 100644 hw/virtio/vhost-user-rng.c
include/hw/virtio/vhost-user-rng.h new file +33 -0
new file mode 100644
index 0000000000..071539996d
@@ -0,0 +1,33 @@
+/*
+ * Vhost-user RNG virtio device
+ *
+ * Copyright (c) 2021 Mathieu Poirier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef _QEMU_VHOST_USER_RNG_H
+#define _QEMU_VHOST_USER_RNG_H
+
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-user.h"
+#include "chardev/char-fe.h"
+
+#define TYPE_VHOST_USER_RNG "vhost-user-rng"
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG)
+
+struct VHostUserRNG {
+    /*< private >*/
+    VirtIODevice parent;
+    CharBackend chardev;
+    struct vhost_virtqueue *vhost_vq;
+    struct vhost_dev vhost_dev;
+    VhostUserState vhost_user;
+    VirtQueue *req_vq;
+    bool connected;
+
+    /*< public >*/
+};
+
+#endif /* _QEMU_VHOST_USER_RNG_H */
hw/virtio/vhost-user-rng.c new file +289 -0

289 lines not on this page · raw message

hw/virtio/Kconfig +5 -0
index 35ab45e209..c144d42f9b 100644
@@ -63,3 +63,8 @@ config VHOST_USER_I2C
     bool
     default y
     depends on VIRTIO && VHOST_USER
+
+config VHOST_USER_RNG
+    bool
+    default y
+    depends on VIRTIO && VHOST_USER
hw/virtio/meson.build +1 -0
index bc352a6009..ae6b2cde10 100644
@@ -27,6 +27,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
 virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
 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_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
Signature · 1 line
MST
#31 lore raw

[PULL v2 43/44] tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35

In reply to Michael S. Tsirkin

From: Ani Sinha <[email protected]>

commit d7346e614f4ec ("acpi: x86: pcihp: add support hotplug on multifunction bridges") added ACPI hotplug descriptions for cold plugged bridges for functions other than 0. For all other devices, the ACPI hotplug descriptions are limited to function 0 only. This change adds unit tests for this feature.

This test adds the following devices to qemu and then checks the changes introduced in the DSDT table due to the addition of the following devices:

(a) a multifunction bridge device
(b) a bridge device with function 1
(c) a non-bridge device with function 2

In the DSDT table, we should see AML hotplug descriptions for (a) and (b). For (a) we should find a hotplug AML description for function 0.

The following diff compares the DSDT table AML with the new unit test before and after the change d7346e614f4ec is introduced. In other words, this diff reflects the changes that occurs in the DSDT table due to the change d7346e614f4ec .

@@ -1,60 +1,38 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20190509 (64-bit version)
* Copyright (c) 2000 - 2019 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/q35/DSDT.multi-bridge, Thu Oct 7 18:56:05 2021
+ * Disassembly of /tmp/aml-AN0DA1, Thu Oct 7 18:56:05 2021
*
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x000020FE (8446)
+ *     Length           0x00002187 (8583)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xDE
+ *     Checksum         0x8D
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)

*/
DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
{
- /*

-     * iASL Warning: There was 1 external control method found during
-     * disassembly, but only 0 were resolved (1 unresolved). Additional
-     * ACPI tables may be required to properly disassemble the code. This
-     * resulting disassembler output file may not compile because the
-     * disassembler did not know how many arguments to assign to the
-     * unresolved methods. Note: SSDTs can be dynamically loaded at
-     * runtime and may or may not be available via the host OS.
-     *
-     * In addition, the -fe option can be used to specify a file containing
-     * control method external declarations with the associated method
-     * argument counts. Each line of the file must be of the form:
-     *     External (<method pathname>, MethodObj, <argument count>)
-     * Invocation:
-     *     iasl -fe refs.txt -d dsdt.aml
-     *
-     * The following methods were unresolved and many not compile properly
-     * because the disassembler had to guess at the number of arguments
-     * required for each:
-     */
-    External (_SB_.PCI0.S19_.PCNT, MethodObj)    // Warning: Unknown method, guessing 1 arguments
-
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

         Method (DBUG, 1, NotSerialized)
         {
             ToHexString (Arg0, Local0)
             ToBuffer (Local0, Local0)
             Local1 = (SizeOf (Local0) - One)
             Local2 = Zero
             While ((Local2 < Local1))
             {
@@ -3322,24 +3300,60 @@
                 Method (DVNT, 2, NotSerialized)
                 {
                     If ((Arg0 & One))
                     {
                         Notify (S00, Arg1)
                     }
                 }

                 Method (PCNT, 0, NotSerialized)
                 {
                     BNUM = One
                     DVNT (PCIU, One)
                     DVNT (PCID, 0x03)
                 }
             }

+ Device (S19)
+ {

+                Name (_ADR, 0x00030001)  // _ADR: Address
+                Name (BSEL, Zero)
+                Device (S00)
+                {
+                    Name (_SUN, Zero)  // _SUN: Slot User Number
+                    Name (_ADR, Zero)  // _ADR: Address
+                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device, x=0-9
+                    {

+ PCEJ (BSEL, _SUN)
+ }
+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+ }
+
+ Method (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
+ }
+
+ Method (PCNT, 0, NotSerialized)
+ {

+                    BNUM = Zero
+                    DVNT (PCIU, One)
+                    DVNT (PCID, 0x03)

+ }
+ }
+
Method (PCNT, 0, NotSerialized)
{

-                ^S19.PCNT (^S10.PCNT ())
+                ^S19.PCNT ()
+                ^S10.PCNT ()
             }
         }
     }

}

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
tests/qtest/bios-tables-test.c +18 -0
index 798f68c737..258874167e 100644
@@ -870,6 +870,23 @@ static void test_acpi_q35_tcg_bridge(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_multif_bridge(void)
+{
+    test_data data = {
+        .machine = MACHINE_Q35,
+        .variant = ".multi-bridge",
+    };
+    test_acpi_one("-device pcie-root-port,id=pcie-root-port-0,"
+                  "multifunction=on,"
+                  "port=0x0,chassis=1,addr=0x2,bus=pcie.0 "
+                  "-device pcie-root-port,id=pcie-root-port-1,"
+                  "port=0x1,chassis=2,addr=0x3.0x1,bus=pcie.0 "
+                  "-device virtio-balloon,id=balloon0,"
+                  "bus=pcie.0,addr=0x4.0x2",
+                  &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_q35_tcg_mmio64(void)
 {
     test_data data = {
@@ -1581,6 +1598,7 @@ int main(int argc, char *argv[])
                        test_acpi_piix4_no_acpi_pci_hotplug);
         qtest_add_func("acpi/q35", test_acpi_q35_tcg);
         qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
+        qtest_add_func("acpi/q35/multif-bridge", test_acpi_q35_multif_bridge);
         qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
         qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
         qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
Signature · 1 line
MST
#32 lore raw

[PULL v2 30/44] bios-tables-test: don't disassemble empty files

In reply to Michael S. Tsirkin

A recommended way to populate new tables is to have an empty expected file. In this case, attempts to disassemble will fail but it is useful to disassemble the actual files. Detect and skip decompile step in this case.

---
 tests/qtest/bios-tables-test.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
tests/qtest/bios-tables-test.c +25 -7
index 6e21a650d2..798f68c737 100644
@@ -271,19 +271,28 @@ static void dump_aml_files(test_data *data, bool rebuild)
     }
 }
 
+static bool create_tmp_asl(AcpiSdtTable *sdt)
+{
+    GError *error = NULL;
+    gint fd;
+
+    fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
+    g_assert_no_error(error);
+    close(fd);
+
+    return false;
+}
+
 static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
 {
     AcpiSdtTable *temp;
     GError *error = NULL;
     GString *command_line = g_string_new(iasl);
-    gint fd;
     gchar *out, *out_err;
     gboolean ret;
     int i;
 
-    fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
-    g_assert_no_error(error);
-    close(fd);
+    create_tmp_asl(sdt);
 
     /* build command line */
     g_string_append_printf(command_line, " -p %s ", sdt->asl_file);
@@ -463,11 +472,20 @@ static void test_acpi_asl(test_data *data)
         err = load_asl(data->tables, sdt);
         asl = normalize_asl(sdt->asl);
 
-        exp_err = load_asl(exp_data.tables, exp_sdt);
-        exp_asl = normalize_asl(exp_sdt->asl);
+        /*
+         * If expected file is empty - it's likely that it was a stub just
+         * created for step 1 above: we do want to decompile the actual one.
+         */
+        if (exp_sdt->aml_len) {
+            exp_err = load_asl(exp_data.tables, exp_sdt);
+            exp_asl = normalize_asl(exp_sdt->asl);
+        } else {
+            exp_err = create_tmp_asl(exp_sdt);
+            exp_asl = g_string_new("");
+        }
 
         /* TODO: check for warnings */
-        g_assert(!err || exp_err);
+        g_assert(!err || exp_err || !exp_sdt->aml_len);
 
         if (g_strcmp0(asl->str, exp_asl->str)) {
             sdt->tmp_files_retain = true;
Signature · 1 line
MST
#33 lore raw

[PULL v2 18/44] vdpa: Check for iova range at mappings changes

In reply to Michael S. Tsirkin

From: Eugenio Pérez <[email protected]>

Check vdpa device range before updating memory regions so we don't add any outside of it, and report the invalid change if any.

Message-Id: <[email protected]>

---
 include/hw/virtio/vhost-vdpa.h |  2 ++
 hw/virtio/vhost-vdpa.c         | 62 ++++++++++++++++++++++++++--------
 hw/virtio/trace-events         |  1 +
 3 files changed, 50 insertions(+), 15 deletions(-)
include/hw/virtio/vhost-vdpa.h +2 -0
index a8963da2d9..c288cf7ecb 100644
@@ -13,6 +13,7 @@
 #define HW_VIRTIO_VHOST_VDPA_H
 
 #include "hw/virtio/virtio.h"
+#include "standard-headers/linux/vhost_types.h"
 
 typedef struct VhostVDPAHostNotifier {
     MemoryRegion mr;
@@ -24,6 +25,7 @@ typedef struct vhost_vdpa {
     uint32_t msg_type;
     bool iotlb_batch_begin_sent;
     MemoryListener listener;
+    struct vhost_vdpa_iova_range iova_range;
     struct vhost_dev *dev;
     VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
 } VhostVDPA;
hw/virtio/vhost-vdpa.c +47 -15

93 lines not on this page · raw message

hw/virtio/trace-events +1 -0
index 8ed19e9d0c..650e521e35 100644
@@ -52,6 +52,7 @@ vhost_vdpa_set_vring_call(void *dev, unsigned int index, int fd) "dev: %p index:
 vhost_vdpa_get_features(void *dev, uint64_t features) "dev: %p features: 0x%"PRIx64
 vhost_vdpa_set_owner(void *dev) "dev: %p"
 vhost_vdpa_vq_get_addr(void *dev, void *vq, uint64_t desc_user_addr, uint64_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64
+vhost_vdpa_get_iova_range(void *dev, uint64_t first, uint64_t last) "dev: %p first: 0x%"PRIx64" last: 0x%"PRIx64
 
 # virtio.c
 virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned out_num) "elem %p size %zd in_num %u out_num %u"
Signature · 1 line
MST
#34 lore raw

[PULL v2 44/44] tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test

In reply to Michael S. Tsirkin

From: Ani Sinha <[email protected]>

We added a new unit test for testing acpi hotplug on multifunction bridges in q35 machines. Here, we update the DSDT table gloden master blob for this unit test.

The test adds the following devices to qemu and then checks the changes introduced in the DSDT table due to the addition of the following devices:

(a) a multifunction bridge device
(b) a bridge device with function 1
(c) a non-bridge device with function 2

In the DSDT table, we should see AML hotplug descriptions for (a) and (b). For (a) we should find a hotplug AML description for function 0.

Following is the ASL diff between the original DSDT table and the modified DSDT table due to the unit test. We see that multifunction bridge on bus 2 and single function bridge on bus 3 function 1 are described, not the non-bridge balloon device on bus 4, function 2.

@@ -1,30 +1,30 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20190509 (64-bit version)
* Copyright (c) 2000 - 2019 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/q35/DSDT, Thu Oct 7 18:29:19 2021
+ * Disassembly of /tmp/aml-C7JCA1, Thu Oct 7 18:29:19 2021 *
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x00002061 (8289)
+ *     Length           0x00002187 (8583)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xF9
+ *     Checksum         0x8D
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
 {
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

@@ -3265,23 +3265,95 @@

                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                 {
                     Return (Zero)
                 }
             }

+ Device (S10)
+ {

+                Name (_ADR, 0x00020000)  // _ADR: Address
+                Name (BSEL, One)
+                Device (S00)
+                {
+                    Name (_SUN, Zero)  // _SUN: Slot User Number
+                    Name (_ADR, Zero)  // _ADR: Address
+                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device, x=0-9
+                    {

+ PCEJ (BSEL, _SUN)
+ }
+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+ }
+
+ Method (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
+ }
+
+ Method (PCNT, 0, NotSerialized)
+ {

+                    BNUM = One
+                    DVNT (PCIU, One)
+                    DVNT (PCID, 0x03)

+ }
+ }
+
+ Device (S19)
+ {

+                Name (_ADR, 0x00030001)  // _ADR: Address
+                Name (BSEL, Zero)
+                Device (S00)
+                {
+                    Name (_SUN, Zero)  // _SUN: Slot User Number
+                    Name (_ADR, Zero)  // _ADR: Address
+                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device, x=0-9
+                    {

+ PCEJ (BSEL, _SUN)
+ }
+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+ }
+
+ Method (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
+ }
+
+ Method (PCNT, 0, NotSerialized)
+ {

+                    BNUM = Zero
+                    DVNT (PCIU, One)
+                    DVNT (PCID, 0x03)

+ }
+ }
+
Method (PCNT, 0, NotSerialized)
{
+ ^S19.PCNT ()
+ ^S10.PCNT ()

             }
         }
     }

}

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 tests/data/acpi/q35/DSDT.multi-bridge       | Bin 0 -> 8583 bytes
 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index dabc024f53..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a24c713d22102a1a1583b5c902edffe1694e5cfe 100644
GIT binary patch
Signature · 1 line
MST
#35 lore raw

[PULL v2 31/44] vhost-vdpa: open device fd in net_init_vhost_vdpa()

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

This patch switches to open device fd in net_init_vhost_vpda(). This is used to prepare for the multiqueue support.

Message-Id: <[email protected]>

---
 net/vhost-vdpa.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
net/vhost-vdpa.c +15 -8
index 6dc68d8677..fd4ff5a0fb 100644
@@ -170,24 +170,19 @@ static NetClientInfo net_vhost_vdpa_info = {
 };
 
 static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
-                               const char *name, const char *vhostdev)
+                               const char *name, int vdpa_device_fd)
 {
     NetClientState *nc = NULL;
     VhostVDPAState *s;
-    int vdpa_device_fd = -1;
     int ret = 0;
     assert(name);
     nc = qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name);
     snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA);
     s = DO_UPCAST(VhostVDPAState, nc, nc);
-    vdpa_device_fd = qemu_open_old(vhostdev, O_RDWR);
-    if (vdpa_device_fd == -1) {
-        return -errno;
-    }
+
     s->vhost_vdpa.device_fd = vdpa_device_fd;
     ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
     if (ret) {
-        qemu_close(vdpa_device_fd);
         qemu_del_net_client(nc);
     }
     return ret;
@@ -197,8 +192,20 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
                         NetClientState *peer, Error **errp)
 {
     const NetdevVhostVDPAOptions *opts;
+    int vdpa_device_fd, ret;
 
     assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
     opts = &netdev->u.vhost_vdpa;
-    return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, opts->vhostdev);
+
+    vdpa_device_fd = qemu_open_old(opts->vhostdev, O_RDWR);
+    if (vdpa_device_fd == -1) {
+        return -errno;
+    }
+
+    ret = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd);
+    if (ret) {
+        qemu_close(vdpa_device_fd);
+    }
+
+    return ret;
 }
Signature · 1 line
MST
#36 lore raw

[PULL v2 38/44] vhost: record the last virtqueue index for the virtio device

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

This patch introduces a new field in the vhost_dev structure to record the last virtqueue index for the virtio device. This will be useful for the vhost backends with 1:N model to start or stop the device after all the vhost_dev structures were started or stopped.

Message-Id: <[email protected]>

---
 include/hw/virtio/vhost.h |  2 ++
 hw/net/vhost_net.c        | 12 +++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)
include/hw/virtio/vhost.h +2 -0
index 1a9fc65089..3fa0b554ef 100644
@@ -74,6 +74,8 @@ struct vhost_dev {
     unsigned int nvqs;
     /* the first virtqueue which would be used by this vhost dev */
     int vq_index;
+    /* the last vq index for the virtio device (not vhost) */
+    int last_index;
     /* if non-zero, minimum required value for max_queues */
     int num_queues;
     uint64_t features;
hw/net/vhost_net.c +9 -3
index 2b594b4642..3aabab06ea 100644
@@ -231,9 +231,11 @@ fail:
     return NULL;
 }
 
-static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index)
+static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index,
+                                   int last_index)
 {
     net->dev.vq_index = vq_index;
+    net->dev.last_index = last_index;
 }
 
 static int vhost_net_start_one(struct vhost_net *net,
@@ -324,9 +326,13 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
     VirtIONet *n = VIRTIO_NET(dev);
     int nvhosts = data_queue_pairs + cvq;
     struct vhost_net *net;
-    int r, e, i;
+    int r, e, i, last_index = data_qps * 2;
     NetClientState *peer;
 
+    if (!cvq) {
+        last_index -= 1;
+    }
+
     if (!k->set_guest_notifiers) {
         error_report("binding does not support guest notifiers");
         return -ENOSYS;
@@ -341,7 +347,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         }
 
         net = get_vhost_net(peer);
-        vhost_net_set_vq_index(net, i * 2);
+        vhost_net_set_vq_index(net, i * 2, last_index);
 
         /* Suppress the masking guest notifiers on vhost user
          * because vhost user doesn't interrupt masking/unmasking
Signature · 1 line
MST
#37 lore raw

[PULL v2 20/44] virtio-iommu: Drop base_name and change generic_name

In reply to Michael S. Tsirkin

From: Eric Auger <[email protected]>

Drop base_name and turn generic_name into
"virtio-iommu-pci". This is more in line with
other modern-only devices.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio-iommu.h | 2 +-
 hw/virtio/virtio-iommu-pci.c     | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
include/hw/virtio/virtio-iommu.h +1 -1
index 273e35c04b..e2339e5b72 100644
@@ -26,7 +26,7 @@
 #include "qom/object.h"
 
 #define TYPE_VIRTIO_IOMMU "virtio-iommu-device"
-#define TYPE_VIRTIO_IOMMU_PCI "virtio-iommu-device-base"
+#define TYPE_VIRTIO_IOMMU_PCI "virtio-iommu-pci"
 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOIOMMU, VIRTIO_IOMMU)
 
 #define TYPE_VIRTIO_IOMMU_MEMORY_REGION "virtio-iommu-memory-region"
hw/virtio/virtio-iommu-pci.c +1 -2
index 86fa4e6c28..a160ae6b41 100644
@@ -98,8 +98,7 @@ static void virtio_iommu_pci_instance_init(Object *obj)
 }
 
 static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = {
-    .base_name             = TYPE_VIRTIO_IOMMU_PCI,
-    .generic_name          = "virtio-iommu-pci",
+    .generic_name          = TYPE_VIRTIO_IOMMU_PCI,
     .instance_size = sizeof(VirtIOIOMMUPCI),
     .instance_init = virtio_iommu_pci_instance_init,
     .class_init    = virtio_iommu_pci_class_init,
Signature · 1 line
MST
#38 lore raw

[PULL v2 34/44] vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState *

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

This patch switches to let net_vhost_vdpa_init() to return NetClientState *. This is used for the callers to allocate multiqueue NetClientState for multiqueue support.

Message-Id: <[email protected]>

---
 net/vhost-vdpa.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
net/vhost-vdpa.c +12 -7
index fd4ff5a0fb..151f60184d 100644
@@ -169,8 +169,10 @@ static NetClientInfo net_vhost_vdpa_info = {
         .check_peer_type = vhost_vdpa_check_peer_type,
 };
 
-static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
-                               const char *name, int vdpa_device_fd)
+static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
+                                           const char *device,
+                                           const char *name,
+                                           int vdpa_device_fd)
 {
     NetClientState *nc = NULL;
     VhostVDPAState *s;
@@ -184,15 +186,17 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
     ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
     if (ret) {
         qemu_del_net_client(nc);
+        return NULL;
     }
-    return ret;
+    return nc;
 }
 
 int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
                         NetClientState *peer, Error **errp)
 {
     const NetdevVhostVDPAOptions *opts;
-    int vdpa_device_fd, ret;
+    int vdpa_device_fd;
+    NetClientState *nc;
 
     assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
     opts = &netdev->u.vhost_vdpa;
@@ -202,10 +206,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
         return -errno;
     }
 
-    ret = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd);
-    if (ret) {
+    nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd);
+    if (!nc) {
         qemu_close(vdpa_device_fd);
+        return -1;
     }
 
-    return ret;
+    return 0;
 }
Signature · 1 line
MST
#39 lore raw

[PULL v2 21/44] libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr

In reply to Michael S. Tsirkin

From: David Hildenbrand <[email protected]>

We end up not copying the mmap_addr of all existing regions, resulting in a SEGFAULT once we actually try to map/access anything within our memory regions.

Fixes 875b9fd97b34 ("Support individual region unmap in libvhost-user")
Cc Michael S. Tsirkin <[email protected]>
Cc Raphael Norwitz <[email protected]>
Cc "Marc-André Lureau" <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Coiby Xu <[email protected]>

Message-Id: <[email protected]>

---
 subprojects/libvhost-user/libvhost-user.c | 1 +
 1 file changed, 1 insertion(+)
subprojects/libvhost-user/libvhost-user.c +1 -0
index bf09693255..787f4d2d4f 100644
@@ -816,6 +816,7 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
             shadow_regions[j].gpa = dev->regions[i].gpa;
             shadow_regions[j].size = dev->regions[i].size;
             shadow_regions[j].qva = dev->regions[i].qva;
+            shadow_regions[j].mmap_addr = dev->regions[i].mmap_addr;
             shadow_regions[j].mmap_offset = dev->regions[i].mmap_offset;
             j++;
         } else {
Signature · 1 line
MST
#40 lore raw

[PULL v2 37/44] virtio-net: use "queue_pairs" instead of "queues" when possible

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

Most of the time, "queues" really means queue pairs. So this patch switch to use "queue_pairs" to avoid confusion.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio-net.h |   4 +-
 hw/net/vhost_net.c             |   6 +-
 hw/net/virtio-net.c            | 150 ++++++++++++++++-----------------
 3 files changed, 80 insertions(+), 80 deletions(-)
include/hw/virtio/virtio-net.h +2 -2
index 74a10ebe85..2903b79a92 100644
@@ -194,8 +194,8 @@ struct VirtIONet {
     NICConf nic_conf;
     DeviceState *qdev;
     int multiqueue;
-    uint16_t max_queues;
-    uint16_t curr_queues;
+    uint16_t max_queue_pairs;
+    uint16_t curr_queue_pairs;
     size_t config_size;
     char *netclient_name;
     char *netclient_type;
hw/net/vhost_net.c +3 -3
index e1e9d1ec89..2b594b4642 100644
@@ -337,7 +337,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         if (i < data_queue_pairs) {
             peer = qemu_get_peer(ncs, i);
         } else { /* Control Virtqueue */
-            peer = qemu_get_peer(ncs, n->max_queues);
+            peer = qemu_get_peer(ncs, n->max_queue_pairs);
         }
 
         net = get_vhost_net(peer);
@@ -362,7 +362,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         if (i < data_queue_pairs) {
             peer = qemu_get_peer(ncs, i);
         } else {
-            peer = qemu_get_peer(ncs, n->max_queues);
+            peer = qemu_get_peer(ncs, n->max_queue_pairs);
         }
         r = vhost_net_start_one(get_vhost_net(peer), dev);
 
@@ -412,7 +412,7 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
         if (i < data_queue_pairs) {
             peer = qemu_get_peer(ncs, i);
         } else {
-            peer = qemu_get_peer(ncs, n->max_queues);
+            peer = qemu_get_peer(ncs, n->max_queue_pairs);
         }
         vhost_net_stop_one(get_vhost_net(peer), dev);
     }
hw/net/virtio-net.c +75 -75

447 lines not on this page · raw message

Signature · 1 line
MST
#41 lore raw

[PULL v2 24/44] docs: Add documentation for vhost based RNG implementation

In reply to Michael S. Tsirkin

From: Mathieu Poirier <[email protected]>

Add description and example for the vhost-user based RNG implementation.

Message-Id: <[email protected]>

---
 docs/system/device-emulation.rst       |  1 +
 docs/system/devices/vhost-user-rng.rst | 39 ++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 docs/system/devices/vhost-user-rng.rst
docs/system/device-emulation.rst +1 -0
index 7afcfd8064..19944f526c 100644
@@ -88,3 +88,4 @@ Emulated Devices
    devices/usb.rst
    devices/vhost-user.rst
    devices/virtio-pmem.rst
+   devices/vhost-user-rng.rst
docs/system/devices/vhost-user-rng.rst new file +39 -0
new file mode 100644
index 0000000000..a145d4105c
@@ -0,0 +1,39 @@
+QEMU vhost-user-rng - RNG emulation
+===================================
+
+Background
+----------
+
+What follows builds on the material presented in vhost-user.rst - it should
+be reviewed before moving forward with the content in this file.
+
+Description
+-----------
+
+The vhost-user-rng device implementation was designed to work with a random
+number generator daemon such as the one found in the vhost-device crate of
+the rust-vmm project available on github [1].
+
+[1]. https://github.com/rust-vmm/vhost-device
+
+Examples
+--------
+
+The daemon should be started first:
+
+::
+
+  host# vhost-device-rng --socket-path=rng.sock -c 1 -m 512 -p 1000
+
+The QEMU invocation needs to create a chardev socket the device can
+use to communicate as well as share the guests memory over a memfd.
+
+::
+
+  host# qemu-system								\
+      -chardev socket,path=$(PATH)/rng.sock,id=rng0				\
+      -device vhost-user-rng-pci,chardev=rng0					\
+      -m 4096 									\
+      -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on	\
+      -numa node,memdev=mem							\
+      ...
Signature · 1 line
MST
#42 lore raw

[PULL v2 36/44] vhost-net: control virtqueue support

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

We assume there's no cvq in the past, this is not true when we need control virtqueue support for vhost-user backends. So this patch implements the control virtqueue support for vhost-net. As datapath, the control virtqueue is also required to be coupled with the NetClientState. The vhost_net_start/stop() are tweaked to accept the number of datapath queue pairs plus the the number of control virtqueue for us to start and stop the vhost device.

Message-Id: <[email protected]>

---
 include/net/vhost_net.h |  6 ++++--
 hw/net/vhost_net-stub.c |  4 ++--
 hw/net/vhost_net.c      | 43 ++++++++++++++++++++++++++++++-----------
 hw/net/virtio-net.c     |  4 ++--
 4 files changed, 40 insertions(+), 17 deletions(-)
include/net/vhost_net.h +4 -2
index fba40cf695..387e913e4e 100644
@@ -21,8 +21,10 @@ typedef struct VhostNetOptions {
 uint64_t vhost_net_get_max_queues(VHostNetState *net);
 struct vhost_net *vhost_net_init(VhostNetOptions *options);
 
-int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int total_queues);
-void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, int total_queues);
+int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
+                    int data_queue_pairs, int cvq);
+void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
+                    int data_queue_pairs, int cvq);
 
 void vhost_net_cleanup(VHostNetState *net);
 
hw/net/vhost_net-stub.c +2 -2
index a7f4252630..89d71cfb8e 100644
@@ -33,13 +33,13 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
 
 int vhost_net_start(VirtIODevice *dev,
                     NetClientState *ncs,
-                    int total_queues)
+                    int data_queue_pairs, int cvq)
 {
     return -ENOSYS;
 }
 void vhost_net_stop(VirtIODevice *dev,
                     NetClientState *ncs,
-                    int total_queues)
+                    int data_queue_pairs, int cvq)
 {
 }
 
hw/net/vhost_net.c +32 -11

91 lines not on this page · raw message

hw/net/virtio-net.c +2 -2
index 3dd2896ff9..5ee6729662 100644
@@ -285,14 +285,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
         }
 
         n->vhost_started = 1;
-        r = vhost_net_start(vdev, n->nic->ncs, queues);
+        r = vhost_net_start(vdev, n->nic->ncs, queues, 0);
         if (r < 0) {
             error_report("unable to start vhost net: %d: "
                          "falling back on userspace virtio", -r);
             n->vhost_started = 0;
         }
     } else {
-        vhost_net_stop(vdev, n->nic->ncs, queues);
+        vhost_net_stop(vdev, n->nic->ncs, queues, 0);
         n->vhost_started = 0;
     }
 }
Signature · 1 line
MST
#43 lore raw

[PULL v2 27/44] vhost-user-blk-test: pass vhost-user socket fds to QSD

In reply to Michael S. Tsirkin

From: Stefan Hajnoczi <[email protected]>

qemu-storage-daemon is launched with the vhost-user listen socket path. The path is first unlinked before opening the listen socket. This prevents stale UNIX domain socket files from stopping socket initialization.

This behavior is undesirable in vhost-user-blk-test and the cause of a bug:

There is a race condition in vhost-user-blk-test when QEMU launches before QSD. It connects to the old socket that QSD unlinks and the vhost-user connection is never serviced, resulting in a hang.

Pass the listen socket fd to QSD to maintain listen socket continuity and prevent the lost connection.

Fixes 806952026df41939680abe92b329715b9b4e01cc ("test: new qTest case to test the vhost-user-blk-server")
Cc Raphael Norwitz <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Coiby Xu <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/vhost-user-blk-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/vhost-user-blk-test.c +2 -2
index 6f108a1b62..62e670f39b 100644
@@ -906,9 +906,9 @@ static void start_vhost_user_blk(GString *cmd_line, int vus_instances,
         img_path = drive_create();
         g_string_append_printf(storage_daemon_command,
             "--blockdev driver=file,node-name=disk%d,filename=%s "
-            "--export type=vhost-user-blk,id=disk%d,addr.type=unix,addr.path=%s,"
+            "--export type=vhost-user-blk,id=disk%d,addr.type=fd,addr.str=%d,"
             "node-name=disk%i,writable=on,num-queues=%d ",
-            i, img_path, i, sock_path, i, num_queues);
+            i, img_path, i, fd, i, num_queues);
 
         g_string_append_printf(cmd_line, "-chardev socket,id=char%d,path=%s ",
                                i + 1, sock_path);
Signature · 1 line
MST
#44 lore raw

[PULL v2 33/44] vhost-vdpa: prepare for the multiqueue support

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

Unlike vhost-kernel, vhost-vdpa adapts a single device multiqueue model. So we need to simply use virtqueue index as the vhost virtqueue index. This is a must for multiqueue to work for vhost-vdpa.

Message-Id: <[email protected]>

---
 hw/virtio/vhost-vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-vdpa.c +2 -2
index ceb53613ba..8948fd316b 100644
@@ -546,8 +546,8 @@ static int vhost_vdpa_get_vq_index(struct vhost_dev *dev, int idx)
 {
     assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
 
-    trace_vhost_vdpa_get_vq_index(dev, idx, idx - dev->vq_index);
-    return idx - dev->vq_index;
+    trace_vhost_vdpa_get_vq_index(dev, idx, idx);
+    return idx;
 }
 
 static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev)
Signature · 1 line
MST
#45 lore raw

[PULL v2 35/44] net: introduce control client

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

This patch introduces a boolean for the device has control queue which can accepts control command via network queue.

The first user would be the control virtqueue support for vhost.

Message-Id: <[email protected]>

---
 include/net/net.h |  5 +++++
 net/net.c         | 24 +++++++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)
include/net/net.h +5 -0
index 986288eb07..523136c7ac 100644
@@ -105,6 +105,7 @@ struct NetClientState {
     int vnet_hdr_len;
     bool is_netdev;
     bool do_not_pad; /* do not pad to the minimum ethernet frame length */
+    bool is_datapath;
     QTAILQ_HEAD(, NetFilterState) filters;
 };
 
@@ -136,6 +137,10 @@ NetClientState *qemu_new_net_client(NetClientInfo *info,
                                     NetClientState *peer,
                                     const char *model,
                                     const char *name);
+NetClientState *qemu_new_net_control_client(NetClientInfo *info,
+                                        NetClientState *peer,
+                                        const char *model,
+                                        const char *name);
 NICState *qemu_new_nic(NetClientInfo *info,
                        NICConf *conf,
                        const char *model,
net/net.c +21 -3
index 52c99196c6..f0d14dbfc1 100644
@@ -239,7 +239,8 @@ static void qemu_net_client_setup(NetClientState *nc,
                                   NetClientState *peer,
                                   const char *model,
                                   const char *name,
-                                  NetClientDestructor *destructor)
+                                  NetClientDestructor *destructor,
+                                  bool is_datapath)
 {
     nc->info = info;
     nc->model = g_strdup(model);
@@ -258,6 +259,7 @@ static void qemu_net_client_setup(NetClientState *nc,
 
     nc->incoming_queue = qemu_new_net_queue(qemu_deliver_packet_iov, nc);
     nc->destructor = destructor;
+    nc->is_datapath = is_datapath;
     QTAILQ_INIT(&nc->filters);
 }
 
@@ -272,7 +274,23 @@ NetClientState *qemu_new_net_client(NetClientInfo *info,
 
     nc = g_malloc0(info->size);
     qemu_net_client_setup(nc, info, peer, model, name,
-                          qemu_net_client_destructor);
+                          qemu_net_client_destructor, true);
+
+    return nc;
+}
+
+NetClientState *qemu_new_net_control_client(NetClientInfo *info,
+                                            NetClientState *peer,
+                                            const char *model,
+                                            const char *name)
+{
+    NetClientState *nc;
+
+    assert(info->size >= sizeof(NetClientState));
+
+    nc = g_malloc0(info->size);
+    qemu_net_client_setup(nc, info, peer, model, name,
+                          qemu_net_client_destructor, false);
 
     return nc;
 }
@@ -297,7 +315,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
 
     for (i = 0; i < queues; i++) {
         qemu_net_client_setup(&nic->ncs[i], info, peers[i], model, name,
-                              NULL);
+                              NULL, true);
         nic->ncs[i].queue_index = i;
     }
 
Signature · 1 line
MST
#46 lore raw

[PULL v2 41/44] pci: fix PCI resource reserve capability on BE

In reply to Michael S. Tsirkin

PCI resource reserve capability should use LE format as all other PCI things. If we don't then seabios won't boot:

=== PCI new allocation pass #1 ===
PCI: check devices
PCI: QEMU resource reserve cap: size 10000000000000 type io
PCI: secondary bus 1 size 10000000000000 type io
PCI: secondary bus 1 size 00200000 type mem
PCI: secondary bus 1 size 00200000 type prefmem === PCI new allocation pass #2 ===
PCI: out of I/O address space

This became more important since we started reserving IO by default, previously no one noticed.

Fixes e2a6290aab ("hw/pcie-root-port: Fix hotplug for PCI devices requiring IO")
Fixes 226263fb5c ("hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port")
Fixes 6755e618d0 ("hw/pci: add PCI resource reserve capability to legacy PCI bridge")
---
 hw/pci/pci_bridge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/pci/pci_bridge.c +5 -5
index d1f902ee86..da34c8ebcd 100644
@@ -448,11 +448,11 @@ int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
     PCIBridgeQemuCap cap = {
             .len = cap_len,
             .type = REDHAT_PCI_CAP_RESOURCE_RESERVE,
-            .bus_res = res_reserve.bus,
-            .io = res_reserve.io,
-            .mem = res_reserve.mem_non_pref,
-            .mem_pref_32 = res_reserve.mem_pref_32,
-            .mem_pref_64 = res_reserve.mem_pref_64
+            .bus_res = cpu_to_le32(res_reserve.bus),
+            .io = cpu_to_le64(res_reserve.io),
+            .mem = cpu_to_le32(res_reserve.mem_non_pref),
+            .mem_pref_32 = cpu_to_le32(res_reserve.mem_pref_32),
+            .mem_pref_64 = cpu_to_le64(res_reserve.mem_pref_64)
     };
 
     int offset = pci_add_capability(dev, PCI_CAP_ID_VNDR,
Signature · 1 line
MST
#47 lore raw
In reply to Michael S. Tsirkin
Quoted 131 lines · Michael S. Tsirkin

The following changes since commit 50352cce138ef3b30c1cda28a4df68fff5da3202:

   Merge remote-tracking branch 'remotes/juanquintela/tags/migration.next-pull-request' into staging (2021-10-19 07:41:04 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a8339e07f94a47f99560baef59d65a9e039aaf45:

tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test (2021-10-20 06:18:17 -0400)

----------------------------------------------------------------
pc,pci,virtio: features, fixes, tests

vhost user rng
vdpa multiqueue
Fixes, cleanups, new tests all over the place.

----------------------------------------------------------------
Ani Sinha (3):
tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35 tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test

David Hildenbrand (1):
libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr

Eric Auger (2):
virtio-iommu: Remove the non transitional name
virtio-iommu: Drop base_name and change generic_name

Eugenio Pérez (3):
vdpa: Skip protected ram IOMMU mappings
vdpa: Add vhost_vdpa_section_end
vdpa: Check for iova range at mappings changes

Igor Mammedov (15):
tests: acpi: dump table with failed checksum
tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator
tests: acpi: whitelist expected tables for acpi/q35/xapic testcase
tests: acpi: q35: test for x2APIC entries in SRAT
tests: acpi: update expected tables blobs
tests: acpi: whitelist new expected table tests/data/acpi/q35/DMAR.dmar
tests: acpi: add testcase for intel_iommu (DMAR table)
tests: acpi: add expected blob for DMAR table
tests: acpi: whitelist expected blobs for new acpi/q35/ivrs testcase
tests: acpi: add testcase for amd-iommu (IVRS table)
tests: acpi: update expected blobs
tests: acpi: arm/virt: drop redundant test_acpi_one() in test_acpi_virt_tcg()
tests: arm-cpu-features: use qtest_has_kvm() API
tests: migration-test: use qtest_has_accel() API
tests: bios-tables-test: use qtest_has_accel() API to register TCG only tests

Jason Wang (10):
vhost-vdpa: open device fd in net_init_vhost_vdpa()
vhost-vdpa: classify one time request
vhost-vdpa: prepare for the multiqueue support
vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState *
net: introduce control client
vhost-net: control virtqueue support
virtio-net: use "queue_pairs" instead of "queues" when possible
vhost: record the last virtqueue index for the virtio device
virtio-net: vhost control virtqueue support
vhost-vdpa: multiqueue support

Laurent Vivier (2):
failover: fix a regression introduced by JSON'ification of -device qdev/qbus: remove failover specific code

Mathieu Poirier (3):
vhost-user-rng: Add vhost-user-rng implementation
vhost-user-rng-pci: Add vhost-user-rng-pci implementation
docs: Add documentation for vhost based RNG implementation

Michael S. Tsirkin (3):
rebuild-expected-aml.sh: allow partial target list
bios-tables-test: don't disassemble empty files
pci: fix PCI resource reserve capability on BE

Stefan Hajnoczi (1):
vhost-user-blk-test: pass vhost-user socket fds to QSD

Xueming Li (1):
vhost-user: fix duplicated notifier MR init

  include/hw/virtio/vhost-user-rng.h        |  33 ++++
  include/hw/virtio/vhost-vdpa.h            |   3 +
  include/hw/virtio/vhost.h                 |   2 +
  include/hw/virtio/virtio-iommu.h          |   2 +-
  include/hw/virtio/virtio-net.h            |   5 +-
  include/net/net.h                         |   5 +
  include/net/vhost_net.h                   |   6 +-
  tests/qtest/libqos/libqtest.h             |   8 +
  hw/net/vhost_net-stub.c                   |   4 +-
  hw/net/vhost_net.c                        |  55 ++++--
  hw/net/virtio-net.c                       | 201 ++++++++++++---------
  hw/pci/pci_bridge.c                       |  10 +-
  hw/virtio/vhost-user-rng-pci.c            |  79 ++++++++
  hw/virtio/vhost-user-rng.c                | 289 ++++++++++++++++++++++++++++++
  hw/virtio/vhost-user.c                    |   5 +-
  hw/virtio/vhost-vdpa.c                    | 140 ++++++++++++---
  hw/virtio/virtio-iommu-pci.c              |   4 +-
  net/net.c                                 |  24 ++-
  net/vhost-vdpa.c                          | 127 +++++++++++--
  softmmu/qdev-monitor.c                    |  18 +-
  subprojects/libvhost-user/libvhost-user.c |   1 +
  tests/qtest/acpi-utils.c                  |  14 ++
  tests/qtest/arm-cpu-features.c            |  29 +--
  tests/qtest/bios-tables-test.c            | 122 ++++++++++---
  tests/qtest/libqtest.c                    |  27 +++
  tests/qtest/migration-test.c              |  15 +-
  tests/qtest/vhost-user-blk-test.c         |   4 +-
  docs/system/device-emulation.rst          |   1 +
  docs/system/devices/vhost-user-rng.rst    |  39 ++++
  hw/virtio/Kconfig                         |   5 +
  hw/virtio/meson.build                     |   2 +
  hw/virtio/trace-events                    |   1 +
  meson.build                               |   6 +
  tests/data/acpi/q35/APIC.xapic            | Bin 0 -> 2686 bytes
  tests/data/acpi/q35/DMAR.dmar             | Bin 0 -> 120 bytes
  tests/data/acpi/q35/DSDT.ivrs             | Bin 0 -> 8306 bytes
  tests/data/acpi/q35/DSDT.multi-bridge     | Bin 0 -> 8583 bytes
  tests/data/acpi/q35/DSDT.xapic            | Bin 0 -> 35652 bytes
  tests/data/acpi/q35/FACP.xapic            | Bin 0 -> 244 bytes
  tests/data/acpi/q35/IVRS.ivrs             | Bin 0 -> 104 bytes
  tests/data/acpi/q35/SRAT.xapic            | Bin 0 -> 5080 bytes
  tests/data/acpi/rebuild-expected-aml.sh   |  22 ++-
  42 files changed, 1075 insertions(+), 233 deletions(-)
Quoted 12 lines

create mode 100644 include/hw/virtio/vhost-user-rng.h create mode 100644 hw/virtio/vhost-user-rng-pci.c create mode 100644 hw/virtio/vhost-user-rng.c create mode 100644 docs/system/devices/vhost-user-rng.rst create mode 100644 tests/data/acpi/q35/APIC.xapic create mode 100644 tests/data/acpi/q35/DMAR.dmar create mode 100644 tests/data/acpi/q35/DSDT.ivrs create mode 100644 tests/data/acpi/q35/DSDT.multi-bridge create mode 100644 tests/data/acpi/q35/DSDT.xapic create mode 100644 tests/data/acpi/q35/FACP.xapic create mode 100644 tests/data/acpi/q35/IVRS.ivrs create mode 100644 tests/data/acpi/q35/SRAT.xapic

Applied, thanks.

r~