Skip to contentSkip to conversation

pc,pci,virtio,crypto: bugfixes

GIT PULL Applied Michael S. Tsirkin 4 participants 30 messages Aug 3, 2023 – Aug 4, 2023

lore
Share & tools
lore
#0 lore raw

The following changes since commit c167c80b463768e04a22fbe37ba6c53a4a08e41e:

Merge tag 'pull-request-2023-08-03' of https://gitlab.com/thuth/qemu into staging (2023-08-03 07:37:17 -0700)

are available in the Git repository at:

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

for you to fetch changes up to 15b11a1da6a4b7c6b8bb37883f52b544dee2b8fd:

cryptodev: Handle unexpected request to avoid crash (2023-08-03 16:16:17 -0400)

----------------------------------------------------------------
pc,pci,virtio,crypto: bugfixes

fixes all over the place.

----------------------------------------------------------------
David Edmondson (1):
hw/virtio: qmp: add RING_RESET to 'info virtio-status'

Eric Auger (2):
hw/virtio-iommu: Fix potential OOB access in virtio_iommu_handle_command()
virtio-iommu: Standardize granule extraction and formatting

Hanna Czenczek (1):
virtio: Fix packed virtqueue used_idx mask

Igor Mammedov (6):
tests: acpi: x86: whitelist expected blobs
x86: acpi: workaround Windows not handling name references in Package properly
tests: acpi: x86: update expected blobs
tests: acpi: whitelist expected blobs
acpi: x86: remove _ADR on host bridges
tests: acpi: update expected blobs

Li Feng (1):
vhost: fix the fd leak

Milan Zamazal (1):
hw/virtio: Add a protection against duplicate vu_scmi_stop calls

Peter Maydell (1):
hw/pci-bridge/cxl_upstream.c: Use g_new0() in build_cdat_table()

Thomas Huth (6):
hw/i386/intel_iommu: Fix trivial endianness problems hw/i386/intel_iommu: Fix endianness problems related to VTD_IR_TableEntry hw/i386/intel_iommu: Fix struct VTDInvDescIEC on big endian hosts hw/i386/intel_iommu: Fix index calculation in vtd_interrupt_remap_msi() hw/i386/x86-iommu: Fix endianness issue in x86_iommu_irq_to_msi_message() include/hw/i386/x86-iommu: Fix struct X86IOMMU_MSIMessage for big endian hosts

Yuri Benditovich (1):
pci: do not respond config requests after PCI device eject

Zhenwei Pi (2):
virtio-crypto: verify src&dst buffer length for sym request
cryptodev: Handle unexpected request to avoid crash

 hw/i386/intel_iommu_internal.h                |   9 +++++
 include/hw/i386/intel_iommu.h                 |  50 +++++++++++++-------------
 include/hw/i386/x86-iommu.h                   |  50 +++++++++++++-------------
 include/hw/virtio/vhost-user-scmi.h           |   1 +
 backends/cryptodev.c                          |  10 ++++++
 hw/i386/acpi-build.c                          |  11 +++---
 hw/i386/intel_iommu.c                         |  23 +++++++-----
 hw/i386/x86-iommu.c                           |   2 +-
 hw/pci-bridge/cxl_upstream.c                  |   5 +--
 hw/pci/pci_host.c                             |  15 ++++++--
 hw/virtio/vhost-user-scmi.c                   |   7 ++++
 hw/virtio/vhost.c                             |   2 ++
 hw/virtio/virtio-crypto.c                     |   5 +++
 hw/virtio/virtio-iommu.c                      |  12 ++++---
 hw/virtio/virtio-qmp.c                        |   2 ++
 hw/virtio/virtio.c                            |   2 +-
 tests/data/acpi/pc/DSDT                       | Bin 6488 -> 6830 bytes
 tests/data/acpi/pc/DSDT.acpierst              | Bin 6411 -> 6741 bytes
 tests/data/acpi/pc/DSDT.acpihmat              | Bin 7813 -> 8155 bytes
 tests/data/acpi/pc/DSDT.bridge                | Bin 12615 -> 13701 bytes
 tests/data/acpi/pc/DSDT.cphp                  | Bin 6952 -> 7294 bytes
 tests/data/acpi/pc/DSDT.dimmpxm               | Bin 8142 -> 8484 bytes
 tests/data/acpi/pc/DSDT.hpbridge              | Bin 6451 -> 6781 bytes
 tests/data/acpi/pc/DSDT.hpbrroot              | Bin 3343 -> 3337 bytes
 tests/data/acpi/pc/DSDT.ipmikcs               | Bin 6560 -> 6902 bytes
 tests/data/acpi/pc/DSDT.memhp                 | Bin 7847 -> 8189 bytes
 tests/data/acpi/pc/DSDT.nohpet                | Bin 6346 -> 6688 bytes
 tests/data/acpi/pc/DSDT.numamem               | Bin 6494 -> 6836 bytes
 tests/data/acpi/pc/DSDT.roothp                | Bin 9873 -> 10623 bytes
 tests/data/acpi/q35/DSDT                      | Bin 8361 -> 8355 bytes
 tests/data/acpi/q35/DSDT.acpierst             | Bin 8378 -> 8372 bytes
 tests/data/acpi/q35/DSDT.acpihmat             | Bin 9686 -> 9680 bytes
 tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8640 -> 8634 bytes
 tests/data/acpi/q35/DSDT.applesmc             | Bin 8407 -> 8401 bytes
 tests/data/acpi/q35/DSDT.bridge               | Bin 11590 -> 11968 bytes
 tests/data/acpi/q35/DSDT.core-count2          | Bin 32501 -> 32495 bytes
 tests/data/acpi/q35/DSDT.cphp                 | Bin 8825 -> 8819 bytes
 tests/data/acpi/q35/DSDT.cxl                  | Bin 9673 -> 9655 bytes
 tests/data/acpi/q35/DSDT.dimmpxm              | Bin 10015 -> 10009 bytes
 tests/data/acpi/q35/DSDT.ipmibt               | Bin 8436 -> 8430 bytes
 tests/data/acpi/q35/DSDT.ipmismbus            | Bin 8449 -> 8443 bytes
 tests/data/acpi/q35/DSDT.ivrs                 | Bin 8378 -> 8372 bytes
 tests/data/acpi/q35/DSDT.memhp                | Bin 9720 -> 9714 bytes
 tests/data/acpi/q35/DSDT.mmio64               | Bin 9491 -> 9485 bytes
 tests/data/acpi/q35/DSDT.multi-bridge         | Bin 12770 -> 13208 bytes
 tests/data/acpi/q35/DSDT.noacpihp             | Bin 8241 -> 8235 bytes
 tests/data/acpi/q35/DSDT.nohpet               | Bin 8219 -> 8213 bytes
 tests/data/acpi/q35/DSDT.numamem              | Bin 8367 -> 8361 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa          | Bin 8462 -> 8456 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12            | Bin 8967 -> 8961 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2             | Bin 8993 -> 8987 bytes
 tests/data/acpi/q35/DSDT.viot                 | Bin 9470 -> 9464 bytes
 tests/data/acpi/q35/DSDT.xapic                | Bin 35724 -> 35718 bytes
 53 files changed, 132 insertions(+), 74 deletions(-)
#1 lore raw

[PULL 15/22] hw/i386/intel_iommu: Fix trivial endianness problems

From: Thomas Huth <[email protected]>

After reading the guest memory with dma_memory_read(), we have to make sure that we byteswap the little endian data to the host's byte order.

Message-Id: <[email protected]>

---
 hw/i386/intel_iommu.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/intel_iommu.c +5 -0
index dcc334060c..13fcde8e91 100644
@@ -756,6 +756,8 @@ static int vtd_get_pdire_from_pdir_table(dma_addr_t pasid_dir_base,
         return -VTD_FR_PASID_TABLE_INV;
     }
 
+    pdire->val = le64_to_cpu(pdire->val);
+
     return 0;
 }
 
@@ -780,6 +782,9 @@ static int vtd_get_pe_in_pasid_leaf_table(IntelIOMMUState *s,
                         pe, entry_size, MEMTXATTRS_UNSPECIFIED)) {
         return -VTD_FR_PASID_TABLE_INV;
     }
