diff --git a/Add-dummy-Aspeed-AST2600-Display-Port-MCU-DPMCU.patch b/Add-dummy-Aspeed-AST2600-Display-Port-MCU-DPMCU.patch new file mode 100644 index 0000000000000000000000000000000000000000..2887ce74c7a7df78e48c21cae92767e2a70d481f --- /dev/null +++ b/Add-dummy-Aspeed-AST2600-Display-Port-MCU-DPMCU.patch @@ -0,0 +1,84 @@ +From 48f112e0b8e65fccc3bf66510fafb6e9a8d58e90 Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Mon, 4 Dec 2023 10:50:04 +0800 +Subject: [PATCH] Add dummy Aspeed AST2600 Display Port MCU (DPMCU) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit d9e9cd59df4bc92e4cf7ad1bfa6e2a8429ff31b4 + +AST2600 Display Port MCU introduces 0x18000000~0x1803FFFF as it's memory +and io address. If guest machine try to access DPMCU memory, it will +cause a fatal error. + +Signed-off-by: Troy Lee +Reviewed-by: Philippe Mathieu-Daudé +Reviewed-by: Cédric Le Goater +Message-id: 20211210083034.726610-1-troy_lee@aspeedtech.com +Signed-off-by: Peter Maydell +Signed-off-by: Luo Yifan +--- + hw/arm/aspeed_ast2600.c | 8 ++++++++ + include/hw/arm/aspeed_soc.h | 2 ++ + 2 files changed, 10 insertions(+) + +diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c +index 0384357a95..e33483fb5d 100644 +--- a/hw/arm/aspeed_ast2600.c ++++ b/hw/arm/aspeed_ast2600.c +@@ -19,9 +19,11 @@ + #include "sysemu/sysemu.h" + + #define ASPEED_SOC_IOMEM_SIZE 0x00200000 ++#define ASPEED_SOC_DPMCU_SIZE 0x00040000 + + static const hwaddr aspeed_soc_ast2600_memmap[] = { + [ASPEED_DEV_SRAM] = 0x10000000, ++ [ASPEED_DEV_DPMCU] = 0x18000000, + /* 0x16000000 0x17FFFFFF : AHB BUS do LPC Bus bridge */ + [ASPEED_DEV_IOMEM] = 0x1E600000, + [ASPEED_DEV_PWM] = 0x1E610000, +@@ -44,6 +46,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { + [ASPEED_DEV_SCU] = 0x1E6E2000, + [ASPEED_DEV_XDMA] = 0x1E6E7000, + [ASPEED_DEV_ADC] = 0x1E6E9000, ++ [ASPEED_DEV_DP] = 0x1E6EB000, + [ASPEED_DEV_VIDEO] = 0x1E700000, + [ASPEED_DEV_SDHCI] = 0x1E740000, + [ASPEED_DEV_EMMC] = 0x1E750000, +@@ -104,6 +107,7 @@ static const int aspeed_soc_ast2600_irqmap[] = { + [ASPEED_DEV_ETH3] = 32, + [ASPEED_DEV_ETH4] = 33, + [ASPEED_DEV_KCS] = 138, /* 138 -> 142 */ ++ [ASPEED_DEV_DP] = 62, + }; + + static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl) +@@ -298,6 +302,10 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) + memory_region_add_subregion(get_system_memory(), + sc->memmap[ASPEED_DEV_SRAM], &s->sram); + ++ /* DPMCU */ ++ create_unimplemented_device("aspeed.dpmcu", sc->memmap[ASPEED_DEV_DPMCU], ++ ASPEED_SOC_DPMCU_SIZE); ++ + /* SCU */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { + return; +diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h +index 8139358549..18fb7eed46 100644 +--- a/include/hw/arm/aspeed_soc.h ++++ b/include/hw/arm/aspeed_soc.h +@@ -139,6 +139,8 @@ enum { + ASPEED_DEV_EMMC, + ASPEED_DEV_KCS, + ASPEED_DEV_HACE, ++ ASPEED_DEV_DPMCU, ++ ASPEED_DEV_DP, + }; + + #endif /* ASPEED_SOC_H */ +-- +2.27.0 + diff --git a/Fix-STM32F2XX-USART-data-register-readout.patch b/Fix-STM32F2XX-USART-data-register-readout.patch new file mode 100644 index 0000000000000000000000000000000000000000..3244c318eea71f252674abbb455bf16e563412b0 --- /dev/null +++ b/Fix-STM32F2XX-USART-data-register-readout.patch @@ -0,0 +1,43 @@ +From 8733b8a26407177b867d3293283c257efeb784a0 Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Fri, 1 Dec 2023 12:51:56 +0800 +Subject: [PATCH] Fix STM32F2XX USART data register readout +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit ab08c3467605365b44fab1b66bb6254db86814f6 + +Fix issue where the data register may be overwritten by next character +reception before being read and returned. + +Signed-off-by: Olivier Hériveaux +Reviewed-by: Peter Maydell +Reviewed-by: Alistair Francis +Message-id: 20211128120723.4053-1-olivier.heriveaux@ledger.fr +Signed-off-by: Peter Maydell +Signed-off-by: Luo Yifan +--- + hw/char/stm32f2xx_usart.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c +index 8df0832424..fde67f4f03 100644 +--- a/hw/char/stm32f2xx_usart.c ++++ b/hw/char/stm32f2xx_usart.c +@@ -103,10 +103,11 @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr, + return retvalue; + case USART_DR: + DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr); ++ retvalue = s->usart_dr & 0x3FF; + s->usart_sr &= ~USART_SR_RXNE; + qemu_chr_fe_accept_input(&s->chr); + qemu_set_irq(s->irq, 0); +- return s->usart_dr & 0x3FF; ++ return retvalue; + case USART_BRR: + return s->usart_brr; + case USART_CR1: +-- +2.27.0 + diff --git a/Fixed-a-QEMU-hang-when-guest-poweroff-in-COLO-mode.patch b/Fixed-a-QEMU-hang-when-guest-poweroff-in-COLO-mode.patch new file mode 100644 index 0000000000000000000000000000000000000000..10e21c23b6636fdda91ab26b467c0c3f781722b2 --- /dev/null +++ b/Fixed-a-QEMU-hang-when-guest-poweroff-in-COLO-mode.patch @@ -0,0 +1,83 @@ +From 6de250962994520ba8daca709cd4b3b54d5e3afb Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Fri, 1 Dec 2023 10:47:48 +0800 +Subject: [PATCH] Fixed a QEMU hang when guest poweroff in COLO mode + +cherry picked from commit 795969ab1fe6d5a0f524be92e2e1ecd13f1873eb + +When the PVM guest poweroff, the COLO thread may wait a semaphore +in colo_process_checkpoint().So, we should wake up the COLO thread +before migration shutdown. + +Signed-off-by: Lei Rao +Reviewed-by: Zhang Chen +Reviewed-by: Juan Quintela +Signed-off-by: Juan Quintela +Signed-off-by: Luo Yifan +--- + include/migration/colo.h | 1 + + migration/colo.c | 20 ++++++++++++++++++++ + migration/migration.c | 6 ++++++ + 3 files changed, 27 insertions(+) + +diff --git a/include/migration/colo.h b/include/migration/colo.h +index 768e1f04c3..5fbe1a6d5d 100644 +--- a/include/migration/colo.h ++++ b/include/migration/colo.h +@@ -37,4 +37,5 @@ COLOMode get_colo_mode(void); + void colo_do_failover(void); + + void colo_checkpoint_notify(void *opaque); ++void colo_shutdown(void); + #endif +diff --git a/migration/colo.c b/migration/colo.c +index 2415325262..0d3d98f707 100644 +--- a/migration/colo.c ++++ b/migration/colo.c +@@ -820,6 +820,26 @@ static void colo_wait_handle_message(MigrationIncomingState *mis, + } + } + ++void colo_shutdown(void) ++{ ++ MigrationIncomingState *mis = NULL; ++ MigrationState *s = NULL; ++ ++ switch (get_colo_mode()) { ++ case COLO_MODE_PRIMARY: ++ s = migrate_get_current(); ++ qemu_event_set(&s->colo_checkpoint_event); ++ qemu_sem_post(&s->colo_exit_sem); ++ break; ++ case COLO_MODE_SECONDARY: ++ mis = migration_incoming_get_current(); ++ qemu_sem_post(&mis->colo_incoming_sem); ++ break; ++ default: ++ break; ++ } ++} ++ + void *colo_process_incoming_thread(void *opaque) + { + MigrationIncomingState *mis = opaque; +diff --git a/migration/migration.c b/migration/migration.c +index 2ec116f901..cceaacc7f7 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -226,6 +226,12 @@ void migration_cancel(const Error *error) + + void migration_shutdown(void) + { ++ /* ++ * When the QEMU main thread exit, the COLO thread ++ * may wait a semaphore. So, we should wakeup the ++ * COLO thread before migration shutdown. ++ */ ++ colo_shutdown(); + /* + * Cancel the current migration - that will (eventually) + * stop the migration using this structure +-- +2.27.0 + diff --git a/Revert-hw-virtio-virtio-iommu-pci-Enforce-the-device.patch b/Revert-hw-virtio-virtio-iommu-pci-Enforce-the-device.patch new file mode 100644 index 0000000000000000000000000000000000000000..b3017089f753ded5c1573abdfd16c620ebde3988 --- /dev/null +++ b/Revert-hw-virtio-virtio-iommu-pci-Enforce-the-device.patch @@ -0,0 +1,49 @@ +From f66f64cf3ca968db2ca7f45bfd125ec7d85624e5 Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Mon, 4 Dec 2023 17:30:02 +0800 +Subject: [PATCH] Revert "hw/virtio/virtio-iommu-pci: Enforce the device is + plugged on the root bus" + +This reverts commit a2323aa79da71c92e818306f1e18184619309a35. + +Signed-off-by: jiangdongxu +--- + hw/virtio/virtio-iommu-pci.c | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + +diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c +index 37eb2fb979..a160ae6b41 100644 +--- a/hw/virtio/virtio-iommu-pci.c ++++ b/hw/virtio/virtio-iommu-pci.c +@@ -44,7 +44,6 @@ static Property virtio_iommu_pci_properties[] = { + static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) + { + VirtIOIOMMUPCI *dev = VIRTIO_IOMMU_PCI(vpci_dev); +- PCIBus *pbus = pci_get_bus(&vpci_dev->pci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); + +@@ -66,17 +65,11 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) + s->reserved_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_MSI) { + error_setg(errp, "reserved region %d has an invalid type", i); + error_append_hint(errp, "Valid values are 0 and 1\n"); +- return; +- } ++ } + } +- if (!pci_bus_is_root(pbus)) { +- error_setg(errp, "virtio-iommu-pci must be plugged on the root bus"); +- return; +- } +- + object_property_set_link(OBJECT(dev), "primary-bus", +- OBJECT(pbus), &error_abort); +- ++ OBJECT(pci_get_bus(&vpci_dev->pci_dev)), ++ &error_abort); + virtio_pci_force_virtio_1(vpci_dev); + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); + } +-- +2.27.0 + diff --git a/balloon-Fix-a-misleading-error-message.patch b/balloon-Fix-a-misleading-error-message.patch new file mode 100644 index 0000000000000000000000000000000000000000..e0f7cdc81da2c8af25954d5783b00a6eb8a5093d --- /dev/null +++ b/balloon-Fix-a-misleading-error-message.patch @@ -0,0 +1,60 @@ +From 0c24a55d582e8219b64f2090cbdd21027d496bb1 Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 10:44:31 +0800 +Subject: [PATCH] balloon: Fix a misleading error message + +cherry picked from eeef44b3a583637265f602882a0d058a52e3a33b + +The error message + + {"execute": "balloon", "arguments":{"value": -1}} + {"error": {"class": "GenericError", "desc": "Parameter 'target' expects a size"}} + +points to 'target' instead of 'value'. Fix: + + {"error": {"class": "GenericError", "desc": "Parameter 'value' expects a size"}} + +Root cause: qmp_balloon()'s parameter is named @target. Rename it to +@value to match the QAPI schema. + +Signed-off-by: Markus Armbruster +Message-ID: <20231031111059.3407803-7-armbru@redhat.com> +Reviewed-by: David Hildenbrand +Reviewed-by: Michael S. Tsirkin +Tested-by: Mario Casquero + +Signed-off-by: boringandboring +--- + softmmu/balloon.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/softmmu/balloon.c b/softmmu/balloon.c +index e0e8969a4b..fda7af832e 100644 +--- a/softmmu/balloon.c ++++ b/softmmu/balloon.c +@@ -90,17 +90,17 @@ BalloonInfo *qmp_query_balloon(Error **errp) + return info; + } + +-void qmp_balloon(int64_t target, Error **errp) ++void qmp_balloon(int64_t value, Error **errp) + { + if (!have_balloon(errp)) { + return; + } + +- if (target <= 0) { +- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size"); ++ if (value <= 0) { ++ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "value", "a size"); + return; + } + +- trace_balloon_event(balloon_opaque, target); +- balloon_event_fn(balloon_opaque, target); ++ trace_balloon_event(balloon_opaque, value); ++ balloon_event_fn(balloon_opaque, value); + } +-- +2.27.0 + diff --git a/block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch b/block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch new file mode 100644 index 0000000000000000000000000000000000000000..eb0595fa8c37155f12a61a658046482cb34f1b88 --- /dev/null +++ b/block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch @@ -0,0 +1,64 @@ +From ba31baabf9ad582c8a256a58123c036b6a70ba15 Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Fri, 1 Dec 2023 10:00:41 +0800 +Subject: [PATCH] block/nvme: fix infinite loop in nvme_free_req_queue_cb() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit cf4fbc3030c974fff726756a7ceef8386cdf500b + +When the request free list is exhausted the coroutine waits on +q->free_req_queue for the next free request. Whenever a request is +completed a BH is scheduled to invoke nvme_free_req_queue_cb() and wake +up waiting coroutines. + +1. nvme_get_free_req() waits for a free request: + + while (q->free_req_head == -1) { + ... + trace_nvme_free_req_queue_wait(q->s, q->index); + qemu_co_queue_wait(&q->free_req_queue, &q->lock); + ... + } + +2. nvme_free_req_queue_cb() wakes up the coroutine: + + while (qemu_co_enter_next(&q->free_req_queue, &q->lock)) { + ^--- infinite loop when free_req_head == -1 + } + +nvme_free_req_queue_cb() and the coroutine form an infinite loop when +q->free_req_head == -1. Fix this by checking q->free_req_head in +nvme_free_req_queue_cb(). If the free request list is exhausted, don't +wake waiting coroutines. Eventually an in-flight request will complete +and the BH will be scheduled again, guaranteeing forward progress. + +Signed-off-by: Stefan Hajnoczi +Reviewed-by: Philippe Mathieu-Daudé +Message-id: 20211208152246.244585-1-stefanha@redhat.com +Signed-off-by: Stefan Hajnoczi +Signed-off-by: Luo Yifan +--- + block/nvme.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/block/nvme.c b/block/nvme.c +index e4f336d79c..fa360b9b3c 100644 +--- a/block/nvme.c ++++ b/block/nvme.c +@@ -206,8 +206,9 @@ static void nvme_free_req_queue_cb(void *opaque) + NVMeQueuePair *q = opaque; + + qemu_mutex_lock(&q->lock); +- while (qemu_co_enter_next(&q->free_req_queue, &q->lock)) { +- /* Retry all pending requests */ ++ while (q->free_req_head != -1 && ++ qemu_co_enter_next(&q->free_req_queue, &q->lock)) { ++ /* Retry waiting requests */ + } + qemu_mutex_unlock(&q->lock); + } +-- +2.27.0 + diff --git a/block-use-unsigned-for-in_flight-field-on-driver-sta.patch b/block-use-unsigned-for-in_flight-field-on-driver-sta.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ff052c60e6eb12a718b004a0f19de951ec3ee14 --- /dev/null +++ b/block-use-unsigned-for-in_flight-field-on-driver-sta.patch @@ -0,0 +1,54 @@ +From d82b2052d61cd57fb2ebf53f633cb0ff272d16c3 Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:53:08 -0800 +Subject: [PATCH] block: use 'unsigned' for in_flight field on driver state + +cherry picked from commit 1b8f777673985af366de099ad4e41d334b36fb12 + +This patch makes in_flight field 'unsigned' for BDRVNBDState and +MirrorBlockJob. This matches the definition of this field on BDS +and is generically correct - we should never get negative value here. + +Signed-off-by: Denis V. Lunev +CC: John Snow +CC: Vladimir Sementsov-Ogievskiy +CC: Kevin Wolf +CC: Hanna Reitz +CC: Eric Blake +Reviewed-by: Vladimir Sementsov-Ogievskiy +Signed-off-by: Vladimir Sementsov-Ogievskiy +Signed-off-by: Wanghe Xiao +--- + block/mirror.c | 2 +- + block/nbd.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/block/mirror.c b/block/mirror.c +index b7f0cba9b9..d1863565c4 100644 +--- a/block/mirror.c ++++ b/block/mirror.c +@@ -72,7 +72,7 @@ typedef struct MirrorBlockJob { + + uint64_t last_pause_ns; + unsigned long *in_flight_bitmap; +- int in_flight; ++ unsigned in_flight; + int64_t bytes_in_flight; + QTAILQ_HEAD(, MirrorOp) ops_in_flight; + int ret; +diff --git a/block/nbd.c b/block/nbd.c +index 33adfddc41..a543e68d2f 100644 +--- a/block/nbd.c ++++ b/block/nbd.c +@@ -76,7 +76,7 @@ typedef struct BDRVNBDState { + CoQueue free_sema; + + CoMutex receive_mutex; +- int in_flight; ++ unsigned in_flight; + NBDClientState state; + + QEMUTimer *reconnect_delay_timer; +-- +2.27.0 + diff --git a/disas-hppa-Show-hexcode-of-instruction-along-with-di.patch b/disas-hppa-Show-hexcode-of-instruction-along-with-di.patch new file mode 100644 index 0000000000000000000000000000000000000000..16cd69a7ef3a4994c3604bc2dcbb551860b0190f --- /dev/null +++ b/disas-hppa-Show-hexcode-of-instruction-along-with-di.patch @@ -0,0 +1,48 @@ +From 7949977cef7b7b4170dad873f9b5788f0c4e40ee Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 10:54:54 +0800 +Subject: [PATCH] disas/hppa: Show hexcode of instruction along with + disassembly + +cherry picked from 2f926bfd5b79e6219ae65a1e530b38f37d62b384 + +On hppa many instructions can be expressed by different bytecodes. +To be able to debug qemu translation bugs it's therefore necessary to see the +currently executed byte codes without the need to lookup the sequence without +the full executable. +With this patch the instruction byte code is shown beside the disassembly. + +Signed-off-by: Helge Deller +Reviewed-by: Richard Henderson + +Signed-off-by: boringandboring +--- + disas/hppa.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/disas/hppa.c b/disas/hppa.c +index dcf9a47f34..cce4f4aa37 100644 +--- a/disas/hppa.c ++++ b/disas/hppa.c +@@ -1968,6 +1968,10 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info) + + insn = bfd_getb32 (buffer); + ++ info->fprintf_func(info->stream, " %02x %02x %02x %02x ", ++ (insn >> 24) & 0xff, (insn >> 16) & 0xff, ++ (insn >> 8) & 0xff, insn & 0xff); ++ + for (i = 0; i < NUMOPCODES; ++i) + { + const struct pa_opcode *opcode = &pa_opcodes[i]; +@@ -2826,6 +2830,6 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info) + return sizeof (insn); + } + } +- (*info->fprintf_func) (info->stream, "#%8x", insn); ++ info->fprintf_func(info->stream, ""); + return sizeof (insn); + } +-- +2.27.0 + diff --git a/hmp-Improve-sync-profile-error-message.patch b/hmp-Improve-sync-profile-error-message.patch new file mode 100644 index 0000000000000000000000000000000000000000..703bbe85f458193426476cdd1d7dcf13d6809ee5 --- /dev/null +++ b/hmp-Improve-sync-profile-error-message.patch @@ -0,0 +1,52 @@ +From 3860a3a40673bdbcf8f8fde9017e9e1ecbd82b36 Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 16:09:24 +0800 +Subject: [PATCH] hmp: Improve sync-profile error message +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from 7200fb211ef306c36d5e9060263b2a4d2f6d4700 + +Improve + + (qemu) sync-profile of + Error: Invalid parameter 'of' + +to + + Error: invalid parameter 'of', expecting 'on', 'off', or 'reset' + +Signed-off-by: Markus Armbruster +Message-ID: <20231031111059.3407803-3-armbru@redhat.com> +Reviewed-by: Philippe Mathieu-Daudé +Reviewed-by: Dr. David Alan Gilbert +--- + monitor/hmp-cmds.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c +index 9570011232..5246c82e14 100644 +--- a/monitor/hmp-cmds.c ++++ b/monitor/hmp-cmds.c +@@ -46,7 +46,6 @@ + #include "qapi/qapi-visit-migration.h" + #include "qapi/qmp/qdict.h" + #include "qapi/qapi-visit-migration.h" +-#include "qapi/qmp/qerror.h" + #include "qapi/string-input-visitor.h" + #include "qapi/string-output-visitor.h" + #include "qom/object_interfaces.h" +@@ -920,7 +919,8 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict) + } else { + Error *err = NULL; + +- error_setg(&err, QERR_INVALID_PARAMETER, op); ++ error_setg(&err, "invalid parameter '%s'," ++ " expecting 'on', 'off', or 'reset'", op); + hmp_handle_error(mon, err); + } + } +-- +2.27.0 + diff --git a/hw-arm-ast2600-Fix-address-mapping-of-second-SPI-con.patch b/hw-arm-ast2600-Fix-address-mapping-of-second-SPI-con.patch new file mode 100644 index 0000000000000000000000000000000000000000..9935b5e9a54dc36340f77f73771a39798be3ac7b --- /dev/null +++ b/hw-arm-ast2600-Fix-address-mapping-of-second-SPI-con.patch @@ -0,0 +1,40 @@ +From 13a37e4130fbdfcd9a5027b4339eee592ee76889 Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Mon, 4 Dec 2023 11:01:29 +0800 +Subject: [PATCH] hw/arm: ast2600: Fix address mapping of second SPI controller +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit 08048cbd5e7dc0a0359ccb8c7968e4d011174801 + +Address should be 0x1E631000 and not 0x1E641000 as initially introduced. + +Resolves: https://gitlab.com/qemu-project/qemu/-/issues/838 +Fixes: f25c0ae1079d ("aspeed/soc: Add AST2600 support") +Suggested-by: Troy Lee +Signed-off-by: Cédric Le Goater +Reviewed-by: Philippe Mathieu-Daudé +Message-id: 20220126083520.4135713-1-clg@kaod.org +Signed-off-by: Peter Maydell +Signed-off-by: Luo Yifan +--- + hw/arm/aspeed_ast2600.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c +index 0384357a95..d83a70300e 100644 +--- a/hw/arm/aspeed_ast2600.c ++++ b/hw/arm/aspeed_ast2600.c +@@ -27,7 +27,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { + [ASPEED_DEV_PWM] = 0x1E610000, + [ASPEED_DEV_FMC] = 0x1E620000, + [ASPEED_DEV_SPI1] = 0x1E630000, +- [ASPEED_DEV_SPI2] = 0x1E641000, ++ [ASPEED_DEV_SPI2] = 0x1E631000, + [ASPEED_DEV_EHCI1] = 0x1E6A1000, + [ASPEED_DEV_EHCI2] = 0x1E6A3000, + [ASPEED_DEV_MII1] = 0x1E650000, +-- +2.27.0 + diff --git a/hw-display-next-fb-Fix-comment-typo.patch b/hw-display-next-fb-Fix-comment-typo.patch new file mode 100644 index 0000000000000000000000000000000000000000..f23a0732040f7dab84df7f2daa7a24c8e84f8482 --- /dev/null +++ b/hw-display-next-fb-Fix-comment-typo.patch @@ -0,0 +1,36 @@ +From 7252e8e0f5a4c43854efa3e31071a678f4e61d37 Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 01:49:31 -0800 +Subject: [PATCH] hw/display/next-fb: Fix comment typo +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit c1966f515d9bb6d8ed7076f4bebdc45407700100 + +Signed-off-by: Evgeny Ermakov +Message-Id: <20221125160849.23711-1-evgeny.v.ermakov@gmail.com> +Reviewed-by: Philippe Mathieu-Daudé +Reviewed-by: Peter Maydell +Signed-off-by: Thomas Huth +Signed-off-by: Wanghe Xiao +--- + hw/display/next-fb.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/display/next-fb.c b/hw/display/next-fb.c +index dd6a1aa8ae..8446ff3c00 100644 +--- a/hw/display/next-fb.c ++++ b/hw/display/next-fb.c +@@ -126,7 +126,7 @@ static void nextfb_class_init(ObjectClass *oc, void *data) + set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); + dc->realize = nextfb_realize; + +- /* Note: This device does not any state that we have to reset or migrate */ ++ /* Note: This device does not have any state that we have to reset or migrate */ + } + + static const TypeInfo nextfb_info = { +-- +2.27.0 + diff --git a/hw-ide-atapi.c-Correct-typos-CD-CDROM-CD-ROM.patch b/hw-ide-atapi.c-Correct-typos-CD-CDROM-CD-ROM.patch new file mode 100644 index 0000000000000000000000000000000000000000..672ab70952fb78c15854cc1d0a4ce7bff17c4ee3 --- /dev/null +++ b/hw-ide-atapi.c-Correct-typos-CD-CDROM-CD-ROM.patch @@ -0,0 +1,41 @@ +From c8c702a9970572800626be337e3b5c8b44e4bcca Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:43:50 -0800 +Subject: [PATCH] hw/ide/atapi.c: Correct typos (CD-CDROM -> CD-ROM) + +cherry picked from commit 99337bd1e3a323d07dc29da99cf3f48d3990ad81 + +Signed-off-by: Lev Kujawski +Reviewed-by: Laurent Vivier +Message-Id: <20220528204702.167912-1-lkujaw@member.fsf.org> +Signed-off-by: Laurent Vivier +Signed-off-by: Wanghe Xiao +--- + hw/ide/atapi.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c +index b626199e3d..88b2890faf 100644 +--- a/hw/ide/atapi.c ++++ b/hw/ide/atapi.c +@@ -318,7 +318,7 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size) + } + } + +-/* start a CD-CDROM read command */ ++/* start a CD-ROM read command */ + static void ide_atapi_cmd_read_pio(IDEState *s, int lba, int nb_sectors, + int sector_size) + { +@@ -417,7 +417,7 @@ eot: + ide_set_inactive(s, false); + } + +-/* start a CD-CDROM read command with DMA */ ++/* start a CD-ROM read command with DMA */ + /* XXX: test if DMA is available */ + static void ide_atapi_cmd_read_dma(IDEState *s, int lba, int nb_sectors, + int sector_size) +-- +2.27.0 + diff --git a/hw-intc-arm_gicv3-ICC_PMR_EL1-high-bits-should-be-RA.patch b/hw-intc-arm_gicv3-ICC_PMR_EL1-high-bits-should-be-RA.patch new file mode 100644 index 0000000000000000000000000000000000000000..92d2b86e043b65d42a950acb354bfba61ea39666 --- /dev/null +++ b/hw-intc-arm_gicv3-ICC_PMR_EL1-high-bits-should-be-RA.patch @@ -0,0 +1,54 @@ +From bd71d640e5d3731a91ccd6cc4ded251d401b4b2d Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Tue, 28 Nov 2023 09:38:09 +0800 +Subject: [PATCH] hw/intc/arm_gicv3: ICC_PMR_EL1 high bits should be RAZ + +cherry picked from 70726a15bc7e61d16f3efe5bfd9b061ca077f533 + +The ICC_PMR_ELx and ICV_PMR_ELx bit masks returned from +ic{c,v}_fullprio_mask should technically also remove any +bit above 7 as these are marked reserved (read 0) and should +therefore should not be written as anything other than 0. + +This was noted during a run of a proprietary test system and +discused on the mailing list [1] and initially thought not to +be an issue due to RES0 being technically allowed to be +written to and read back as long as the implementation does +not use the RES0 bits. It is very possible that the values +are used in comparison without masking, as pointed out by +Peter in [2], if (cs->hppi.prio >= cs->icc_pmr_el1) may well +do the wrong thing. + +Masking these values in ic{c,v}_fullprio_mask() should fix +this and prevent any future problems with playing with the +values. + +[1]: https://lists.nongnu.org/archive/html/qemu-arm/2023-11/msg00607.html +[2]: https://lists.nongnu.org/archive/html/qemu-arm/2023-11/msg00737.html + +Signed-off-by: Ben Dooks +Message-id: 20231116172818.792364-1-ben.dooks@codethink.co.uk +Suggested-by: Peter Maydell +Reviewed-by: Peter Maydell +Signed-off-by: Peter Maydell +Signed-off-by: boringandboring +--- + hw/intc/arm_gicv3_cpuif.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c +index 274a40a40c..eaa1381b3d 100644 +--- a/hw/intc/arm_gicv3_cpuif.c ++++ b/hw/intc/arm_gicv3_cpuif.c +@@ -137,7 +137,7 @@ static uint32_t icv_fullprio_mask(GICv3CPUState *cs) + * with the group priority, whose mask depends on the value of VBPR + * for the interrupt group.) + */ +- return ~0U << (8 - cs->vpribits); ++ return (~0U << (8 - cs->vpribits)) & 0xff; + } + + static int ich_highest_active_virt_prio(GICv3CPUState *cs) +-- +2.27.0 + diff --git a/hw-net-npcm7xx_emc-fix-missing-queue_flush.patch b/hw-net-npcm7xx_emc-fix-missing-queue_flush.patch new file mode 100644 index 0000000000000000000000000000000000000000..bce9a4f925f61e43711dae879a820c206619cf4a --- /dev/null +++ b/hw-net-npcm7xx_emc-fix-missing-queue_flush.patch @@ -0,0 +1,75 @@ +From cf11e02156e202db1be5e9c85b67d5dfaa56ce48 Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Mon, 4 Dec 2023 10:28:53 +0800 +Subject: [PATCH] hw/net: npcm7xx_emc fix missing queue_flush +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit 530cd6c26df47c4f294c6335c9829e6c968fe7a8 + +The rx_active boolean change to true should always trigger a try_read +call that flushes the queue. + +Signed-off-by: Patrick Venture +Reviewed-by: Philippe Mathieu-Daudé +Message-id: 20211203221002.1719306-1-venture@google.com +Signed-off-by: Peter Maydell +Signed-off-by: Luo Yifan +--- + hw/net/npcm7xx_emc.c | 18 ++++++++---------- + 1 file changed, 8 insertions(+), 10 deletions(-) + +diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c +index df2efe1bf8..9a2328935c 100644 +--- a/hw/net/npcm7xx_emc.c ++++ b/hw/net/npcm7xx_emc.c +@@ -286,6 +286,12 @@ static void emc_halt_rx(NPCM7xxEMCState *emc, uint32_t mista_flag) + emc_set_mista(emc, mista_flag); + } + ++static void emc_enable_rx_and_flush(NPCM7xxEMCState *emc) ++{ ++ emc->rx_active = true; ++ qemu_flush_queued_packets(qemu_get_queue(emc->nic)); ++} ++ + static void emc_set_next_tx_descriptor(NPCM7xxEMCState *emc, + const NPCM7xxEMCTxDesc *tx_desc, + uint32_t desc_addr) +@@ -585,13 +591,6 @@ static ssize_t emc_receive(NetClientState *nc, const uint8_t *buf, size_t len1) + return len; + } + +-static void emc_try_receive_next_packet(NPCM7xxEMCState *emc) +-{ +- if (emc_can_receive(qemu_get_queue(emc->nic))) { +- qemu_flush_queued_packets(qemu_get_queue(emc->nic)); +- } +-} +- + static uint64_t npcm7xx_emc_read(void *opaque, hwaddr offset, unsigned size) + { + NPCM7xxEMCState *emc = opaque; +@@ -707,7 +706,7 @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, + emc->regs[REG_MGSTA] |= REG_MGSTA_RXHA; + } + if (value & REG_MCMDR_RXON) { +- emc->rx_active = true; ++ emc_enable_rx_and_flush(emc); + } else { + emc_halt_rx(emc, 0); + } +@@ -743,8 +742,7 @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, + break; + case REG_RSDR: + if (emc->regs[REG_MCMDR] & REG_MCMDR_RXON) { +- emc->rx_active = true; +- emc_try_receive_next_packet(emc); ++ emc_enable_rx_and_flush(emc); + } + break; + case REG_MIIDA: +-- +2.27.0 + diff --git a/hw-riscv-boot-Reduce-FDT-address-alignment-constrain.patch b/hw-riscv-boot-Reduce-FDT-address-alignment-constrain.patch new file mode 100644 index 0000000000000000000000000000000000000000..ca3125a43beed631db6e1fc0c283aa22914839d9 --- /dev/null +++ b/hw-riscv-boot-Reduce-FDT-address-alignment-constrain.patch @@ -0,0 +1,46 @@ +From 919af9a7472996b17c45fcd508ae29ec58117e8c Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:39:26 -0800 +Subject: [PATCH] hw/riscv: boot: Reduce FDT address alignment constraints + +cherry picked from commit ec2c62dacc186893a6ce63089f96b1906dd68804 + +We previously stored the device tree at a 16MB alignment from the end of +memory (or 3GB). This means we need at least 16MB of memory to be able +to do this. We don't actually need the FDT to be 16MB aligned, so let's +drop it down to 2MB so that we can support systems with less memory, +while also allowing FDT size expansion. + +Resolves: https://gitlab.com/qemu-project/qemu/-/issues/992 +Signed-off-by: Alistair Francis +Reviewed-by: Atish Patra +Reviewed-by: Bin Meng +Tested-by: Bin Meng +Message-Id: <20220608062015.317894-1-alistair.francis@opensource.wdc.com> +Signed-off-by: Alistair Francis +Signed-off-by: Wanghe Xiao +--- + hw/riscv/boot.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c +index 519fa455a1..c035aa68f5 100644 +--- a/hw/riscv/boot.c ++++ b/hw/riscv/boot.c +@@ -217,11 +217,11 @@ uint32_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt) + /* + * We should put fdt as far as possible to avoid kernel/initrd overwriting + * its content. But it should be addressable by 32 bit system as well. +- * Thus, put it at an 16MB aligned address that less than fdt size from the ++ * Thus, put it at an 2MB aligned address that less than fdt size from the + * end of dram or 3GB whichever is lesser. + */ + temp = MIN(dram_end, 3072 * MiB); +- fdt_addr = QEMU_ALIGN_DOWN(temp - fdtsize, 16 * MiB); ++ fdt_addr = QEMU_ALIGN_DOWN(temp - fdtsize, 2 * MiB); + + ret = fdt_pack(fdt); + /* Should only fail if we've built a corrupted tree */ +-- +2.27.0 + diff --git a/hw-usb-dev-mtp-Use-g_mkdir.patch b/hw-usb-dev-mtp-Use-g_mkdir.patch new file mode 100644 index 0000000000000000000000000000000000000000..4e866717a8a86eae95e563f8cbc6ebbb3ddd14ba --- /dev/null +++ b/hw-usb-dev-mtp-Use-g_mkdir.patch @@ -0,0 +1,48 @@ +From af6c51e5ef35cdf966888fb6874944d9615384a8 Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:20:54 -0800 +Subject: [PATCH] hw/usb: dev-mtp: Use g_mkdir() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit 34b55848a15bca120d9b9381881c40b045409ee9 + +Use g_mkdir() to create a directory on all platforms. + +Signed-off-by: Bin Meng +Acked-by: Gerd Hoffmann +Signed-off-by: Alex Bennée +Reviewed-by: Philippe Mathieu-Daudé +Message-Id: <20221006151927.2079583-8-bmeng.cn@gmail.com> +Message-Id: <20221027183637.2772968-15-alex.bennee@linaro.org> +Signed-off-by: Wanghe Xiao +--- + hw/usb/dev-mtp.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c +index c1d1694fd0..882f6bc72f 100644 +--- a/hw/usb/dev-mtp.c ++++ b/hw/usb/dev-mtp.c +@@ -15,7 +15,7 @@ + #include "qemu/error-report.h" + #include + #include +- ++#include + #include + + +@@ -1623,7 +1623,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t handle) + if (s->dataset.filename) { + path = g_strdup_printf("%s/%s", parent->path, s->dataset.filename); + if (s->dataset.format == FMT_ASSOCIATION) { +- ret = mkdir(path, mask); ++ ret = g_mkdir(path, mask); + if (!ret) { + usb_mtp_queue_result(s, RES_OK, d->trans, 3, + QEMU_STORAGE_ID, +-- +2.27.0 + diff --git a/hw-virtio-virtio-iommu-pci-Enforce-the-device-is-plu.patch b/hw-virtio-virtio-iommu-pci-Enforce-the-device-is-plu.patch new file mode 100644 index 0000000000000000000000000000000000000000..f442f06b339a0ced45647349d10ee50bdeb7fba0 --- /dev/null +++ b/hw-virtio-virtio-iommu-pci-Enforce-the-device-is-plu.patch @@ -0,0 +1,69 @@ +From a2323aa79da71c92e818306f1e18184619309a35 Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:03:07 -0800 +Subject: [PATCH] hw/virtio/virtio-iommu-pci: Enforce the device is plugged on + the root bus + +cherry picked from commit e72cfabf4ef2f0031e5d0b8129fb1533d383654d + +In theory the virtio-iommu-pci could be plugged anywhere in the PCIe +topology and as long as the dt/acpi info are properly built this should +work. However at the moment we fail to do that because the +virtio-iommu-pci BDF is not computed at plug time and in that case +vms->virtio_iommu_bdf gets an incorrect value. + +For instance if the virtio-iommu-pci is plugged onto a pcie root port +and the virtio-iommu protects a virtio-block-pci device the guest does +not boot. + +So let's do not pretend we do support this case and fail the initialize() +if we detect the virtio-iommu-pci is plugged anywhere else than on the +root bus. Anyway this ability is not needed. + +Signed-off-by: Eric Auger +Message-Id: <20221012163448.121368-1-eric.auger@redhat.com> +Reviewed-by: Jean-Philippe Brucker +Tested-by: Jean-Philippe Brucker +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +Signed-off-by: Wanghe Xiao +--- + hw/virtio/virtio-iommu-pci.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c +index a160ae6b41..37eb2fb979 100644 +--- a/hw/virtio/virtio-iommu-pci.c ++++ b/hw/virtio/virtio-iommu-pci.c +@@ -44,6 +44,7 @@ static Property virtio_iommu_pci_properties[] = { + static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) + { + VirtIOIOMMUPCI *dev = VIRTIO_IOMMU_PCI(vpci_dev); ++ PCIBus *pbus = pci_get_bus(&vpci_dev->pci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); + +@@ -65,11 +66,17 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) + s->reserved_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_MSI) { + error_setg(errp, "reserved region %d has an invalid type", i); + error_append_hint(errp, "Valid values are 0 and 1\n"); +- } ++ return; ++ } + } ++ if (!pci_bus_is_root(pbus)) { ++ error_setg(errp, "virtio-iommu-pci must be plugged on the root bus"); ++ return; ++ } ++ + object_property_set_link(OBJECT(dev), "primary-bus", +- OBJECT(pci_get_bus(&vpci_dev->pci_dev)), +- &error_abort); ++ OBJECT(pbus), &error_abort); ++ + virtio_pci_force_virtio_1(vpci_dev); + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); + } +-- +2.27.0 + diff --git a/migration-colo-More-accurate-update-checkpoint-time.patch b/migration-colo-More-accurate-update-checkpoint-time.patch new file mode 100644 index 0000000000000000000000000000000000000000..21a4aad3d6658494bfcfd01464eaf09af55d8837 --- /dev/null +++ b/migration-colo-More-accurate-update-checkpoint-time.patch @@ -0,0 +1,44 @@ +From 3577b5c059bd3f83d47f72ef400e85160d56bc58 Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Fri, 1 Dec 2023 11:11:43 +0800 +Subject: [PATCH] migration/colo: More accurate update checkpoint time + +cherry picked from commit 0e0f0479e28c6c1a1d024b2e5200cade479d6901 + +Previous operation(like vm_start and replication_start_all) will consume +extra time before update the timer, so reduce time in this patch. + +Signed-off-by: Zhang Chen +Reviewed-by: Juan Quintela +Signed-off-by: Juan Quintela +Signed-off-by: Luo Yifan +--- + migration/colo.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/migration/colo.c b/migration/colo.c +index 2415325262..c8fadae956 100644 +--- a/migration/colo.c ++++ b/migration/colo.c +@@ -530,7 +530,6 @@ static void colo_process_checkpoint(MigrationState *s) + { + QIOChannelBuffer *bioc; + QEMUFile *fb = NULL; +- int64_t current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); + Error *local_err = NULL; + int ret; + +@@ -578,8 +577,8 @@ static void colo_process_checkpoint(MigrationState *s) + qemu_mutex_unlock_iothread(); + trace_colo_vm_state_change("stop", "run"); + +- timer_mod(s->colo_delay_timer, +- current_time + s->parameters.x_checkpoint_delay); ++ timer_mod(s->colo_delay_timer, qemu_clock_get_ms(QEMU_CLOCK_HOST) + ++ s->parameters.x_checkpoint_delay); + + while (s->state == MIGRATION_STATUS_COLO) { + if (failover_get_state() != FAILOVER_STATUS_NONE) { +-- +2.27.0 + diff --git a/qemu.spec b/qemu.spec index 56bec06b12cdf257c9fbf82adcc7dadbefd6ffcd..bc9d629cb94b3d6f22c43f3c95ff26e1b5f9ba9f 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Name: qemu Version: 6.2.0 -Release: 85 +Release: 86 Epoch: 10 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 @@ -785,6 +785,54 @@ Patch0770: libvhost-user-Fix-VHOST_USER_GET_MAX_MEM_SLOTS-reply.patch Patch0771: tests-qtest-check-the-return-value.patch Patch0772: hw-net-cadence_gem.c-spelling-fixes-Octects.patch Patch0773: hw-arm-fsl-imx-Do-not-ignore-Error-argument.patch +Patch0774: xen-pass-through-don-t-create-needless-register-grou.patch +Patch0775: spapr-pci-Correct-does-not-support-hotplugging-error.patch +Patch0776: hmp-Improve-sync-profile-error-message.patch +Patch0777: qga-Improve-guest-exec-status-error-message.patch +Patch0778: ui-qmp-cmds-Improve-two-error-messages.patch +Patch0779: tcg-loongarch64-Fix-tcg_out_mov-Aborted.patch +Patch0780: disas-hppa-Show-hexcode-of-instruction-along-with-di.patch +Patch0781: target-arm-Don-t-set-syndrome-ISS-for-loads-and-stor.patch +Patch0782: balloon-Fix-a-misleading-error-message.patch +Patch0783: target-i386-cpu-Improve-error-message-for-property-v.patch +Patch0784: tests-qtest-migration-test.c-spelling-fix-bandwith.patch +Patch0785: xen-pass-through-merge-emulated-bits-correctly.patch +Patch0786: hw-display-next-fb-Fix-comment-typo.patch +Patch0787: hw-virtio-virtio-iommu-pci-Enforce-the-device-is-plu.patch +Patch0788: hw-ide-atapi.c-Correct-typos-CD-CDROM-CD-ROM.patch +Patch0789: trivial-typos-namesapce.patch +Patch0790: tests-qtest-Fix-two-format-strings.patch +Patch0791: sphinx-change-default-language-to-en.patch +Patch0792: block-use-unsigned-for-in_flight-field-on-driver-sta.patch +Patch0793: Fix-STM32F2XX-USART-data-register-readout.patch +Patch0794: Revert-hw-virtio-virtio-iommu-pci-Enforce-the-device.patch +Patch0795: hw-riscv-boot-Reduce-FDT-address-alignment-constrain.patch +Patch0796: vhost-user-blk-propagate-error-return-from-generic-v.patch +Patch0797: vhost-user-blk-reconnect-on-any-error-during-realize.patch +Patch0798: hw-arm-ast2600-Fix-address-mapping-of-second-SPI-con.patch +Patch0799: Add-dummy-Aspeed-AST2600-Display-Port-MCU-DPMCU.patch +Patch0800: hw-net-npcm7xx_emc-fix-missing-queue_flush.patch +Patch0801: block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch +Patch0802: scripts-entitlement.sh-Use-backward-compatible-cp-fl.patch +Patch0803: migration-colo-More-accurate-update-checkpoint-time.patch +Patch0804: Fixed-a-QEMU-hang-when-guest-poweroff-in-COLO-mode.patch +Patch0805: hw-intc-arm_gicv3-ICC_PMR_EL1-high-bits-should-be-RA.patch +Patch0806: target-ppc-cpu-models-Remove-the-default-CPU-alias.patch +Patch0807: hw-usb-dev-mtp-Use-g_mkdir.patch +Patch0808: ui-gtk-prevent-ui-lock-up-when-dpy_gl_update-called-.patch +Patch0809: vhost-fix-null-pointer-access.patch +Patch0810: vhost-vdpa-add-VHOST_BACKEND_F_BYTEMAPLOG.patch +Patch0811: vhost-vdpa-add-migration-log-ops-for-VhostOps.patch +Patch0812: vhost-introduce-bytemap-for-vhost-backend-logging.patch +Patch0813: vhost-add-vhost_dev_suspend-resume_op.patch +Patch0814: vhost-implement-vhost-vdpa-suspend-resume.patch +Patch0815: vhost-implement-vhost_vdpa_device_suspend-resume.patch +Patch0816: vhost-implement-savevm_hanlder-for-vdpa-device.patch +Patch0817: vhost-implement-migration-state-notifier-for-vdpa-de.patch +Patch0818: vhost-implement-post-resume-bh.patch +Patch0819: vdpa-implement-vdpa-device-migration.patch +Patch0820: vdpa-move-memory-listener-to-the-realize-stage.patch + BuildRequires: flex BuildRequires: gcc @@ -1383,6 +1431,55 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Tue Dec 5 2023 - 10:6.2.0-86 +- vdpa: move memory listener to the realize stage +- vdpa: implement vdpa device migration +- vhost: implement post resume bh +- vhost: implement migration state notifier for vdpa device +- vhost: implement savevm_hanlder for vdpa device +- vhost: implement vhost_vdpa_device_suspend/resume +- vhost: implement vhost-vdpa suspend/resume +- vhost: add vhost_dev_suspend/resume_op +- vhost: introduce bytemap for vhost backend logging +- vhost-vdpa: add migration log ops for VhostOps +- vhost-vdpa: add VHOST_BACKEND_F_BYTEMAPLOG +- vhost: fix null pointer access +- ui/gtk: prevent ui lock up when dpy_gl_update called again before current draw event occurs +- hw/usb: dev-mtp: Use g_mkdir() +- target/ppc/cpu-models: Remove the "default" CPU alias +- hw/intc/arm_gicv3: ICC_PMR_EL1 high bits should be RAZ +- Fixed a QEMU hang when guest poweroff in COLO mode +- migration/colo: More accurate update checkpoint time +- scripts/entitlement.sh: Use backward-compatible cp flags +- block/nvme: fix infinite loop in nvme_free_req_queue_cb() +- hw/net: npcm7xx_emc fix missing queue_flush +- Add dummy Aspeed AST2600 Display Port MCU (DPMCU) +- hw/arm: ast2600: Fix address mapping of second SPI controller +- vhost-user-blk: reconnect on any error during realize +- vhost-user-blk: propagate error return from generic vhost +- hw/riscv: boot: Reduce FDT address alignment constraints +- Revert "hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus" +- Fix STM32F2XX USART data register readout +- block: use 'unsigned' for in_flight field on driver state +- sphinx: change default language to 'en' +- tests/qtest: Fix two format strings +- trivial typos: namesapce +- hw/ide/atapi.c: Correct typos (CD-CDROM -> CD-ROM) +- hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus +- hw/display/next-fb: Fix comment typo +- xen/pass-through: merge emulated bits correctly mainline inclusion commit be9c61da9fc57eb7d293f380d0805ca6f46c2657 category: bugfix +- tests/qtest/migration-test.c: spelling fix: bandwith +- target/i386/cpu: Improve error message for property "vendor" +- balloon: Fix a misleading error message +- target/arm: Don't set syndrome ISS for loads and stores with writeback mainline inclusion commit 53ae2fdef1f5661cbaa2ea571c517f98e6041cb8 category: bugfix +- disas/hppa: Show hexcode of instruction along with disassembly +- tcg/loongarch64: Fix tcg_out_mov() Aborted +- ui/qmp-cmds: Improve two error messages +- qga: Improve guest-exec-status error message +- hmp: Improve sync-profile error message +- spapr/pci: Correct "does not support hotplugging error messages +- xen/pass-through: don't create needless register group mainline inclusion commit c0e86b7624cb9d6db03e0d48cf82659e5b89a6a6 category: bugfix + * Fri Dec 1 2023 - 10:6.2.0-85 - spec: Add support for the ppc64le platform diff --git a/qga-Improve-guest-exec-status-error-message.patch b/qga-Improve-guest-exec-status-error-message.patch new file mode 100644 index 0000000000000000000000000000000000000000..debbba7942c2ece1ea3f38ec47cfae531a8ace81 --- /dev/null +++ b/qga-Improve-guest-exec-status-error-message.patch @@ -0,0 +1,42 @@ +From f28bc5e3a6418d8477e84b52e06dcab5db7cbf15 Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 15:52:06 +0800 +Subject: [PATCH] qga: Improve guest-exec-status error message +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from b665165938d89c8e1f83f970d3722f507ce87acd + +When the PID passed to guest-exec-status does not exist, we report + + "Invalid parameter 'pid'" + +Improve this to + + "PID 1234 does not exist" + +Signed-off-by: Markus Armbruster +Message-ID: <20231031111059.3407803-4-armbru@redhat.com> +Reviewed-by: Konstantin Kostiuk +Reviewed-by: Philippe Mathieu-Daudé +--- + qga/commands.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/qga/commands.c b/qga/commands.c +index 05f89725be..9fe73786fc 100644 +--- a/qga/commands.c ++++ b/qga/commands.c +@@ -156,7 +156,7 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **errp) + + gei = guest_exec_info_find(pid); + if (gei == NULL) { +- error_setg(errp, QERR_INVALID_PARAMETER, "pid"); ++ error_setg(errp, "PID " PRId64 " does not exist"); + return NULL; + } + +-- +2.27.0 + diff --git a/scripts-entitlement.sh-Use-backward-compatible-cp-fl.patch b/scripts-entitlement.sh-Use-backward-compatible-cp-fl.patch new file mode 100644 index 0000000000000000000000000000000000000000..6139fc97205503e47538d872a4bb89f448bf3005 --- /dev/null +++ b/scripts-entitlement.sh-Use-backward-compatible-cp-fl.patch @@ -0,0 +1,35 @@ +From 66da71e852323bf1eb7b75b93cfb13eb748ad10f Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Mon, 4 Dec 2023 10:09:12 +0800 +Subject: [PATCH] scripts/entitlement.sh: Use backward-compatible cp flags + +cherry picked from commit 4006a27c5e44734350009262efb0e2ec8da5ff09 + +Older versions of Mac OS X do not support cp -a. The cp man page indicates +that -a is equivalent to -pPR. + +Signed-off-by: Evan Miller +Message-Id: <40635C6E-059A-4146-B1E2-F6376700EE85@gmail.com> +[Leave out -R, these are files and not directories. - Paolo] +Signed-off-by: Paolo Bonzini +Signed-off-by: Luo Yifan +--- + scripts/entitlement.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh +index e2c956a3ac..0f412949ec 100755 +--- a/scripts/entitlement.sh ++++ b/scripts/entitlement.sh +@@ -15,7 +15,7 @@ ENTITLEMENT="$4" + + if $in_place; then + trap 'rm "$DST.tmp"' exit +- cp -af "$SRC" "$DST.tmp" ++ cp -pPf "$SRC" "$DST.tmp" + SRC="$DST.tmp" + else + cd "$MESON_INSTALL_DESTDIR_PREFIX" +-- +2.27.0 + diff --git a/spapr-pci-Correct-does-not-support-hotplugging-error.patch b/spapr-pci-Correct-does-not-support-hotplugging-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..cb82a76b8f5921ec0e6db32fe1ddc787c2325243 --- /dev/null +++ b/spapr-pci-Correct-does-not-support-hotplugging-error.patch @@ -0,0 +1,45 @@ +From f647bc67bcdbfc2dd1cb1f1ba1abdb2b04c5c10f Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 16:19:33 +0800 +Subject: [PATCH] spapr/pci: Correct "does not support hotplugging error + messages + +cherry picked from db8227a68addb9db6392001c7e02d406282ea462 + +When dynamic-reconfiguration is off, hot plug / unplug can fail with +"Bus 'spapr-pci-host-bridge' does not support hotplugging". +spapr-pci-host-bridge is a device, not a bus. Report the name of the +bus it provides instead: 'pci.0'. + +Signed-off-by: Markus Armbruster +Message-ID: <20231031111059.3407803-2-armbru@redhat.com> +Reviewed-by: Daniel Henrique Barboza +--- + hw/ppc/spapr_pci.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c +index d3367e8578..3b518f1be9 100644 +--- a/hw/ppc/spapr_pci.c ++++ b/hw/ppc/spapr_pci.c +@@ -1554,7 +1554,7 @@ static void spapr_pci_pre_plug(HotplugHandler *plug_handler, + */ + if (plugged_dev->hotplugged) { + error_setg(errp, QERR_BUS_NO_HOTPLUG, +- object_get_typename(OBJECT(phb))); ++ phb->parent_obj.bus->qbus.name); + return; + } + } +@@ -1677,7 +1677,7 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler, + + if (!phb->dr_enabled) { + error_setg(errp, QERR_BUS_NO_HOTPLUG, +- object_get_typename(OBJECT(phb))); ++ phb->parent_obj.bus->qbus.name); + return; + } + +-- +2.27.0 + diff --git a/sphinx-change-default-language-to-en.patch b/sphinx-change-default-language-to-en.patch new file mode 100644 index 0000000000000000000000000000000000000000..77f2b2af213566c273c942fe6d9f18b56c352d3e --- /dev/null +++ b/sphinx-change-default-language-to-en.patch @@ -0,0 +1,38 @@ +From a6861159f23833f878be833e2c0c37060ac14513 Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:57:47 -0800 +Subject: [PATCH] sphinx: change default language to 'en' + +cherry picked from commit ba1a6723f58640ba281bc952abc255e97c70bad5 + +Fixes the following Sphinx warning (treated as error) starting +with 5.0 release: + +Warning, treated as error: +Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English). + +Signed-off-by: Martin Liska +Message-id: e91e51ee-48ac-437e-6467-98b56ee40042@suse.cz +Reviewed-by: Peter Maydell +Signed-off-by: Peter Maydell +Signed-off-by: Wanghe Xiao +--- + docs/conf.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/docs/conf.py b/docs/conf.py +index 763e7d2434..84b593e12a 100644 +--- a/docs/conf.py ++++ b/docs/conf.py +@@ -120,7 +120,7 @@ + # + # This is also used if you do content translation via gettext catalogs. + # Usually you set "language" from the command line for these cases. +-language = None ++language = 'en' + + # List of patterns, relative to source directory, that match files and + # directories to ignore when looking for source files. +-- +2.27.0 + diff --git a/target-arm-Don-t-set-syndrome-ISS-for-loads-and-stor.patch b/target-arm-Don-t-set-syndrome-ISS-for-loads-and-stor.patch new file mode 100644 index 0000000000000000000000000000000000000000..4fe6a0cd77d1839db5c46f6b149bc4b996cc8672 --- /dev/null +++ b/target-arm-Don-t-set-syndrome-ISS-for-loads-and-stor.patch @@ -0,0 +1,51 @@ +From dd5bf5817259ea414f40b25f4aef3864eddb9706 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Mon, 27 Nov 2023 03:24:57 +0000 +Subject: [PATCH] target/arm: Don't set syndrome ISS for loads and stores with + writeback mainline inclusion commit 53ae2fdef1f5661cbaa2ea571c517f98e6041cb8 + category: bugfix + +--------------------------------------------------------------- + +The architecture requires that for faults on loads and stores which +do writeback, the syndrome information does not have the ISS +instruction syndrome information (i.e. ISV is 0). We got this wrong +for the load and store instructions covered by disas_ldst_reg_imm9(). +Calculate iss_valid correctly so that if the insn is a writeback one +it is false. + +Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1057 +Signed-off-by: Peter Maydell +Reviewed-by: Richard Henderson +Message-id: 20220715123323.1550983-1-peter.maydell@linaro.org + +Signed-off-by: tangbinzy +--- + target/arm/translate-a64.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c +index cec672f229..549a671bea 100644 +--- a/target/arm/translate-a64.c ++++ b/target/arm/translate-a64.c +@@ -3039,7 +3039,7 @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn, + bool is_store = false; + bool is_extended = false; + bool is_unpriv = (idx == 2); +- bool iss_valid = !is_vector; ++ bool iss_valid; + bool post_index; + bool writeback; + int memidx; +@@ -3092,6 +3092,8 @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn, + g_assert_not_reached(); + } + ++ iss_valid = !is_vector && !writeback; ++ + if (rn == 31) { + gen_check_sp_alignment(s); + } +-- +2.27.0 + diff --git a/target-i386-cpu-Improve-error-message-for-property-v.patch b/target-i386-cpu-Improve-error-message-for-property-v.patch new file mode 100644 index 0000000000000000000000000000000000000000..462d4877ef1b5836e15e636f41a5050972c2fdd0 --- /dev/null +++ b/target-i386-cpu-Improve-error-message-for-property-v.patch @@ -0,0 +1,45 @@ +From dca8f8c8bc4466d2502bcd305fcc8e84adf992da Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 10:20:40 +0800 +Subject: [PATCH] target/i386/cpu: Improve error message for property "vendor" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from 298d8b122056052951bda487392d8aabbfd0f3e5 + +Improve + + $ qemu-system-x86_64 -device max-x86_64-cpu,vendor=me + qemu-system-x86_64: -device max-x86_64-cpu,vendor=me: Property '.vendor' doesn't take value 'me' + +to + + qemu-system-x86_64: -device max-x86_64-cpu,vendor=0123456789abc: value of property 'vendor' must consist of exactly 12 characters + +Signed-off-by: Markus Armbruster +Message-ID: <20231031111059.3407803-8-armbru@redhat.com> +Reviewed-by: Philippe Mathieu-Daudé + +Signed-off-by: boringandboring +--- + target/i386/cpu.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/target/i386/cpu.c b/target/i386/cpu.c +index 6aaa730a0d..53a7484ca8 100644 +--- a/target/i386/cpu.c ++++ b/target/i386/cpu.c +@@ -4805,7 +4805,8 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value, + int i; + + if (strlen(value) != CPUID_VENDOR_SZ) { +- error_setg(errp, QERR_PROPERTY_VALUE_BAD, "", "vendor", value); ++ error_setg(errp, "value of property 'vendor' must consist of" ++ " exactly " stringify(CPUID_VENDOR_SZ) " characters"); + return; + } + +-- +2.27.0 + diff --git a/target-ppc-cpu-models-Remove-the-default-CPU-alias.patch b/target-ppc-cpu-models-Remove-the-default-CPU-alias.patch new file mode 100644 index 0000000000000000000000000000000000000000..048ca97c37788c5137a63877b726accc13f9b17b --- /dev/null +++ b/target-ppc-cpu-models-Remove-the-default-CPU-alias.patch @@ -0,0 +1,40 @@ +From 73ece819848b2ecc110ec676413d5a86ffc0f8fc Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:26:10 -0800 +Subject: [PATCH] target/ppc/cpu-models: Remove the "default" CPU alias +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit 7886605961d0a9c40ada0c28dee5fa0b42a30836 + +QEMU emulates a *lot* of PowerPC-based machines - having a CPU +that is named "default" and cannot be used with most of those +machines sounds just wrong. Thus let's remove this old and confusing +alias now. + +Signed-off-by: Thomas Huth +Reviewed-by: Greg Kurz +Reviewed-by: Cédric Le Goater +Message-Id: <20220705151030.662140-1-thuth@redhat.com> +Signed-off-by: Daniel Henrique Barboza +Signed-off-by: Wanghe Xiao +--- + target/ppc/cpu-models.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c +index 4baa111713..02efc95723 100644 +--- a/target/ppc/cpu-models.c ++++ b/target/ppc/cpu-models.c +@@ -963,6 +963,6 @@ PowerPCCPUAlias ppc_cpu_aliases[] = { + #endif + { "ppc32", "604" }, + { "ppc", "604" }, +- { "default", "604" }, ++ + { NULL, NULL } + }; +-- +2.27.0 + diff --git a/tcg-loongarch64-Fix-tcg_out_mov-Aborted.patch b/tcg-loongarch64-Fix-tcg_out_mov-Aborted.patch new file mode 100644 index 0000000000000000000000000000000000000000..190a5c3273ce557e8c98a0c174bdb33ec68bb21a --- /dev/null +++ b/tcg-loongarch64-Fix-tcg_out_mov-Aborted.patch @@ -0,0 +1,64 @@ +From ea14e0f1c97b6af8db9fa7b2d0df14ef03d9acb9 Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 14:04:58 +0800 +Subject: [PATCH] tcg/loongarch64: Fix tcg_out_mov() Aborted +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from 85d57a37be1461d599747ab86dc0acc46732dbce + +On LoongArch host, we got an Aborted from tcg_out_mov(). + +qemu-x86_64 configure with '--enable-debug'. + +> (gdb) b /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312 +> Breakpoint 1 at 0x2576f0: file /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc, line 312. +> (gdb) run hello +[...] +> Thread 1 "qemu-x86_64" hit Breakpoint 1, tcg_out_mov (s=0xaaaae91760 , type=TCG_TYPE_V128, ret=TCG_REG_V2, +> arg=TCG_REG_V0) at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312 +> 312 g_assert_not_reached(); +> (gdb) bt +> #0 tcg_out_mov (s=0xaaaae91760 , type=TCG_TYPE_V128, ret=TCG_REG_V2, arg=TCG_REG_V0) +> at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312 +> #1 0x000000aaaad0fee0 in tcg_reg_alloc_mov (s=0xaaaae91760 , op=0xaaaaf67c20) at ../tcg/tcg.c:4632 +> #2 0x000000aaaad142f4 in tcg_gen_code (s=0xaaaae91760 , tb=0xffe8030340 , +> pc_start=4346094) at ../tcg/tcg.c:6135 +[...] +> (gdb) c +> Continuing. +> ** +> ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached +> Bail out! ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached +> +> Thread 1 "qemu-x86_64" received signal SIGABRT, Aborted. +> 0x000000fff7b1c390 in raise () from /lib64/libc.so.6 +> (gdb) q + +Fixes: 16288ded94 ("tcg/loongarch64: Lower basic tcg vec ops to LSX") +Reviewed-by: Philippe Mathieu-Daudé +Reviewed-by: Richard Henderson +Signed-off-by: Song Gao +Message-Id: <20231120065916.374045-1-gaosong@loongson.cn> +--- + tcg/loongarch64/tcg-target.c.inc | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc +index 0b28b30002..ee7d4d728d 100644 +--- a/tcg/loongarch64/tcg-target.c.inc ++++ b/tcg/loongarch64/tcg-target.c.inc +@@ -255,6 +255,9 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) + */ + tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO); + break; ++ case TCG_TYPE_V128: ++ tcg_out_opc_vori_b(s, ret, arg, 0); ++ break; + default: + g_assert_not_reached(); + } +-- +2.27.0 + diff --git a/tests-qtest-Fix-two-format-strings.patch b/tests-qtest-Fix-two-format-strings.patch new file mode 100644 index 0000000000000000000000000000000000000000..ed739b906000a35e8c5efa91a34e6fa072b7f63d --- /dev/null +++ b/tests-qtest-Fix-two-format-strings.patch @@ -0,0 +1,44 @@ +From 00b21f96b39b892d9dff0fc7616e88e7238d54cc Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:14:16 -0800 +Subject: [PATCH] tests/qtest: Fix two format strings +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit d46e6bba55f858b829251e2f4bd7b150cdb5b1d6 + +Signed-off-by: Stefan Weil +Message-Id: <20221105115525.623059-1-sw@weilnetz.de> +Reviewed-by: Philippe Mathieu-Daudé +Signed-off-by: Thomas Huth +Signed-off-by: Wanghe Xiao +--- + tests/qtest/migration-test.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c +index 8fad247f6c..194c7cb661 100644 +--- a/tests/qtest/migration-test.c ++++ b/tests/qtest/migration-test.c +@@ -1406,7 +1406,7 @@ static void calc_dirty_rate(QTestState *who, uint64_t calc_time) + qobject_unref(qmp_command(who, + "{ 'execute': 'calc-dirty-rate'," + "'arguments': { " +- "'calc-time': %ld," ++ "'calc-time': %" PRIu64 "," + "'mode': 'dirty-ring' }}", + calc_time)); + } +@@ -1421,7 +1421,7 @@ static void dirtylimit_set_all(QTestState *who, uint64_t dirtyrate) + qobject_unref(qmp_command(who, + "{ 'execute': 'set-vcpu-dirty-limit'," + "'arguments': { " +- "'dirty-rate': %ld } }", ++ "'dirty-rate': %" PRIu64 " } }", + dirtyrate)); + } + +-- +2.27.0 + diff --git a/tests-qtest-migration-test.c-spelling-fix-bandwith.patch b/tests-qtest-migration-test.c-spelling-fix-bandwith.patch new file mode 100644 index 0000000000000000000000000000000000000000..93b57eb5e4c4f498d2f37084f65ec600ac685aa3 --- /dev/null +++ b/tests-qtest-migration-test.c-spelling-fix-bandwith.patch @@ -0,0 +1,26 @@ +From a13b274df192b01a2b8f3f5ca5497a330705caa3 Mon Sep 17 00:00:00 2001 +From: zhujun2 +Date: Fri, 24 Nov 2023 00:46:51 -0800 +Subject: [PATCH] tests/qtest/migration-test.c: spelling fix: bandwith + +Signed-off-by: zhujun2 +--- + tests/qtest/migration-test.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c +index 8fad247f6c..3813b15ea9 100644 +--- a/tests/qtest/migration-test.c ++++ b/tests/qtest/migration-test.c +@@ -1157,7 +1157,7 @@ static void test_migrate_auto_converge(void) + + /* + * We want the test to be stable and as fast as possible. +- * E.g., with 1Gb/s bandwith migration may pass without throttling, ++ * E.g., with 1Gb/s bandwidth migration may pass without throttling, + * so we need to decrease a bandwidth. + */ + const int64_t init_pct = 5, inc_pct = 50, max_pct = 95; +-- +2.27.0 + diff --git a/trivial-typos-namesapce.patch b/trivial-typos-namesapce.patch new file mode 100644 index 0000000000000000000000000000000000000000..60564e4efeb1b2667058de6897035cb5aa3dfcc0 --- /dev/null +++ b/trivial-typos-namesapce.patch @@ -0,0 +1,89 @@ +From ec92a6e31bb5bf118a09bdc085e1e4f476b98f1e Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 02:48:55 -0800 +Subject: [PATCH] trivial typos: namesapce + +cherry picked from commit a0984714fb700683094a754a2320a2e150cf10a7 + +'namespace' is misspelled in a bunch of places. + +Signed-off-by: Dr. David Alan Gilbert +Reviewed-by: Klaus Jensen +Message-Id: <20220614104045.85728-3-dgilbert@redhat.com> +Signed-off-by: Laurent Vivier +Signed-off-by: Wanghe Xiao +--- + hw/9pfs/9p-xattr-user.c | 8 ++++---- + hw/acpi/nvdimm.c | 2 +- + hw/nvme/ctrl.c | 2 +- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/hw/9pfs/9p-xattr-user.c b/hw/9pfs/9p-xattr-user.c +index f2ae9582e6..535677ed60 100644 +--- a/hw/9pfs/9p-xattr-user.c ++++ b/hw/9pfs/9p-xattr-user.c +@@ -27,7 +27,7 @@ static ssize_t mp_user_getxattr(FsContext *ctx, const char *path, + { + if (strncmp(name, "user.virtfs.", 12) == 0) { + /* +- * Don't allow fetch of user.virtfs namesapce ++ * Don't allow fetch of user.virtfs namespace + * in case of mapped security + */ + errno = ENOATTR; +@@ -49,7 +49,7 @@ static ssize_t mp_user_listxattr(FsContext *ctx, const char *path, + name_size -= 12; + } else { + /* +- * Don't allow fetch of user.virtfs namesapce ++ * Don't allow fetch of user.virtfs namespace + * in case of mapped security + */ + return 0; +@@ -74,7 +74,7 @@ static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name, + { + if (strncmp(name, "user.virtfs.", 12) == 0) { + /* +- * Don't allow fetch of user.virtfs namesapce ++ * Don't allow fetch of user.virtfs namespace + * in case of mapped security + */ + errno = EACCES; +@@ -88,7 +88,7 @@ static int mp_user_removexattr(FsContext *ctx, + { + if (strncmp(name, "user.virtfs.", 12) == 0) { + /* +- * Don't allow fetch of user.virtfs namesapce ++ * Don't allow fetch of user.virtfs namespace + * in case of mapped security + */ + errno = EACCES; +diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c +index 0d43da19ea..5f85b16327 100644 +--- a/hw/acpi/nvdimm.c ++++ b/hw/acpi/nvdimm.c +@@ -476,7 +476,7 @@ struct NvdimmFuncGetLabelDataOut { + /* the size of buffer filled by QEMU. */ + uint32_t len; + uint32_t func_ret_status; /* return status code. */ +- uint8_t out_buf[]; /* the data got via Get Namesapce Label function. */ ++ uint8_t out_buf[]; /* the data got via Get Namespace Label function. */ + } QEMU_PACKED; + typedef struct NvdimmFuncGetLabelDataOut NvdimmFuncGetLabelDataOut; + QEMU_BUILD_BUG_ON(sizeof(NvdimmFuncGetLabelDataOut) > NVDIMM_DSM_MEMORY_SIZE); +diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c +index d64dd9c361..7c9f97bdb3 100644 +--- a/hw/nvme/ctrl.c ++++ b/hw/nvme/ctrl.c +@@ -71,7 +71,7 @@ + * the SUBNQN field in the controller will report the NQN of the subsystem + * device. This also enables multi controller capability represented in + * Identify Controller data structure in CMIC (Controller Multi-path I/O and +- * Namesapce Sharing Capabilities). ++ * Namespace Sharing Capabilities). + * + * - `aerl` + * The Asynchronous Event Request Limit (AERL). Indicates the maximum number +-- +2.27.0 + diff --git a/ui-gtk-prevent-ui-lock-up-when-dpy_gl_update-called-.patch b/ui-gtk-prevent-ui-lock-up-when-dpy_gl_update-called-.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b658ad6cb1e68c7cf5873523c600f778daf0fec --- /dev/null +++ b/ui-gtk-prevent-ui-lock-up-when-dpy_gl_update-called-.patch @@ -0,0 +1,71 @@ +From 37625d78afdadb5e88aa4616d613f64184db41bf Mon Sep 17 00:00:00 2001 +From: Wanghe Xiao +Date: Sat, 25 Nov 2023 01:42:26 -0800 +Subject: [PATCH] ui/gtk: prevent ui lock up when dpy_gl_update called again + before current draw event occurs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from commit 64f1359bd08060ffe7a5689fdcbaeec6d8a59980 + +A warning, "qemu: warning: console: no gl-unblock within" followed by +guest scanout lockup can happen if dpy_gl_update is called in a row +and the second call is made before gd_draw_event scheduled by the first +call is taking place. This is because draw call returns without decrementing +gl_block ref count if the dmabuf was already submitted as shown below. + +(gd_gl_area_draw/gd_egl_draw) + + if (dmabuf) { + if (!dmabuf->draw_submitted) { + return; + } else { + dmabuf->draw_submitted = false; + } + } + +So it should not schedule any redundant draw event in case draw_submitted is +already set in gd_egl_fluch/gd_gl_area_scanout_flush. + +Cc: Gerd Hoffmann +Cc: Vivek Kasireddy +Signed-off-by: Dongwon Kim +Reviewed-by: Marc-André Lureau +Message-Id: <20221021192315.9110-1-dongwon.kim@intel.com> +Signed-off-by: Gerd Hoffmann +Signed-off-by: Wanghe Xiao +--- + ui/gtk-egl.c | 2 +- + ui/gtk-gl-area.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c +index 45cb67712d..0e1e5bfaaa 100644 +--- a/ui/gtk-egl.c ++++ b/ui/gtk-egl.c +@@ -340,7 +340,7 @@ void gd_egl_flush(DisplayChangeListener *dcl, + VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); + GtkWidget *area = vc->gfx.drawing_area; + +- if (vc->gfx.guest_fb.dmabuf) { ++ if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) { + graphic_hw_gl_block(vc->gfx.dcl.con, true); + vc->gfx.guest_fb.dmabuf->draw_submitted = true; + gtk_widget_queue_draw_area(area, x, y, w, h); +diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c +index 01e4e74ee3..11e0cb4af2 100644 +--- a/ui/gtk-gl-area.c ++++ b/ui/gtk-gl-area.c +@@ -246,7 +246,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, + { + VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); + +- if (vc->gfx.guest_fb.dmabuf) { ++ if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) { + graphic_hw_gl_block(vc->gfx.dcl.con, true); + vc->gfx.guest_fb.dmabuf->draw_submitted = true; + } +-- +2.27.0 + diff --git a/ui-qmp-cmds-Improve-two-error-messages.patch b/ui-qmp-cmds-Improve-two-error-messages.patch new file mode 100644 index 0000000000000000000000000000000000000000..9cab96b9627fe5f75717433db4032e2d29a3efae --- /dev/null +++ b/ui-qmp-cmds-Improve-two-error-messages.patch @@ -0,0 +1,68 @@ +From 0425d773b3fa0da62be489ae6c76d1805f28f388 Mon Sep 17 00:00:00 2001 +From: boringandboring +Date: Mon, 27 Nov 2023 15:47:21 +0800 +Subject: [PATCH] ui/qmp-cmds: Improve two error messages +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cherry picked from 517b0220efd421acf885eed109571a61e95b192a + +set_password with "protocol": "vnc" supports only "connected": "keep". +Any other value is rejected with + + Invalid parameter 'connected' + +Improve this to + + parameter 'connected' must be 'keep' when 'protocol' is 'vnc' + +client_migrate_info requires "port" or "tls-port". When both are +missing, it fails with + + Parameter 'port/tls-port' is missing + +Improve this to + + parameter 'port' or 'tls-port' is required + +Signed-off-by: Markus Armbruster +Message-ID: <20231031111059.3407803-5-armbru@redhat.com> +Reviewed-by: Philippe Mathieu-Daudé + +Signed-off-by: boringandboring +--- + monitor/misc.c | 2 +- + monitor/qmp-cmds.c | 3 ++- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/monitor/misc.c b/monitor/misc.c +index a3a6e47844..25a23e2290 100644 +--- a/monitor/misc.c ++++ b/monitor/misc.c +@@ -397,7 +397,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname, + } + + if (!has_port && !has_tls_port) { +- error_setg(errp, QERR_MISSING_PARAMETER, "port/tls-port"); ++ error_setg(errp, "parameter 'port' or 'tls-port' is required"); + return; + } + +diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c +index d71beace6a..b44cca8234 100644 +--- a/monitor/qmp-cmds.c ++++ b/monitor/qmp-cmds.c +@@ -199,7 +199,8 @@ void qmp_set_password(const char *protocol, const char *password, + } else if (strcmp(protocol, "vnc") == 0) { + if (fail_if_connected || disconnect_if_connected) { + /* vnc supports "connected=keep" only */ +- error_setg(errp, QERR_INVALID_PARAMETER, "connected"); ++ error_setg(errp, "parameter 'connected' must be 'keep'" ++ " when 'protocol' is 'vnc'"); + return; + } + /* Note that setting an empty password will not disable login through +-- +2.27.0 + diff --git a/vdpa-implement-vdpa-device-migration.patch b/vdpa-implement-vdpa-device-migration.patch new file mode 100644 index 0000000000000000000000000000000000000000..ffc1d79586d2f3d9d24b6b1fea57c12de8b04182 --- /dev/null +++ b/vdpa-implement-vdpa-device-migration.patch @@ -0,0 +1,77 @@ +From 722147da4fb76c0ee6e75957712073a820ab1d75 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:59:56 +0800 +Subject: [PATCH] vdpa: implement vdpa device migration + +Integrate the live migration code, call the registered live +migration function, and open the vdpa live migration prototype + +Signed-off-by: libai +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vdpa-dev.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c +index 254a213117..986b5d0a78 100644 +--- a/hw/virtio/vdpa-dev.c ++++ b/hw/virtio/vdpa-dev.c +@@ -29,6 +29,8 @@ + #include "hw/virtio/vdpa-dev.h" + #include "sysemu/sysemu.h" + #include "sysemu/runstate.h" ++#include "hw/virtio/vdpa-dev-mig.h" ++#include "migration/migration.h" + + static void + vhost_vdpa_device_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq) +@@ -155,6 +157,8 @@ static void vhost_vdpa_device_realize(DeviceState *dev, Error **errp) + vhost_vdpa_device_dummy_handle_output); + } + ++ vdpa_migration_register(v); ++ + return; + + free_config: +@@ -174,6 +178,7 @@ static void vhost_vdpa_device_unrealize(DeviceState *dev) + VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev); + int i; + ++ vdpa_migration_unregister(s); + virtio_set_status(vdev, 0); + + for (i = 0; i < s->num_queues; i++) { +@@ -306,6 +311,7 @@ static void vhost_vdpa_device_stop(VirtIODevice *vdev) + static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status) + { + VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev); ++ MigrationState *ms = migrate_get_current(); + bool should_start = virtio_device_started(vdev, status); + Error *local_err = NULL; + int ret; +@@ -318,6 +324,11 @@ static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status) + return; + } + ++ if (ms->state == RUN_STATE_PAUSED || ++ ms->state == RUN_STATE_RESTORE_VM) { ++ return; ++ } ++ + if (should_start) { + ret = vhost_vdpa_device_start(vdev, &local_err); + if (ret < 0) { +@@ -336,7 +347,7 @@ static Property vhost_vdpa_device_properties[] = { + + static const VMStateDescription vmstate_vhost_vdpa_device = { + .name = "vhost-vdpa-device", +- .unmigratable = 1, ++ .unmigratable = 0, + .minimum_version_id = 1, + .version_id = 1, + .fields = (VMStateField[]) { +-- +2.27.0 + diff --git a/vdpa-move-memory-listener-to-the-realize-stage.patch b/vdpa-move-memory-listener-to-the-realize-stage.patch new file mode 100644 index 0000000000000000000000000000000000000000..b762409f80c54c62452261f93903341edcbe8ff7 --- /dev/null +++ b/vdpa-move-memory-listener-to-the-realize-stage.patch @@ -0,0 +1,112 @@ +From 232ee383f3a2363bdc8f1bde873740375b5b92bb Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 16:01:16 +0800 +Subject: [PATCH] vdpa: move memory listener to the realize stage + +Move the memory listener registration of vdpa from the start stage +to the realize stage. Avoid that in the start phase, the memory +listener callback function has not yet been processed. + +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vdpa-dev.c | 4 ++++ + hw/virtio/vhost-vdpa.c | 8 -------- + 2 files changed, 4 insertions(+), 8 deletions(-) + +diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c +index 986b5d0a78..143dadc88d 100644 +--- a/hw/virtio/vdpa-dev.c ++++ b/hw/virtio/vdpa-dev.c +@@ -31,6 +31,7 @@ + #include "sysemu/runstate.h" + #include "hw/virtio/vdpa-dev-mig.h" + #include "migration/migration.h" ++#include "exec/address-spaces.h" + + static void + vhost_vdpa_device_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq) +@@ -126,6 +127,7 @@ static void vhost_vdpa_device_realize(DeviceState *dev, Error **errp) + goto free_vqs; + } + ++ memory_listener_register(&v->vdpa.listener, &address_space_memory); + v->config_size = vhost_vdpa_device_get_u32(v->vhostfd, + VHOST_VDPA_GET_CONFIG_SIZE, + errp); +@@ -164,6 +166,7 @@ static void vhost_vdpa_device_realize(DeviceState *dev, Error **errp) + free_config: + g_free(v->config); + vhost_cleanup: ++ memory_listener_unregister(&v->vdpa.listener); + vhost_dev_cleanup(&v->dev); + free_vqs: + g_free(vqs); +@@ -189,6 +192,7 @@ static void vhost_vdpa_device_unrealize(DeviceState *dev) + + g_free(s->config); + g_free(s->dev.vqs); ++ memory_listener_unregister(&s->vdpa.listener); + vhost_dev_cleanup(&s->dev); + qemu_close(s->vhostfd); + s->vhostfd = -1; +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index 7688dc0eba..c7aaff7f20 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -1100,7 +1100,6 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev) + + static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) + { +- struct vhost_vdpa *v = dev->opaque; + bool ok; + trace_vhost_vdpa_dev_start(dev, started); + +@@ -1121,14 +1120,11 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) + } + + if (started) { +- memory_listener_register(&v->listener, &address_space_memory); + return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); + } else { + vhost_vdpa_reset_device(dev); + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER); +- memory_listener_unregister(&v->listener); +- + return 0; + } + } +@@ -1320,7 +1316,6 @@ static unsigned int vhost_vdpa_get_used_memslots(void) + + static int vhost_vdpa_suspend_device(struct vhost_dev *dev) + { +- struct vhost_vdpa *v = dev->opaque; + int ret; + + vhost_vdpa_svqs_stop(dev); +@@ -1331,13 +1326,11 @@ static int vhost_vdpa_suspend_device(struct vhost_dev *dev) + } + + ret = vhost_vdpa_call(dev, VHOST_VDPA_SUSPEND, NULL); +- memory_listener_unregister(&v->listener); + return ret; + } + + static int vhost_vdpa_resume_device(struct vhost_dev *dev) + { +- struct vhost_vdpa *v = dev->opaque; + bool ok; + + vhost_vdpa_host_notifiers_init(dev); +@@ -1351,7 +1344,6 @@ static int vhost_vdpa_resume_device(struct vhost_dev *dev) + return 0; + } + +- memory_listener_register(&v->listener, &address_space_memory); + return vhost_vdpa_call(dev, VHOST_VDPA_RESUME, NULL); + } + +-- +2.27.0 + diff --git a/vhost-add-vhost_dev_suspend-resume_op.patch b/vhost-add-vhost_dev_suspend-resume_op.patch new file mode 100644 index 0000000000000000000000000000000000000000..e09763177b5fb22aba7309292ae5bfcee21b2811 --- /dev/null +++ b/vhost-add-vhost_dev_suspend-resume_op.patch @@ -0,0 +1,64 @@ +From 745bbf64b2a1e74366550bffbb68da1df2a9f378 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:13:41 +0800 +Subject: [PATCH] vhost: add vhost_dev_suspend/resume_op + +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + include/hw/virtio/vhost-backend.h | 5 +++++ + linux-headers/linux/vhost.h | 17 +++++++++++++++++ + 2 files changed, 22 insertions(+) + +diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h +index 86154dd0b2..2ca6250567 100644 +--- a/include/hw/virtio/vhost-backend.h ++++ b/include/hw/virtio/vhost-backend.h +@@ -135,6 +135,9 @@ typedef int (*vhost_set_config_call_op)(struct vhost_dev *dev, + typedef void (*vhost_set_used_memslots_op)(struct vhost_dev *dev); + typedef unsigned int (*vhost_get_used_memslots_op)(void); + ++typedef int (*vhost_dev_suspend_op)(struct vhost_dev *dev); ++typedef int (*vhost_dev_resume_op)(struct vhost_dev *dev); ++ + typedef struct VhostOps { + VhostBackendType backend_type; + vhost_backend_init vhost_backend_init; +@@ -186,6 +189,8 @@ typedef struct VhostOps { + vhost_set_config_call_op vhost_set_config_call; + vhost_set_used_memslots_op vhost_set_used_memslots; + vhost_get_used_memslots_op vhost_get_used_memslots; ++ vhost_dev_suspend_op vhost_dev_suspend; ++ vhost_dev_resume_op vhost_dev_resume; + } VhostOps; + + int vhost_backend_update_device_iotlb(struct vhost_dev *dev, +diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h +index 65c6b49788..9b3f71b20f 100644 +--- a/linux-headers/linux/vhost.h ++++ b/linux-headers/linux/vhost.h +@@ -175,4 +175,21 @@ + #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ + struct vhost_vring_state) + ++/* Suspend a device so it does not process virtqueue requests anymore ++ * ++ * After the return of ioctl the device must preserve all the necessary state ++ * (the virtqueue vring base plus the possible device specific states) that is ++ * required for restoring in the future. The device must not change its ++ * configuration after that point. ++ */ ++#define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) ++ ++/* Resume a device so it can resume processing virtqueue requests ++ * ++ * After the return of this ioctl the device will have restored all the ++ * necessary states and it is fully operational to continue processing the ++ * virtqueue descriptors. ++ */ ++#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) ++ + #endif +-- +2.27.0 + diff --git a/vhost-fix-null-pointer-access.patch b/vhost-fix-null-pointer-access.patch new file mode 100644 index 0000000000000000000000000000000000000000..432e8a78babd183447b47c676fbfcc3988ae26b2 --- /dev/null +++ b/vhost-fix-null-pointer-access.patch @@ -0,0 +1,74 @@ +From e2db610c0b0cb9130ba1ce2668a57318a416fdc4 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 14:48:18 +0800 +Subject: [PATCH] vhost: fix null pointer access + +Check vhost_get/set_used_memslots function before calling it. + +Signed-off-by: libai +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vhost.c | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c +index 59a12735f9..7930b37499 100644 +--- a/hw/virtio/vhost.c ++++ b/hw/virtio/vhost.c +@@ -58,6 +58,10 @@ bool vhost_has_free_slot(void) + struct vhost_dev *hdev; + + QLIST_FOREACH(hdev, &vhost_devices, entry) { ++ if (!hdev->vhost_ops->vhost_get_used_memslots || ++ !hdev->vhost_ops->vhost_backend_memslots_limit) { ++ continue; ++ } + if (hdev->vhost_ops->vhost_get_used_memslots() >= + hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) { + return false; +@@ -748,7 +752,9 @@ static void vhost_region_add_section(struct vhost_dev *dev, + dev->tmp_sections[dev->n_tmp_sections - 1].fv = NULL; + memory_region_ref(section->mr); + } +- dev->vhost_ops->vhost_set_used_memslots(dev); ++ if (dev->vhost_ops->vhost_set_used_memslots) { ++ dev->vhost_ops->vhost_set_used_memslots(dev); ++ } + } + + /* Used for both add and nop callbacks */ +@@ -772,7 +778,9 @@ static void vhost_region_del(MemoryListener *listener, + if (!vhost_section(dev, section)) { + return; + } +- dev->vhost_ops->vhost_set_used_memslots(dev); ++ if (dev->vhost_ops->vhost_set_used_memslots) { ++ dev->vhost_ops->vhost_set_used_memslots(dev); ++ } + } + + static void vhost_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb) +@@ -1367,6 +1375,11 @@ static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq) + + static bool vhost_dev_used_memslots_is_exceeded(struct vhost_dev *hdev) + { ++ if (!hdev->vhost_ops->vhost_get_used_memslots || ++ !hdev->vhost_ops->vhost_backend_memslots_limit) { ++ goto out; ++ } ++ + if (hdev->vhost_ops->vhost_get_used_memslots() > + hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) { + error_report("vhost backend memory slots limit is less" +@@ -1375,6 +1388,7 @@ static bool vhost_dev_used_memslots_is_exceeded(struct vhost_dev *hdev) + return true; + } + ++out: + used_memslots_exceeded = false; + return false; + } +-- +2.27.0 + diff --git a/vhost-implement-migration-state-notifier-for-vdpa-de.patch b/vhost-implement-migration-state-notifier-for-vdpa-de.patch new file mode 100644 index 0000000000000000000000000000000000000000..246961427a2f65208c2bd25d1b3531f226484c65 --- /dev/null +++ b/vhost-implement-migration-state-notifier-for-vdpa-de.patch @@ -0,0 +1,78 @@ +From ce5fa02db01263ef5188b3bb3a1367c806ddb7ce Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:55:53 +0800 +Subject: [PATCH] vhost: implement migration state notifier for vdpa device + +Signed-off-by: libai +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vdpa-dev-mig.c | 28 ++++++++++++++++++++++++++++ + include/hw/virtio/vdpa-dev.h | 1 + + 2 files changed, 29 insertions(+) + +diff --git a/hw/virtio/vdpa-dev-mig.c b/hw/virtio/vdpa-dev-mig.c +index c0bcbda7d4..a36517b147 100644 +--- a/hw/virtio/vdpa-dev-mig.c ++++ b/hw/virtio/vdpa-dev-mig.c +@@ -344,6 +344,31 @@ static SaveVMHandlers savevm_vdpa_handlers = { + .load_setup = vdpa_load_setup, + }; + ++static void vdpa_migration_state_notifier(Notifier *notifier, void *data) ++{ ++ MigrationState *s = data; ++ VhostVdpaDevice *vdev = container_of(notifier, ++ VhostVdpaDevice, ++ migration_state); ++ struct vhost_dev *hdev = &vdev->dev; ++ int ret; ++ ++ switch (s->state) { ++ case MIGRATION_STATUS_CANCELLING: ++ case MIGRATION_STATUS_CANCELLED: ++ case MIGRATION_STATUS_FAILED: ++ ret = vhost_vdpa_set_mig_state(hdev, VDPA_DEVICE_CANCEL); ++ if (ret) { ++ error_report("Failed to set state CANCEL\n"); ++ } ++ ++ break; ++ case MIGRATION_STATUS_COMPLETED: ++ default: ++ break; ++ } ++} ++ + void vdpa_migration_register(VhostVdpaDevice *vdev) + { + vdev->vmstate = qdev_add_vm_change_state_handler(DEVICE(vdev), +@@ -351,10 +376,13 @@ void vdpa_migration_register(VhostVdpaDevice *vdev) + DEVICE(vdev)); + register_savevm_live("vdpa", -1, 1, + &savevm_vdpa_handlers, DEVICE(vdev)); ++ vdev->migration_state.notify = vdpa_migration_state_notifier; ++ add_migration_state_change_notifier(&vdev->migration_state); + } + + void vdpa_migration_unregister(VhostVdpaDevice *vdev) + { ++ remove_migration_state_change_notifier(&vdev->migration_state); + unregister_savevm(VMSTATE_IF(&vdev->parent_obj.parent_obj), "vdpa", DEVICE(vdev)); + qemu_del_vm_change_state_handler(vdev->vmstate); + } +diff --git a/include/hw/virtio/vdpa-dev.h b/include/hw/virtio/vdpa-dev.h +index 43cbcef81b..20f50c76c6 100644 +--- a/include/hw/virtio/vdpa-dev.h ++++ b/include/hw/virtio/vdpa-dev.h +@@ -39,6 +39,7 @@ struct VhostVdpaDevice { + bool started; + int (*post_init)(VhostVdpaDevice *v, Error **errp); + VMChangeStateEntry *vmstate; ++ Notifier migration_state; + }; + + #endif +-- +2.27.0 + diff --git a/vhost-implement-post-resume-bh.patch b/vhost-implement-post-resume-bh.patch new file mode 100644 index 0000000000000000000000000000000000000000..b16606d7c30046a97dddba1bd47c86bf04bfcfbd --- /dev/null +++ b/vhost-implement-post-resume-bh.patch @@ -0,0 +1,56 @@ +From 07fc3e07d6160508f7e6543e2fc49668607f79ad Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:57:35 +0800 +Subject: [PATCH] vhost: implement post resume bh + +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vdpa-dev-mig.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/hw/virtio/vdpa-dev-mig.c b/hw/virtio/vdpa-dev-mig.c +index a36517b147..ee3e27f2bb 100644 +--- a/hw/virtio/vdpa-dev-mig.c ++++ b/hw/virtio/vdpa-dev-mig.c +@@ -33,6 +33,7 @@ + #include "qemu/error-report.h" + #include "hw/virtio/vdpa-dev-mig.h" + #include "migration/qemu-file-types.h" ++#include "qemu/main-loop.h" + + /* + * Flags used as delimiter: +@@ -225,6 +226,18 @@ err_host_notifiers: + return ret; + } + ++static void vdpa_dev_migration_handle_incoming_bh(void *opaque) ++{ ++ struct vhost_dev *hdev = opaque; ++ int ret; ++ ++ /* Post start device, unsupport rollback if failed! */ ++ ret = vhost_vdpa_set_mig_state(hdev, VDPA_DEVICE_POST_START); ++ if (ret) { ++ error_report("Failed to set state: POST_START\n"); ++ } ++} ++ + static void vdpa_dev_vmstate_change(void *opaque, bool running, RunState state) + { + VhostVdpaDevice *vdpa = VHOST_VDPA_DEVICE(opaque); +@@ -254,6 +267,10 @@ static void vdpa_dev_vmstate_change(void *opaque, bool running, RunState state) + + if (mis->state == RUN_STATE_RESTORE_VM) { + vhost_vdpa_call(hdev, VHOST_VDPA_RESUME, NULL); ++ /* post resume */ ++ mis->bh = qemu_bh_new(vdpa_dev_migration_handle_incoming_bh, ++ hdev); ++ qemu_bh_schedule(mis->bh); + } + } + } +-- +2.27.0 + diff --git a/vhost-implement-savevm_hanlder-for-vdpa-device.patch b/vhost-implement-savevm_hanlder-for-vdpa-device.patch new file mode 100644 index 0000000000000000000000000000000000000000..16cacc110077ed3c5c5652dd313f953d19875de7 --- /dev/null +++ b/vhost-implement-savevm_hanlder-for-vdpa-device.patch @@ -0,0 +1,265 @@ +From 9cd596fd081bdb88b03b5e969631d8d08797c14d Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:53:28 +0800 +Subject: [PATCH] vhost: implement savevm_hanlder for vdpa device + +Signed-off-by: libai +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vdpa-dev-mig.c | 174 +++++++++++++++++++++++++++++++ + include/hw/virtio/vdpa-dev-mig.h | 13 +++ + linux-headers/linux/vhost.h | 8 ++ + 3 files changed, 195 insertions(+) + +diff --git a/hw/virtio/vdpa-dev-mig.c b/hw/virtio/vdpa-dev-mig.c +index 64c9e245d1..c0bcbda7d4 100644 +--- a/hw/virtio/vdpa-dev-mig.c ++++ b/hw/virtio/vdpa-dev-mig.c +@@ -32,6 +32,17 @@ + #include "sysemu/runstate.h" + #include "qemu/error-report.h" + #include "hw/virtio/vdpa-dev-mig.h" ++#include "migration/qemu-file-types.h" ++ ++/* ++ * Flags used as delimiter: ++ * 0xffffffff => MSB 32-bit all 1s ++ * 0xef10 => emulated (virtual) function IO ++ * 0x0000 => 16-bits reserved for flags ++ */ ++#define VDPA_MIG_FLAG_END_OF_STATE (0xffffffffef100001ULL) ++#define VDPA_MIG_FLAG_DEV_CONFIG_STATE (0xffffffffef100002ULL) ++#define VDPA_MIG_FLAG_DEV_SETUP_STATE (0xffffffffef100003ULL) + + static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int request, + void *arg) +@@ -47,6 +58,80 @@ static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int request, + return ioctl(fd, request, arg); + } + ++static int vhost_vdpa_set_mig_state(struct vhost_dev *dev, uint8_t state) ++{ ++ return vhost_vdpa_call(dev, VHOST_VDPA_SET_MIG_STATE, &state); ++} ++ ++static int vhost_vdpa_dev_buffer_size(struct vhost_dev *dev, uint32_t *size) ++{ ++ return vhost_vdpa_call(dev, VHOST_GET_DEV_BUFFER_SIZE, size); ++} ++ ++static int vhost_vdpa_dev_buffer_save(struct vhost_dev *dev, QEMUFile *f) ++{ ++ struct vhost_vdpa_config *config; ++ unsigned long config_size = offsetof(struct vhost_vdpa_config, buf); ++ uint32_t buffer_size = 0; ++ int ret; ++ ++ ret = vhost_vdpa_dev_buffer_size(dev, &buffer_size); ++ if (ret) { ++ error_report("get dev buffer size failed: %d\n", ret); ++ return ret; ++ } ++ ++ qemu_put_be32(f, buffer_size); ++ ++ config = g_malloc(buffer_size + config_size); ++ config->off = 0; ++ config->len = buffer_size; ++ ++ ret = vhost_vdpa_call(dev, VHOST_GET_DEV_BUFFER, config); ++ if (ret) { ++ error_report("get dev buffer failed: %d\n", ret); ++ goto free; ++ } ++ ++ qemu_put_buffer(f, config->buf, buffer_size); ++free: ++ g_free(config); ++ ++ return ret; ++} ++ ++static int vhost_vdpa_dev_buffer_load(struct vhost_dev *dev, QEMUFile *f) ++{ ++ struct vhost_vdpa_config *config; ++ unsigned long config_size = offsetof(struct vhost_vdpa_config, buf); ++ uint32_t buffer_size, recv_size; ++ int ret; ++ ++ buffer_size = qemu_get_be32(f); ++ ++ config = g_malloc(buffer_size + config_size); ++ config->off = 0; ++ config->len = buffer_size; ++ ++ recv_size = qemu_get_buffer(f, config->buf, buffer_size); ++ if (recv_size != buffer_size) { ++ error_report("read dev mig buffer failed, buffer_size: %u, " ++ "recv_size: %u\n", buffer_size, recv_size); ++ ret = -EINVAL; ++ goto free; ++ } ++ ++ ret = vhost_vdpa_call(dev, VHOST_SET_DEV_BUFFER, config); ++ if (ret) { ++ error_report("set dev buffer failed: %d\n", ret); ++ } ++ ++free: ++ g_free(config); ++ ++ return ret; ++} ++ + static int vhost_vdpa_device_suspend(VhostVdpaDevice *vdpa) + { + VirtIODevice *vdev = VIRTIO_DEVICE(vdpa); +@@ -173,14 +258,103 @@ static void vdpa_dev_vmstate_change(void *opaque, bool running, RunState state) + } + } + ++static int vdpa_save_setup(QEMUFile *f, void *opaque) ++{ ++ qemu_put_be64(f, VDPA_MIG_FLAG_DEV_SETUP_STATE); ++ qemu_put_be64(f, VDPA_MIG_FLAG_END_OF_STATE); ++ ++ return qemu_file_get_error(f); ++} ++ ++static int vdpa_save_complete_precopy(QEMUFile *f, void *opaque) ++{ ++ VhostVdpaDevice *vdev = VHOST_VDPA_DEVICE(opaque); ++ struct vhost_dev *hdev = &vdev->dev; ++ int ret; ++ ++ qemu_put_be64(f, VDPA_MIG_FLAG_DEV_CONFIG_STATE); ++ ret = vhost_vdpa_dev_buffer_save(hdev, f); ++ if (ret) { ++ error_report("Save vdpa device buffer failed: %d\n", ret); ++ return ret; ++ } ++ qemu_put_be64(f, VDPA_MIG_FLAG_END_OF_STATE); ++ ++ return qemu_file_get_error(f); ++} ++ ++static int vdpa_load_state(QEMUFile *f, void *opaque, int version_id) ++{ ++ VhostVdpaDevice *vdev = VHOST_VDPA_DEVICE(opaque); ++ struct vhost_dev *hdev = &vdev->dev; ++ ++ int ret; ++ uint64_t data; ++ ++ data = qemu_get_be64(f); ++ while (data != VDPA_MIG_FLAG_END_OF_STATE) { ++ if (data == VDPA_MIG_FLAG_DEV_SETUP_STATE) { ++ data = qemu_get_be64(f); ++ if (data == VDPA_MIG_FLAG_END_OF_STATE) { ++ return 0; ++ } else { ++ error_report("SETUP STATE: EOS not found 0x%lx\n", data); ++ return -EINVAL; ++ } ++ } else if (data == VDPA_MIG_FLAG_DEV_CONFIG_STATE) { ++ ret = vhost_vdpa_dev_buffer_load(hdev, f); ++ if (ret) { ++ error_report("fail to restore device buffer.\n"); ++ return ret; ++ } ++ } ++ ++ ret = qemu_file_get_error(f); ++ if (ret) { ++ error_report("qemu file error: %d\n", ret); ++ return ret; ++ } ++ data = qemu_get_be64(f); ++ } ++ ++ return 0; ++} ++ ++static int vdpa_load_setup(QEMUFile *f, void *opaque) ++{ ++ VhostVdpaDevice *v = VHOST_VDPA_DEVICE(opaque); ++ struct vhost_dev *hdev = &v->dev; ++ int ret = 0; ++ ++ ret = vhost_vdpa_set_mig_state(hdev, VDPA_DEVICE_PRE_START); ++ if (ret) { ++ error_report("pre start device failed: %d\n", ret); ++ goto out; ++ } ++ ++ return qemu_file_get_error(f); ++out: ++ return ret; ++} ++ ++static SaveVMHandlers savevm_vdpa_handlers = { ++ .save_setup = vdpa_save_setup, ++ .save_live_complete_precopy = vdpa_save_complete_precopy, ++ .load_state = vdpa_load_state, ++ .load_setup = vdpa_load_setup, ++}; ++ + void vdpa_migration_register(VhostVdpaDevice *vdev) + { + vdev->vmstate = qdev_add_vm_change_state_handler(DEVICE(vdev), + vdpa_dev_vmstate_change, + DEVICE(vdev)); ++ register_savevm_live("vdpa", -1, 1, ++ &savevm_vdpa_handlers, DEVICE(vdev)); + } + + void vdpa_migration_unregister(VhostVdpaDevice *vdev) + { ++ unregister_savevm(VMSTATE_IF(&vdev->parent_obj.parent_obj), "vdpa", DEVICE(vdev)); + qemu_del_vm_change_state_handler(vdev->vmstate); + } +diff --git a/include/hw/virtio/vdpa-dev-mig.h b/include/hw/virtio/vdpa-dev-mig.h +index 89665ca747..adc1d657f7 100644 +--- a/include/hw/virtio/vdpa-dev-mig.h ++++ b/include/hw/virtio/vdpa-dev-mig.h +@@ -9,6 +9,19 @@ + + #include "hw/virtio/vdpa-dev.h" + ++enum { ++ VDPA_DEVICE_START, ++ VDPA_DEVICE_STOP, ++ VDPA_DEVICE_PRE_START, ++ VDPA_DEVICE_PRE_STOP, ++ VDPA_DEVICE_CANCEL, ++ VDPA_DEVICE_POST_START, ++ VDPA_DEVICE_START_ASYNC, ++ VDPA_DEVICE_STOP_ASYNC, ++ VDPA_DEVICE_PRE_START_ASYNC, ++ VDPA_DEVICE_QUERY_OP_STATE, ++}; ++ + void vdpa_migration_register(VhostVdpaDevice *vdev); + + void vdpa_migration_unregister(VhostVdpaDevice *vdev); +diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h +index 9b3f71b20f..457923974c 100644 +--- a/linux-headers/linux/vhost.h ++++ b/linux-headers/linux/vhost.h +@@ -192,4 +192,12 @@ + */ + #define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) + ++/* set and get device buffer */ ++#define VHOST_GET_DEV_BUFFER _IOR(VHOST_VIRTIO, 0xb0, struct vhost_vdpa_config) ++#define VHOST_SET_DEV_BUFFER _IOW(VHOST_VIRTIO, 0xb1, struct vhost_vdpa_config) ++#define VHOST_GET_DEV_BUFFER_SIZE _IOR(VHOST_VIRTIO, 0xb3, __u32) ++ ++/* set device migtration state */ ++#define VHOST_VDPA_SET_MIG_STATE _IOW(VHOST_VIRTIO, 0xb2, __u8) ++ + #endif +-- +2.27.0 + diff --git a/vhost-implement-vhost-vdpa-suspend-resume.patch b/vhost-implement-vhost-vdpa-suspend-resume.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a499e6cee0c8aae98d989aa1cff4ef88cafd6b9 --- /dev/null +++ b/vhost-implement-vhost-vdpa-suspend-resume.patch @@ -0,0 +1,85 @@ +From 98c74a827b742807f979fc36bca99ba0db38d295 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:22:20 +0800 +Subject: [PATCH] vhost: implement vhost-vdpa suspend/resume + +vhost-vdpa implements the vhost_dev_suspend interface, +which will be called during the shutdown phase of the +live migration source virtual machine to suspend the +device but not reset the device information. + +vhost-vdpa implements the vhost_dev_resume interface. +If the live migration fails, it will be called during +the startup phase of the source virtual machine. +Enable the device but set the status, etc. + +Signed-off-by: libai +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vhost-vdpa.c | 44 ++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 42 insertions(+), 2 deletions(-) + +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index 7663d78b43..7688dc0eba 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -1318,6 +1318,43 @@ static unsigned int vhost_vdpa_get_used_memslots(void) + return vhost_vdpa_used_memslots; + } + ++static int vhost_vdpa_suspend_device(struct vhost_dev *dev) ++{ ++ struct vhost_vdpa *v = dev->opaque; ++ int ret; ++ ++ vhost_vdpa_svqs_stop(dev); ++ vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); ++ ++ if (dev->vq_index + dev->nvqs != dev->vq_index_end) { ++ return 0; ++ } ++ ++ ret = vhost_vdpa_call(dev, VHOST_VDPA_SUSPEND, NULL); ++ memory_listener_unregister(&v->listener); ++ return ret; ++} ++ ++static int vhost_vdpa_resume_device(struct vhost_dev *dev) ++{ ++ struct vhost_vdpa *v = dev->opaque; ++ bool ok; ++ ++ vhost_vdpa_host_notifiers_init(dev); ++ ok = vhost_vdpa_svqs_start(dev); ++ if (unlikely(!ok)) { ++ return -1; ++ } ++ vhost_vdpa_set_vring_ready(dev); ++ ++ if (dev->vq_index + dev->nvqs != dev->vq_index_end) { ++ return 0; ++ } ++ ++ memory_listener_register(&v->listener, &address_space_memory); ++ return vhost_vdpa_call(dev, VHOST_VDPA_RESUME, NULL); ++} ++ + static int vhost_vdpa_log_sync(struct vhost_dev *dev) + { + struct vhost_vdpa *v = dev->opaque; +@@ -1364,6 +1401,9 @@ const VhostOps vdpa_ops = { + .vhost_force_iommu = vhost_vdpa_force_iommu, + .vhost_log_sync = vhost_vdpa_log_sync, + .vhost_set_config_call = vhost_vdpa_set_config_call, +- .vhost_set_used_memslots = vhost_vdpa_set_used_memslots, +- .vhost_get_used_memslots = vhost_vdpa_get_used_memslots, ++ .vhost_set_used_memslots = vhost_vdpa_set_used_memslots, ++ .vhost_get_used_memslots = vhost_vdpa_get_used_memslots, ++ .vhost_dev_suspend = vhost_vdpa_suspend_device, ++ .vhost_dev_resume = vhost_vdpa_resume_device, ++ + }; +-- +2.27.0 + diff --git a/vhost-implement-vhost_vdpa_device_suspend-resume.patch b/vhost-implement-vhost_vdpa_device_suspend-resume.patch new file mode 100644 index 0000000000000000000000000000000000000000..9345bd282e10ec6383af29d23e4a78807e86fcd4 --- /dev/null +++ b/vhost-implement-vhost_vdpa_device_suspend-resume.patch @@ -0,0 +1,453 @@ +From a21603f7ecfaa2fb53b2037f46ee3fb868d8c9cb Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:27:34 +0800 +Subject: [PATCH] vhost: implement vhost_vdpa_device_suspend/resume + +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/meson.build | 2 +- + hw/virtio/vdpa-dev-mig.c | 186 +++++++++++++++++++++++++++++++ + hw/virtio/vhost.c | 138 +++++++++++++++++++++++ + include/hw/virtio/vdpa-dev-mig.h | 16 +++ + include/hw/virtio/vdpa-dev.h | 1 + + include/hw/virtio/vhost.h | 4 + + migration/migration.c | 3 +- + migration/migration.h | 2 + + 8 files changed, 349 insertions(+), 3 deletions(-) + create mode 100644 hw/virtio/vdpa-dev-mig.c + create mode 100644 include/hw/virtio/vdpa-dev-mig.h + +diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build +index c2da69616f..94a030f329 100644 +--- a/hw/virtio/meson.build ++++ b/hw/virtio/meson.build +@@ -29,7 +29,7 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) + virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2C'], if_true: files('vhost-user-i2c-pci.c')) + virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) + virtio_ss.add(when: ['CONFIG_VHOST_USER_RNG', 'CONFIG_VIRTIO_PCI'], if_true: files('vhost-user-rng-pci.c')) +-virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')) ++virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c', 'vdpa-dev-mig.c')) + + virtio_pci_ss = ss.source_set() + virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) +diff --git a/hw/virtio/vdpa-dev-mig.c b/hw/virtio/vdpa-dev-mig.c +new file mode 100644 +index 0000000000..64c9e245d1 +--- /dev/null ++++ b/hw/virtio/vdpa-dev-mig.c +@@ -0,0 +1,186 @@ ++/* ++ * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, see . ++ */ ++ ++#include ++#include ++#include "qemu/osdep.h" ++#include "migration/misc.h" ++#include "hw/qdev-core.h" ++#include "hw/qdev-properties.h" ++#include "hw/virtio/vhost.h" ++#include "hw/virtio/vdpa-dev.h" ++#include "hw/virtio/virtio.h" ++#include "hw/virtio/virtio-bus.h" ++#include "hw/virtio/virtio-access.h" ++#include "migration/register.h" ++#include "migration/migration.h" ++#include "qemu-common.h" ++#include "sysemu/runstate.h" ++#include "qemu/error-report.h" ++#include "hw/virtio/vdpa-dev-mig.h" ++ ++static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int request, ++ void *arg) ++{ ++ struct vhost_vdpa *v = dev->opaque; ++ int fd = v->device_fd; ++ ++ if (dev->vhost_ops->backend_type != VHOST_BACKEND_TYPE_VDPA) { ++ error_report("backend type isn't VDPA. Operation not permitted!\n"); ++ return -EPERM; ++ } ++ ++ return ioctl(fd, request, arg); ++} ++ ++static int vhost_vdpa_device_suspend(VhostVdpaDevice *vdpa) ++{ ++ VirtIODevice *vdev = VIRTIO_DEVICE(vdpa); ++ BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); ++ VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); ++ int ret; ++ ++ if (!vdpa->started) { ++ return -EFAULT; ++ } ++ ++ if (!k->set_guest_notifiers) { ++ return -EFAULT; ++ } ++ ++ vdpa->started = false; ++ ++ ret = vhost_dev_suspend(&vdpa->dev, vdev, false); ++ if (ret) { ++ goto suspend_fail; ++ } ++ ++ ret = k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, false); ++ if (ret < 0) { ++ error_report("vhost guest notifier cleanup failed: %d\n", ret); ++ goto set_guest_notifiers_fail; ++ } ++ ++ vhost_dev_disable_notifiers(&vdpa->dev, vdev); ++ return ret; ++ ++set_guest_notifiers_fail: ++ ret = k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, true); ++ if (ret) { ++ error_report("vhost guest notifier restore failed: %d\n", ret); ++ } ++ ++suspend_fail: ++ vdpa->started = true; ++ return ret; ++} ++ ++static int vhost_vdpa_device_resume(VhostVdpaDevice *vdpa) ++{ ++ VirtIODevice *vdev = VIRTIO_DEVICE(vdpa); ++ BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); ++ VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); ++ int i, ret; ++ ++ if (!k->set_guest_notifiers) { ++ error_report("binding does not support guest notifiers\n"); ++ return -ENOSYS; ++ } ++ ++ ret = vhost_dev_enable_notifiers(&vdpa->dev, vdev); ++ if (ret < 0) { ++ error_report("Error enabling host notifiers: %d\n", ret); ++ return ret; ++ } ++ ++ ret = k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, true); ++ if (ret < 0) { ++ error_report("Error binding guest notifier: %d\n", ret); ++ goto err_host_notifiers; ++ } ++ ++ vdpa->dev.acked_features = vdev->guest_features; ++ ++ ret = vhost_dev_resume(&vdpa->dev, vdev, false); ++ if (ret < 0) { ++ error_report("Error starting vhost: %d\n", ret); ++ goto err_guest_notifiers; ++ } ++ vdpa->started = true; ++ ++ /* ++ * guest_notifier_mask/pending not used yet, so just unmask ++ * everything here. virtio-pci will do the right thing by ++ * enabling/disabling irqfd. ++ */ ++ for (i = 0; i < vdpa->dev.nvqs; i++) { ++ vhost_virtqueue_mask(&vdpa->dev, vdev, i, false); ++ } ++ ++ return ret; ++ ++err_guest_notifiers: ++ k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, false); ++err_host_notifiers: ++ vhost_dev_disable_notifiers(&vdpa->dev, vdev); ++ return ret; ++} ++ ++static void vdpa_dev_vmstate_change(void *opaque, bool running, RunState state) ++{ ++ VhostVdpaDevice *vdpa = VHOST_VDPA_DEVICE(opaque); ++ struct vhost_dev *hdev = &vdpa->dev; ++ int ret; ++ MigrationState *ms = migrate_get_current(); ++ MigrationIncomingState *mis = migration_incoming_get_current(); ++ ++ if (!running) { ++ if (ms->state == RUN_STATE_PAUSED) { ++ ret = vhost_vdpa_device_suspend(vdpa); ++ if (ret) { ++ error_report("suspend vdpa device failed: %d\n", ret); ++ if (ms->migration_thread_running) { ++ migrate_fd_cancel(ms); ++ } ++ } ++ } ++ } else { ++ if (ms->state == RUN_STATE_RESTORE_VM) { ++ ret = vhost_vdpa_device_resume(vdpa); ++ if (ret) { ++ error_report("migration dest resume device failed, abort!\n"); ++ exit(EXIT_FAILURE); ++ } ++ } ++ ++ if (mis->state == RUN_STATE_RESTORE_VM) { ++ vhost_vdpa_call(hdev, VHOST_VDPA_RESUME, NULL); ++ } ++ } ++} ++ ++void vdpa_migration_register(VhostVdpaDevice *vdev) ++{ ++ vdev->vmstate = qdev_add_vm_change_state_handler(DEVICE(vdev), ++ vdpa_dev_vmstate_change, ++ DEVICE(vdev)); ++} ++ ++void vdpa_migration_unregister(VhostVdpaDevice *vdev) ++{ ++ qemu_del_vm_change_state_handler(vdev->vmstate); ++} +diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c +index d2b9278474..ed1506d3e0 100644 +--- a/hw/virtio/vhost.c ++++ b/hw/virtio/vhost.c +@@ -2201,3 +2201,141 @@ bool used_memslots_is_exceeded(void) + { + return used_memslots_exceeded; + } ++ ++int vhost_dev_resume(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) ++{ ++ int i, r; ++ EventNotifier *e = &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; ++ ++ /* should only be called after backend is connected */ ++ if (!hdev->vhost_ops) { ++ error_report("Missing vhost_ops! Operation not permitted!\n"); ++ return -EPERM; ++ } ++ ++ vdev->vhost_started = true; ++ hdev->started = true; ++ hdev->vdev = vdev; ++ ++ if (vhost_dev_has_iommu(hdev)) { ++ memory_listener_register(&hdev->iommu_listener, vdev->dma_as); ++ } ++ ++ r = hdev->vhost_ops->vhost_set_mem_table(hdev, hdev->mem); ++ if (r < 0) { ++ VHOST_OPS_DEBUG(r, "vhost_set_mem_table failed"); ++ goto fail_mem; ++ } ++ for (i = 0; i < hdev->nvqs; ++i) { ++ r = vhost_virtqueue_start(hdev, ++ vdev, ++ hdev->vqs + i, ++ hdev->vq_index + i); ++ if (r < 0) { ++ goto fail_vq; ++ } ++ } ++ ++ r = event_notifier_init(e, 0); ++ if (r < 0) { ++ return r; ++ } ++ event_notifier_test_and_clear(e); ++ if (!vdev->use_guest_notifier_mask) { ++ vhost_config_mask(hdev, vdev, true); ++ } ++ if (vrings) { ++ r = vhost_dev_set_vring_enable(hdev, true); ++ if (r) { ++ goto fail_vq; ++ } ++ } ++ if (hdev->vhost_ops->vhost_dev_resume) { ++ r = hdev->vhost_ops->vhost_dev_resume(hdev); ++ if (r) { ++ goto fail_start; ++ } ++ } ++ if (vhost_dev_has_iommu(hdev)) { ++ hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true); ++ ++ /* ++ * Update used ring information for IOTLB to work correctly, ++ * vhost-kernel code requires for this. ++ */ ++ for (i = 0; i < hdev->nvqs; ++i) { ++ struct vhost_virtqueue *vq = hdev->vqs + i; ++ vhost_device_iotlb_miss(hdev, vq->used_phys, true); ++ } ++ } ++ vhost_start_config_intr(hdev); ++ return 0; ++fail_start: ++ if (vrings) { ++ vhost_dev_set_vring_enable(hdev, false); ++ } ++fail_vq: ++ while (--i >= 0) { ++ vhost_virtqueue_stop(hdev, ++ vdev, ++ hdev->vqs + i, ++ hdev->vq_index + i); ++ } ++ ++fail_mem: ++ vdev->vhost_started = false; ++ hdev->started = false; ++ return r; ++} ++ ++int vhost_dev_suspend(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) ++{ ++ int i; ++ int ret = 0; ++ EventNotifier *e = &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; ++ ++ /* should only be called after backend is connected */ ++ if (!hdev->vhost_ops) { ++ error_report("Missing vhost_ops! Operation not permitted!\n"); ++ return -EPERM; ++ } ++ ++ event_notifier_test_and_clear(e); ++ event_notifier_test_and_clear(&vdev->config_notifier); ++ ++ if (hdev->vhost_ops->vhost_dev_suspend) { ++ ret = hdev->vhost_ops->vhost_dev_suspend(hdev); ++ if (ret) { ++ goto fail_suspend; ++ } ++ } ++ if (vrings) { ++ ret = vhost_dev_set_vring_enable(hdev, false); ++ if (ret) { ++ goto fail_suspend; ++ } ++ } ++ for (i = 0; i < hdev->nvqs; ++i) { ++ vhost_virtqueue_stop(hdev, ++ vdev, ++ hdev->vqs + i, ++ hdev->vq_index + i); ++ } ++ ++ if (vhost_dev_has_iommu(hdev)) { ++ hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false); ++ memory_listener_unregister(&hdev->iommu_listener); ++ } ++ vhost_stop_config_intr(hdev); ++ vhost_log_put(hdev, true); ++ hdev->started = false; ++ vdev->vhost_started = false; ++ hdev->vdev = NULL; ++ ++ return ret; ++ ++fail_suspend: ++ event_notifier_test_and_clear(e); ++ ++ return ret; ++} +diff --git a/include/hw/virtio/vdpa-dev-mig.h b/include/hw/virtio/vdpa-dev-mig.h +new file mode 100644 +index 0000000000..89665ca747 +--- /dev/null ++++ b/include/hw/virtio/vdpa-dev-mig.h +@@ -0,0 +1,16 @@ ++/* ++ * Vhost Vdpa Device Migration Header ++ * ++ * Copyright (c) Huawei Technologies Co., Ltd. 2023. All Rights Reserved. ++ */ ++ ++#ifndef _VHOST_VDPA_MIGRATION_H ++#define _VHOST_VDPA_MIGRATION_H ++ ++#include "hw/virtio/vdpa-dev.h" ++ ++void vdpa_migration_register(VhostVdpaDevice *vdev); ++ ++void vdpa_migration_unregister(VhostVdpaDevice *vdev); ++ ++#endif /* _VHOST_VDPA_MIGRATION_H */ +diff --git a/include/hw/virtio/vdpa-dev.h b/include/hw/virtio/vdpa-dev.h +index 4dbf98195c..43cbcef81b 100644 +--- a/include/hw/virtio/vdpa-dev.h ++++ b/include/hw/virtio/vdpa-dev.h +@@ -38,6 +38,7 @@ struct VhostVdpaDevice { + uint16_t queue_size; + bool started; + int (*post_init)(VhostVdpaDevice *v, Error **errp); ++ VMChangeStateEntry *vmstate; + }; + + #endif +diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h +index 0491fe1ed7..9441b4c50e 100644 +--- a/include/hw/virtio/vhost.h ++++ b/include/hw/virtio/vhost.h +@@ -277,4 +277,8 @@ int vhost_dev_set_inflight(struct vhost_dev *dev, + int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, + struct vhost_inflight *inflight); + bool used_memslots_is_exceeded(void); ++ ++int vhost_dev_resume(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings); ++int vhost_dev_suspend(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings); ++ + #endif +diff --git a/migration/migration.c b/migration/migration.c +index 2ec116f901..40e743b4e9 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -178,7 +178,6 @@ static bool migration_object_check(MigrationState *ms, Error **errp); + static int migration_maybe_pause(MigrationState *s, + int *current_active_state, + int new_state); +-static void migrate_fd_cancel(MigrationState *s); + + static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp) + { +@@ -1914,7 +1913,7 @@ void migrate_fd_error(MigrationState *s, const Error *error) + migrate_set_error(s, error); + } + +-static void migrate_fd_cancel(MigrationState *s) ++void migrate_fd_cancel(MigrationState *s) + { + int old_state ; + QEMUFile *f = migrate_get_current()->to_dst_file; +diff --git a/migration/migration.h b/migration/migration.h +index 4ed4f555da..a87fd54d10 100644 +--- a/migration/migration.h ++++ b/migration/migration.h +@@ -393,4 +393,6 @@ void migration_cancel(const Error *error); + + void populate_vfio_info(MigrationInfo *info); + ++void migrate_fd_cancel(MigrationState *s); ++ + #endif +-- +2.27.0 + diff --git a/vhost-introduce-bytemap-for-vhost-backend-logging.patch b/vhost-introduce-bytemap-for-vhost-backend-logging.patch new file mode 100644 index 0000000000000000000000000000000000000000..afa3d4d1adef19e67d80318cdf628773cb0ea66d --- /dev/null +++ b/vhost-introduce-bytemap-for-vhost-backend-logging.patch @@ -0,0 +1,271 @@ +From e2f1953ad26a61e59f1d45892c6937d7454e65b5 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:09:26 +0800 +Subject: [PATCH] vhost: introduce bytemap for vhost backend logging + +As vhost backend may use bytemap for logging, when get log_size +of vhost device, check whether vhost device support VHOST_BACKEND_F_BYTEMAPLOG. +If vhost device support, use bytemap for logging. + +By the way, add log_resize func pointer check and vhost_log_sync return +value check. + +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vhost.c | 144 ++++++++++++++++++++++++++++++++++++-- + include/hw/virtio/vhost.h | 1 + + 2 files changed, 139 insertions(+), 6 deletions(-) + +diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c +index 7930b37499..d2b9278474 100644 +--- a/hw/virtio/vhost.c ++++ b/hw/virtio/vhost.c +@@ -19,9 +19,11 @@ + #include "qemu/atomic.h" + #include "qemu/range.h" + #include "qemu/error-report.h" ++#include "cpu.h" + #include "qemu/memfd.h" + #include "qemu/log.h" + #include "standard-headers/linux/vhost_types.h" ++#include "exec/ram_addr.h" + #include "hw/virtio/virtio-bus.h" + #include "hw/virtio/virtio-access.h" + #include "migration/blocker.h" +@@ -30,6 +32,7 @@ + #include "sysemu/dma.h" + #include "sysemu/tcg.h" + #include "trace.h" ++#include "qapi/qapi-commands-migration.h" + + /* enabled until disconnected backend stabilizes */ + #define _VHOST_DEBUG 1 +@@ -45,6 +48,11 @@ + do { } while (0) + #endif + ++static inline bool vhost_bytemap_log_support(struct vhost_dev *dev) ++{ ++ return (dev->backend_cap & BIT_ULL(VHOST_BACKEND_F_BYTEMAPLOG)); ++} ++ + static struct vhost_log *vhost_log; + static struct vhost_log *vhost_log_shm; + +@@ -213,12 +221,93 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev, + return 0; + } + ++#define BYTES_PER_LONG (sizeof(unsigned long)) ++#define BYTE_WORD(nr) ((nr) / BYTES_PER_LONG) ++#define BYTES_TO_LONGS(nr) DIV_ROUND_UP(nr, BYTES_PER_LONG) ++ ++static inline int64_t _set_dirty_bytemap_atomic(unsigned long *bytemap, unsigned long cur_pfn) ++{ ++ char *byte_of_long = (char *)bytemap; ++ int i; ++ int64_t dirty_num = 0; ++ ++ for (i = 0; i < BYTES_PER_LONG; i++) { ++ if (byte_of_long[i]) { ++ cpu_physical_memory_set_dirty_range((cur_pfn + i) << TARGET_PAGE_BITS, ++ TARGET_PAGE_SIZE, ++ 1 << DIRTY_MEMORY_MIGRATION); ++ /* Per byte ops, no need to atomic_xchg */ ++ byte_of_long[i] = 0; ++ dirty_num++; ++ } ++ } ++ ++ return dirty_num; ++} ++ ++static inline int64_t cpu_physical_memory_set_dirty_bytemap(unsigned long *bytemap, ++ ram_addr_t start, ++ ram_addr_t pages) ++{ ++ unsigned long i; ++ unsigned long len = BYTES_TO_LONGS(pages); ++ unsigned long pfn = (start >> TARGET_PAGE_BITS) / ++ BYTES_PER_LONG * BYTES_PER_LONG; ++ int64_t dirty_mig_bits = 0; ++ ++ for (i = 0; i < len; i++) { ++ if (bytemap[i]) { ++ dirty_mig_bits += _set_dirty_bytemap_atomic(&bytemap[i], ++ pfn + BYTES_PER_LONG * i); ++ } ++ } ++ ++ return dirty_mig_bits; ++} ++ ++static int vhost_sync_dirty_bytemap(struct vhost_dev *dev, ++ MemoryRegionSection *section) ++{ ++ struct vhost_log *log = dev->log; ++ ++ ram_addr_t start = section->offset_within_region + ++ memory_region_get_ram_addr(section->mr); ++ ram_addr_t pages = int128_get64(section->size) >> TARGET_PAGE_BITS; ++ ++ hwaddr idx = BYTE_WORD( ++ section->offset_within_address_space >> TARGET_PAGE_BITS); ++ ++ return cpu_physical_memory_set_dirty_bytemap((unsigned long *)log->log + idx, ++ start, pages); ++} ++ + static void vhost_log_sync(MemoryListener *listener, + MemoryRegionSection *section) + { + struct vhost_dev *dev = container_of(listener, struct vhost_dev, + memory_listener); +- vhost_sync_dirty_bitmap(dev, section, 0x0, ~0x0ULL); ++ MigrationState *ms = migrate_get_current(); ++ ++ if (!dev->log_enabled || !dev->started) { ++ return; ++ } ++ ++ if (dev->vhost_ops->vhost_log_sync) { ++ int r = dev->vhost_ops->vhost_log_sync(dev); ++ if (r < 0) { ++ error_report("Failed to sync dirty log: 0x%x\n", r); ++ if (migration_is_running(ms->state)) { ++ qmp_migrate_cancel(NULL); ++ } ++ return; ++ } ++ } ++ ++ if (vhost_bytemap_log_support(dev)) { ++ vhost_sync_dirty_bytemap(dev, section); ++ } else { ++ vhost_sync_dirty_bitmap(dev, section, 0x0, ~0x0ULL); ++ } + } + + static void vhost_log_sync_range(struct vhost_dev *dev, +@@ -228,7 +317,11 @@ static void vhost_log_sync_range(struct vhost_dev *dev, + /* FIXME: this is N^2 in number of sections */ + for (i = 0; i < dev->n_mem_sections; ++i) { + MemoryRegionSection *section = &dev->mem_sections[i]; +- vhost_sync_dirty_bitmap(dev, section, first, last); ++ if (vhost_bytemap_log_support(dev)) { ++ vhost_sync_dirty_bytemap(dev, section); ++ } else { ++ vhost_sync_dirty_bitmap(dev, section, first, last); ++ } + } + } + +@@ -236,11 +329,19 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev) + { + uint64_t log_size = 0; + int i; ++ uint64_t vhost_log_chunk_size; ++ ++ if (vhost_bytemap_log_support(dev)) { ++ vhost_log_chunk_size = VHOST_LOG_CHUNK_BYTES; ++ } else { ++ vhost_log_chunk_size = VHOST_LOG_CHUNK; ++ } ++ + for (i = 0; i < dev->mem->nregions; ++i) { + struct vhost_memory_region *reg = dev->mem->regions + i; + uint64_t last = range_get_last(reg->guest_phys_addr, + reg->memory_size); +- log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1); ++ log_size = MAX(log_size, last / vhost_log_chunk_size + 1); + } + return log_size; + } +@@ -358,12 +459,21 @@ static bool vhost_dev_log_is_shared(struct vhost_dev *dev) + dev->vhost_ops->vhost_requires_shm_log(dev); + } + +-static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size) ++static inline int vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size) + { + struct vhost_log *log = vhost_log_get(size, vhost_dev_log_is_shared(dev)); +- uint64_t log_base = (uintptr_t)log->log; ++ uint64_t log_base; ++ int log_fd; + int r; + ++ if (!log) { ++ r = -ENOMEM; ++ goto out; ++ } ++ ++ log_base = (uint64_t)log->log; ++ log_fd = log_fd; ++ + /* inform backend of log switching, this must be done before + releasing the current log, to ensure no logging is lost */ + r = dev->vhost_ops->vhost_set_log_base(dev, log_base, log); +@@ -371,9 +481,19 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size) + VHOST_OPS_DEBUG(r, "vhost_set_log_base failed"); + } + ++ if (dev->vhost_ops->vhost_set_log_size) { ++ r = dev->vhost_ops->vhost_set_log_size(dev, size, dev->log); ++ if (r < 0) { ++ VHOST_OPS_DEBUG(r, "vhost_set_log_size failed"); ++ } ++ } ++ + vhost_log_put(dev, true); + dev->log = log; + dev->log_size = size; ++ ++out: ++ return r; + } + + static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr, +@@ -990,7 +1110,11 @@ static int vhost_migration_log(MemoryListener *listener, bool enable) + } + vhost_log_put(dev, false); + } else { +- vhost_dev_log_resize(dev, vhost_get_log_size(dev)); ++ r = vhost_dev_log_resize(dev, vhost_get_log_size(dev)); ++ if ( r < 0 ) { ++ return r; ++ } ++ + r = vhost_dev_set_log(dev, true); + if (r < 0) { + goto check_dev_state; +@@ -1967,6 +2091,14 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) + VHOST_OPS_DEBUG(r, "vhost_set_log_base failed"); + goto fail_log; + } ++ ++ if (hdev->vhost_ops->vhost_set_log_size) { ++ r = hdev->vhost_ops->vhost_set_log_size(hdev, hdev->log_size, hdev->log); ++ if (r < 0) { ++ VHOST_OPS_DEBUG(r, "vhost_set_log_size failed"); ++ goto fail_log; ++ } ++ } + } + if (vrings) { + r = vhost_dev_set_vring_enable(hdev, true); +diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h +index 420f93e5cd..0491fe1ed7 100644 +--- a/include/hw/virtio/vhost.h ++++ b/include/hw/virtio/vhost.h +@@ -40,6 +40,7 @@ typedef unsigned long vhost_log_chunk_t; + #define VHOST_LOG_PAGE 0x1000 + #define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t)) + #define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS) ++#define VHOST_LOG_CHUNK_BYTES (VHOST_LOG_PAGE * sizeof(vhost_log_chunk_t)) + #define VHOST_INVALID_FEATURE_BIT (0xff) + #define VHOST_QUEUE_NUM_CONFIG_INR 0 + +-- +2.27.0 + diff --git a/vhost-user-blk-propagate-error-return-from-generic-v.patch b/vhost-user-blk-propagate-error-return-from-generic-v.patch new file mode 100644 index 0000000000000000000000000000000000000000..7894db573723a59ed7e8ee70af058b0bf48eddb1 --- /dev/null +++ b/vhost-user-blk-propagate-error-return-from-generic-v.patch @@ -0,0 +1,36 @@ +From 2a4dcc55ce71f1251d0dc0ccd293866bfe4dc071 Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Mon, 4 Dec 2023 11:15:58 +0800 +Subject: [PATCH] vhost-user-blk: propagate error return from generic vhost + +cherry picked from commit fb767859345506d747876c23d181155b183f8e94 + +Fix the only callsite that doesn't propagate the error code from the +generic vhost code. + +Signed-off-by: Roman Kagan +Message-Id: <20211111153354.18807-11-rvkagan@yandex-team.ru> +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +Reviewed-by: Raphael Norwitz +Signed-off-by: Luo Yifan +--- + hw/block/vhost-user-blk.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c +index eddc5588fa..f1a281a965 100644 +--- a/hw/block/vhost-user-blk.c ++++ b/hw/block/vhost-user-blk.c +@@ -104,7 +104,7 @@ static int vhost_user_blk_handle_config_change(struct vhost_dev *dev) + &local_err); + if (ret < 0) { + error_report_err(local_err); +- return -1; ++ return ret; + } + + /* valid for resize only */ +-- +2.27.0 + diff --git a/vhost-user-blk-reconnect-on-any-error-during-realize.patch b/vhost-user-blk-reconnect-on-any-error-during-realize.patch new file mode 100644 index 0000000000000000000000000000000000000000..25eaab24a154eb9e72caa7a38137c74b6b98fbdb --- /dev/null +++ b/vhost-user-blk-reconnect-on-any-error-during-realize.patch @@ -0,0 +1,51 @@ +From a64c32378bd5a1119ea69d8c29f93b6365d3346b Mon Sep 17 00:00:00 2001 +From: Luo Yifan +Date: Mon, 4 Dec 2023 11:11:29 +0800 +Subject: [PATCH] vhost-user-blk: reconnect on any error during realize + +cherry picked from commit b7107e758f4ecdd8f07ede3f093cbbfdb623e865 + +vhost-user-blk realize only attempts to reconnect if the previous +connection attempt failed on "a problem with the connection and not an +error related to the content (which would fail again the same way in the +next attempt)". + +However this distinction is very subtle, and may be inadvertently broken +if the code changes somewhere deep down the stack and a new error gets +propagated up to here. + +OTOH now that the number of reconnection attempts is limited it seems +harmless to try reconnecting on any error. + +So relax the condition of whether to retry connecting to check for any +error. + +This patch amends a527e312b5 "vhost-user-blk: Implement reconnection +during realize". + +Signed-off-by: Roman Kagan +Message-Id: <20211111153354.18807-2-rvkagan@yandex-team.ru> +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +Reviewed-by: Raphael Norwitz +Signed-off-by: Luo Yifan +--- + hw/block/vhost-user-blk.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c +index eddc5588fa..a2236c5239 100644 +--- a/hw/block/vhost-user-blk.c ++++ b/hw/block/vhost-user-blk.c +@@ -516,7 +516,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) + *errp = NULL; + } + ret = vhost_user_blk_realize_connect(s, errp); +- } while (ret == -EPROTO && retries--); ++ } while (ret < 0 && retries--); + + if (ret < 0) { + goto virtio_err; +-- +2.27.0 + diff --git a/vhost-vdpa-add-VHOST_BACKEND_F_BYTEMAPLOG.patch b/vhost-vdpa-add-VHOST_BACKEND_F_BYTEMAPLOG.patch new file mode 100644 index 0000000000000000000000000000000000000000..d40dd186cc2313bcf9321399b8d12f916066b473 --- /dev/null +++ b/vhost-vdpa-add-VHOST_BACKEND_F_BYTEMAPLOG.patch @@ -0,0 +1,49 @@ +From b0c67874628455a869ca1afde0de44572c70d5b9 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 14:49:53 +0800 +Subject: [PATCH] vhost-vdpa: add VHOST_BACKEND_F_BYTEMAPLOG + +support VHOST_BACKEND_F_BYTEMAPLOG to support vhost +device bytemap logging. + +Signed-off-by: libai +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vhost-vdpa.c | 7 ++++--- + include/standard-headers/linux/vhost_types.h | 2 ++ + 2 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index 986fc795bf..e1c90cf6c2 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -660,9 +660,10 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev, + static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) + { + uint64_t features; +- uint64_t f = 0x1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2 | +- 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH | +- 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID; ++ uint64_t f = BIT_ULL(VHOST_BACKEND_F_IOTLB_MSG_V2) | ++ BIT_ULL(VHOST_BACKEND_F_IOTLB_BATCH) | ++ BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID) | ++ BIT_ULL(VHOST_BACKEND_F_BYTEMAPLOG); + int r; + + if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, &features)) { +diff --git a/include/standard-headers/linux/vhost_types.h b/include/standard-headers/linux/vhost_types.h +index 17833e320e..3801d95182 100644 +--- a/include/standard-headers/linux/vhost_types.h ++++ b/include/standard-headers/linux/vhost_types.h +@@ -157,5 +157,7 @@ struct vhost_vdpa_iova_range { + * message + */ + #define VHOST_BACKEND_F_IOTLB_ASID 0x3 ++/* device can use bytemap log */ ++#define VHOST_BACKEND_F_BYTEMAPLOG 0x3f + + #endif +-- +2.27.0 + diff --git a/vhost-vdpa-add-migration-log-ops-for-VhostOps.patch b/vhost-vdpa-add-migration-log-ops-for-VhostOps.patch new file mode 100644 index 0000000000000000000000000000000000000000..9de17d74f0dd9ef3cdd260e53f994272fff96c35 --- /dev/null +++ b/vhost-vdpa-add-migration-log-ops-for-VhostOps.patch @@ -0,0 +1,129 @@ +From 51c8cb0fa2481be78282e7ea8f24a3f97083e2fd Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 4 Dec 2023 15:04:25 +0800 +Subject: [PATCH] vhost-vdpa: add migration log ops for VhostOps + +Implement vhost_set_log_size for setting buffer size for logging. +Implement vhost_set_log_fd to specify an eventfd to signal on log write. +Implement vhost_log_sync for getting dirtymap logged by vhost backend. + +Signed-off-by: libai +Signed-off-by: jiangdongxu +Signed-off-by: fangyi +--- + hw/virtio/vhost-vdpa.c | 37 +++++++++++++++++++++++++++++++ + include/hw/virtio/vhost-backend.h | 8 +++++++ + linux-headers/linux/vhost.h | 4 ++++ + 3 files changed, 49 insertions(+) + +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index e1c90cf6c2..7663d78b43 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -1146,6 +1146,30 @@ static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, + return vhost_vdpa_call(dev, VHOST_SET_LOG_BASE, &base); + } + ++static int vhost_vdpa_set_log_fd(struct vhost_dev *dev, int fd, ++ struct vhost_log *log) ++{ ++ struct vhost_vdpa *v = dev->opaque; ++ if (v->shadow_vqs_enabled || !vhost_vdpa_first_dev(dev)) { ++ return 0; ++ } ++ ++ return vhost_vdpa_call(dev, VHOST_SET_LOG_FD, &fd); ++} ++ ++static int vhost_vdpa_set_log_size(struct vhost_dev *dev, uint64_t size, ++ struct vhost_log *log) ++{ ++ struct vhost_vdpa *v = dev->opaque; ++ uint64_t logsize = size * sizeof(*(log->log)); ++ ++ if (v->shadow_vqs_enabled || !vhost_vdpa_first_dev(dev)) { ++ return 0; ++ } ++ ++ return vhost_vdpa_call(dev, VHOST_SET_LOG_SIZE, &logsize); ++} ++ + static int vhost_vdpa_set_vring_addr(struct vhost_dev *dev, + struct vhost_vring_addr *addr) + { +@@ -1294,11 +1318,23 @@ static unsigned int vhost_vdpa_get_used_memslots(void) + return vhost_vdpa_used_memslots; + } + ++static int vhost_vdpa_log_sync(struct vhost_dev *dev) ++{ ++ struct vhost_vdpa *v = dev->opaque; ++ if (v->shadow_vqs_enabled || !vhost_vdpa_first_dev(dev)) { ++ return 0; ++ } ++ ++ return vhost_vdpa_call(dev, VHOST_LOG_SYNC, NULL); ++} ++ + const VhostOps vdpa_ops = { + .backend_type = VHOST_BACKEND_TYPE_VDPA, + .vhost_backend_init = vhost_vdpa_init, + .vhost_backend_cleanup = vhost_vdpa_cleanup, + .vhost_set_log_base = vhost_vdpa_set_log_base, ++ .vhost_set_log_size = vhost_vdpa_set_log_size, ++ .vhost_set_log_fd = vhost_vdpa_set_log_fd, + .vhost_set_vring_addr = vhost_vdpa_set_vring_addr, + .vhost_set_vring_num = vhost_vdpa_set_vring_num, + .vhost_set_vring_base = vhost_vdpa_set_vring_base, +@@ -1326,6 +1362,7 @@ const VhostOps vdpa_ops = { + .vhost_get_device_id = vhost_vdpa_get_device_id, + .vhost_vq_get_addr = vhost_vdpa_vq_get_addr, + .vhost_force_iommu = vhost_vdpa_force_iommu, ++ .vhost_log_sync = vhost_vdpa_log_sync, + .vhost_set_config_call = vhost_vdpa_set_config_call, + .vhost_set_used_memslots = vhost_vdpa_set_used_memslots, + .vhost_get_used_memslots = vhost_vdpa_get_used_memslots, +diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h +index bd1c7dfe4f..86154dd0b2 100644 +--- a/include/hw/virtio/vhost-backend.h ++++ b/include/hw/virtio/vhost-backend.h +@@ -53,6 +53,11 @@ typedef int (*vhost_scsi_get_abi_version_op)(struct vhost_dev *dev, + int *version); + typedef int (*vhost_set_log_base_op)(struct vhost_dev *dev, uint64_t base, + struct vhost_log *log); ++typedef int (*vhost_set_log_size_op)(struct vhost_dev *dev, uint64_t size, ++ struct vhost_log *log); ++typedef int (*vhost_set_log_fd_op)(struct vhost_dev *dev, int fd, ++ struct vhost_log *log); ++typedef int (*vhost_log_sync_op)(struct vhost_dev *dev); + typedef int (*vhost_set_mem_table_op)(struct vhost_dev *dev, + struct vhost_memory *mem); + typedef int (*vhost_set_vring_addr_op)(struct vhost_dev *dev, +@@ -141,6 +146,9 @@ typedef struct VhostOps { + vhost_scsi_clear_endpoint_op vhost_scsi_clear_endpoint; + vhost_scsi_get_abi_version_op vhost_scsi_get_abi_version; + vhost_set_log_base_op vhost_set_log_base; ++ vhost_set_log_size_op vhost_set_log_size; ++ vhost_set_log_fd_op vhost_set_log_fd; ++ vhost_log_sync_op vhost_log_sync; + vhost_set_mem_table_op vhost_set_mem_table; + vhost_set_vring_addr_op vhost_set_vring_addr; + vhost_set_vring_endian_op vhost_set_vring_endian; +diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h +index b6ded7f831..65c6b49788 100644 +--- a/linux-headers/linux/vhost.h ++++ b/linux-headers/linux/vhost.h +@@ -43,6 +43,10 @@ + * The bit is set using an atomic 32 bit operation. */ + /* Set base address for logging. */ + #define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64) ++/* Set buffer size for logging */ ++#define VHOST_SET_LOG_SIZE _IOW(VHOST_VIRTIO, 0x05, __u64) ++/* Logging sync */ ++#define VHOST_LOG_SYNC _IO(VHOST_VIRTIO, 0x06) + /* Specify an eventfd file descriptor to signal on log write. */ + #define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int) + +-- +2.27.0 + diff --git a/xen-pass-through-don-t-create-needless-register-grou.patch b/xen-pass-through-don-t-create-needless-register-grou.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c45f2be52dd8620f387617e0dd7a99fa55dac5d --- /dev/null +++ b/xen-pass-through-don-t-create-needless-register-grou.patch @@ -0,0 +1,63 @@ +From 125b3c3ef9db4cda5e6f08d2f1f5b3d1fe853ef7 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Fri, 24 Nov 2023 08:33:13 +0000 +Subject: [PATCH] xen/pass-through: don't create needless register group + mainline inclusion commit c0e86b7624cb9d6db03e0d48cf82659e5b89a6a6 category: + bugfix + +--------------------------------------------------------------- + +Currently we are creating a register group for the Intel IGD OpRegion +for every device we pass through, but the XEN_PCI_INTEL_OPREGION +register group is only valid for an Intel IGD. Add a check to make +sure the device is an Intel IGD and a check that the administrator has +enabled gfx_passthru in the xl domain configuration. Require both checks +to be true before creating the register group. Use the existing +is_igd_vga_passthrough() function to check for a graphics device from +any vendor and that the administrator enabled gfx_passthru in the xl +domain configuration, but further require that the vendor be Intel, +because only Intel IGD devices have an Intel OpRegion. These are the +same checks hvmloader and libxl do to determine if the Intel OpRegion +needs to be mapped into the guest's memory. Also, move the comment +about trapping 0xfc for the Intel OpRegion where it belongs after +applying this patch. + +Signed-off-by: Chuck Zmudzinski +Reviewed-by: Anthony PERARD +Message-Id: +Signed-off-by: Anthony PERARD + +Signed-off-by: tangbinzy +--- + hw/xen/xen_pt_config_init.c | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c +index e7bcbe4c4f..b9833d2fa7 100644 +--- a/hw/xen/xen_pt_config_init.c ++++ b/hw/xen/xen_pt_config_init.c +@@ -2031,12 +2031,16 @@ void xen_pt_config_init(XenPCIPassthroughState *s, Error **errp) + } + } + +- /* +- * By default we will trap up to 0x40 in the cfg space. +- * If an intel device is pass through we need to trap 0xfc, +- * therefore the size should be 0xff. +- */ + if (xen_pt_emu_reg_grps[i].grp_id == XEN_PCI_INTEL_OPREGION) { ++ if (!is_igd_vga_passthrough(&s->real_device) || ++ s->real_device.vendor_id != PCI_VENDOR_ID_INTEL) { ++ continue; ++ } ++ /* ++ * By default we will trap up to 0x40 in the cfg space. ++ * If an intel device is pass through we need to trap 0xfc, ++ * therefore the size should be 0xff. ++ */ + reg_grp_offset = XEN_PCI_INTEL_OPREGION; + } + +-- +2.27.0 + diff --git a/xen-pass-through-merge-emulated-bits-correctly.patch b/xen-pass-through-merge-emulated-bits-correctly.patch new file mode 100644 index 0000000000000000000000000000000000000000..e4bc9c4a56def04713a93624c2c4c6852449bf85 --- /dev/null +++ b/xen-pass-through-merge-emulated-bits-correctly.patch @@ -0,0 +1,67 @@ +From feec0d41c0737ce46860fd7b34324d41498fdb9d Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Fri, 24 Nov 2023 08:20:17 +0000 +Subject: [PATCH] xen/pass-through: merge emulated bits correctly mainline + inclusion commit be9c61da9fc57eb7d293f380d0805ca6f46c2657 category: bugfix + +--------------------------------------------------------------- + +In xen_pt_config_reg_init(), there is an error in the merging of the +emulated data with the host value. With the current Qemu, instead of +merging the emulated bits with the host bits as defined by emu_mask, +the emulated bits are merged with the host bits as defined by the +inverse of emu_mask. In some cases, depending on the data in the +registers on the host, the way the registers are setup, and the +initial values of the emulated bits, the end result will be that +the register is initialized with the wrong value. + +To correct this error, use the XEN_PT_MERGE_VALUE macro to help ensure +the merge is done correctly. + +This correction is needed to resolve Qemu project issue #1061, which +describes the failure of Xen HVM Linux guests to boot in certain +configurations with passed through PCI devices, that is, when this error +disables instead of enables the PCI_STATUS_CAP_LIST bit of the +PCI_STATUS register of a passed through PCI device, which in turn +disables the MSI-X capability of the device in Linux guests with the end +result being that the Linux guest never completes the boot process. + +Fixes: 2e87512eccf3 ("xen/pt: Sync up the dev.config and data values") +Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1061 +Buglink: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988333 + +Signed-off-by: Chuck Zmudzinski +Reviewed-by: Anthony PERARD +Message-Id: +Signed-off-by: Anthony PERARD + +Signed-off-by: tangbinzy +--- + hw/xen/xen_pt_config_init.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c +index e7bcbe4c4f..d04c12ce3d 100644 +--- a/hw/xen/xen_pt_config_init.c ++++ b/hw/xen/xen_pt_config_init.c +@@ -1965,11 +1965,12 @@ static void xen_pt_config_reg_init(XenPCIPassthroughState *s, + + if ((data & host_mask) != (val & host_mask)) { + uint32_t new_val; +- +- /* Mask out host (including past size). */ +- new_val = val & host_mask; +- /* Merge emulated ones (excluding the non-emulated ones). */ +- new_val |= data & host_mask; ++ /* ++ * Merge the emulated bits (data) with the host bits (val) ++ * and mask out the bits past size to enable restoration ++ * of the proper value for logging below. ++ */ ++ new_val = XEN_PT_MERGE_VALUE(val, data, host_mask) & size_mask; + /* Leave intact host and emulated values past the size - even though + * we do not care as we write per reg->size granularity, but for the + * logging below lets have the proper value. */ +-- +2.27.0 +