+    for (size_t i = 0; i < ARRAY_SIZE(pe->val); i++) {
+        pe->val[i] = le64_to_cpu(pe->val[i]);
+    }
 
     /* Do translation type check */
     if (!vtd_pe_type_check(x86_iommu, pe)) {
Signature · 1 line
MST
#2 lore raw

[PULL 02/22] hw/pci-bridge/cxl_upstream.c: Use g_new0() in build_cdat_table()

In reply to Michael S. Tsirkin

From: Peter Maydell <[email protected]>

In build_cdat_table() we do:
*cdat_table = g_malloc0(sizeof(*cdat_table) * CXL_USP_CDAT_NUM_ENTRIES);
This is wrong because:
- cdat_table has type CDATSubHeader ***
- so *cdat_table has type CDATSubHeader **
- so the array we're allocating here should be items of type CDATSubHeader *
- but we pass sizeof(*cdat_table), which is sizeof(CDATSubHeader **), implying that we're allocating an array of CDATSubHeader **

It happens that sizeof(CDATSubHeader **) == sizeof(CDATSubHeader *) so nothing blows up, but this should be sizeof(**cdat_table).

Avoid this excessively hard-to-understand code by using g_new0() instead, which will do the type checking for us. While we're here, we can drop the useless check against failure, as g_malloc0() and g_new0() never fail.

This fixes Coverity issue CID 1508120.

Message-Id: <[email protected]>

---
 hw/pci-bridge/cxl_upstream.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
hw/pci-bridge/cxl_upstream.c +1 -4
index ef47e5d625..9159f48a8c 100644
@@ -274,10 +274,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv)
         };
     }
 
-    *cdat_table = g_malloc0(sizeof(*cdat_table) * CXL_USP_CDAT_NUM_ENTRIES);
-    if (!*cdat_table) {
-        return -ENOMEM;
-    }
+    *cdat_table = g_new0(CDATSubHeader *, CXL_USP_CDAT_NUM_ENTRIES);
 
     /* Header always at start of structure */
     (*cdat_table)[CXL_USP_CDAT_SSLBIS_LAT] = g_steal_pointer(&sslbis_latency);
Signature · 1 line
MST
#3 lore raw

[PULL 09/22] acpi: x86: remove _ADR on host bridges

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

ACPI spec (since 2.0a) says
"
A device object must contain either an _HID object or an _ADR object, but can contain both.
"

_ADR is used when device is attached to an ennumerable bus, however hostbridge is not and uses dedicated _HID for discovery, drop _ADR field.

It doesn't seem that having _ADR has a negative effects OSes manage to tolerate that, but there is no point of having it there. (only pc/q35 has it hostbridge description, while others (microvm/arm) don't)

Message-Id: <[email protected]>

---
 hw/i386/acpi-build.c | 3 ---
 1 file changed, 3 deletions(-)
hw/i386/acpi-build.c +0 -3
index 19d268ff59..bb12b0ad43 100644
@@ -1464,7 +1464,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         sb_scope = aml_scope("_SB");
         dev = aml_device("PCI0");
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
-        aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
         aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
         aml_append(dev, aml_pci_edsm());
         aml_append(sb_scope, dev);
@@ -1479,7 +1478,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         dev = aml_device("PCI0");
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
         aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
-        aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
         aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
         aml_append(dev, build_q35_osc_method(!pm->pcihp_bridge_en));
         aml_append(dev, aml_pci_edsm());
@@ -1593,7 +1591,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                 aml_append(pkg, aml_eisaid("PNP0A08"));
                 aml_append(pkg, aml_eisaid("PNP0A03"));
                 aml_append(dev, aml_name_decl("_CID", pkg));
-                aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
                 build_cxl_osc_method(dev);
             } else if (pci_bus_is_express(bus)) {
                 aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
Signature · 1 line
MST
#4 lore raw

[PULL 17/22] hw/i386/intel_iommu: Fix struct VTDInvDescIEC on big endian hosts

In reply to Michael S. Tsirkin

From: Thomas Huth <[email protected]>

On big endian hosts, we need to reverse the bitfield order in the struct VTDInvDescIEC, just like it is already done for the other bitfields in the various structs of the intel-iommu device.

Message-Id: <[email protected]>

---
 hw/i386/intel_iommu_internal.h | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/i386/intel_iommu_internal.h +9 -0
index 2e61eec2f5..e1450c5cfe 100644
@@ -321,12 +321,21 @@ typedef enum VTDFaultReason {
 
 /* Interrupt Entry Cache Invalidation Descriptor: VT-d 6.5.2.7. */
 struct VTDInvDescIEC {
+#if HOST_BIG_ENDIAN
+    uint64_t reserved_2:16;
+    uint64_t index:16;          /* Start index to invalidate */
+    uint64_t index_mask:5;      /* 2^N for continuous int invalidation */
+    uint64_t resved_1:22;
+    uint64_t granularity:1;     /* If set, it's global IR invalidation */
+    uint64_t type:4;            /* Should always be 0x4 */
+#else
     uint32_t type:4;            /* Should always be 0x4 */
     uint32_t granularity:1;     /* If set, it's global IR invalidation */
     uint32_t resved_1:22;
     uint32_t index_mask:5;      /* 2^N for continuous int invalidation */
     uint32_t index:16;          /* Start index to invalidate */
     uint32_t reserved_2:16;
+#endif
 };
 typedef struct VTDInvDescIEC VTDInvDescIEC;
 
Signature · 1 line
MST
#5 lore raw

[PULL 19/22] hw/i386/x86-iommu: Fix endianness issue in x86_iommu_irq_to_msi_message()

In reply to Michael S. Tsirkin

From: Thomas Huth <[email protected]>

The values in "msg" are assembled in host endian byte order (the other field are also not swapped), so we must not swap the __addr_head here.

Message-Id: <[email protected]>

---
 hw/i386/x86-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/x86-iommu.c +1 -1
index 01d11325a6..726e9e1d16 100644
@@ -63,7 +63,7 @@ void x86_iommu_irq_to_msi_message(X86IOMMUIrq *irq, MSIMessage *msg_out)
     msg.redir_hint = irq->redir_hint;
     msg.dest = irq->dest;
     msg.__addr_hi = irq->dest & 0xffffff00;
-    msg.__addr_head = cpu_to_le32(0xfee);
+    msg.__addr_head = 0xfee;
     /* Keep this from original MSI address bits */
     msg.__not_used = irq->msi_addr_last_bits;
 
Signature · 1 line
MST
#6 lore raw

[PULL 16/22] hw/i386/intel_iommu: Fix endianness problems related to VTD_IR_TableEntry

In reply to Michael S. Tsirkin

From: Thomas Huth <[email protected]>

The code already tries to do some endianness handling here, but currently fails badly:
- While it already swaps the data when logging errors / tracing, it fails to byteswap the value before e.g. accessing entry->irte.present
- entry->irte.source_id is swapped with le32_to_cpu(), though this is a 16-bit value
- The whole union is apparently supposed to be swapped via the 64-bit data[2] array, but the struct is a mixture between 32 bit values (the first 8 bytes) and 64 bit values (the second 8 bytes), so this cannot work as expected.

Fix it by converting the struct to two proper 64-bit bitfields, and by swapping the values only once for everybody right after reading the data from memory.

Message-Id: <[email protected]>

---
 include/hw/i386/intel_iommu.h | 50 ++++++++++++++++++-----------------
 hw/i386/intel_iommu.c         | 16 +++++------
 2 files changed, 34 insertions(+), 32 deletions(-)
include/hw/i386/intel_iommu.h +26 -24
index 89dcbc5e1e..7fa0a695c8 100644
@@ -178,37 +178,39 @@ enum {
 union VTD_IR_TableEntry {
     struct {
 #if HOST_BIG_ENDIAN
-        uint32_t __reserved_1:8;     /* Reserved 1 */
-        uint32_t vector:8;           /* Interrupt Vector */
-        uint32_t irte_mode:1;        /* IRTE Mode */
-        uint32_t __reserved_0:3;     /* Reserved 0 */
-        uint32_t __avail:4;          /* Available spaces for software */
-        uint32_t delivery_mode:3;    /* Delivery Mode */
-        uint32_t trigger_mode:1;     /* Trigger Mode */
-        uint32_t redir_hint:1;       /* Redirection Hint */
-        uint32_t dest_mode:1;        /* Destination Mode */
-        uint32_t fault_disable:1;    /* Fault Processing Disable */
-        uint32_t present:1;          /* Whether entry present/available */
+        uint64_t dest_id:32;         /* Destination ID */
+        uint64_t __reserved_1:8;     /* Reserved 1 */
+        uint64_t vector:8;           /* Interrupt Vector */
+        uint64_t irte_mode:1;        /* IRTE Mode */
+        uint64_t __reserved_0:3;     /* Reserved 0 */
+        uint64_t __avail:4;          /* Available spaces for software */
+        uint64_t delivery_mode:3;    /* Delivery Mode */
+        uint64_t trigger_mode:1;     /* Trigger Mode */
+        uint64_t redir_hint:1;       /* Redirection Hint */
+        uint64_t dest_mode:1;        /* Destination Mode */
+        uint64_t fault_disable:1;    /* Fault Processing Disable */
+        uint64_t present:1;          /* Whether entry present/available */
 #else
-        uint32_t present:1;          /* Whether entry present/available */
-        uint32_t fault_disable:1;    /* Fault Processing Disable */
-        uint32_t dest_mode:1;        /* Destination Mode */
-        uint32_t redir_hint:1;       /* Redirection Hint */
-        uint32_t trigger_mode:1;     /* Trigger Mode */
-        uint32_t delivery_mode:3;    /* Delivery Mode */
-        uint32_t __avail:4;          /* Available spaces for software */
-        uint32_t __reserved_0:3;     /* Reserved 0 */
-        uint32_t irte_mode:1;        /* IRTE Mode */
-        uint32_t vector:8;           /* Interrupt Vector */
-        uint32_t __reserved_1:8;     /* Reserved 1 */
+        uint64_t present:1;          /* Whether entry present/available */
+        uint64_t fault_disable:1;    /* Fault Processing Disable */
+        uint64_t dest_mode:1;        /* Destination Mode */
+        uint64_t redir_hint:1;       /* Redirection Hint */
+        uint64_t trigger_mode:1;     /* Trigger Mode */
+        uint64_t delivery_mode:3;    /* Delivery Mode */
+        uint64_t __avail:4;          /* Available spaces for software */
+        uint64_t __reserved_0:3;     /* Reserved 0 */
+        uint64_t irte_mode:1;        /* IRTE Mode */
+        uint64_t vector:8;           /* Interrupt Vector */
+        uint64_t __reserved_1:8;     /* Reserved 1 */
+        uint64_t dest_id:32;         /* Destination ID */
 #endif
-        uint32_t dest_id;            /* Destination ID */
-        uint16_t source_id;          /* Source-ID */
 #if HOST_BIG_ENDIAN
         uint64_t __reserved_2:44;    /* Reserved 2 */
         uint64_t sid_vtype:2;        /* Source-ID Validation Type */
         uint64_t sid_q:2;            /* Source-ID Qualifier */
+        uint64_t source_id:16;       /* Source-ID */
 #else
+        uint64_t source_id:16;       /* Source-ID */
         uint64_t sid_q:2;            /* Source-ID Qualifier */
         uint64_t sid_vtype:2;        /* Source-ID Validation Type */
         uint64_t __reserved_2:44;    /* Reserved 2 */
hw/i386/intel_iommu.c +8 -8
index 13fcde8e91..4028e32701 100644
@@ -3328,14 +3328,15 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
         return -VTD_FR_IR_ROOT_INVAL;
     }
 
-    trace_vtd_ir_irte_get(index, le64_to_cpu(entry->data[1]),
-                          le64_to_cpu(entry->data[0]));
+    entry->data[0] = le64_to_cpu(entry->data[0]);
+    entry->data[1] = le64_to_cpu(entry->data[1]);
+
+    trace_vtd_ir_irte_get(index, entry->data[1], entry->data[0]);
 
     if (!entry->irte.present) {
         error_report_once("%s: detected non-present IRTE "
                           "(index=%u, high=0x%" PRIx64 ", low=0x%" PRIx64 ")",
-                          __func__, index, le64_to_cpu(entry->data[1]),
-                          le64_to_cpu(entry->data[0]));
+                          __func__, index, entry->data[1], entry->data[0]);
         return -VTD_FR_IR_ENTRY_P;
     }
 
@@ -3343,14 +3344,13 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
         entry->irte.__reserved_2) {
         error_report_once("%s: detected non-zero reserved IRTE "
                           "(index=%u, high=0x%" PRIx64 ", low=0x%" PRIx64 ")",
-                          __func__, index, le64_to_cpu(entry->data[1]),
-                          le64_to_cpu(entry->data[0]));
+                          __func__, index, entry->data[1], entry->data[0]);
         return -VTD_FR_IR_IRTE_RSVD;
     }
 
     if (sid != X86_IOMMU_SID_INVALID) {
         /* Validate IRTE SID */
-        source_id = le32_to_cpu(entry->irte.source_id);
+        source_id = entry->irte.source_id;
         switch (entry->irte.sid_vtype) {
         case VTD_SVT_NONE:
             break;
@@ -3404,7 +3404,7 @@ static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index,
     irq->trigger_mode = irte.irte.trigger_mode;
     irq->vector = irte.irte.vector;
     irq->delivery_mode = irte.irte.delivery_mode;
-    irq->dest = le32_to_cpu(irte.irte.dest_id);
+    irq->dest = irte.irte.dest_id;
     if (!iommu->intr_eime) {
 #define  VTD_IR_APIC_DEST_MASK         (0xff00ULL)
 #define  VTD_IR_APIC_DEST_SHIFT        (8)
Signature · 1 line
MST
#7 lore raw

[PULL 18/22] hw/i386/intel_iommu: Fix index calculation in vtd_interrupt_remap_msi()

In reply to Michael S. Tsirkin

From: Thomas Huth <[email protected]>

The values in "addr" are populated locally in this function in host endian byte order, so we must not swap the index_l field here.

Message-Id: <[email protected]>

---
 hw/i386/intel_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/intel_iommu.c +1 -1
index 4028e32701..3ca71df369 100644
@@ -3459,7 +3459,7 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
         goto out;
     }
 
-    index = addr.addr.index_h << 15 | le16_to_cpu(addr.addr.index_l);
+    index = addr.addr.index_h << 15 | addr.addr.index_l;
 
 #define  VTD_IR_MSI_DATA_SUBHANDLE       (0x0000ffff)
 #define  VTD_IR_MSI_DATA_RESERVED        (0xffff0000)
Signature · 1 line
MST
#8 lore raw

[PULL 22/22] cryptodev: Handle unexpected request to avoid crash

In reply to Michael S. Tsirkin

From: zhenwei pi <[email protected]>

Generally guest side should discover which services the device is able to offer, then do requests on device.

However it's also possible to break this rule in a guest. Handle unexpected request here to avoid NULL pointer dereference.

Fixes e7a775fd ('cryptodev: Account statistics')
Cc Gonglei <[email protected]>
Cc Mauro Matteo Cascella <[email protected]>
Cc Xiao Lei <[email protected]>
Cc Yongkang Jia <[email protected]>

Message-Id: <[email protected]>

---
 backends/cryptodev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
backends/cryptodev.c +10 -0
index 7d29517843..4d183f7237 100644
@@ -191,6 +191,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,
     if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
         CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
         len = asym_op_info->src_len;
+
+        if (unlikely(!backend->asym_stat)) {
+            error_report("cryptodev: Unexpected asym operation");
+            return -VIRTIO_CRYPTO_NOTSUPP;
+        }
         switch (op_info->op_code) {
         case VIRTIO_CRYPTO_AKCIPHER_ENCRYPT:
             CryptodevAsymStatIncEncrypt(backend, len);
@@ -210,6 +215,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,
     } else if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
         CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info;
         len = sym_op_info->src_len;
+
+        if (unlikely(!backend->sym_stat)) {
+            error_report("cryptodev: Unexpected sym operation");
+            return -VIRTIO_CRYPTO_NOTSUPP;
+        }
         switch (op_info->op_code) {
         case VIRTIO_CRYPTO_CIPHER_ENCRYPT:
             CryptodevSymStatIncEncrypt(backend, len);
Signature · 1 line
MST
#9 lore raw

Re: [PULL 22/22] cryptodev: Handle unexpected request to avoid crash

Quoted 15 lines · Michael S. Tsirkin

From: zhenwei pi <[email protected]>

Generally guest side should discover which services the device is able to offer, then do requests on device.

However it's also possible to break this rule in a guest. Handle unexpected request here to avoid NULL pointer dereference.

Fixes e7a775fd ('cryptodev: Account statistics')
Cc Gonglei <[email protected]>
Cc Mauro Matteo Cascella <[email protected]>
Cc Xiao Lei <[email protected]>
Cc Yongkang Jia <[email protected]>
Quoted 3 lines

Message-Id: <[email protected]>

This smells like a stable-8.0 material. Please let me know if it is not.

Thanks,

/mjt

#10 lore raw

Re: Re: [PULL 22/22] cryptodev: Handle unexpected request to avoid crash

Quoted 20 lines · Michael Tokarev
Quoted 15 lines · Michael S. Tsirkin

From: zhenwei pi <[email protected]>

Generally guest side should discover which services the device is able to offer, then do requests on device.

However it's also possible to break this rule in a guest. Handle unexpected request here to avoid NULL pointer dereference.

Fixes e7a775fd ('cryptodev: Account statistics')
Cc Gonglei <[email protected]>
Cc Mauro Matteo Cascella <[email protected]>
Cc Xiao Lei <[email protected]>
Cc Yongkang Jia <[email protected]>
Quoted 3 lines

Message-Id: <[email protected]>

Quoted 5 lines

This smells like a stable-8.0 material. Please let me know if it is not.

Thanks,

/mjt

Hi,

Both this one [1] and the previous one [2] should be table-8.0 material, I think.

[1][PULL 22/22] cryptodev: Handle unexpected request to avoid crash [2][PULL 21/22] virtio-crypto: verify src&dst buffer length for sym request

Signature · 1 line
zhenwei pi
#11 lore raw

Re: [PULL 22/22] cryptodev: Handle unexpected request to avoid crash

04.08.2023 09:10, zhenwei pi wrote:
..

Quoted 6 lines
Quoted 1 line

This smells like a stable-8.0 material. Please let me know if it is not.

Both this one [1] and the previous one [2] should be table-8.0 material, I think.

[1][PULL 22/22] cryptodev: Handle unexpected request to avoid crash [2][PULL 21/22] virtio-crypto: verify src&dst buffer length for sym request

I picked up the 21 one (virtio-crypto) already without questions (for both 8.0 and 7.2) since it fixes a CVE, but I wasn't 100% sure for the 22 one (cryptodev).

Thank you for letting me know.

/mjt

#12 lore raw

[PULL 01/22] hw/virtio-iommu: Fix potential OOB access in virtio_iommu_handle_command()

In reply to Michael S. Tsirkin

From: Eric Auger <[email protected]>

In the virtio_iommu_handle_command() when a PROBE request is handled, output_size takes a value greater than the tail size and on a subsequent iteration we can get a stack out-of-band access. Initialize the output_size on each iteration.

The issue was found with ASAN. Credits to:
Yiming Tao(Zhejiang University)
Gaoning Pan(Zhejiang University)

Fixes 1733eebb9e7 ("virtio-iommu: Implement RESV_MEM probe request")

Message-Id: <[email protected]>

---
 hw/virtio/virtio-iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/virtio/virtio-iommu.c +3 -1
index 201127c488..4dcf1d5c62 100644
@@ -728,13 +728,15 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)
     VirtIOIOMMU *s = VIRTIO_IOMMU(vdev);
     struct virtio_iommu_req_head head;
     struct virtio_iommu_req_tail tail = {};
-    size_t output_size = sizeof(tail), sz;
     VirtQueueElement *elem;
     unsigned int iov_cnt;
     struct iovec *iov;
     void *buf = NULL;
+    size_t sz;
 
     for (;;) {
+        size_t output_size = sizeof(tail);
+
         elem = virtqueue_pop(vq, sizeof(VirtQueueElement));
         if (!elem) {
             return;
Signature · 1 line
MST
#13 lore raw

[PULL 11/22] hw/virtio: qmp: add RING_RESET to 'info virtio-status'

In reply to Michael S. Tsirkin

From: David Edmondson <[email protected]>

Message-Id: <[email protected]>

---
 hw/virtio/virtio-qmp.c | 2 ++
 1 file changed, 2 insertions(+)
hw/virtio/virtio-qmp.c +2 -0
index 3d32dbec8d..7515b0947b 100644
@@ -79,6 +79,8 @@ static const qmp_virtio_feature_map_t virtio_transport_map[] = {
             "VIRTIO_F_ORDER_PLATFORM: Memory accesses ordered by platform"),
     FEATURE_ENTRY(VIRTIO_F_SR_IOV, \
             "VIRTIO_F_SR_IOV: Device supports single root I/O virtualization"),
+    FEATURE_ENTRY(VIRTIO_F_RING_RESET, \
+            "VIRTIO_F_RING_RESET: Driver can reset a queue individually"),
     /* Virtio ring transport features */
     FEATURE_ENTRY(VIRTIO_RING_F_INDIRECT_DESC, \
             "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported"),
Signature · 1 line
MST
#14 lore raw

[PULL 20/22] include/hw/i386/x86-iommu: Fix struct X86IOMMU_MSIMessage for big endian hosts

In reply to Michael S. Tsirkin

From: Thomas Huth <[email protected]>

The first bitfield here is supposed to be used as a 64-bit equivalent to the "uint64_t msi_addr" in the union. To make this work correctly on big endian hosts, too, the __addr_hi field has to be part of the bitfield, and the the bitfield members must be declared with "uint64_t" instead of "uint32_t" - otherwise the values are placed in the wrong bytes on big endian hosts.

Same applies to the 32-bit "msi_data" field: __resved1 must be part of the bitfield, and the members must be declared with "uint32_t" instead of "uint16_t".

Message-Id: <[email protected]>

---
 include/hw/i386/x86-iommu.h | 50 +++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 24 deletions(-)
include/hw/i386/x86-iommu.h +26 -24
index 8d8d53b18b..bfd21649d0 100644
@@ -87,40 +87,42 @@ struct X86IOMMU_MSIMessage {
     union {
         struct {
 #if HOST_BIG_ENDIAN
-            uint32_t __addr_head:12; /* 0xfee */
-            uint32_t dest:8;
-            uint32_t __reserved:8;
-            uint32_t redir_hint:1;
-            uint32_t dest_mode:1;
-            uint32_t __not_used:2;
+            uint64_t __addr_hi:32;
+            uint64_t __addr_head:12; /* 0xfee */
+            uint64_t dest:8;
+            uint64_t __reserved:8;
+            uint64_t redir_hint:1;
+            uint64_t dest_mode:1;
+            uint64_t __not_used:2;
 #else
-            uint32_t __not_used:2;
-            uint32_t dest_mode:1;
-            uint32_t redir_hint:1;
-            uint32_t __reserved:8;
-            uint32_t dest:8;
-            uint32_t __addr_head:12; /* 0xfee */
+            uint64_t __not_used:2;
+            uint64_t dest_mode:1;
+            uint64_t redir_hint:1;
+            uint64_t __reserved:8;
+            uint64_t dest:8;
+            uint64_t __addr_head:12; /* 0xfee */
+            uint64_t __addr_hi:32;
 #endif
-            uint32_t __addr_hi;
         } QEMU_PACKED;
         uint64_t msi_addr;
     };
     union {
         struct {
 #if HOST_BIG_ENDIAN
-            uint16_t trigger_mode:1;
-            uint16_t level:1;
-            uint16_t __resved:3;
-            uint16_t delivery_mode:3;
-            uint16_t vector:8;
+            uint32_t __resved1:16;
+            uint32_t trigger_mode:1;
+            uint32_t level:1;
+            uint32_t __resved:3;
+            uint32_t delivery_mode:3;
+            uint32_t vector:8;
 #else
-            uint16_t vector:8;
-            uint16_t delivery_mode:3;
-            uint16_t __resved:3;
-            uint16_t level:1;
-            uint16_t trigger_mode:1;
+            uint32_t vector:8;
+            uint32_t delivery_mode:3;
+            uint32_t __resved:3;
+            uint32_t level:1;
+            uint32_t trigger_mode:1;
+            uint32_t __resved1:16;
 #endif
-            uint16_t __resved1;
         } QEMU_PACKED;
         uint32_t msi_data;
     };
Signature · 1 line
MST
#15 lore raw

[PULL 08/22] tests: acpi: whitelist expected blobs

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h | 37 +++++++++++++++++++++
 1 file changed, 37 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +37 -0
index dfb8523c8b..8911b10650 100644
@@ -1 +1,38 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/DSDT",
+"tests/data/acpi/pc/DSDT.acpierst",
+"tests/data/acpi/pc/DSDT.acpihmat",
+"tests/data/acpi/pc/DSDT.bridge",
+"tests/data/acpi/pc/DSDT.cphp",
+"tests/data/acpi/pc/DSDT.dimmpxm",
+"tests/data/acpi/pc/DSDT.hpbridge",
+"tests/data/acpi/pc/DSDT.hpbrroot",
+"tests/data/acpi/pc/DSDT.ipmikcs",
+"tests/data/acpi/pc/DSDT.memhp",
+"tests/data/acpi/pc/DSDT.nohpet",
+"tests/data/acpi/pc/DSDT.numamem",
+"tests/data/acpi/pc/DSDT.roothp",
+"tests/data/acpi/q35/DSDT",
+"tests/data/acpi/q35/DSDT.acpierst",
+"tests/data/acpi/q35/DSDT.acpihmat",
+"tests/data/acpi/q35/DSDT.acpihmat-noinitiator",
+"tests/data/acpi/q35/DSDT.applesmc",
+"tests/data/acpi/q35/DSDT.bridge",
+"tests/data/acpi/q35/DSDT.core-count2",
+"tests/data/acpi/q35/DSDT.cphp",
+"tests/data/acpi/q35/DSDT.cxl",
+"tests/data/acpi/q35/DSDT.dimmpxm",
+"tests/data/acpi/q35/DSDT.ipmibt",
+"tests/data/acpi/q35/DSDT.ipmismbus",
+"tests/data/acpi/q35/DSDT.ivrs",
+"tests/data/acpi/q35/DSDT.memhp",
+"tests/data/acpi/q35/DSDT.mmio64",
+"tests/data/acpi/q35/DSDT.multi-bridge",
+"tests/data/acpi/q35/DSDT.noacpihp",
+"tests/data/acpi/q35/DSDT.nohpet",
+"tests/data/acpi/q35/DSDT.numamem",
+"tests/data/acpi/q35/DSDT.pvpanic-isa",
+"tests/data/acpi/q35/DSDT.tis.tpm12",
+"tests/data/acpi/q35/DSDT.tis.tpm2",
+"tests/data/acpi/q35/DSDT.viot",
+"tests/data/acpi/q35/DSDT.xapic",
Signature · 1 line
MST
#16 lore raw

[PULL 06/22] x86: acpi: workaround Windows not handling name references in Package properly

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

it seems that Windows is unable to handle variable references
making it choke up when accessing ASUN during _DSM call
when device is hotplugged (it lists package elements as DataAlias
but despite that later on it misbehaves) with following error
shown up in AMLI debugger (WS2012r2):
Store(ShiftLeft(One,Arg1="ASUN",) AMLI_ERROR(c0140008): Unexpected argument type
ValidateArgTypes: expected Arg1 to be type Integer (Type=String)
Similar outcome with WS2022.

Issue is not fatal but as result acpi-index/"PCI Label ID" property is either not shown in device details page or shows incorrect value.

Fix it by doing assignment of BSEL/ASUN values to package elements manually after package declaration.

Fix was tested with: WS2012r2, WS2022, RHEL9

Fixes 467d099a2985 (x86: acpi: _DSM: use Package to pass parameters)

Message-Id: <[email protected]>

---
 hw/i386/acpi-build.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
hw/i386/acpi-build.c +6 -2
index 9c74fa17ad..19d268ff59 100644
@@ -362,9 +362,13 @@ Aml *aml_pci_device_dsm(void)
     {
         Aml *params = aml_local(0);
         Aml *pkg = aml_package(2);
-        aml_append(pkg, aml_name("BSEL"));
-        aml_append(pkg, aml_name("ASUN"));
+        aml_append(pkg, aml_int(0));
+        aml_append(pkg, aml_int(0));
         aml_append(method, aml_store(pkg, params));
+        aml_append(method,
+            aml_store(aml_name("BSEL"), aml_index(params, aml_int(0))));
+        aml_append(method,
+            aml_store(aml_name("ASUN"), aml_index(params, aml_int(1))));
         aml_append(method,
             aml_return(aml_call5("PDSM", aml_arg(0), aml_arg(1),
                                  aml_arg(2), aml_arg(3), params))
Signature · 1 line
MST
#17 lore raw

[PULL 14/22] vhost: fix the fd leak

In reply to Michael S. Tsirkin

From: Li Feng <[email protected]>

When the vhost-user reconnect to the backend, the notifer should be cleanup. Otherwise, the fd resource will be exhausted.

Fixes f9a09ca3ea ("vhost: add support for configure interrupt")

Message-Id: <[email protected]>

---
 hw/virtio/vhost.c | 2 ++
 1 file changed, 2 insertions(+)
hw/virtio/vhost.c +2 -0
index abf0d03c8d..e2f6ffb446 100644
@@ -2044,6 +2044,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
     event_notifier_test_and_clear(
         &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
     event_notifier_test_and_clear(&vdev->config_notifier);
+    event_notifier_cleanup(
+        &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
 
     trace_vhost_dev_stop(hdev, vdev->name, vrings);
 
Signature · 1 line
MST
#18 lore raw

Re: [PULL 14/22] vhost: fix the fd leak

Quoted 5 lines · Michael S. Tsirkin

From: Li Feng <[email protected]>

When the vhost-user reconnect to the backend, the notifer should be cleanup. Otherwise, the fd resource will be exhausted.

Quoted 8 lines
Fixes f9a09ca3ea ("vhost: add support for configure interrupt")

Message-Id: <[email protected]>

This smells like a stable-8.0 material. Please let me know if it is not.

/mjt

#19 lore raw

Re: [PULL 14/22] vhost: fix the fd leak

Quoted 1 line · Michael Tokarev

This smells like a stable-8.0 material. Please let me know if it is not.

Ah, it is, Cc'd -stable already. N/m, picked this one up.

/mjt

#20 lore raw

[PULL 03/22] virtio-iommu: Standardize granule extraction and formatting

In reply to Michael S. Tsirkin

From: Eric Auger <[email protected]>

At several locations we compute the granule from the config page_size_mask using ctz() and then format it in traces using BIT(). As the page_size_mask is 64b we should use ctz64 and BIT_ULL() for formatting. We failed to be consistent.

Note the page_size_mask is garanteed to be non null. The spec mandates the device to set at least one bit, so ctz64 cannot return 64. This is garanteed by the fact the device initializes the page_size_mask to qemu_target_page_mask() and then the page_size_mask is further constrained by virtio_iommu_set_page_size_mask() callback which can't result in a new mask being null. So if Coverity complains round those ctz64/BIT_ULL with CID 1517772 this is a false positive

Fixes 94df5b2180 ("virtio-iommu: Fix 64kB host page size VFIO device assignment")

Message-Id: <[email protected]>

---
 hw/virtio/virtio-iommu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
hw/virtio/virtio-iommu.c +5 -3
index 4dcf1d5c62..be51635895 100644
@@ -854,17 +854,19 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
     VirtIOIOMMUEndpoint *ep;
     uint32_t sid, flags;
     bool bypass_allowed;
+    int granule;
     bool found;
     int i;
 
     interval.low = addr;
     interval.high = addr + 1;
+    granule = ctz64(s->config.page_size_mask);
 
     IOMMUTLBEntry entry = {
         .target_as = &address_space_memory,
         .iova = addr,
         .translated_addr = addr,
-        .addr_mask = (1 << ctz32(s->config.page_size_mask)) - 1,
+        .addr_mask = BIT_ULL(granule) - 1,
         .perm = IOMMU_NONE,
     };
 
@@ -1117,7 +1119,7 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr,
     if (s->granule_frozen) {
         int cur_granule = ctz64(cur_mask);
 
-        if (!(BIT(cur_granule) & new_mask)) {
+        if (!(BIT_ULL(cur_granule) & new_mask)) {
             error_setg(errp, "virtio-iommu %s does not support frozen granule 0x%llx",
                        mr->parent_obj.name, BIT_ULL(cur_granule));
             return -1;
@@ -1163,7 +1165,7 @@ static void virtio_iommu_freeze_granule(Notifier *notifier, void *data)
     }
     s->granule_frozen = true;
     granule = ctz64(s->config.page_size_mask);
-    trace_virtio_iommu_freeze_granule(BIT(granule));
+    trace_virtio_iommu_freeze_granule(BIT_ULL(granule));
 }
 
 static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
Signature · 1 line
MST
#21 lore raw

[PULL 05/22] tests: acpi: x86: whitelist expected blobs

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +14 -0
index dfb8523c8b..1983fa596b 100644
@@ -1 +1,15 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/DSDT",
+"tests/data/acpi/pc/DSDT.acpierst",
+"tests/data/acpi/pc/DSDT.acpihmat",
+"tests/data/acpi/pc/DSDT.bridge",
+"tests/data/acpi/pc/DSDT.cphp",
+"tests/data/acpi/pc/DSDT.dimmpxm",
+"tests/data/acpi/pc/DSDT.hpbridge",
+"tests/data/acpi/pc/DSDT.ipmikcs",
+"tests/data/acpi/pc/DSDT.memhp",
+"tests/data/acpi/pc/DSDT.nohpet",
+"tests/data/acpi/pc/DSDT.numamem",
+"tests/data/acpi/pc/DSDT.roothp",
+"tests/data/acpi/q35/DSDT.bridge",
+"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
MST
#22 lore raw

[PULL 04/22] hw/virtio: Add a protection against duplicate vu_scmi_stop calls

In reply to Michael S. Tsirkin

From: Milan Zamazal <[email protected]>

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
msix_unset_vector_notifiers: Assertion `dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed. ../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_disconnect
...
qemu_chr_write_buffer

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_set_status
...
qemu_cleanup

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")

Message-Id: <[email protected]>

---
 include/hw/virtio/vhost-user-scmi.h | 1 +
 hw/virtio/vhost-user-scmi.c         | 7 +++++++
 2 files changed, 8 insertions(+)
include/hw/virtio/vhost-user-scmi.h +1 -0
index 6175a74ebd..c90db77dd5 100644
@@ -25,6 +25,7 @@ struct VHostUserSCMI {
     VirtQueue *cmd_vq;
     VirtQueue *event_vq;
     bool connected;
+    bool started_vu;
 };
 
 #endif /* _QEMU_VHOST_USER_SCMI_H */
hw/virtio/vhost-user-scmi.c +7 -0
index d386fb2df9..918bb7dcf7 100644
@@ -63,6 +63,7 @@ static int vu_scmi_start(VirtIODevice *vdev)
         error_report("Error starting vhost-user-scmi: %d", ret);
         goto err_guest_notifiers;
     }
+    scmi->started_vu = true;
 
     /*
      * guest_notifier_mask/pending not used yet, so just unmask
@@ -90,6 +91,12 @@ static void vu_scmi_stop(VirtIODevice *vdev)
     struct vhost_dev *vhost_dev = &scmi->vhost_dev;
     int ret;
 
+    /* vhost_dev_is_started() check in the callers is not fully reliable. */
+    if (!scmi->started_vu) {
+        return;
+    }
+    scmi->started_vu = false;
+
     if (!k->set_guest_notifiers) {
         return;
     }
Signature · 1 line
MST
#23 lore raw

[PULL 13/22] pci: do not respond config requests after PCI device eject

In reply to Michael S. Tsirkin

From: Yuri Benditovich <[email protected]>

In migration with VF failover, Windows guest and ACPI hot unplug we do not need to satisfy config requests, otherwise the guest immediately detects the device and brings up its driver. Many network VF's are stuck on the guest PCI bus after the migration.

Message-Id: <[email protected]>

---
 hw/pci/pci_host.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
hw/pci/pci_host.c +13 -2
index 7af8afdcbe..a18aa0a8d4 100644
@@ -62,6 +62,17 @@ static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
     }
 }
 
+static bool is_pci_dev_ejected(PCIDevice *pci_dev)
+{
+    /*
+     * device unplug was requested and the guest acked it,
+     * so we stop responding config accesses even if the
+     * device is not deleted (failover flow)
+     */
+    return pci_dev && pci_dev->partially_hotplugged &&
+           !pci_dev->qdev.pending_deleted_event;
+}
+
 void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
                                   uint32_t limit, uint32_t val, uint32_t len)
 {
@@ -75,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
      * allowing direct removal of unexposed functions.
      */
     if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) ||
-        !pci_dev->has_power) {
+        !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) {
         return;
     }
 
@@ -100,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,
      * allowing direct removal of unexposed functions.
      */
     if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) ||
-        !pci_dev->has_power) {
+        !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) {
         return ~0x0;
     }
 
Signature · 1 line
MST
#24 lore raw

Re: [PULL 13/22] pci: do not respond config requests after PCI device eject

Quoted 10 lines · Michael S. Tsirkin

From: Yuri Benditovich <[email protected]>

In migration with VF failover, Windows guest and ACPI hot unplug we do not need to satisfy config requests, otherwise the guest immediately detects the device and brings up its driver. Many network VF's are stuck on the guest PCI bus after the migration.

Quoted 4 lines

Message-Id: <[email protected]>

Is it a stable-8.0 (and stable-7.2) material?

Thanks,

/mjt

#25 lore raw

[PULL 12/22] virtio: Fix packed virtqueue used_idx mask

In reply to Michael S. Tsirkin

From: Hanna Czenczek <[email protected]>

virtio_queue_packed_set_last_avail_idx() is used by vhost devices to set the internal queue indices to what has been reported by the vhost back-end through GET_VRING_BASE. For packed virtqueues, this 32-bit value is expected to contain both the device's internal avail and used indices, as well as their respective wrap counters.

To get the used index, we shift the 32-bit value right by 16, and then apply a mask of 0x7ffff. That seems to be a typo, because it should be 0x7fff; first of all, the virtio specification says that the maximum queue size for packed virt queues is 2^15, so the indices cannot exceed 2^15 - 1 anyway, making 0x7fff the correct mask. Second, the mask clearly is wrong from context, too, given that (A) idx & 0x70000 must be 0 at this point (idx is 32 bit and was shifted to the right by 16 already), (B) idx & 0x8000 is the used_wrap_counter, so should not be part of the used index, and (C) vq->used_idx is a uint16_t, so cannot fit the 0x70000 part of the mask anyway.

This most likely never produced any guest-visible bugs, though, because for a vhost device, qemu will probably not evaluate the used index outside of virtio_queue_packed_get_last_avail_idx(), where we reconstruct the 32-bit value from avail and used indices and their wrap counters again. There, it does not matter whether the highest bit of the used_idx is the used index wrap counter, because we put the wrap counter exactly in that position anyway.

Message-Id: <[email protected]>

---
 hw/virtio/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio.c +1 -1
index 295a603e58..309038fd46 100644
@@ -3321,7 +3321,7 @@ static void virtio_queue_packed_set_last_avail_idx(VirtIODevice *vdev,
     vq->last_avail_wrap_counter =
         vq->shadow_avail_wrap_counter = !!(idx & 0x8000);
     idx >>= 16;
-    vq->used_idx = idx & 0x7ffff;
+    vq->used_idx = idx & 0x7fff;
     vq->used_wrap_counter = !!(idx & 0x8000);
 }
 
Signature · 1 line
MST
#26 lore raw

[PULL 10/22] tests: acpi: update expected blobs

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Expected change is that _ADR object is removed from hostbridge descriptor in DSDT for PC and Q35 machines.

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h   |  37 ------------------
 tests/data/acpi/pc/DSDT                       | Bin 6836 -> 6830 bytes
 tests/data/acpi/pc/DSDT.acpierst              | Bin 6747 -> 6741 bytes
 tests/data/acpi/pc/DSDT.acpihmat              | Bin 8161 -> 8155 bytes
 tests/data/acpi/pc/DSDT.bridge                | Bin 13707 -> 13701 bytes
 tests/data/acpi/pc/DSDT.cphp                  | Bin 7300 -> 7294 bytes
 tests/data/acpi/pc/DSDT.dimmpxm               | Bin 8490 -> 8484 bytes
 tests/data/acpi/pc/DSDT.hpbridge              | Bin 6787 -> 6781 bytes
 tests/data/acpi/pc/DSDT.hpbrroot              | Bin 3343 -> 3337 bytes
 tests/data/acpi/pc/DSDT.ipmikcs               | Bin 6908 -> 6902 bytes
 tests/data/acpi/pc/DSDT.memhp                 | Bin 8195 -> 8189 bytes
 tests/data/acpi/pc/DSDT.nohpet                | Bin 6694 -> 6688 bytes
 tests/data/acpi/pc/DSDT.numamem               | Bin 6842 -> 6836 bytes
 tests/data/acpi/pc/DSDT.roothp                | Bin 10629 -> 10623 bytes
 tests/data/acpi/q35/DSDT                      | Bin 8361 -> 8355 bytes
 tests/data/acpi/q35/DSDT.acpierst             | Bin 8378 -> 8372 bytes
 tests/data/acpi/q35/DSDT.acpihmat             | Bin 9686 -> 9680 bytes
 tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8640 -> 8634 bytes
 tests/data/acpi/q35/DSDT.applesmc             | Bin 8407 -> 8401 bytes
 tests/data/acpi/q35/DSDT.bridge               | Bin 11974 -> 11968 bytes
 tests/data/acpi/q35/DSDT.core-count2          | Bin 32501 -> 32495 bytes
 tests/data/acpi/q35/DSDT.cphp                 | Bin 8825 -> 8819 bytes
 tests/data/acpi/q35/DSDT.cxl                  | Bin 9673 -> 9655 bytes
 tests/data/acpi/q35/DSDT.dimmpxm              | Bin 10015 -> 10009 bytes
 tests/data/acpi/q35/DSDT.ipmibt               | Bin 8436 -> 8430 bytes
 tests/data/acpi/q35/DSDT.ipmismbus            | Bin 8449 -> 8443 bytes
 tests/data/acpi/q35/DSDT.ivrs                 | Bin 8378 -> 8372 bytes
 tests/data/acpi/q35/DSDT.memhp                | Bin 9720 -> 9714 bytes
 tests/data/acpi/q35/DSDT.mmio64               | Bin 9491 -> 9485 bytes
 tests/data/acpi/q35/DSDT.multi-bridge         | Bin 13214 -> 13208 bytes
 tests/data/acpi/q35/DSDT.noacpihp             | Bin 8241 -> 8235 bytes
 tests/data/acpi/q35/DSDT.nohpet               | Bin 8219 -> 8213 bytes
 tests/data/acpi/q35/DSDT.numamem              | Bin 8367 -> 8361 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa          | Bin 8462 -> 8456 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12            | Bin 8967 -> 8961 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2             | Bin 8993 -> 8987 bytes
 tests/data/acpi/q35/DSDT.viot                 | Bin 9470 -> 9464 bytes
 tests/data/acpi/q35/DSDT.xapic                | Bin 35724 -> 35718 bytes
 38 files changed, 37 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -37
index 8911b10650..dfb8523c8b 100644
@@ -1,38 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/pc/DSDT.acpierst",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.hpbridge",
-"tests/data/acpi/pc/DSDT.hpbrroot",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.nohpet",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/pc/DSDT.roothp",
-"tests/data/acpi/q35/DSDT",
-"tests/data/acpi/q35/DSDT.acpierst",
-"tests/data/acpi/q35/DSDT.acpihmat",
-"tests/data/acpi/q35/DSDT.acpihmat-noinitiator",
-"tests/data/acpi/q35/DSDT.applesmc",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.core-count2",
-"tests/data/acpi/q35/DSDT.cphp",
-"tests/data/acpi/q35/DSDT.cxl",
-"tests/data/acpi/q35/DSDT.dimmpxm",
-"tests/data/acpi/q35/DSDT.ipmibt",
-"tests/data/acpi/q35/DSDT.ipmismbus",
-"tests/data/acpi/q35/DSDT.ivrs",
-"tests/data/acpi/q35/DSDT.memhp",
-"tests/data/acpi/q35/DSDT.mmio64",
-"tests/data/acpi/q35/DSDT.multi-bridge",
-"tests/data/acpi/q35/DSDT.noacpihp",
-"tests/data/acpi/q35/DSDT.nohpet",
-"tests/data/acpi/q35/DSDT.numamem",
-"tests/data/acpi/q35/DSDT.pvpanic-isa",
-"tests/data/acpi/q35/DSDT.tis.tpm12",
-"tests/data/acpi/q35/DSDT.tis.tpm2",
-"tests/data/acpi/q35/DSDT.viot",
-"tests/data/acpi/q35/DSDT.xapic",
tests/data/acpi/pc/DSDT binary +0 -0
index 3f104cc65c4fcc55616540867ec1ec50a7b9c7fd..c93ad6b7f83a168a1833d7dba1112dd2ab8a431f 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
index d33cffc67a5dc49694a6c6a57b3f26da1f759bbe..f643fa2d034053fa07f74f095565b64f021d4290 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
index 726741a0f0934fa6504ab451d6374a739f704301..9d3695ff289036856886a093733926667a32a058 100644
GIT binary patch
tests/data/acpi/pc/DSDT.bridge binary +0 -0
index 89b5ee17e156d08168fcc93ab635dfb83d63b335..840b45f354ac14c858d0af8fbd31e97949a65d4b 100644
GIT binary patch
tests/data/acpi/pc/DSDT.cphp binary +0 -0
index cb9fc3c524f238f90d9d84d795061fe78a21a6dd..dbc0141b2bbc77a6d806ff046dc137992c59a899 100644
GIT binary patch
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
index 3fcb0a22a3d074ce3e6e6d12eed95d174876ff99..1294f655d418dbdccc095e0d47ab220869a61a07 100644
GIT binary patch
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
index 2cb4310af36c483e62671c9a9eaefef9363e59c7..8012b5eb3155377dc7995b73059ecb267d19232c 100644
GIT binary patch
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
index a4073f36d686201296455e142e3bcbb2f368bbd2..4fa0c6fe720f7859f0541b82f828c0329a3c0548 100644
GIT binary patch
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
index b0e0922f5e38f01b9eed33d6b7c7d60f81850a20..0a891baf458abee4a772ffba7a31914ec22418ec 100644
GIT binary patch
tests/data/acpi/pc/DSDT.memhp binary +0 -0
index 61b66fcf9a9ca62436f933c40e116a16686445c7..9b442a64cf711b33d80691fe84f1d3a6256f943b 100644
GIT binary patch
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
index 57ccde1618ae08a8f7ad65553387ddcfe26b178b..1754c6878839fc657230e1e714cd7c5142e0a77e 100644
GIT binary patch
tests/data/acpi/pc/DSDT.numamem binary +0 -0
index 36bf83259ed7d3cb51e426d83663421ede24d998..9fc731d3d2bcde5e2612a8ccd81e12098134afe9 100644
GIT binary patch
tests/data/acpi/pc/DSDT.roothp binary +0 -0
index ca44cca6a3e46777e1e3433512dfd101c1c7bb8b..e654c83ebe40c413b204c711adcefe3f04655e8c 100644
GIT binary patch
tests/data/acpi/q35/DSDT binary +0 -0
index 720e8cbbbb10d86a458027b5cb47884bf8c5ee78..fb89ae0ac6d4346e33156e9e4d3718698a0a1a8e 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpierst binary +0 -0
index f26b1f2a19529c508d53ed3f434be0083c18dbab..46fd25400b7c00ee9149ddb64cb5d5bd73f6a82b 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
index 86771f17466a85e3c938e86d1a5c6cee7c0ec4b6..61c5bd52a42242e85090934e8e45bf01642609d6 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpihmat-noinitiator binary +0 -0
index a894a2d16c81fff8ade2c5ddb20858a03169fd47..3aaa2bbdf54a0d0cade14421e84c6ec5a42f96fa 100644
GIT binary patch
tests/data/acpi/q35/DSDT.applesmc binary +0 -0
index 276ae1df511346ccd286216c6de03cd56db410fd..944209adeaa5bbb722431161c404cb51b8209993 100644
GIT binary patch
tests/data/acpi/q35/DSDT.bridge binary +0 -0
index a6765cebb6b95b9f192a04a79ac86c7386e35052..d9938dba8fa5d405f7696c0dbdc24f3ae42ec934 100644
GIT binary patch
tests/data/acpi/q35/DSDT.core-count2 binary +0 -0
index 2ec11fe3c36d635080af05afa32852fcc1bf10be..b47891ec10be131a59bf404242241c054ac902f8 100644
GIT binary patch
tests/data/acpi/q35/DSDT.cphp binary +0 -0
index 612c85b1b4c8e4cc642734b1d52f5d5e1e2ec4eb..20955d0aa30120553da35d5a6640055d26255cf9 100644
GIT binary patch
tests/data/acpi/q35/DSDT.cxl binary +0 -0
index f049f414f0e789324e82916cfd0aa955211408c4..ee16a861c2de7b7caaf11d91c50fcdf308815233 100644
GIT binary patch
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
index 23dabeacb06b3ad4360c1ca142c06a173f82ff51..228374b55bd544116e359f659e546fc66cf8a895 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
index 541bb70522e72dd477f72cba2f71a336f6978de4..45f911ada5645f158f3d6c0c430ec1d52cadc5d8 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
index e2d57a331873ada2fcbcdc1f0f7a244f235d7447..e5d6811bee1233d74236453c49060390d74d4416 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ivrs binary +0 -0
index f26b1f2a19529c508d53ed3f434be0083c18dbab..46fd25400b7c00ee9149ddb64cb5d5bd73f6a82b 100644
GIT binary patch
tests/data/acpi/q35/DSDT.memhp binary +0 -0
index 809d7e2f0fc15351abc99031a118b4012822deea..5ce081187a578ba7145a9ba20d30be36c13b7663 100644
GIT binary patch
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
index ab3fe3c1b56a35d1312779412978cc1d51f05d33..8459b82c958b842cd7b92c2145977634fb9c6e5d 100644
GIT binary patch
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
index 15eef675913d2f10173f96ff6fc42b230d0a6618..1db43a69e4c2affd8bd678bbef4d3c228380288e 100644
GIT binary patch
tests/data/acpi/q35/DSDT.noacpihp binary +0 -0
index 8cab2f8eb9ae94e0165f3f17857ec7d080fb0e13..8bc16887e1c963c61aaecf71712a09c0554f6d67 100644
GIT binary patch
tests/data/acpi/q35/DSDT.nohpet binary +0 -0
index becb5f7cad68361463b30be80095ab10966d7c88..c13e45e3612646cc2e30f00b3b7e53335da816ea 100644
GIT binary patch
tests/data/acpi/q35/DSDT.numamem binary +0 -0
index 0cdec0b4c53b2b0e38cd019caab552f66f7728e7..ba6669437e65952f24516ded954b33fe54bdedfb 100644
GIT binary patch
tests/data/acpi/q35/DSDT.pvpanic-isa binary +0 -0
index 6a9904ec947e373520e0135a89c559cb4f57fa7d..6ad42873e91c80cef5a42224cb4d31936dad59b4 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
index 628bf628f6891f906bf872f8916692ba0ccb6877..e381ce4cbf2b11f56a2d0537db4d21acc97450c9 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
index 35c6b08068d4d2fb0353802dc2460cc2912c129c..a09253042ce4a715922027245de8a2ab7449c5b7 100644
GIT binary patch
tests/data/acpi/q35/DSDT.viot binary +0 -0
index 3ad4d26b7f5c183fd3e146b67ebb23662b5108eb..64e81f571120e3eb2b8c6c9545293a78c75b7bbd 100644
GIT binary patch
tests/data/acpi/q35/DSDT.xapic binary +0 -0
index d4a34e23512c295f73abbe5ef1370fac7a1a06cd..d4acd851c62c956436a436f9fa6d08fc5f370fa7 100644
GIT binary patch
Signature · 1 line
MST
#27 lore raw

[PULL 07/22] tests: acpi: x86: update expected blobs

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Following change is expected on each PCI slot with enabled ACPI PCI hotplug

-                            BSEL,
-                            ASUN
+                            Zero,
+                            Zero
                         }

+ Local0 [Zero] = BSEL /* \_SB_.PCI0.BSEL */
+ Local0 [One] = ASUN /* \_SB_.PCI0.S18_.ASUN */

Message-Id: <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h |  14 --------------
 tests/data/acpi/pc/DSDT                     | Bin 6488 -> 6836 bytes
 tests/data/acpi/pc/DSDT.acpierst            | Bin 6411 -> 6747 bytes
 tests/data/acpi/pc/DSDT.acpihmat            | Bin 7813 -> 8161 bytes
 tests/data/acpi/pc/DSDT.bridge              | Bin 12615 -> 13707 bytes
 tests/data/acpi/pc/DSDT.cphp                | Bin 6952 -> 7300 bytes
 tests/data/acpi/pc/DSDT.dimmpxm             | Bin 8142 -> 8490 bytes
 tests/data/acpi/pc/DSDT.hpbridge            | Bin 6451 -> 6787 bytes
 tests/data/acpi/pc/DSDT.ipmikcs             | Bin 6560 -> 6908 bytes
 tests/data/acpi/pc/DSDT.memhp               | Bin 7847 -> 8195 bytes
 tests/data/acpi/pc/DSDT.nohpet              | Bin 6346 -> 6694 bytes
 tests/data/acpi/pc/DSDT.numamem             | Bin 6494 -> 6842 bytes
 tests/data/acpi/pc/DSDT.roothp              | Bin 9873 -> 10629 bytes
 tests/data/acpi/q35/DSDT.bridge             | Bin 11590 -> 11974 bytes
 tests/data/acpi/q35/DSDT.multi-bridge       | Bin 12770 -> 13214 bytes
 15 files changed, 14 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -14
index 1983fa596b..dfb8523c8b 100644
@@ -1,15 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/pc/DSDT.acpierst",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.hpbridge",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.nohpet",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/pc/DSDT.roothp",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/pc/DSDT binary +0 -0
index 32d255cfc0a207c89bf8459edaca11fad12979e9..3f104cc65c4fcc55616540867ec1ec50a7b9c7fd 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
index 33e872b2fae3d974a3dc4ec0401b1f1734db313b..d33cffc67a5dc49694a6c6a57b3f26da1f759bbe 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
index cd84abc1b1d026e6055057f4c6170146e1921ea6..726741a0f0934fa6504ab451d6374a739f704301 100644
GIT binary patch
tests/data/acpi/pc/DSDT.bridge binary +0 -0
index 69a73ea2a691de387b82bf85a7ba1a2279c01a0c..89b5ee17e156d08168fcc93ab635dfb83d63b335 100644
GIT binary patch
tests/data/acpi/pc/DSDT.cphp binary +0 -0
index 20379056b399bf1ad8b8316453eac344f604d3b6..cb9fc3c524f238f90d9d84d795061fe78a21a6dd 100644
GIT binary patch
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
index 435496e836939eeb767f1a524dc1471740ad917e..3fcb0a22a3d074ce3e6e6d12eed95d174876ff99 100644
GIT binary patch
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
index b6eafab250d508e1358ea09f81eb1b2a6d96ce32..2cb4310af36c483e62671c9a9eaefef9363e59c7 100644
GIT binary patch
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
index 06aa7bfdeca40e10ee8411eeda08486599b90e39..b0e0922f5e38f01b9eed33d6b7c7d60f81850a20 100644
GIT binary patch
tests/data/acpi/pc/DSDT.memhp binary +0 -0
index 10a0e44d610976cd5f08d53ec32c7d5eda064e1c..61b66fcf9a9ca62436f933c40e116a16686445c7 100644
GIT binary patch
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
index 6905312d827502e8bb5852418cf58290eda8d86b..57ccde1618ae08a8f7ad65553387ddcfe26b178b 100644
GIT binary patch
tests/data/acpi/pc/DSDT.numamem binary +0 -0
index 59e31338eeb3a84c39ed3ae63105226ce2ad1125..36bf83259ed7d3cb51e426d83663421ede24d998 100644
GIT binary patch
tests/data/acpi/pc/DSDT.roothp binary +0 -0
index 448d596cf413d7e487af114e5c80bc73311d17f9..ca44cca6a3e46777e1e3433512dfd101c1c7bb8b 100644
GIT binary patch
tests/data/acpi/q35/DSDT.bridge binary +0 -0
index 9f8a208aaadc167135e59839eefcd5b594c2f28a..a6765cebb6b95b9f192a04a79ac86c7386e35052 100644
GIT binary patch
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
index 9ae8ee0b41738bd8951b9449abcfc67c293fdce1..15eef675913d2f10173f96ff6fc42b230d0a6618 100644
GIT binary patch
Signature · 1 line
MST
#28 lore raw

[PULL 21/22] virtio-crypto: verify src&dst buffer length for sym request

In reply to Michael S. Tsirkin

From: zhenwei pi <[email protected]>

For symmetric algorithms, the length of ciphertext must be as same as the plaintext.
The missing verification of the src_len and the dst_len in virtio_crypto_sym_op_helper() may lead buffer overflow/divulged.

This patch is originally written by Yiming Tao for QEMU-SECURITY, resend it(a few changes of error message) in qemu-devel.

Fixes CVE-2023-3180
Fixes 04b9b37edda("virtio-crypto: add data queue processing handler")
Cc Gonglei <[email protected]>
Cc Mauro Matteo Cascella <[email protected]>
Cc Yiming Tao <[email protected]>

Message-Id: <[email protected]>

---
 hw/virtio/virtio-crypto.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/virtio/virtio-crypto.c +5 -0
index 44faf5a522..13aec771e1 100644
@@ -634,6 +634,11 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev,
         return NULL;
     }
 
+    if (unlikely(src_len != dst_len)) {
+        virtio_error(vdev, "sym request src len is different from dst len");
+        return NULL;
+    }
+
     max_len = (uint64_t)iv_len + aad_len + src_len + dst_len + hash_result_len;
     if (unlikely(max_len > vcrypto->conf.max_size)) {
         virtio_error(vdev, "virtio-crypto too big length");
Signature · 1 line
MST
#29 lore raw
In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin

The following changes since commit c167c80b463768e04a22fbe37ba6c53a4a08e41e:

   Merge tag 'pull-request-2023-08-03' ofhttps://gitlab.com/thuth/qemu  into staging (2023-08-03 07:37:17 -0700)

are available in the Git repository at:

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

for you to fetch changes up to 15b11a1da6a4b7c6b8bb37883f52b544dee2b8fd:

Quoted 8 lines

cryptodev: Handle unexpected request to avoid crash (2023-08-03 16:16:17 -0400)

----------------------------------------------------------------
pc,pci,virtio,crypto: bugfixes

fixes all over the place.

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.

r~