diff --git a/Allow-UNIX-socket-option-for-VNC-websocket.patch b/Allow-UNIX-socket-option-for-VNC-websocket.patch new file mode 100644 index 0000000000000000000000000000000000000000..da5947b6a0c03e2e7c9008277fece7e3e8ac78e7 --- /dev/null +++ b/Allow-UNIX-socket-option-for-VNC-websocket.patch @@ -0,0 +1,57 @@ +From b149e82858eb16bcede32b86518a7a2f6f259b5b Mon Sep 17 00:00:00 2001 +From: dinglimin +Date: Thu, 23 May 2024 16:45:25 +0800 +Subject: [PATCH] Allow UNIX socket option for VNC websocket +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cheery-pick from 41582637b1577c261f19634bdd1bb5e7ed6e258d + +- Remove unix socket option limitation for VNC websocket +- Reflect websocket option changes in documentation + +Signed-off-by: Sergii Zasenko +Reviewed-by: Marc-André Lureau +Message-Id: <20230724100353.16628-1-sergii@zasenko.name> + +Signed-off-by: dinglimin +--- + qemu-options.hx | 4 ++++ + ui/vnc.c | 5 ----- + 2 files changed, 4 insertions(+), 5 deletions(-) + +diff --git a/qemu-options.hx b/qemu-options.hx +index d940b4aea5..ab82ad4150 100644 +--- a/qemu-options.hx ++++ b/qemu-options.hx +@@ -2339,6 +2339,10 @@ SRST + host. It is possible to control the websocket listen address + independently, using the syntax ``websocket``\ =host:port. + ++ Websocket could be allowed over UNIX domain socket, using the syntax ++ ``websocket``\ =unix:path, where path is the location of a unix socket ++ to listen for connections on. ++ + If no TLS credentials are provided, the websocket connection + runs in unencrypted mode. If TLS credentials are provided, the + websocket connection requires encrypted client connections. +diff --git a/ui/vnc.c b/ui/vnc.c +index 71e3627be2..3cb24badf6 100644 +--- a/ui/vnc.c ++++ b/ui/vnc.c +@@ -3725,11 +3725,6 @@ static int vnc_display_get_address(const char *addrstr, + addr->type = SOCKET_ADDRESS_TYPE_UNIX; + addr->u.q_unix.path = g_strdup(addrstr + 5); + +- if (websocket) { +- error_setg(errp, "UNIX sockets not supported with websock"); +- goto cleanup; +- } +- + if (to) { + error_setg(errp, "Port range not support with UNIX socket"); + goto cleanup; +-- +2.27.0 + diff --git a/Change-the-value-of-no_ged-from-true-to-false.patch b/Change-the-value-of-no_ged-from-true-to-false.patch new file mode 100644 index 0000000000000000000000000000000000000000..ea634a6b601ea8c889166d4667e712e53f720256 --- /dev/null +++ b/Change-the-value-of-no_ged-from-true-to-false.patch @@ -0,0 +1,29 @@ +From 96e753e741a21d8bc1f59120dd70ce140129b737 Mon Sep 17 00:00:00 2001 +From: weishaokun +Date: Fri, 31 May 2024 13:48:59 +0800 +Subject: [PATCH] Change the value of no_ged from true to false + +It fixes the issue of the `no_ged` parameter mismatch +when migrating a virtual machine started with QEMU 4.1 to a QEMU 6.2 + +Signed-off-by: Shaokun Wei +--- + hw/arm/virt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/arm/virt.c b/hw/arm/virt.c +index 93554cccf1..eadba9535e 100644 +--- a/hw/arm/virt.c ++++ b/hw/arm/virt.c +@@ -3290,7 +3290,7 @@ static void virt_machine_4_1_options(MachineClass *mc) + + virt_machine_4_2_options(mc); + compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); +- vmc->no_ged = true; ++ vmc->no_ged = false; + mc->auto_enable_numa_with_memhp = false; + } + DEFINE_VIRT_MACHINE(4, 1) +-- +2.27.0 + diff --git a/KVM-dirty-ring-add-missing-memory-barrier.patch b/KVM-dirty-ring-add-missing-memory-barrier.patch new file mode 100644 index 0000000000000000000000000000000000000000..27e6c8799623f583258884bb4651d5200bb1dada --- /dev/null +++ b/KVM-dirty-ring-add-missing-memory-barrier.patch @@ -0,0 +1,45 @@ +From 63d3efed81ddf36acfec73910a84dee426450012 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Wed, 15 May 2024 01:03:38 +0000 +Subject: [PATCH] KVM: dirty ring: add missing memory barrier mainline + inclusion commit 4802bf910eee98312c4a9777ac2567e6a0445c46 category: bugfix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--------------------------------------------------------------- + +The KVM_DIRTY_GFN_F_DIRTY flag ensures that the entry is valid. If +the read of the fields are not ordered after the read of the flag, +QEMU might see stale values. + +Cc: Gavin Shan +Reviewed-by: Philippe Mathieu-Daudé +Reviewed-by: Peter Xu +Signed-off-by: Paolo Bonzini + +Signed-off-by: tangbinzy +--- + accel/kvm/kvm-all.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c +index c477f7a635..e55b2b6a16 100644 +--- a/accel/kvm/kvm-all.c ++++ b/accel/kvm/kvm-all.c +@@ -661,7 +661,11 @@ static void kvm_dirty_ring_mark_page(KVMState *s, uint32_t as_id, + + static bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn) + { +- return gfn->flags == KVM_DIRTY_GFN_F_DIRTY; ++ /* ++ * Read the flags before the value. Pairs with barrier in ++ * KVM's kvm_dirty_ring_push() function. ++ */ ++ return qatomic_load_acquire(&gfn->flags) == KVM_DIRTY_GFN_F_DIRTY; + } + + static void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn) +-- +2.27.0 + diff --git a/chardev-char-socket-Update-AF_UNIX-for-Windows.patch b/chardev-char-socket-Update-AF_UNIX-for-Windows.patch new file mode 100644 index 0000000000000000000000000000000000000000..a16b4940667b7383e9fbd8fe4293abc0083dabb4 --- /dev/null +++ b/chardev-char-socket-Update-AF_UNIX-for-Windows.patch @@ -0,0 +1,56 @@ +From 83a0636d6eb42c223ca4d6c0d26ca3a2075de532 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Wed, 15 May 2024 01:21:57 +0000 +Subject: [PATCH] chardev/char-socket: Update AF_UNIX for Windows mainline + inclusion commit 120fa5e0e6ebacd811e4d830cff8a405806d305c category: bugfix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--------------------------------------------------------------- + +Now that AF_UNIX has come to Windows, update the existing logic in +qemu_chr_compute_filename() and qmp_chardev_open_socket() for Windows. + +Signed-off-by: Bin Meng +Reviewed-by: Marc-André Lureau +Message-Id: <20220802075200.907360-4-bmeng.cn@gmail.com> + +Signed-off-by: tangbinzy +--- + chardev/char-socket.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/chardev/char-socket.c b/chardev/char-socket.c +index ef5d3053f3..278190dd93 100644 +--- a/chardev/char-socket.c ++++ b/chardev/char-socket.c +@@ -632,12 +632,10 @@ static char *qemu_chr_compute_filename(SocketChardev *s) + const char *left = "", *right = ""; + + switch (ss->ss_family) { +-#ifndef _WIN32 + case AF_UNIX: + return g_strdup_printf("unix:%s%s", + ((struct sockaddr_un *)(ss))->sun_path, + s->is_listen ? ",server=on" : ""); +-#endif + case AF_INET6: + left = "["; + right = "]"; +@@ -1450,10 +1448,12 @@ static void qmp_chardev_open_socket(Chardev *chr, + } + + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE); ++#ifndef _WIN32 + /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */ + if (addr->type == SOCKET_ADDRESS_TYPE_UNIX) { + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); + } ++#endif + + /* + * In the chardev-change special-case, we shouldn't register a new yank +-- +2.27.0 + diff --git a/dbus-vmstate-Restrict-error-checks-to-registered-pro.patch b/dbus-vmstate-Restrict-error-checks-to-registered-pro.patch new file mode 100644 index 0000000000000000000000000000000000000000..f6d29b94720d05e57ad0509c1dddb34b5ceba5d8 --- /dev/null +++ b/dbus-vmstate-Restrict-error-checks-to-registered-pro.patch @@ -0,0 +1,67 @@ +From a5a46593ade242686a670756530026914ed51eaf Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Tue, 14 May 2024 09:27:10 +0000 +Subject: [PATCH] dbus-vmstate: Restrict error checks to registered proxies in + dbus_get_proxies mainline inclusion commit + 2748583211d6e4d14f8862c65276b2d6cc1681ad category: bugfix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--------------------------------------------------------------- + +The purpose of dbus_get_proxies to construct the proxies corresponding to the +IDs registered to dbus-vmstate. + +Currenty, this function returns an error in case there is any failure +while instantiating proxy for "all" the names on dbus. + +Ideally this function should error out only if it is not able to find and +validate the proxies registered to the backend otherwise any offending +process(for eg: the process purposefully may not export its Id property on +the dbus) may connect to the dbus and can lead to migration failures. + +This commit ensures that dbus_get_proxies returns an error if it is not +able to find and validate the proxies of interest(the IDs registered +during the dbus-vmstate instantiation). + +Signed-off-by: Priyankar Jain +Reviewed-by: Marc-André Lureau +Message-Id: <1637936117-37977-1-git-send-email-priyankar.jain@nutanix.com> + +Signed-off-by: tangbinzy +--- + backends/dbus-vmstate.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c +index 9cfd758c42..57369ec0f2 100644 +--- a/backends/dbus-vmstate.c ++++ b/backends/dbus-vmstate.c +@@ -114,14 +114,19 @@ dbus_get_proxies(DBusVMState *self, GError **err) + "org.qemu.VMState1", + NULL, err); + if (!proxy) { +- return NULL; ++ if (err != NULL && *err != NULL) { ++ warn_report("%s: Failed to create proxy: %s", ++ __func__, (*err)->message); ++ g_clear_error(err); ++ } ++ continue; + } + + result = g_dbus_proxy_get_cached_property(proxy, "Id"); + if (!result) { +- g_set_error_literal(err, G_IO_ERROR, G_IO_ERROR_FAILED, +- "VMState Id property is missing."); +- return NULL; ++ warn_report("%s: VMState Id property is missing.", __func__); ++ g_clear_object(&proxy); ++ continue; + } + + id = g_variant_dup_string(result, &size); +-- +2.27.0 + diff --git a/docs-system-target-arm-Re-alphabetize-board-list.patch b/docs-system-target-arm-Re-alphabetize-board-list.patch new file mode 100644 index 0000000000000000000000000000000000000000..757fcc67626f03c8614f7027a2666d3448e83c3d --- /dev/null +++ b/docs-system-target-arm-Re-alphabetize-board-list.patch @@ -0,0 +1,54 @@ +From 5f9795e17706aa4bcac46724330761c74cc767c4 Mon Sep 17 00:00:00 2001 +From: tangzhongrui +Date: Mon, 3 Jun 2024 20:58:36 +0800 +Subject: [PATCH] docs/system/target-arm: Re-alphabetize board list +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The board list in target-arm.rst is supposed to be in alphabetical +order by the title text of each file (which is not the same as +alphabetical order by filename). A few items had got out of order; +correct them. + +The entry for +"Facebook Yosemite v3.5 Platform and CraterLake Server (fby35)" +remains out-of-order, because this is not its own file +but is currently part of the aspeed.rst file. + +Signed-off-by: Peter Maydell +Reviewed-by: Richard Henderson +Reviewed-by: Philippe Mathieu-Daudé +Message-id: 20240520141421.1895138-1-peter.maydell@linaro.org + +Signed-off-by: Zhongrui Tang +--- + docs/system/target-arm.rst | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst +index 91ebc26c6d..d3d2c28417 100644 +--- a/docs/system/target-arm.rst ++++ b/docs/system/target-arm.rst +@@ -84,16 +84,16 @@ undocumented; you can get a complete list by running + arm/vexpress + arm/aspeed + arm/sabrelite ++ arm/highbank + arm/digic + arm/cubieboard + arm/emcraft-sf2 +- arm/highbank + arm/musicpal + arm/gumstix + arm/mainstone + arm/kzm +- arm/nrf + arm/nseries ++ arm/nrf + arm/nuvoton + arm/imx25-pdk + arm/orangepi +-- +2.27.0 + diff --git a/esp-Handle-CMD_BUSRESET-by-resetting-the-SCSI-bus.patch b/esp-Handle-CMD_BUSRESET-by-resetting-the-SCSI-bus.patch new file mode 100644 index 0000000000000000000000000000000000000000..5172defb744084afa85788bc8976701500933f3a --- /dev/null +++ b/esp-Handle-CMD_BUSRESET-by-resetting-the-SCSI-bus.patch @@ -0,0 +1,53 @@ +From 3f186cb242429e6d19f95e259e226658f0d605a9 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Tue, 14 May 2024 09:53:37 +0000 +Subject: [PATCH] esp: Handle CMD_BUSRESET by resetting the SCSI bus mainline + inclusion commit c6e51f1bb28ed762d2039c063cbb71a8ad29762d category: bugfix + +--------------------------------------------------------------- + +Per investigation on the linked ticket, SunOS issues a SCSI bus reset +to the ESP as part of its boot sequence. If this ESP command doesn't +cause devices to assert sense flag UNIT ATTENTION, SunOS will consider +the CD-ROM device to be non-compliant with Common Command Set (CCS). +In this condition, the SunOS installer's early userspace doesn't set +the installation source location to sr0 and the miniroot copy fails. + +Signed-off-by: John Millikin +Suggested-by: Bill Paul +Buglink: https://gitlab.com/qemu-project/qemu/-/issues/1127 +Message-Id: <20220817053846.699310-1-john@john-millikin.com> +Signed-off-by: Paolo Bonzini + +Signed-off-by: tangbinzy +--- + hw/scsi/esp.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c +index 435a81bbfd..9f071e7218 100644 +--- a/hw/scsi/esp.c ++++ b/hw/scsi/esp.c +@@ -912,6 +912,11 @@ static void esp_soft_reset(ESPState *s) + esp_hard_reset(s); + } + ++static void esp_bus_reset(ESPState *s) ++{ ++ qbus_reset_all(BUS(&s->bus)); ++} ++ + static void parent_esp_reset(ESPState *s, int irq, int level) + { + if (level) { +@@ -1040,6 +1045,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) + break; + case CMD_BUSRESET: + trace_esp_mem_writeb_cmd_bus_reset(val); ++ esp_bus_reset(s); + if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) { + s->rregs[ESP_RINTR] |= INTR_RST; + esp_raise_irq(s); +-- +2.27.0 + diff --git a/hw-virtio-handle-un-configured-shutdown-in-virtio-pc.patch b/hw-virtio-handle-un-configured-shutdown-in-virtio-pc.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac5e28bf7264f38485ade964f1f83ed77146763b --- /dev/null +++ b/hw-virtio-handle-un-configured-shutdown-in-virtio-pc.patch @@ -0,0 +1,51 @@ +From 8e15820dcf4f343ad21e01d8a6c9516b79ee4e7c Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Tue, 30 Apr 2024 09:42:08 +0000 +Subject: [PATCH] hw/virtio: handle un-configured shutdown in virtio-pci + mainline inclusion commit 5a9d5f09b1f61bc7072c2389ba5b11350ae76b0d category: + bugfix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--------------------------------------------------------------- + +The assert() protecting against leakage is a little aggressive and +causes needless crashes if a device is shutdown without having been +configured. In this case no descriptors are lost because none have +been assigned. + +Signed-off-by: Alex Bennée +Message-Id: <20220728135503.1060062-4-alex.bennee@linaro.org> +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin + +Signed-off-by: tangbinzy +--- + hw/virtio/virtio-pci.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c +index 6b45683280..389a8db0ec 100644 +--- a/hw/virtio/virtio-pci.c ++++ b/hw/virtio/virtio-pci.c +@@ -1213,9 +1213,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) + + nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX); + +- /* When deassigning, pass a consistent nvqs value +- * to avoid leaking notifiers. ++ /* ++ * When deassigning, pass a consistent nvqs value to avoid leaking ++ * notifiers. But first check we've actually been configured, exit ++ * early if we haven't. + */ ++ if (!assign && !proxy->nvqs_with_notifiers) { ++ return 0; ++ } + assert(assign || nvqs == proxy->nvqs_with_notifiers); + + proxy->nvqs_with_notifiers = nvqs; +-- +2.27.0 + diff --git a/i386-reset-KVM-nested-state-upon-CPU-reset.patch b/i386-reset-KVM-nested-state-upon-CPU-reset.patch new file mode 100644 index 0000000000000000000000000000000000000000..0705a2ce7c67d69ebe606a469d862764eb68c361 --- /dev/null +++ b/i386-reset-KVM-nested-state-upon-CPU-reset.patch @@ -0,0 +1,90 @@ +From 6257f125bc58952f49cbbc28210099a6333152a8 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Tue, 14 May 2024 10:05:16 +0000 +Subject: [PATCH] i386: reset KVM nested state upon CPU reset mainline + inclusion commit 3cafdb67504a34a0305260f0c86a73d5a3fb000b category: bugfix + +--------------------------------------------------------------- + +Make sure env->nested_state is cleaned up when a vCPU is reset, it may +be stale after an incoming migration, kvm_arch_put_registers() may +end up failing or putting vCPU in a weird state. + +Reviewed-by: Maxim Levitsky +Signed-off-by: Vitaly Kuznetsov +Message-Id: <20220818150113.479917-2-vkuznets@redhat.com> +Signed-off-by: Paolo Bonzini + +Signed-off-by: tangbinzy +--- + target/i386/kvm/kvm.c | 37 +++++++++++++++++++++++++++---------- + 1 file changed, 27 insertions(+), 10 deletions(-) + +diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c +index 99be7f6155..9f3ddd5da2 100644 +--- a/target/i386/kvm/kvm.c ++++ b/target/i386/kvm/kvm.c +@@ -1623,6 +1623,30 @@ static void kvm_init_xsave(CPUX86State *env) + env->xsave_buf_len); + } + ++static void kvm_init_nested_state(CPUX86State *env) ++{ ++ struct kvm_vmx_nested_state_hdr *vmx_hdr; ++ uint32_t size; ++ ++ if (!env->nested_state) { ++ return; ++ } ++ ++ size = env->nested_state->size; ++ ++ memset(env->nested_state, 0, size); ++ env->nested_state->size = size; ++ ++ if (cpu_has_vmx(env)) { ++ env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX; ++ vmx_hdr = &env->nested_state->hdr.vmx; ++ vmx_hdr->vmxon_pa = -1ull; ++ vmx_hdr->vmcs12_pa = -1ull; ++ } else if (cpu_has_svm(env)) { ++ env->nested_state->format = KVM_STATE_NESTED_FORMAT_SVM; ++ } ++} ++ + int kvm_arch_init_vcpu(CPUState *cs) + { + struct { +@@ -2051,19 +2075,10 @@ int kvm_arch_init_vcpu(CPUState *cs) + assert(max_nested_state_len >= offsetof(struct kvm_nested_state, data)); + + if (cpu_has_vmx(env) || cpu_has_svm(env)) { +- struct kvm_vmx_nested_state_hdr *vmx_hdr; +- + env->nested_state = g_malloc0(max_nested_state_len); + env->nested_state->size = max_nested_state_len; + +- if (cpu_has_vmx(env)) { +- env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX; +- vmx_hdr = &env->nested_state->hdr.vmx; +- vmx_hdr->vmxon_pa = -1ull; +- vmx_hdr->vmcs12_pa = -1ull; +- } else { +- env->nested_state->format = KVM_STATE_NESTED_FORMAT_SVM; +- } ++ kvm_init_nested_state(env); + } + } + +@@ -2126,6 +2141,8 @@ void kvm_arch_reset_vcpu(X86CPU *cpu) + /* enabled by default */ + env->poll_control_msr = 1; + ++ kvm_init_nested_state(env); ++ + sev_es_set_reset_vector(CPU(cpu)); + } + +-- +2.27.0 + diff --git a/migration-Extend-query-migrate-to-provide-dirty-page.patch b/migration-Extend-query-migrate-to-provide-dirty-page.patch new file mode 100644 index 0000000000000000000000000000000000000000..4c72a4fa356e305b5e08cd1d68c14689ac56f5c4 --- /dev/null +++ b/migration-Extend-query-migrate-to-provide-dirty-page.patch @@ -0,0 +1,176 @@ +From ba8973a75fffa55977dfa12a850827e11081280f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= + +Date: Thu, 8 Jun 2023 00:21:58 +0800 +Subject: [PATCH] migration: Extend query-migrate to provide dirty page limit + info +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There is a conflict when merging patches in qemu-6.2.0, and there is a phenomenon that the corresponding files and functions cannot be found.Merge after modifying the patch by wangguochun@kylinos.cn + +Extend query-migrate to provide throttle time and estimated +ring full time with dirty-limit capability enabled, through which +we can observe if dirty limit take effect during live migration. + +Signed-off-by: Hyman Huang(黄勇) +Reviewed-by: Markus Armbruster +Reviewed-by: Juan Quintela +Message-ID: <168733225273.5845.15871826788879741674-8@git.sr.ht> +Signed-off-by: Juan Quintela +--- + include/sysemu/dirtylimit.h | 2 ++ + migration/migration.c | 10 ++++++++++ + monitor/hmp-cmds.c | 10 ++++++++++ + qapi/migration.json | 16 ++++++++++++++- + softmmu/dirtylimit.c | 39 +++++++++++++++++++++++++++++++++++++ + 5 files changed, 76 insertions(+), 1 deletion(-) + +diff --git a/include/sysemu/dirtylimit.h b/include/sysemu/dirtylimit.h +index 8d2c1f3a6b..d11ebbbbdb 100644 +--- a/include/sysemu/dirtylimit.h ++++ b/include/sysemu/dirtylimit.h +@@ -34,4 +34,6 @@ void dirtylimit_set_vcpu(int cpu_index, + void dirtylimit_set_all(uint64_t quota, + bool enable); + void dirtylimit_vcpu_execute(CPUState *cpu); ++uint64_t dirtylimit_throttle_time_per_round(void); ++uint64_t dirtylimit_ring_full_time(void); + #endif +diff --git a/migration/migration.c b/migration/migration.c +index e6a2e48f7a..3da2ed37f3 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -61,6 +61,7 @@ + #include "sysemu/cpus.h" + #include "yank_functions.h" + #include "sysemu/kvm.h" ++#include "sysemu/dirtylimit.h" + + #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */ + +@@ -1060,6 +1061,15 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s) + info->ram->remaining = ram_bytes_remaining(); + info->ram->dirty_pages_rate = ram_counters.dirty_pages_rate; + } ++ ++ if (migrate_dirty_limit() && dirtylimit_in_service()) { ++ info->has_dirty_limit_throttle_time_per_round = true; ++ info->dirty_limit_throttle_time_per_round = ++ dirtylimit_throttle_time_per_round(); ++ ++ info->has_dirty_limit_ring_full_time = true; ++ info->dirty_limit_ring_full_time = dirtylimit_ring_full_time(); ++ } + } + + static void populate_disk_info(MigrationInfo *info) +diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c +index 01493cd2c0..c139e8087e 100644 +--- a/monitor/hmp-cmds.c ++++ b/monitor/hmp-cmds.c +@@ -339,6 +339,16 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) + info->cpu_throttle_percentage); + } + ++ if (info->has_dirty_limit_throttle_time_per_round) { ++ monitor_printf(mon, "dirty-limit throttle time: %" PRIu64 " us\n", ++ info->dirty_limit_throttle_time_per_round); ++ } ++ ++ if (info->has_dirty_limit_ring_full_time) { ++ monitor_printf(mon, "dirty-limit ring full time: %" PRIu64 " us\n", ++ info->dirty_limit_ring_full_time); ++ } ++ + if (info->has_postcopy_blocktime) { + monitor_printf(mon, "postcopy blocktime: %u\n", + info->postcopy_blocktime); +diff --git a/qapi/migration.json b/qapi/migration.json +index 4751c5ee53..a36a4e943b 100644 +--- a/qapi/migration.json ++++ b/qapi/migration.json +@@ -228,6 +228,18 @@ + # Present and non-empty when migration is blocked. + # (since 6.0) + # ++# @dirty-limit-throttle-time-per-round: Maximum throttle time (in microseconds) of virtual ++# CPUs each dirty ring full round, which shows how ++# MigrationCapability dirty-limit affects the guest ++# during live migration. (since 8.1) ++# ++# @dirty-limit-ring-full-time: Estimated average dirty ring full time (in microseconds) ++# each dirty ring full round, note that the value equals ++# dirty ring memory size divided by average dirty page rate ++# of virtual CPU, which can be used to observe the average ++# memory load of virtual CPU indirectly. Note that zero ++# means guest doesn't dirty memory (since 8.1) ++# + # Since: 0.14 + ## + { 'struct': 'MigrationInfo', +@@ -245,7 +257,9 @@ + '*postcopy-blocktime' : 'uint32', + '*postcopy-vcpu-blocktime': ['uint32'], + '*compression': 'CompressionStats', +- '*socket-address': ['SocketAddress'] } } ++ '*socket-address': ['SocketAddress'], ++ '*dirty-limit-throttle-time-per-round': 'uint64', ++ '*dirty-limit-ring-full-time': 'uint64'} } + + ## + # @query-migrate: +diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c +index a3337c0e20..5e6e5aba67 100644 +--- a/softmmu/dirtylimit.c ++++ b/softmmu/dirtylimit.c +@@ -564,6 +564,45 @@ out: + hmp_handle_error(mon, err); + } + ++/* Return the max throttle time of each virtual CPU */ ++uint64_t dirtylimit_throttle_time_per_round(void) ++{ ++ CPUState *cpu; ++ int64_t max = 0; ++ ++ CPU_FOREACH(cpu) { ++ if (cpu->throttle_us_per_full > max) { ++ max = cpu->throttle_us_per_full; ++ } ++ } ++ ++ return max; ++} ++ ++/* ++ * Estimate average dirty ring full time of each virtaul CPU. ++ * Return 0 if guest doesn't dirty memory. ++ */ ++uint64_t dirtylimit_ring_full_time(void) ++{ ++ CPUState *cpu; ++ uint64_t curr_rate = 0; ++ int nvcpus = 0; ++ ++ CPU_FOREACH(cpu) { ++ if (cpu->running) { ++ nvcpus++; ++ curr_rate += vcpu_dirty_rate_get(cpu->cpu_index); ++ } ++ } ++ ++ if (!curr_rate || !nvcpus) { ++ return 0; ++ } ++ ++ return dirtylimit_dirty_ring_full_time(curr_rate / nvcpus); ++} ++ + static struct DirtyLimitInfo *dirtylimit_query_vcpu(int cpu_index) + { + DirtyLimitInfo *info = NULL; +-- +2.27.0 + diff --git a/migration-Implement-dirty-limit-convergence-algo.patch b/migration-Implement-dirty-limit-convergence-algo.patch new file mode 100644 index 0000000000000000000000000000000000000000..febfe486e3dcd4a08987568e05c54fc066d589ac --- /dev/null +++ b/migration-Implement-dirty-limit-convergence-algo.patch @@ -0,0 +1,183 @@ +From 39cdcd0405657abfd81563d1f3801252e0ea8707 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= + +Date: Thu, 8 Jun 2023 00:12:40 +0800 +Subject: [PATCH] migration: Implement dirty-limit convergence algo +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Implement dirty-limit convergence algo for live migration, +which is kind of like auto-converge algo but using dirty-limit +instead of cpu throttle to make migration convergent. + +Enable dirty page limit if dirty_rate_high_cnt greater than 2 +when dirty-limit capability enabled, Disable dirty-limit if +migration be canceled. + +Note that "set_vcpu_dirty_limit", "cancel_vcpu_dirty_limit" +commands are not allowed during dirty-limit live migration. + +Signed-off-by: Hyman Huang(黄勇) +Reviewed-by: Markus Armbruster +Message-ID: <168733225273.5845.15871826788879741674-7@git.sr.ht> +Reviewed-by: Juan Quintela +Signed-off-by: Juan Quintela +--- + migration/migration.c | 3 +++ + migration/ram.c | 36 ++++++++++++++++++++++++++++++++++++ + migration/trace-events | 1 + + softmmu/dirtylimit.c | 29 +++++++++++++++++++++++++++++ + 4 files changed, 69 insertions(+) + +diff --git a/migration/migration.c b/migration/migration.c +index 50c33fecf3..e6a2e48f7a 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -224,6 +224,9 @@ void migration_cancel(const Error *error) + if (error) { + migrate_set_error(current_migration, error); + } ++ if (migrate_dirty_limit()) { ++ qmp_cancel_vcpu_dirty_limit(false, -1, NULL); ++ } + migrate_fd_cancel(current_migration); + } + +diff --git a/migration/ram.c b/migration/ram.c +index 20f228e6bb..998ee96e63 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -43,6 +43,7 @@ + #include "qapi/error.h" + #include "qapi/qapi-types-migration.h" + #include "qapi/qapi-events-migration.h" ++#include "qapi/qapi-commands-migration.h" + #include "qapi/qmp/qerror.h" + #include "trace.h" + #include "exec/ram_addr.h" +@@ -55,6 +56,8 @@ + #include "qemu/iov.h" + #include "multifd.h" + #include "sysemu/runstate.h" ++#include "sysemu/dirtylimit.h" ++#include "sysemu/kvm.h" + + #include "hw/boards.h" /* for machine_dump_guest_core() */ + +@@ -1399,6 +1402,37 @@ static void migration_update_rates(RAMState *rs, int64_t end_time) + } + } + ++/* ++ * Enable dirty-limit to throttle down the guest ++ */ ++static void migration_dirty_limit_guest(void) ++{ ++ /* ++ * dirty page rate quota for all vCPUs fetched from ++ * migration parameter 'vcpu_dirty_limit' ++ */ ++ static int64_t quota_dirtyrate; ++ MigrationState *s = migrate_get_current(); ++ ++ /* ++ * If dirty limit already enabled and migration parameter ++ * vcpu-dirty-limit untouched. ++ */ ++ if (dirtylimit_in_service() && ++ quota_dirtyrate == s->parameters.vcpu_dirty_limit) { ++ return; ++ } ++ ++ quota_dirtyrate = s->parameters.vcpu_dirty_limit; ++ ++ /* ++ * Set all vCPU a quota dirtyrate, note that the second ++ * parameter will be ignored if setting all vCPU for the vm ++ */ ++ qmp_set_vcpu_dirty_limit(false, -1, quota_dirtyrate, NULL); ++ trace_migration_dirty_limit_guest(quota_dirtyrate); ++} ++ + static void migration_trigger_throttle(RAMState *rs) + { + MigrationState *s = migrate_get_current(); +@@ -1429,6 +1463,8 @@ static void migration_trigger_throttle(RAMState *rs) + trace_migration_throttle(); + mig_throttle_guest_down(bytes_dirty_period, + bytes_dirty_threshold); ++ } else if (migrate_dirty_limit()) { ++ migration_dirty_limit_guest(); + } + } + } +diff --git a/migration/trace-events b/migration/trace-events +index b48d873b8a..246710f488 100644 +--- a/migration/trace-events ++++ b/migration/trace-events +@@ -92,6 +92,7 @@ migration_bitmap_sync_start(void) "" + migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64 + migration_bitmap_clear_dirty(char *str, uint64_t start, uint64_t size, unsigned long page) "rb %s start 0x%"PRIx64" size 0x%"PRIx64" page 0x%lx" + migration_throttle(void) "" ++migration_dirty_limit_guest(int64_t dirtyrate) "guest dirty page rate limit %" PRIi64 " MB/s" + ram_discard_range(const char *rbname, uint64_t start, size_t len) "%s: start: %" PRIx64 " %zx" + ram_load_loop(const char *rbname, uint64_t addr, int flags, void *host) "%s: addr: 0x%" PRIx64 " flags: 0x%x host: %p" + ram_load_postcopy_loop(uint64_t addr, int flags) "@%" PRIx64 " %x" +diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c +index 4d770aaba4..a3337c0e20 100644 +--- a/softmmu/dirtylimit.c ++++ b/softmmu/dirtylimit.c +@@ -435,6 +435,23 @@ static void dirtylimit_cleanup(void) + dirtylimit_state_finalize(); + } + ++/* ++ * dirty page rate limit is not allowed to set if migration ++ * is running with dirty-limit capability enabled. ++ */ ++static bool dirtylimit_is_allowed(void) ++{ ++ MigrationState *ms = migrate_get_current(); ++ ++ if (migration_is_running(ms->state) && ++ (!qemu_thread_is_self(&ms->thread)) && ++ migrate_dirty_limit() && ++ dirtylimit_in_service()) { ++ return false; ++ } ++ return true; ++} ++ + void qmp_cancel_vcpu_dirty_limit(bool has_cpu_index, + int64_t cpu_index, + Error **errp) +@@ -448,6 +465,12 @@ void qmp_cancel_vcpu_dirty_limit(bool has_cpu_index, + return; + } + ++ if (!dirtylimit_is_allowed()) { ++ error_setg(errp, "can't cancel dirty page rate limit while" ++ " migration is running"); ++ return; ++ } ++ + if (!dirtylimit_in_service()) { + return; + } +@@ -498,6 +521,12 @@ void qmp_set_vcpu_dirty_limit(bool has_cpu_index, + return; + } + ++ if (!dirtylimit_is_allowed()) { ++ error_setg(errp, "can't set dirty page rate limit while" ++ " migration is running"); ++ return; ++ } ++ + if (!dirty_rate) { + qmp_cancel_vcpu_dirty_limit(has_cpu_index, cpu_index, errp); + return; +-- +2.27.0 + diff --git a/migration-Introduce-dirty-limit-capability.patch b/migration-Introduce-dirty-limit-capability.patch new file mode 100644 index 0000000000000000000000000000000000000000..79f0c99a493a61fa2d4d2a0da6dac1d7a8588cef --- /dev/null +++ b/migration-Introduce-dirty-limit-capability.patch @@ -0,0 +1,183 @@ +From c7ae0b39eec728d7f88029f932fdd6d3bfda6e68 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= + +Date: Wed, 7 Jun 2023 23:30:50 +0800 +Subject: [PATCH] migration: Introduce dirty-limit capability +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There is a conflict when merging patches in qemu-6.2.0, and there is a phenomenon that the corresponding files and functions cannot be found.Merge after modifying the patch by wangguochun@kylinos.cn + +Introduce migration dirty-limit capability, which can +be turned on before live migration and limit dirty +page rate durty live migration. + +Introduce migrate_dirty_limit function to help check +if dirty-limit capability enabled during live migration. + +Meanwhile, refactor vcpu_dirty_rate_stat_collect +so that period can be configured instead of hardcoded. + +dirty-limit capability is kind of like auto-converge +but using dirty limit instead of traditional cpu-throttle +to throttle guest down. To enable this feature, turn on +the dirty-limit capability before live migration using +migrate-set-capabilities, and set the parameters +"x-vcpu-dirty-limit-period", "vcpu-dirty-limit" suitably +to speed up convergence. + +Signed-off-by: Hyman Huang(黄勇) +Acked-by: Peter Xu +Reviewed-by: Juan Quintela +Message-Id: <168618975839.6361.17407633874747688653-4@git.sr.ht> +Signed-off-by: Juan Quintela +--- + migration/migration.c | 25 +++++++++++++++++++++++++ + migration/migration.h | 1 + + qapi/migration.json | 13 ++++++++++++- + softmmu/dirtylimit.c | 17 +++++++++++++---- + 4 files changed, 51 insertions(+), 5 deletions(-) + +diff --git a/migration/migration.c b/migration/migration.c +index 06d9b6a15d..50c33fecf3 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -60,6 +60,7 @@ + #include "qemu/yank.h" + #include "sysemu/cpus.h" + #include "yank_functions.h" ++#include "sysemu/kvm.h" + + #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */ + +@@ -1265,6 +1266,20 @@ static bool migrate_caps_check(bool *cap_list, + error_setg(errp, "multifd is not supported by current protocol"); + return false; + } ++ ++ if (cap_list[MIGRATION_CAPABILITY_DIRTY_LIMIT]) { ++ if (cap_list[MIGRATION_CAPABILITY_AUTO_CONVERGE]) { ++ error_setg(errp, "dirty-limit conflicts with auto-converge" ++ " either of then available currently"); ++ return false; ++ } ++ ++ if (!kvm_enabled() || !kvm_dirty_ring_enabled()) { ++ error_setg(errp, "dirty-limit requires KVM with accelerator" ++ " property 'dirty-ring-size' set"); ++ return false; ++ } ++ } + + return true; + } +@@ -2550,6 +2565,15 @@ bool migrate_dirty_bitmaps(void) + return s->enabled_capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS]; + } + ++bool migrate_dirty_limit(void) ++{ ++ MigrationState *s; ++ ++ s = migrate_get_current(); ++ ++ return s->enabled_capabilities[MIGRATION_CAPABILITY_DIRTY_LIMIT]; ++} ++ + bool migrate_ignore_shared(void) + { + MigrationState *s; +@@ -4316,6 +4340,7 @@ static Property migration_properties[] = { + DEFINE_PROP_UINT64("vcpu-dirty-limit", MigrationState, + parameters.vcpu_dirty_limit, + DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT), ++ DEFINE_PROP_MIG_CAP("x-dirty-limit", MIGRATION_CAPABILITY_DIRTY_LIMIT), + + /* Migration capabilities */ + DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), +diff --git a/migration/migration.h b/migration/migration.h +index 6b546a6ac7..9ce1fc8ea0 100644 +--- a/migration/migration.h ++++ b/migration/migration.h +@@ -329,6 +329,7 @@ bool migrate_release_ram(void); + bool migrate_postcopy_ram(void); + bool migrate_zero_blocks(void); + bool migrate_dirty_bitmaps(void); ++bool migrate_dirty_limit(void); + bool migrate_ignore_shared(void); + bool migrate_validate_uuid(void); + +diff --git a/qapi/migration.json b/qapi/migration.json +index f35f0377dc..4751c5ee53 100644 +--- a/qapi/migration.json ++++ b/qapi/migration.json +@@ -452,6 +452,16 @@ + # procedure starts. The VM RAM is saved with running VM. + # (since 6.0) + # ++# @dirty-limit: If enabled, migration will use the dirty-limit algo to ++# throttle down guest instead of auto-converge algo. ++# Throttle algo only works when vCPU's dirtyrate greater ++# than 'vcpu-dirty-limit', read processes in guest os ++# aren't penalized any more, so this algo can improve ++# performance of vCPU during live migration. This is an ++# optional performance feature and should not affect the ++# correctness of the existing auto-converge algo. ++# (since 8.1) ++# + # Features: + # @unstable: Members @x-colo and @x-ignore-shared are experimental. + # +@@ -465,7 +475,8 @@ + 'block', 'return-path', 'pause-before-switchover', 'multifd', + 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', + { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, +- 'validate-uuid', 'background-snapshot'] } ++ 'validate-uuid', 'background-snapshot', ++ 'dirty-limit'] } + + ## + # @MigrationCapabilityStatus: +diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c +index 5041c230d0..4d770aaba4 100644 +--- a/softmmu/dirtylimit.c ++++ b/softmmu/dirtylimit.c +@@ -24,6 +24,8 @@ + #include "hw/boards.h" + #include "sysemu/kvm.h" + #include "trace.h" ++#include "migration/misc.h" ++#include "migration/migration.h" + + /* + * Dirtylimit stop working if dirty page rate error +@@ -75,14 +77,21 @@ static bool dirtylimit_quit; + + static void vcpu_dirty_rate_stat_collect(void) + { ++ MigrationState *s = migrate_get_current(); + VcpuStat stat; + int i = 0; ++ int64_t period = DIRTYLIMIT_CALC_TIME_MS; ++ ++ if (migrate_dirty_limit() && ++ migration_is_active(s)) { ++ period = s->parameters.x_vcpu_dirty_limit_period; ++ } + + /* calculate vcpu dirtyrate */ +- vcpu_calculate_dirtyrate(DIRTYLIMIT_CALC_TIME_MS, +- &stat, +- GLOBAL_DIRTY_LIMIT, +- false); ++ vcpu_calculate_dirtyrate(period, ++ &stat, ++ GLOBAL_DIRTY_LIMIT, ++ false); + + for (i = 0; i < stat.nvcpu; i++) { + vcpu_dirty_rate_stat->stat.rates[i].id = i; +-- +2.27.0 + diff --git a/migration-Put-the-detection-logic-before-auto-conver.patch b/migration-Put-the-detection-logic-before-auto-conver.patch new file mode 100644 index 0000000000000000000000000000000000000000..e45bd4797ac763fde7aef6d4f2ff208039cf8b3b --- /dev/null +++ b/migration-Put-the-detection-logic-before-auto-conver.patch @@ -0,0 +1,61 @@ +From 0f564d8940367ccdfb39b33be048f1b85e097e89 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= + +Date: Thu, 15 Jun 2023 21:29:44 +0800 +Subject: [PATCH] migration: Put the detection logic before auto-converge + checking +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This commit is prepared for the implementation of dirty-limit +convergence algo. + +The detection logic of throttling condition can apply to both +auto-converge and dirty-limit algo, putting it's position +before the checking logic for auto-converge feature. + +Signed-off-by: Hyman Huang(黄勇) +Reviewed-by: Juan Quintela +Message-ID: <168733225273.5845.15871826788879741674-6@git.sr.ht> +Signed-off-by: Juan Quintela +--- + migration/ram.c | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +diff --git a/migration/ram.c b/migration/ram.c +index 87e551913c..20f228e6bb 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -1415,17 +1415,18 @@ static void migration_trigger_throttle(RAMState *rs) + return; + } + +- if (migrate_auto_converge()) { +- /* The following detection logic can be refined later. For now: +- Check to see if the ratio between dirtied bytes and the approx. +- amount of bytes that just got transferred since the last time +- we were in this routine reaches the threshold. If that happens +- twice, start or increase throttling. */ +- +- if ((bytes_dirty_period > bytes_dirty_threshold) && +- (++rs->dirty_rate_high_cnt >= 2)) { ++ /* ++ * The following detection logic can be refined later. For now: ++ * Check to see if the ratio between dirtied bytes and the approx. ++ * amount of bytes that just got transferred since the last time ++ * we were in this routine reaches the threshold. If that happens ++ * twice, start or increase throttling. ++ */ ++ if ((bytes_dirty_period > bytes_dirty_threshold) && ++ (++rs->dirty_rate_high_cnt >= 2)) { ++ rs->dirty_rate_high_cnt = 0; ++ if (migrate_auto_converge()) { + trace_migration_throttle(); +- rs->dirty_rate_high_cnt = 0; + mig_throttle_guest_down(bytes_dirty_period, + bytes_dirty_threshold); + } +-- +2.27.0 + diff --git a/migration-Refactor-auto-converge-capability-logic.patch b/migration-Refactor-auto-converge-capability-logic.patch new file mode 100644 index 0000000000000000000000000000000000000000..ecf095ab69ef502f393e545b34aa27049e1a4d36 --- /dev/null +++ b/migration-Refactor-auto-converge-capability-logic.patch @@ -0,0 +1,45 @@ +From b4f95f541ce2d428956508d8ce874377499c200c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= + +Date: Wed, 7 Jun 2023 23:32:51 +0800 +Subject: [PATCH] migration: Refactor auto-converge capability logic +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Check if block migration is running before throttling +guest down in auto-converge way. + +Note that this modification is kind of like code clean, +because block migration does not depend on auto-converge +capability, so the order of checks can be adjusted. + +Signed-off-by: Hyman Huang(黄勇) +Acked-by: Peter Xu +Reviewed-by: Juan Quintela +Message-Id: <168618975839.6361.17407633874747688653-5@git.sr.ht> +Signed-off-by: Juan Quintela +--- + migration/ram.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/migration/ram.c b/migration/ram.c +index c245b04cf2..87e551913c 100644 +--- a/migration/ram.c ++++ b/migration/ram.c +@@ -1411,7 +1411,11 @@ static void migration_trigger_throttle(RAMState *rs) + /* During block migration the auto-converge logic incorrectly detects + * that ram migration makes no progress. Avoid this by disabling the + * throttling logic during the bulk phase of block migration. */ +- if (migrate_auto_converge() && !blk_mig_bulk_active()) { ++ if (blk_mig_bulk_active()) { ++ return; ++ } ++ ++ if (migrate_auto_converge()) { + /* The following detection logic can be refined later. For now: + Check to see if the ratio between dirtied bytes and the approx. + amount of bytes that just got transferred since the last time +-- +2.27.0 + diff --git a/pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch b/pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch new file mode 100644 index 0000000000000000000000000000000000000000..1e08b025808e4551b2a824de5cd3b4111f69eca1 --- /dev/null +++ b/pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch @@ -0,0 +1,60 @@ +From e254e3404d9eedcc028c16933052c3fed37eb651 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Tue, 30 Apr 2024 08:32:41 +0000 +Subject: [PATCH] pc-bios/s390-ccw: Fix booting with logical block size < + physical block size mainline inclusion commit + 393296de19650e1400ca265914cfdeb313725363 category: bugfix + +--------------------------------------------------------------- + +For accessing single blocks during boot, it's the logical block size that +matters. (Physical block sizes are rather interesting e.g. for creating +file systems with the correct alignment for speed reasons etc.). +So the s390-ccw bios has to use the logical block size for calculating +sector numbers during the boot phase, the "physical_block_exp" shift +value must not be taken into account. This change fixes the boot process +when the guest hast been installed on a disk where the logical block size +differs from the physical one, e.g. if the guest has been installed +like this: + + qemu-system-s390x -nographic -accel kvm -m 2G \ + -drive if=none,id=d1,file=fedora.iso,format=raw,media=cdrom \ + -device virtio-scsi -device scsi-cd,drive=d1 \ + -drive if=none,id=d2,file=test.qcow2,format=qcow2 + -device virtio-blk,drive=d2,physical_block_size=4096,logical_block_size=512 + +Linux correctly uses the logical block size of 512 for the installation, +but the s390-ccw bios tries to boot from a disk with 4096 block size so +far, as long as this patch has not been applied yet (well, it used to work +by accident in the past due to the virtio_assume_scsi() hack that used to +enforce 512 byte sectors on all virtio-block disks, but that hack has been +well removed in commit 5447de2619050a0a4d to fix other scenarios). + +Fixes: 5447de2619 ("pc-bios/s390-ccw/virtio-blkdev: Remove virtio_assume_scsi()") +Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2112303 +Message-Id: <20220805094214.285223-1-thuth@redhat.com> +Reviewed-by: Cornelia Huck +Reviewed-by: Eric Farman +Signed-off-by: Thomas Huth + +Signed-off-by: tangbinzy +--- + pc-bios/s390-ccw/virtio-blkdev.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c +index 7d35050292..263a84d391 100644 +--- a/pc-bios/s390-ccw/virtio-blkdev.c ++++ b/pc-bios/s390-ccw/virtio-blkdev.c +@@ -214,7 +214,7 @@ int virtio_get_block_size(void) + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: +- return vdev->config.blk.blk_size << vdev->config.blk.physical_block_exp; ++ return vdev->config.blk.blk_size; + case VIRTIO_ID_SCSI: + return vdev->scsi_block_size; + } +-- +2.27.0 + diff --git a/qapi-migration-Introduce-vcpu-dirty-limit-parameters.patch b/qapi-migration-Introduce-vcpu-dirty-limit-parameters.patch new file mode 100644 index 0000000000000000000000000000000000000000..a66bf9f0989163dd50d07cb7ee05e6099ebf12b0 --- /dev/null +++ b/qapi-migration-Introduce-vcpu-dirty-limit-parameters.patch @@ -0,0 +1,200 @@ +From 52201bf437125bb73deb8945491f7f823bdeb64a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= + +Date: Wed, 7 Jun 2023 22:58:32 +0800 +Subject: [PATCH] qapi/migration: Introduce vcpu-dirty-limit parameters +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There is a conflict when merging patches in qemu-6.2.0, and there is a phenomenon that the corresponding files and functions cannot be found.Merge after modifying the patch by wangguochun@kylinos.cn + +Introduce "vcpu-dirty-limit" migration parameter used +to limit dirty page rate during live migration. + +"vcpu-dirty-limit" and "x-vcpu-dirty-limit-period" are +two dirty-limit-related migration parameters, which can +be set before and during live migration by qmp +migrate-set-parameters. + +This two parameters are used to help implement the dirty +page rate limit algo of migration. + +Signed-off-by: Hyman Huang(黄勇) +Acked-by: Peter Xu +Reviewed-by: Juan Quintela +Message-Id: <168618975839.6361.17407633874747688653-3@git.sr.ht> +Signed-off-by: Juan Quintela +--- + migration/migration.c | 21 +++++++++++++++++++++ + monitor/hmp-cmds.c | 8 ++++++++ + qapi/migration.json | 18 +++++++++++++++--- + 3 files changed, 44 insertions(+), 3 deletions(-) + +diff --git a/migration/migration.c b/migration/migration.c +index 9672266e16..06d9b6a15d 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -117,6 +117,7 @@ + #define DEFAULT_MIGRATE_ANNOUNCE_STEP 100 + + #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD 1000 /* milliseconds */ ++#define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT 1 /* MB/s */ + + static NotifierList migration_state_notifiers = + NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); +@@ -920,6 +921,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) + + params->has_x_vcpu_dirty_limit_period = true; + params->x_vcpu_dirty_limit_period = s->parameters.x_vcpu_dirty_limit_period; ++ params->has_vcpu_dirty_limit = true; ++ params->vcpu_dirty_limit = s->parameters.vcpu_dirty_limit; + + return params; + } +@@ -1513,6 +1516,14 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp) + return false; + } + ++ if (params->has_vcpu_dirty_limit && ++ (params->vcpu_dirty_limit < 1)) { ++ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, ++ "vcpu_dirty_limit", ++ "is invalid, it must greater then 1 MB/s"); ++ return false; ++ } ++ + return true; + } + +@@ -1621,6 +1632,9 @@ static void migrate_params_test_apply(MigrateSetParameters *params, + dest->x_vcpu_dirty_limit_period = + params->x_vcpu_dirty_limit_period; + } ++ if (params->has_vcpu_dirty_limit) { ++ dest->vcpu_dirty_limit = params->vcpu_dirty_limit; ++ } + } + + static void migrate_params_apply(MigrateSetParameters *params, Error **errp) +@@ -1752,6 +1766,9 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) + s->parameters.x_vcpu_dirty_limit_period = + params->x_vcpu_dirty_limit_period; + } ++ if (params->has_vcpu_dirty_limit) { ++ s->parameters.vcpu_dirty_limit = params->vcpu_dirty_limit; ++ } + } + + void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) +@@ -4296,6 +4313,9 @@ static Property migration_properties[] = { + DEFINE_PROP_UINT64("x-vcpu-dirty-limit-period", MigrationState, + parameters.x_vcpu_dirty_limit_period, + DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD), ++ DEFINE_PROP_UINT64("vcpu-dirty-limit", MigrationState, ++ parameters.vcpu_dirty_limit, ++ DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT), + + /* Migration capabilities */ + DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), +@@ -4372,6 +4392,7 @@ void migrate_params_init(MigrationParameters *params) + params->has_announce_rounds = true; + params->has_announce_step = true; + params->has_x_vcpu_dirty_limit_period = true; ++ params->has_vcpu_dirty_limit = true; + } + + +diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c +index 680696ddd5..01493cd2c0 100644 +--- a/monitor/hmp-cmds.c ++++ b/monitor/hmp-cmds.c +@@ -520,6 +520,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) + monitor_printf(mon, "%s: %" PRIu64 " ms\n", + MigrationParameter_str(MIGRATION_PARAMETER_X_VCPU_DIRTY_LIMIT_PERIOD), + params->x_vcpu_dirty_limit_period); ++ ++ monitor_printf(mon, "%s: %" PRIu64 " MB/s\n", ++ MigrationParameter_str(MIGRATION_PARAMETER_VCPU_DIRTY_LIMIT), ++ params->vcpu_dirty_limit); + } + + qapi_free_MigrationParameters(params); +@@ -1353,6 +1357,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) + p->has_x_vcpu_dirty_limit_period = true; + visit_type_size(v, param, &p->x_vcpu_dirty_limit_period, &err); + break; ++ case MIGRATION_PARAMETER_VCPU_DIRTY_LIMIT: ++ p->has_vcpu_dirty_limit = true; ++ visit_type_size(v, param, &p->vcpu_dirty_limit, &err); ++ break; + default: + assert(0); + } +diff --git a/qapi/migration.json b/qapi/migration.json +index b7dc85f7c1..f35f0377dc 100644 +--- a/qapi/migration.json ++++ b/qapi/migration.json +@@ -770,6 +770,9 @@ + # live migration. Should be in the range 1 to 1000ms, + # defaults to 1000ms. (Since 8.1) + # ++# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration. ++# Defaults to 1. (Since 8.1) ++# + # Features: + # @unstable: Members @x-checkpoint-delay and @x-vcpu-dirty-limit-period + # are experimental. +@@ -791,7 +794,8 @@ + 'max-cpu-throttle', 'multifd-compression', + 'multifd-zlib-level', 'multifd-zstd-level', + 'block-bitmap-mapping', +- { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] } ] } ++ { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] }, ++ 'vcpu-dirty-limit'] } + + ## + # @MigrateSetParameters: +@@ -943,6 +947,9 @@ + # live migration. Should be in the range 1 to 1000ms, + # defaults to 1000ms. (Since 8.1) + # ++# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration. ++# Defaults to 1. (Since 8.1) ++# + # Features: + # @unstable: Members @x-checkpoint-delay and @x-vcpu-dirty-limit-period + # are experimental. +@@ -982,7 +989,8 @@ + '*multifd-zstd-level': 'uint8', + '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ], + '*x-vcpu-dirty-limit-period': { 'type': 'uint64', +- 'features': [ 'unstable' ] } } } ++ 'features': [ 'unstable' ] }, ++ '*vcpu-dirty-limit': 'uint64'} } + + ## + # @migrate-set-parameters: +@@ -1154,6 +1162,9 @@ + # live migration. Should be in the range 1 to 1000ms, + # defaults to 1000ms. (Since 8.1) + # ++# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration. ++# Defaults to 1. (Since 8.1) ++# + # Features: + # @unstable: Members @x-checkpoint-delay and @x-vcpu-dirty-limit-period + # are experimental. +@@ -1191,7 +1202,8 @@ + '*multifd-zstd-level': 'uint8', + '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ], + '*x-vcpu-dirty-limit-period': { 'type': 'uint64', +- 'features': [ 'unstable' ] } } } ++ 'features': [ 'unstable' ] }, ++ '*vcpu-dirty-limit': 'uint64'} } + + ## + # @query-migrate-parameters: +-- +2.27.0 + diff --git a/qapi-migration-Introduce-x-vcpu-dirty-limit-period-p.patch b/qapi-migration-Introduce-x-vcpu-dirty-limit-period-p.patch new file mode 100644 index 0000000000000000000000000000000000000000..5a3427da98bc7d1f546fbf72ac1c0b4ee5e422ed --- /dev/null +++ b/qapi-migration-Introduce-x-vcpu-dirty-limit-period-p.patch @@ -0,0 +1,273 @@ +From 6a9933b302c0fb396c6ede78fdef75385e1436e0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= + +Date: Wed, 7 Jun 2023 21:32:59 +0800 +Subject: [PATCH] qapi/migration: Introduce x-vcpu-dirty-limit-period parameter +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There is a conflict when merging patches in qemu-6.2.0, and there is a phenomenon that the corresponding files and functions cannot be found.Merge after modifying the patch by wangguochun@kylinos.cn + +Introduce "x-vcpu-dirty-limit-period" migration experimental +parameter, which is in the range of 1 to 1000ms and used to +make dirtyrate calculation period configurable. + +Currently with the "x-vcpu-dirty-limit-period" varies, the +total time of live migration changes, test results show the +optimal value of "x-vcpu-dirty-limit-period" ranges from +500ms to 1000 ms. "x-vcpu-dirty-limit-period" should be made +stable once it proves best value can not be determined with +developer's experiments. + +Signed-off-by: Hyman Huang(黄勇) +Reviewed-by: Markus Armbruster +Reviewed-by: Juan Quintela +Message-Id: <168618975839.6361.17407633874747688653-2@git.sr.ht> +Signed-off-by: Juan Quintela +--- + migration/migration.c | 53 +++++++++++++++++++++++++++++++++++-------- + migration/migration.h | 1 + + monitor/hmp-cmds.c | 8 +++++++ + qapi/migration.json | 35 +++++++++++++++++++++------- + 4 files changed, 79 insertions(+), 18 deletions(-) + +diff --git a/migration/migration.c b/migration/migration.c +index 7ca5b58839..9672266e16 100644 +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -116,6 +116,8 @@ + #define DEFAULT_MIGRATE_ANNOUNCE_ROUNDS 5 + #define DEFAULT_MIGRATE_ANNOUNCE_STEP 100 + ++#define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD 1000 /* milliseconds */ ++ + static NotifierList migration_state_notifiers = + NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); + +@@ -916,6 +918,9 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) + s->parameters.block_bitmap_mapping); + } + ++ params->has_x_vcpu_dirty_limit_period = true; ++ params->x_vcpu_dirty_limit_period = s->parameters.x_vcpu_dirty_limit_period; ++ + return params; + } + +@@ -1499,6 +1504,15 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp) + return false; + } + ++ if (params->has_x_vcpu_dirty_limit_period && ++ (params->x_vcpu_dirty_limit_period < 1 || ++ params->x_vcpu_dirty_limit_period > 1000)) { ++ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, ++ "x-vcpu-dirty-limit-period", ++ "a value between 1 and 1000"); ++ return false; ++ } ++ + return true; + } + +@@ -1602,6 +1616,11 @@ static void migrate_params_test_apply(MigrateSetParameters *params, + dest->has_block_bitmap_mapping = true; + dest->block_bitmap_mapping = params->block_bitmap_mapping; + } ++ ++ if (params->has_x_vcpu_dirty_limit_period) { ++ dest->x_vcpu_dirty_limit_period = ++ params->x_vcpu_dirty_limit_period; ++ } + } + + static void migrate_params_apply(MigrateSetParameters *params, Error **errp) +@@ -1728,6 +1747,11 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) + QAPI_CLONE(BitmapMigrationNodeAliasList, + params->block_bitmap_mapping); + } ++ ++ if (params->has_x_vcpu_dirty_limit_period) { ++ s->parameters.x_vcpu_dirty_limit_period = ++ params->x_vcpu_dirty_limit_period; ++ } + } + + void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) +@@ -4269,6 +4293,9 @@ static Property migration_properties[] = { + DEFINE_PROP_SIZE("announce-step", MigrationState, + parameters.announce_step, + DEFAULT_MIGRATE_ANNOUNCE_STEP), ++ DEFINE_PROP_UINT64("x-vcpu-dirty-limit-period", MigrationState, ++ parameters.x_vcpu_dirty_limit_period, ++ DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD), + + /* Migration capabilities */ + DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), +@@ -4315,17 +4342,8 @@ static void migration_instance_finalize(Object *obj) + error_free(ms->error); + } + +-static void migration_instance_init(Object *obj) ++void migrate_params_init(MigrationParameters *params) + { +- MigrationState *ms = MIGRATION_OBJ(obj); +- MigrationParameters *params = &ms->parameters; +- +- ms->state = MIGRATION_STATUS_NONE; +- ms->mbps = -1; +- ms->pages_per_second = -1; +- qemu_sem_init(&ms->pause_sem, 0); +- qemu_mutex_init(&ms->error_mutex); +- + params->tls_hostname = g_strdup(""); + params->tls_creds = g_strdup(""); + +@@ -4353,6 +4371,21 @@ static void migration_instance_init(Object *obj) + params->has_announce_max = true; + params->has_announce_rounds = true; + params->has_announce_step = true; ++ params->has_x_vcpu_dirty_limit_period = true; ++} ++ ++ ++static void migration_instance_init(Object *obj) ++{ ++ MigrationState *ms = MIGRATION_OBJ(obj); ++ ++ ms->state = MIGRATION_STATUS_NONE; ++ ms->mbps = -1; ++ ms->pages_per_second = -1; ++ qemu_sem_init(&ms->pause_sem, 0); ++ qemu_mutex_init(&ms->error_mutex); ++ ++ migrate_params_init(&ms->parameters); + + qemu_sem_init(&ms->postcopy_pause_sem, 0); + qemu_sem_init(&ms->postcopy_pause_rp_sem, 0); +diff --git a/migration/migration.h b/migration/migration.h +index a87fd54d10..6b546a6ac7 100644 +--- a/migration/migration.h ++++ b/migration/migration.h +@@ -317,6 +317,7 @@ bool migration_is_setup_or_active(int state); + bool migration_is_running(int state); + + void migrate_init(MigrationState *s); ++void migrate_params_init(MigrationParameters *params); + bool migration_is_blocked(Error **errp); + /* True if outgoing migration has entered postcopy phase */ + bool migration_in_postcopy(void); +diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c +index 5246c82e14..680696ddd5 100644 +--- a/monitor/hmp-cmds.c ++++ b/monitor/hmp-cmds.c +@@ -516,6 +516,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) + } + } + } ++ ++ monitor_printf(mon, "%s: %" PRIu64 " ms\n", ++ MigrationParameter_str(MIGRATION_PARAMETER_X_VCPU_DIRTY_LIMIT_PERIOD), ++ params->x_vcpu_dirty_limit_period); + } + + qapi_free_MigrationParameters(params); +@@ -1345,6 +1349,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) + error_setg(&err, "The block-bitmap-mapping parameter can only be set " + "through QMP"); + break; ++ case MIGRATION_PARAMETER_X_VCPU_DIRTY_LIMIT_PERIOD: ++ p->has_x_vcpu_dirty_limit_period = true; ++ visit_type_size(v, param, &p->x_vcpu_dirty_limit_period, &err); ++ break; + default: + assert(0); + } +diff --git a/qapi/migration.json b/qapi/migration.json +index e965f4329b..b7dc85f7c1 100644 +--- a/qapi/migration.json ++++ b/qapi/migration.json +@@ -766,9 +766,13 @@ + # block device name if there is one, and to their node name + # otherwise. (Since 5.2) + # +-# Features: +-# @unstable: Member @x-checkpoint-delay is experimental. ++# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty limit during ++# live migration. Should be in the range 1 to 1000ms, ++# defaults to 1000ms. (Since 8.1) + # ++# Features: ++# @unstable: Members @x-checkpoint-delay and @x-vcpu-dirty-limit-period ++# are experimental. + # Since: 2.4 + ## + { 'enum': 'MigrationParameter', +@@ -785,8 +789,9 @@ + 'multifd-channels', + 'xbzrle-cache-size', 'max-postcopy-bandwidth', + 'max-cpu-throttle', 'multifd-compression', +- 'multifd-zlib-level' ,'multifd-zstd-level', +- 'block-bitmap-mapping' ] } ++ 'multifd-zlib-level', 'multifd-zstd-level', ++ 'block-bitmap-mapping', ++ { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] } ] } + + ## + # @MigrateSetParameters: +@@ -934,8 +939,13 @@ + # block device name if there is one, and to their node name + # otherwise. (Since 5.2) + # ++# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty limit during ++# live migration. Should be in the range 1 to 1000ms, ++# defaults to 1000ms. (Since 8.1) ++# + # Features: +-# @unstable: Member @x-checkpoint-delay is experimental. ++# @unstable: Members @x-checkpoint-delay and @x-vcpu-dirty-limit-period ++# are experimental. + # + # Since: 2.4 + ## +@@ -970,7 +980,9 @@ + '*multifd-compression': 'MultiFDCompression', + '*multifd-zlib-level': 'uint8', + '*multifd-zstd-level': 'uint8', +- '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } } ++ '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ], ++ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', ++ 'features': [ 'unstable' ] } } } + + ## + # @migrate-set-parameters: +@@ -1138,8 +1150,13 @@ + # block device name if there is one, and to their node name + # otherwise. (Since 5.2) + # ++# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty limit during ++# live migration. Should be in the range 1 to 1000ms, ++# defaults to 1000ms. (Since 8.1) ++# + # Features: +-# @unstable: Member @x-checkpoint-delay is experimental. ++# @unstable: Members @x-checkpoint-delay and @x-vcpu-dirty-limit-period ++# are experimental. + # + # Since: 2.4 + ## +@@ -1172,7 +1189,9 @@ + '*multifd-compression': 'MultiFDCompression', + '*multifd-zlib-level': 'uint8', + '*multifd-zstd-level': 'uint8', +- '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } } ++ '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ], ++ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', ++ 'features': [ 'unstable' ] } } } + + ## + # @query-migrate-parameters: +-- +2.27.0 + diff --git a/qemu.spec b/qemu.spec index ca2f21a66e6e7a87266d7301292df5cb3a215ef4..d4b1dec965526839fc607cd5c28ead987b9ee34b 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Name: qemu Version: 6.2.0 -Release: 91 +Release: 92 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 @@ -938,6 +938,32 @@ Patch0923: hw-virtio-Introduce-virtio_bh_new_guarded-helper.patch Patch0924: hw-display-virtio-gpu-Protect-from-DMA-re-entrancy-b.patch Patch0925: hw-char-virtio-serial-bus-Protect-from-DMA-re-entran.patch Patch0926: hw-virtio-virtio-crypto-Protect-from-DMA-re-entrancy.patch +Patch0927: pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch +Patch0928: target-i386-display-deprecation-status-in-cpu-help.patch +Patch0929: target-s390x-display-deprecation-status-in-cpu-help.patch +Patch0930: hw-virtio-handle-un-configured-shutdown-in-virtio-pc.patch +Patch0931: target-i386-Introduce-Icelake-Server-v7-to-enable-TS.patch +Patch0932: target-i386-Add-new-CPU-model-SierraForest.patch +Patch0933: target-i386-Export-RFDS-bit-to-guests.patch +Patch0934: vfio-pci-Add-Ascend310b-scend910b-support.patch +Patch0935: dbus-vmstate-Restrict-error-checks-to-registered-pro.patch +Patch0936: esp-Handle-CMD_BUSRESET-by-resetting-the-SCSI-bus.patch +Patch0937: i386-reset-KVM-nested-state-upon-CPU-reset.patch +Patch0938: KVM-dirty-ring-add-missing-memory-barrier.patch +Patch0939: chardev-char-socket-Update-AF_UNIX-for-Windows.patch +Patch0940: tpm_emulator-Avoid-double-initialization-during-migr.patch +Patch0941: Allow-UNIX-socket-option-for-VNC-websocket.patch +Patch0942: Change-the-value-of-no_ged-from-true-to-false.patch +Patch0943: qapi-migration-Introduce-x-vcpu-dirty-limit-period-p.patch +Patch0944: qapi-migration-Introduce-vcpu-dirty-limit-parameters.patch +Patch0945: migration-Introduce-dirty-limit-capability.patch +Patch0946: migration-Refactor-auto-converge-capability-logic.patch +Patch0947: migration-Put-the-detection-logic-before-auto-conver.patch +Patch0948: migration-Implement-dirty-limit-convergence-algo.patch +Patch0949: migration-Extend-query-migrate-to-provide-dirty-page.patch +Patch0950: docs-system-target-arm-Re-alphabetize-board-list.patch +Patch0951: target-ppc-Remove-msr_pr-macro.patch +Patch0952: s390x-sclp-Simplify-get_sclp_device.patch BuildRequires: flex BuildRequires: gcc @@ -1536,6 +1562,34 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Thu Jun 13 2024 - 10:6.2.0-92 +- s390x/sclp: Simplify get_sclp_device() +- target/ppc: Remove msr_pr macro +- docs/system/target-arm: Re-alphabetize board list +- migration: Extend query-migrate to provide dirty page limit info +- migration: Implement dirty-limit convergence algo +- migration: Put the detection logic before auto-converge checking +- migration: Refactor auto-converge capability logic +- migration: Introduce dirty-limit capability +- qapi/migration: Introduce vcpu-dirty-limit parameters +- qapi/migration: Introduce x-vcpu-dirty-limit-period parameter +- Change the value of no_ged from true to false +- Allow UNIX socket option for VNC websocket +- tpm_emulator: Avoid double initialization during +- chardev/char-socket: Update AF_UNIX for Windows +- KVM: dirty ring: add missing memory barrier +- i386: reset KVM nested state upon CPU reset +- esp: Handle CMD_BUSRESET by resetting the SCSI bus +- dbus-vmstate: Restrict error checks to registered proxies in dbus_get_proxies +- vfio/pci: Add Ascend310b scend910b support +- target/i386: Export RFDS bit to guests +- target/i386: Add new CPU model SierraForest +- target/i386: Introduce Icelake-Server-v7 to enable TSX +- hw/virtio: handle un-configured shutdown in virtio-pci +- target/s390x: display deprecation status in '-cpu help' +- target/i386: display deprecation status in '-cpu help' +- pc-bios/s390-ccw: Fix booting with logical block size < physical block size + * Mon Apr 22 2024 - 10:6.2.0-91 - hw/virtio/virtio-crypto: Protect from DMA re-entrancy bugs(CVE-2024-3446) - hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs(CVE-2024-3446) diff --git a/s390x-sclp-Simplify-get_sclp_device.patch b/s390x-sclp-Simplify-get_sclp_device.patch new file mode 100644 index 0000000000000000000000000000000000000000..839a659f0237daa48831b3fd5351d9634c867dd8 --- /dev/null +++ b/s390x-sclp-Simplify-get_sclp_device.patch @@ -0,0 +1,46 @@ +From d25446c995e2c562d62d832bc8da58d13b731974 Mon Sep 17 00:00:00 2001 +From: dinglimin +Date: Mon, 10 Jun 2024 20:00:42 +0800 +Subject: [PATCH] s390x/sclp: Simplify get_sclp_device() cheery-pick from + 3d9836e46dbe1e46c39fe76a62d3085a71ddbf7a get_sclp_device() scans the whole + machine to find a TYPE_SCLP object. Now that the SCLPDevice instance is + available under the machine state, use it to simplify the lookup. While at + it, remove the inline to let the compiler decide on how to optimize. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Cédric Le Goater +Message-ID: <20240502131533.377719-4-clg@redhat.com> +Reviewed-by: Thomas Huth +Signed-off-by: Thomas Huth + +Signed-off-by: dinglimin +--- + hw/s390x/sclp.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c +index 89c30a8a91..24e29e8cda 100644 +--- a/hw/s390x/sclp.c ++++ b/hw/s390x/sclp.c +@@ -20,13 +20,14 @@ + #include "hw/s390x/event-facility.h" + #include "hw/s390x/s390-pci-bus.h" + #include "hw/s390x/ipl.h" ++#include "hw/s390x/s390-virtio-ccw.h" + +-static inline SCLPDevice *get_sclp_device(void) ++static SCLPDevice *get_sclp_device(void) + { + static SCLPDevice *sclp; + + if (!sclp) { +- sclp = SCLP(object_resolve_path_type("", TYPE_SCLP, NULL)); ++ sclp = S390_CCW_MACHINE(qdev_get_machine())->sclp; + } + return sclp; + } +-- +2.27.0 + diff --git a/target-i386-Add-new-CPU-model-SierraForest.patch b/target-i386-Add-new-CPU-model-SierraForest.patch new file mode 100644 index 0000000000000000000000000000000000000000..657e14e80f8ca669d0c5c7cbe79c97271b8866fb --- /dev/null +++ b/target-i386-Add-new-CPU-model-SierraForest.patch @@ -0,0 +1,212 @@ +From f315e08911bcfdbbb287aa35453acc71867ccd1e Mon Sep 17 00:00:00 2001 +From: Tao Su +Date: Wed, 20 Mar 2024 10:10:44 +0800 +Subject: [PATCH] target/i386: Add new CPU model SierraForest +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +commit 6e82d3b6220777667968a04c87e1667f164ebe88 upstream. + +According to table 1-2 in Intel Architecture Instruction Set Extensions and +Future Features (rev 051) [1], SierraForest has the following new features +which have already been virtualized: + +- CMPCCXADD CPUID.(EAX=7,ECX=1):EAX[bit 7] +- AVX-IFMA CPUID.(EAX=7,ECX=1):EAX[bit 23] +- AVX-VNNI-INT8 CPUID.(EAX=7,ECX=1):EDX[bit 4] +- AVX-NE-CONVERT CPUID.(EAX=7,ECX=1):EDX[bit 5] + +Add above features to new CPU model SierraForest. Comparing with GraniteRapids +CPU model, SierraForest bare-metal removes the following features: + +- HLE CPUID.(EAX=7,ECX=0):EBX[bit 4] +- RTM CPUID.(EAX=7,ECX=0):EBX[bit 11] +- AVX512F CPUID.(EAX=7,ECX=0):EBX[bit 16] +- AVX512DQ CPUID.(EAX=7,ECX=0):EBX[bit 17] +- AVX512_IFMA CPUID.(EAX=7,ECX=0):EBX[bit 21] +- AVX512CD CPUID.(EAX=7,ECX=0):EBX[bit 28] +- AVX512BW CPUID.(EAX=7,ECX=0):EBX[bit 30] +- AVX512VL CPUID.(EAX=7,ECX=0):EBX[bit 31] +- AVX512_VBMI CPUID.(EAX=7,ECX=0):ECX[bit 1] +- AVX512_VBMI2 CPUID.(EAX=7,ECX=0):ECX[bit 6] +- AVX512_VNNI CPUID.(EAX=7,ECX=0):ECX[bit 11] +- AVX512_BITALG CPUID.(EAX=7,ECX=0):ECX[bit 12] +- AVX512_VPOPCNTDQ CPUID.(EAX=7,ECX=0):ECX[bit 14] +- LA57 CPUID.(EAX=7,ECX=0):ECX[bit 16] +- TSXLDTRK CPUID.(EAX=7,ECX=0):EDX[bit 16] +- AMX-BF16 CPUID.(EAX=7,ECX=0):EDX[bit 22] +- AVX512_FP16 CPUID.(EAX=7,ECX=0):EDX[bit 23] +- AMX-TILE CPUID.(EAX=7,ECX=0):EDX[bit 24] +- AMX-INT8 CPUID.(EAX=7,ECX=0):EDX[bit 25] +- AVX512_BF16 CPUID.(EAX=7,ECX=1):EAX[bit 5] +- fast zero-length MOVSB CPUID.(EAX=7,ECX=1):EAX[bit 10] +- fast short CMPSB, SCASB CPUID.(EAX=7,ECX=1):EAX[bit 12] +- AMX-FP16 CPUID.(EAX=7,ECX=1):EAX[bit 21] +- PREFETCHI CPUID.(EAX=7,ECX=1):EDX[bit 14] +- XFD CPUID.(EAX=0xD,ECX=1):EAX[bit 4] +- EPT_PAGE_WALK_LENGTH_5 VMX_EPT_VPID_CAP(0x48c)[bit 7] + +Add all features of GraniteRapids CPU model except above features to +SierraForest CPU model. + +SierraForest doesn’t support TSX and RTM but supports TAA_NO. When RTM is +not enabled in host, KVM will not report TAA_NO. So, just don't include +TAA_NO in SierraForest CPU model. + +[1] https://cdrdv2.intel.com/v1/dl/getContent/671368 + +Intel-SIG: commit 6e82d3b62207 target/i386: Add new CPU model SierraForest. +6.2.0-Add SRF CPU module support + +Reviewed-by: Zhao Liu +Reviewed-by: Xiaoyao Li +Signed-off-by: Tao Su +Message-ID: <20240320021044.508263-1-tao1.su@linux.intel.com> +Signed-off-by: Paolo Bonzini +[ Quanxian Wang: amend commit log ] +Signed-off-by: Quanxian Wang +--- + target/i386/cpu.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 126 insertions(+) + +diff --git a/target/i386/cpu.c b/target/i386/cpu.c +index b5bf5ce7aa..eb7fda0299 100644 +--- a/target/i386/cpu.c ++++ b/target/i386/cpu.c +@@ -3893,6 +3893,132 @@ static const X86CPUDefinition builtin_x86_defs[] = { + { /* end of list */ }, + }, + }, ++ { ++ .name = "SierraForest", ++ .level = 0x23, ++ .vendor = CPUID_VENDOR_INTEL, ++ .family = 6, ++ .model = 175, ++ .stepping = 0, ++ /* ++ * please keep the ascending order so that we can have a clear view of ++ * bit position of each feature. ++ */ ++ .features[FEAT_1_EDX] = ++ CPUID_FP87 | CPUID_VME | CPUID_DE | CPUID_PSE | CPUID_TSC | ++ CPUID_MSR | CPUID_PAE | CPUID_MCE | CPUID_CX8 | CPUID_APIC | ++ CPUID_SEP | CPUID_MTRR | CPUID_PGE | CPUID_MCA | CPUID_CMOV | ++ CPUID_PAT | CPUID_PSE36 | CPUID_CLFLUSH | CPUID_MMX | CPUID_FXSR | ++ CPUID_SSE | CPUID_SSE2, ++ .features[FEAT_1_ECX] = ++ CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSSE3 | ++ CPUID_EXT_FMA | CPUID_EXT_CX16 | CPUID_EXT_PCID | CPUID_EXT_SSE41 | ++ CPUID_EXT_SSE42 | CPUID_EXT_X2APIC | CPUID_EXT_MOVBE | ++ CPUID_EXT_POPCNT | CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_AES | ++ CPUID_EXT_XSAVE | CPUID_EXT_AVX | CPUID_EXT_F16C | CPUID_EXT_RDRAND, ++ .features[FEAT_8000_0001_EDX] = ++ CPUID_EXT2_SYSCALL | CPUID_EXT2_NX | CPUID_EXT2_PDPE1GB | ++ CPUID_EXT2_RDTSCP | CPUID_EXT2_LM, ++ .features[FEAT_8000_0001_ECX] = ++ CPUID_EXT3_LAHF_LM | CPUID_EXT3_ABM | CPUID_EXT3_3DNOWPREFETCH, ++ .features[FEAT_8000_0008_EBX] = ++ CPUID_8000_0008_EBX_WBNOINVD, ++ .features[FEAT_7_0_EBX] = ++ CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 | ++ CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | ++ CPUID_7_0_EBX_INVPCID | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | ++ CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSHOPT | CPUID_7_0_EBX_CLWB | ++ CPUID_7_0_EBX_SHA_NI, ++ .features[FEAT_7_0_ECX] = ++ CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU | CPUID_7_0_ECX_GFNI | ++ CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ | ++ CPUID_7_0_ECX_RDPID | CPUID_7_0_ECX_BUS_LOCK_DETECT, ++ .features[FEAT_7_0_EDX] = ++ CPUID_7_0_EDX_FSRM | CPUID_7_0_EDX_SERIALIZE | ++ CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_ARCH_CAPABILITIES | ++ CPUID_7_0_EDX_SPEC_CTRL_SSBD, ++ .features[FEAT_ARCH_CAPABILITIES] = ++ MSR_ARCH_CAP_RDCL_NO | MSR_ARCH_CAP_IBRS_ALL | ++ MSR_ARCH_CAP_SKIP_L1DFL_VMENTRY | MSR_ARCH_CAP_MDS_NO | ++ MSR_ARCH_CAP_PSCHANGE_MC_NO | MSR_ARCH_CAP_SBDR_SSDP_NO | ++ MSR_ARCH_CAP_FBSDP_NO | MSR_ARCH_CAP_PSDP_NO | ++ MSR_ARCH_CAP_PBRSB_NO, ++ .features[FEAT_XSAVE] = ++ CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | ++ CPUID_XSAVE_XGETBV1 | CPUID_XSAVE_XSAVES, ++ .features[FEAT_6_EAX] = ++ CPUID_6_EAX_ARAT, ++ .features[FEAT_7_1_EAX] = ++ CPUID_7_1_EAX_AVX_VNNI | CPUID_7_1_EAX_CMPCCXADD | ++ CPUID_7_1_EAX_FSRS | CPUID_7_1_EAX_AVX_IFMA, ++ .features[FEAT_7_1_EDX] = ++ CPUID_7_1_EDX_AVX_VNNI_INT8 | CPUID_7_1_EDX_AVX_NE_CONVERT, ++ .features[FEAT_7_2_EDX] = ++ CPUID_7_2_EDX_MCDT_NO, ++ .features[FEAT_VMX_BASIC] = ++ MSR_VMX_BASIC_INS_OUTS | MSR_VMX_BASIC_TRUE_CTLS, ++ .features[FEAT_VMX_ENTRY_CTLS] = ++ VMX_VM_ENTRY_LOAD_DEBUG_CONTROLS | VMX_VM_ENTRY_IA32E_MODE | ++ VMX_VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL | ++ VMX_VM_ENTRY_LOAD_IA32_PAT | VMX_VM_ENTRY_LOAD_IA32_EFER, ++ .features[FEAT_VMX_EPT_VPID_CAPS] = ++ MSR_VMX_EPT_EXECONLY | MSR_VMX_EPT_PAGE_WALK_LENGTH_4 | ++ MSR_VMX_EPT_WB | MSR_VMX_EPT_2MB | MSR_VMX_EPT_1GB | ++ MSR_VMX_EPT_INVEPT | MSR_VMX_EPT_AD_BITS | ++ MSR_VMX_EPT_INVEPT_SINGLE_CONTEXT | MSR_VMX_EPT_INVEPT_ALL_CONTEXT | ++ MSR_VMX_EPT_INVVPID | MSR_VMX_EPT_INVVPID_SINGLE_ADDR | ++ MSR_VMX_EPT_INVVPID_SINGLE_CONTEXT | ++ MSR_VMX_EPT_INVVPID_ALL_CONTEXT | ++ MSR_VMX_EPT_INVVPID_SINGLE_CONTEXT_NOGLOBALS, ++ .features[FEAT_VMX_EXIT_CTLS] = ++ VMX_VM_EXIT_SAVE_DEBUG_CONTROLS | ++ VMX_VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL | ++ VMX_VM_EXIT_ACK_INTR_ON_EXIT | VMX_VM_EXIT_SAVE_IA32_PAT | ++ VMX_VM_EXIT_LOAD_IA32_PAT | VMX_VM_EXIT_SAVE_IA32_EFER | ++ VMX_VM_EXIT_LOAD_IA32_EFER | VMX_VM_EXIT_SAVE_VMX_PREEMPTION_TIMER, ++ .features[FEAT_VMX_MISC] = ++ MSR_VMX_MISC_STORE_LMA | MSR_VMX_MISC_ACTIVITY_HLT | ++ MSR_VMX_MISC_VMWRITE_VMEXIT, ++ .features[FEAT_VMX_PINBASED_CTLS] = ++ VMX_PIN_BASED_EXT_INTR_MASK | VMX_PIN_BASED_NMI_EXITING | ++ VMX_PIN_BASED_VIRTUAL_NMIS | VMX_PIN_BASED_VMX_PREEMPTION_TIMER | ++ VMX_PIN_BASED_POSTED_INTR, ++ .features[FEAT_VMX_PROCBASED_CTLS] = ++ VMX_CPU_BASED_VIRTUAL_INTR_PENDING | ++ VMX_CPU_BASED_USE_TSC_OFFSETING | VMX_CPU_BASED_HLT_EXITING | ++ VMX_CPU_BASED_INVLPG_EXITING | VMX_CPU_BASED_MWAIT_EXITING | ++ VMX_CPU_BASED_RDPMC_EXITING | VMX_CPU_BASED_RDTSC_EXITING | ++ VMX_CPU_BASED_CR3_LOAD_EXITING | VMX_CPU_BASED_CR3_STORE_EXITING | ++ VMX_CPU_BASED_CR8_LOAD_EXITING | VMX_CPU_BASED_CR8_STORE_EXITING | ++ VMX_CPU_BASED_TPR_SHADOW | VMX_CPU_BASED_VIRTUAL_NMI_PENDING | ++ VMX_CPU_BASED_MOV_DR_EXITING | VMX_CPU_BASED_UNCOND_IO_EXITING | ++ VMX_CPU_BASED_USE_IO_BITMAPS | VMX_CPU_BASED_MONITOR_TRAP_FLAG | ++ VMX_CPU_BASED_USE_MSR_BITMAPS | VMX_CPU_BASED_MONITOR_EXITING | ++ VMX_CPU_BASED_PAUSE_EXITING | ++ VMX_CPU_BASED_ACTIVATE_SECONDARY_CONTROLS, ++ .features[FEAT_VMX_SECONDARY_CTLS] = ++ VMX_SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | ++ VMX_SECONDARY_EXEC_ENABLE_EPT | VMX_SECONDARY_EXEC_DESC | ++ VMX_SECONDARY_EXEC_RDTSCP | ++ VMX_SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | ++ VMX_SECONDARY_EXEC_ENABLE_VPID | VMX_SECONDARY_EXEC_WBINVD_EXITING | ++ VMX_SECONDARY_EXEC_UNRESTRICTED_GUEST | ++ VMX_SECONDARY_EXEC_APIC_REGISTER_VIRT | ++ VMX_SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | ++ VMX_SECONDARY_EXEC_RDRAND_EXITING | ++ VMX_SECONDARY_EXEC_ENABLE_INVPCID | ++ VMX_SECONDARY_EXEC_ENABLE_VMFUNC | VMX_SECONDARY_EXEC_SHADOW_VMCS | ++ VMX_SECONDARY_EXEC_RDSEED_EXITING | VMX_SECONDARY_EXEC_ENABLE_PML | ++ VMX_SECONDARY_EXEC_XSAVES, ++ .features[FEAT_VMX_VMFUNC] = ++ MSR_VMX_VMFUNC_EPT_SWITCHING, ++ .xlevel = 0x80000008, ++ .model_id = "Intel Xeon Processor (SierraForest)", ++ .versions = (X86CPUVersionDefinition[]) { ++ { .version = 1 }, ++ { /* end of list */ }, ++ }, ++ }, + { + .name = "Denverton", + .level = 21, +-- +2.27.0 + diff --git a/target-i386-Export-RFDS-bit-to-guests.patch b/target-i386-Export-RFDS-bit-to-guests.patch new file mode 100644 index 0000000000000000000000000000000000000000..76d592bf95d36126860adbe350fabcfadfa5283a --- /dev/null +++ b/target-i386-Export-RFDS-bit-to-guests.patch @@ -0,0 +1,47 @@ +From 2ddb661f2566d8835103c0beedf24e36adc2608d Mon Sep 17 00:00:00 2001 +From: Pawan Gupta +Date: Wed, 13 Mar 2024 07:53:23 -0700 +Subject: [PATCH] target/i386: Export RFDS bit to guests + +commit 41bdd9812863c150284a9339a048ed88c40f4df7 upstream. + +Register File Data Sampling (RFDS) is a CPU side-channel vulnerability +that may expose stale register value. CPUs that set RFDS_NO bit in MSR +IA32_ARCH_CAPABILITIES indicate that they are not vulnerable to RFDS. +Similarly, RFDS_CLEAR indicates that CPU is affected by RFDS, and has +the microcode to help mitigate RFDS. + +Make RFDS_CLEAR and RFDS_NO bits available to guests. + +Intel-SIG: commit 41bdd9812863 target/i386: Export RFDS bit to guests. +6.2.0-Add SRF CPU module support + +Signed-off-by: Pawan Gupta +Reviewed-by: Xiaoyao Li +Reviewed-by: Zhao Liu +Message-ID: <9a38877857392b5c2deae7e7db1b170d15510314.1710341348.git.pawan.kumar.gupta@linux.intel.com> +Signed-off-by: Paolo Bonzini +[ Quanxian Wang: amend commit log ] +Signed-off-by: Quanxian Wang +--- + target/i386/cpu.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/target/i386/cpu.c b/target/i386/cpu.c +index eb7fda0299..a11f3373ea 100644 +--- a/target/i386/cpu.c ++++ b/target/i386/cpu.c +@@ -1052,8 +1052,8 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { + NULL, "sbdr-ssdp-no", "fbsdp-no", "psdp-no", + NULL, "fb-clear", NULL, NULL, + NULL, NULL, NULL, NULL, +- "pbrsb-no", NULL, "gds-no", NULL, +- NULL, NULL, NULL, NULL, ++ "pbrsb-no", NULL, "gds-no", "rfds-no", ++ "rfds-clear", NULL, NULL, NULL, + }, + .msr = { + .index = MSR_IA32_ARCH_CAPABILITIES, +-- +2.27.0 + diff --git a/target-i386-Introduce-Icelake-Server-v7-to-enable-TS.patch b/target-i386-Introduce-Icelake-Server-v7-to-enable-TS.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d1e85f53a0a1ae2da0c0e923fa09f6893bf6dac --- /dev/null +++ b/target-i386-Introduce-Icelake-Server-v7-to-enable-TS.patch @@ -0,0 +1,64 @@ +From 2f722c0308c72223e1fe13caf1a3e5843635c98e Mon Sep 17 00:00:00 2001 +From: Zhenzhong Duan +Date: Wed, 20 Mar 2024 17:31:38 +0800 +Subject: [PATCH] target/i386: Introduce Icelake-Server-v7 to enable TSX + +commit c895fa54e3060c5ac6f3888dce96c9b78626072b upstream. + +When start L2 guest with both L1/L2 using Icelake-Server-v3 or above, +QEMU reports below warning: + +"warning: host doesn't support requested feature: MSR(10AH).taa-no [bit 8]" + +Reason is QEMU Icelake-Server-v3 has TSX feature disabled but enables taa-no +bit. It's meaningless that TSX isn't supported but still claim TSX is secure. +So L1 KVM doesn't expose taa-no to L2 if TSX is unsupported, then starting L2 +triggers the warning. + +Fix it by introducing a new version Icelake-Server-v7 which has both TSX +and taa-no features. Then guest can use TSX securely when it see taa-no. + +This matches the production Icelake which supports TSX and isn't susceptible +to TSX Async Abort (TAA) vulnerabilities, a.k.a, taa-no. + +Ideally, TSX should have being enabled together with taa-no since v3, but for +compatibility, we'd better to add v7 to enable it. + +Fixes: d965dc35592d ("target/i386: Add ARCH_CAPABILITIES related bits into Icelake-Server CPU model") +Intel-SIG: commit c895fa54e306 target/i386: Introduce Icelake-Server-v7 to enable TSX. +6.2.0-Add SRF CPU module support + +Tested-by: Xiangfei Ma +Signed-off-by: Zhenzhong Duan +Message-ID: <20240320093138.80267-2-zhenzhong.duan@intel.com> +Signed-off-by: Paolo Bonzini +[ Quanxian Wang: amend commit log ] +Signed-off-by: Quanxian Wang +--- + target/i386/cpu.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/target/i386/cpu.c b/target/i386/cpu.c +index 62ac5ed005..b5bf5ce7aa 100644 +--- a/target/i386/cpu.c ++++ b/target/i386/cpu.c +@@ -3606,6 +3606,16 @@ static const X86CPUDefinition builtin_x86_defs[] = { + { /* end of list */ } + }, + }, ++ { ++ .version = 7, ++ .note = "TSX, taa-no", ++ .props = (PropValue[]) { ++ /* Restore TSX features removed by -v2 above */ ++ { "hle", "on" }, ++ { "rtm", "on" }, ++ { /* end of list */ } ++ }, ++ }, + { /* end of list */ } + } + }, +-- +2.27.0 + diff --git a/target-i386-display-deprecation-status-in-cpu-help.patch b/target-i386-display-deprecation-status-in-cpu-help.patch new file mode 100644 index 0000000000000000000000000000000000000000..7821487effcce5e95b82e88ce3c47af0c85d57b1 --- /dev/null +++ b/target-i386-display-deprecation-status-in-cpu-help.patch @@ -0,0 +1,42 @@ +From 7df11d09bea98ef7ef90518030ab6d694b832418 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Tue, 30 Apr 2024 09:04:20 +0000 +Subject: [PATCH] target/i386: display deprecation status in '-cpu help' + mainline inclusion commit 5dfa9e8689d08c529bf772fc199597efa947fa27 category: + bugfix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--------------------------------------------------------------- + +When the user queries CPU models via QMP there is a 'deprecated' flag +present, however, this is not done for the CLI '-cpu help' command. + +Reviewed-by: Cornelia Huck +Signed-off-by: Daniel P. Berrangé + +Signed-off-by: tangbinzy +--- + target/i386/cpu.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/target/i386/cpu.c b/target/i386/cpu.c +index 62ac5ed005..f4b010c249 100644 +--- a/target/i386/cpu.c ++++ b/target/i386/cpu.c +@@ -5255,6 +5255,11 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data) + desc = g_strdup_printf("%s", model_id); + } + ++ if (cc->model && cc->model->cpudef->deprecation_note) { ++ g_autofree char *olddesc = desc; ++ desc = g_strdup_printf("%s (deprecated)", olddesc); ++ } ++ + qemu_printf("x86 %-20s %s\n", name, desc); + } + +-- +2.27.0 + diff --git a/target-ppc-Remove-msr_pr-macro.patch b/target-ppc-Remove-msr_pr-macro.patch new file mode 100644 index 0000000000000000000000000000000000000000..b6cff3784c725e49eac4bfad73c9607ffb22b359 --- /dev/null +++ b/target-ppc-Remove-msr_pr-macro.patch @@ -0,0 +1,236 @@ +From d83a066d969070373afe68f32f8584c66f2ee747 Mon Sep 17 00:00:00 2001 +From: dinglimin +Date: Sun, 9 Jun 2024 14:04:03 +0800 +Subject: [PATCH] target/ppc: Remove msr_pr macro cheery-pick from + d41ccf6eea918ec121cd38eda6e2526b446013f4 msr_pr macro hides the usage of + env->msr, which is a bad behavior Substitute it with FIELD_EX64 calls that + explicitly use env->msr as a parameter. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Suggested-by: Richard Henderson +Signed-off-by: Víctor Colombo +Reviewed-by: Richard Henderson +Message-Id: <20220504210541.115256-4-victor.colombo@eldorado.org.br> +Signed-off-by: Daniel Henrique Barboza +Signed-off-by: dinglimin +--- + hw/ppc/pegasos2.c | 2 +- + hw/ppc/spapr.c | 2 +- + target/ppc/cpu.h | 4 +++- + target/ppc/cpu_init.c | 4 ++-- + target/ppc/excp_helper.c | 3 ++- + target/ppc/mem_helper.c | 5 +++-- + target/ppc/mmu-radix64.c | 5 +++-- + target/ppc/mmu_common.c | 24 +++++++++++++----------- + 8 files changed, 28 insertions(+), 21 deletions(-) + +diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c +index 298e6b93e2..7b7eb38152 100644 +--- a/hw/ppc/pegasos2.c ++++ b/hw/ppc/pegasos2.c +@@ -457,7 +457,7 @@ static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu) + /* The TCG path should also be holding the BQL at this point */ + g_assert(qemu_mutex_iothread_locked()); + +- if (msr_pr) { ++ if (FIELD_EX64(env->msr, MSR, PR)) { + qemu_log_mask(LOG_GUEST_ERROR, "Hypercall made with MSR[PR]=1\n"); + env->gpr[3] = H_PRIVILEGE; + } else if (env->gpr[3] == KVMPPC_H_RTAS) { +diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c +index 7f352ceaaa..d1fbea16e3 100644 +--- a/hw/ppc/spapr.c ++++ b/hw/ppc/spapr.c +@@ -1268,7 +1268,7 @@ static void emulate_spapr_hypercall(PPCVirtualHypervisor *vhyp, + /* The TCG path should also be holding the BQL at this point */ + g_assert(qemu_mutex_iothread_locked()); + +- if (msr_pr) { ++ if (FIELD_EX64(env->msr, MSR, PR)) { + hcall_dprintf("Hypercall made with MSR[PR]=1\n"); + env->gpr[3] = H_PRIVILEGE; + } else { +diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h +index 26312f9d5f..8b214b2cc1 100644 +--- a/target/ppc/cpu.h ++++ b/target/ppc/cpu.h +@@ -24,6 +24,7 @@ + #include "exec/cpu-defs.h" + #include "cpu-qom.h" + #include "qom/object.h" ++#include "hw/registerfields.h" + + #define TCG_GUEST_DEFAULT_MO 0 + +@@ -343,6 +344,8 @@ typedef struct ppc_v3_pate_t { + #define MSR_RI 1 /* Recoverable interrupt 1 */ + #define MSR_LE 0 /* Little-endian mode 1 hflags */ + ++FIELD(MSR, PR, MSR_PR, 1) ++ + /* PMU bits */ + #define MMCR0_FC PPC_BIT(32) /* Freeze Counters */ + #define MMCR0_PMAO PPC_BIT(56) /* Perf Monitor Alert Occurred */ +@@ -443,7 +446,6 @@ typedef struct ppc_v3_pate_t { + #define msr_ce ((env->msr >> MSR_CE) & 1) + #define msr_ile ((env->msr >> MSR_ILE) & 1) + #define msr_ee ((env->msr >> MSR_EE) & 1) +-#define msr_pr ((env->msr >> MSR_PR) & 1) + #define msr_fp ((env->msr >> MSR_FP) & 1) + #define msr_me ((env->msr >> MSR_ME) & 1) + #define msr_fe0 ((env->msr >> MSR_FE0) & 1) +diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c +index 986d16a24d..d3b283dcd2 100644 +--- a/target/ppc/cpu_init.c ++++ b/target/ppc/cpu_init.c +@@ -7961,7 +7961,7 @@ static bool cpu_has_work_POWER9(CPUState *cs) + if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) && + (env->spr[SPR_LPCR] & LPCR_EEE)) { + bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC); +- if (heic == 0 || !msr_hv || msr_pr) { ++ if (!heic || !msr_hv || FIELD_EX64(env->msr, MSR, PR)) { + return true; + } + } +@@ -8170,7 +8170,7 @@ static bool cpu_has_work_POWER10(CPUState *cs) + if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) && + (env->spr[SPR_LPCR] & LPCR_EEE)) { + bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC); +- if (heic == 0 || !msr_hv || msr_pr) { ++ if (!heic || !msr_hv || FIELD_EX64(env->msr, MSR, PR)) { + return true; + } + } +diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c +index f66063d55c..3576e87b28 100644 +--- a/target/ppc/excp_helper.c ++++ b/target/ppc/excp_helper.c +@@ -976,7 +976,8 @@ static void ppc_hw_interrupt(CPUPPCState *env) + bool lpes0 = !!(env->spr[SPR_LPCR] & LPCR_LPES0); + bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC); + /* HEIC blocks delivery to the hypervisor */ +- if ((async_deliver && !(heic && msr_hv && !msr_pr)) || ++ if ((async_deliver && !(heic && msr_hv && ++ !FIELD_EX64(env->msr, MSR, PR))) || + (env->has_hv_mode && msr_hv == 0 && !lpes0)) { + powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_EXTERNAL); + return; +diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c +index 39945d9ea5..ceb4aa41d7 100644 +--- a/target/ppc/mem_helper.c ++++ b/target/ppc/mem_helper.c +@@ -613,10 +613,11 @@ void helper_tbegin(CPUPPCState *env) + (1ULL << TEXASR_FAILURE_PERSISTENT) | + (1ULL << TEXASR_NESTING_OVERFLOW) | + (msr_hv << TEXASR_PRIVILEGE_HV) | +- (msr_pr << TEXASR_PRIVILEGE_PR) | ++ (FIELD_EX64(env->msr, MSR, PR) << TEXASR_PRIVILEGE_PR) | + (1ULL << TEXASR_FAILURE_SUMMARY) | + (1ULL << TEXASR_TFIAR_EXACT); +- env->spr[SPR_TFIAR] = env->nip | (msr_hv << 1) | msr_pr; ++ env->spr[SPR_TFIAR] = env->nip | (msr_hv << 1) | ++ FIELD_EX64(env->msr, MSR, PR); + env->spr[SPR_TFHAR] = env->nip + 4; + env->crf[0] = 0xB; /* 0b1010 = transaction failure */ + } +diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c +index 5b0e62e676..3f016730cd 100644 +--- a/target/ppc/mmu-radix64.c ++++ b/target/ppc/mmu-radix64.c +@@ -171,12 +171,13 @@ static bool ppc_radix64_check_prot(PowerPCCPU *cpu, MMUAccessType access_type, + } + + /* Determine permissions allowed by Encoded Access Authority */ +- if (!partition_scoped && (pte & R_PTE_EAA_PRIV) && msr_pr) { ++ if (!partition_scoped && (pte & R_PTE_EAA_PRIV) && ++ FIELD_EX64(env->msr, MSR, PR)) { + *prot = 0; + } else if (mmuidx_pr(mmu_idx) || (pte & R_PTE_EAA_PRIV) || + partition_scoped) { + *prot = ppc_radix64_get_prot_eaa(pte); +- } else { /* !msr_pr && !(pte & R_PTE_EAA_PRIV) && !partition_scoped */ ++ } else { /* !MSR_PR && !(pte & R_PTE_EAA_PRIV) && !partition_scoped */ + *prot = ppc_radix64_get_prot_eaa(pte); + *prot &= ppc_radix64_get_prot_amr(cpu); /* Least combined permissions */ + } +diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c +index 754509e556..fb1059bcf2 100644 +--- a/target/ppc/mmu_common.c ++++ b/target/ppc/mmu_common.c +@@ -292,8 +292,8 @@ static inline void bat_size_prot(CPUPPCState *env, target_ulong *blp, + bl = (*BATu & 0x00001FFC) << 15; + valid = 0; + prot = 0; +- if (((msr_pr == 0) && (*BATu & 0x00000002)) || +- ((msr_pr != 0) && (*BATu & 0x00000001))) { ++ if ((!FIELD_EX64(env->msr, MSR, PR) && (*BATu & 0x00000002)) || ++ (FIELD_EX64(env->msr, MSR, PR) && (*BATu & 0x00000001))) { + valid = 1; + pp = *BATl & 0x00000003; + if (pp != 0) { +@@ -386,16 +386,17 @@ static int get_segment_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, + PowerPCCPU *cpu = env_archcpu(env); + hwaddr hash; + target_ulong vsid; +- int ds, pr, target_page_bits; ++ int ds, target_page_bits; ++ bool pr; + int ret; + target_ulong sr, pgidx; + +- pr = msr_pr; ++ pr = FIELD_EX64(env->msr, MSR, PR); + ctx->eaddr = eaddr; + + sr = env->sr[eaddr >> 28]; +- ctx->key = (((sr & 0x20000000) && (pr != 0)) || +- ((sr & 0x40000000) && (pr == 0))) ? 1 : 0; ++ ctx->key = (((sr & 0x20000000) && pr) || ++ ((sr & 0x40000000) && !pr)) ? 1 : 0; + ds = sr & 0x80000000 ? 1 : 0; + ctx->nx = sr & 0x10000000 ? 1 : 0; + vsid = sr & 0x00FFFFFF; +@@ -404,8 +405,9 @@ static int get_segment_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, + "Check segment v=" TARGET_FMT_lx " %d " TARGET_FMT_lx + " nip=" TARGET_FMT_lx " lr=" TARGET_FMT_lx + " ir=%d dr=%d pr=%d %d t=%d\n", +- eaddr, (int)(eaddr >> 28), sr, env->nip, env->lr, (int)msr_ir, +- (int)msr_dr, pr != 0 ? 1 : 0, access_type == MMU_DATA_STORE, type); ++ eaddr, (int)(eaddr >> 28), sr, env->nip, env->lr, ++ (int)msr_ir, (int)msr_dr, pr ? 1 : 0, ++ access_type == MMU_DATA_STORE, type); + pgidx = (eaddr & ~SEGMENT_MASK_256M) >> target_page_bits; + hash = vsid ^ pgidx; + ctx->ptem = (vsid << 7) | (pgidx >> 10); +@@ -566,7 +568,7 @@ static int mmu40x_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, + + ret = -1; + raddr = (hwaddr)-1ULL; +- pr = msr_pr; ++ pr = FIELD_EX64(env->msr, MSR, PR); + for (i = 0; i < env->nb_tlb; i++) { + tlb = &env->tlb.tlbe[i]; + if (ppcemb_tlb_check(env, tlb, &raddr, address, +@@ -651,7 +653,7 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb, + + found_tlb: + +- if (msr_pr != 0) { ++ if (FIELD_EX64(env->msr, MSR, PR)) { + prot2 = tlb->prot & 0xF; + } else { + prot2 = (tlb->prot >> 4) & 0xF; +@@ -799,7 +801,7 @@ static bool mmubooke206_get_as(CPUPPCState *env, + return true; + } else { + *as_out = msr_ds; +- *pr_out = msr_pr; ++ *pr_out = FIELD_EX64(env->msr, MSR, PR); + return false; + } + } +-- +2.27.0 + diff --git a/target-s390x-display-deprecation-status-in-cpu-help.patch b/target-s390x-display-deprecation-status-in-cpu-help.patch new file mode 100644 index 0000000000000000000000000000000000000000..2a639a0fc4de11b60772fb0b79f759723694bf0d --- /dev/null +++ b/target-s390x-display-deprecation-status-in-cpu-help.patch @@ -0,0 +1,67 @@ +From 054d100649c34dd4e5a13140b09b8c080e85ffde Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Tue, 30 Apr 2024 09:24:09 +0000 +Subject: [PATCH] target/s390x: display deprecation status in '-cpu help' + mainline inclusion commit 738cdc2f6ea1ce22bb3f2a4e0fc84fc8121896fb category: + bugfix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--------------------------------------------------------------- + +When the user queries CPU models via QMP there is a 'deprecated' flag +present, however, this is not done for the CLI '-cpu help' command. + +Reviewed-by: Cornelia Huck +Signed-off-by: Daniel P. Berrangé + +Signed-off-by: tangbinzy +--- + target/s390x/cpu_models.c | 23 ++++++++++++++++++----- + 1 file changed, 18 insertions(+), 5 deletions(-) + +diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c +index 11e06cc51f..65908c6d36 100644 +--- a/target/s390x/cpu_models.c ++++ b/target/s390x/cpu_models.c +@@ -334,18 +334,31 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga, + static void s390_print_cpu_model_list_entry(gpointer data, gpointer user_data) + { + const S390CPUClass *scc = S390_CPU_CLASS((ObjectClass *)data); ++ CPUClass *cc = CPU_CLASS(scc); + char *name = g_strdup(object_class_get_name((ObjectClass *)data)); +- const char *details = ""; ++ g_autoptr(GString) details = g_string_new(""); + + if (scc->is_static) { +- details = "(static, migration-safe)"; +- } else if (scc->is_migration_safe) { +- details = "(migration-safe)"; ++ g_string_append(details, "static, "); ++ } ++ if (scc->is_migration_safe) { ++ g_string_append(details, "migration-safe, "); ++ } ++ if (cc->deprecation_note) { ++ g_string_append(details, "deprecated, "); ++ } ++ if (details->len) { ++ /* cull trailing ', ' */ ++ g_string_truncate(details, details->len - 2); + } + + /* strip off the -s390x-cpu */ + g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0; +- qemu_printf("s390 %-15s %-35s %s\n", name, scc->desc, details); ++ if (details->len) { ++ qemu_printf("s390 %-15s %-35s (%s)\n", name, scc->desc, details->str); ++ } else { ++ qemu_printf("s390 %-15s %-35s\n", name, scc->desc); ++ } + g_free(name); + } + +-- +2.27.0 + diff --git a/tpm_emulator-Avoid-double-initialization-during-migr.patch b/tpm_emulator-Avoid-double-initialization-during-migr.patch new file mode 100644 index 0000000000000000000000000000000000000000..aff54f80b4ee61b9f74a69fc1c6db22a6109e49c --- /dev/null +++ b/tpm_emulator-Avoid-double-initialization-during-migr.patch @@ -0,0 +1,58 @@ +From 65582eea0238d4b833934281fc6580a28cc82694 Mon Sep 17 00:00:00 2001 +From: tangbinzy +Date: Wed, 15 May 2024 01:33:59 +0000 +Subject: [PATCH] tpm_emulator: Avoid double initialization during migration + mainline inclusion commit a0bcec03761477371ff7c2e80dc07fff14222d92 category: + bugfix +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--------------------------------------------------------------- + +When resuming after a migration, the backend sends CMD_INIT to the +emulator from the startup callback, then it sends the migration state +from the vmstate to the emulator, then it sends CMD_INIT again. Skip the +first CMD_INIT during a migration to avoid initializing the TPM twice. + +Signed-off-by: Ross Lagerwall +Reviewed-by: Marc-André Lureau +Tested-by: Stefan Berger +Signed-off-by: Stefan Berger + +Signed-off-by: tangbinzy +--- + backends/tpm/tpm_emulator.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c +index 87d061e9bb..9b50c5b3e2 100644 +--- a/backends/tpm/tpm_emulator.c ++++ b/backends/tpm/tpm_emulator.c +@@ -32,6 +32,7 @@ + #include "qemu/sockets.h" + #include "qemu/lockable.h" + #include "io/channel-socket.h" ++#include "sysemu/runstate.h" + #include "sysemu/tpm_backend.h" + #include "sysemu/tpm_util.h" + #include "tpm_int.h" +@@ -383,6 +384,15 @@ err_exit: + + static int tpm_emulator_startup_tpm(TPMBackend *tb, size_t buffersize) + { ++ /* TPM startup will be done from post_load hook */ ++ if (runstate_check(RUN_STATE_INMIGRATE)) { ++ if (buffersize != 0) { ++ return tpm_emulator_set_buffer_size(tb, buffersize, NULL); ++ } ++ ++ return 0; ++ } ++ + return tpm_emulator_startup_tpm_resume(tb, buffersize, false); + } + +-- +2.27.0 + diff --git a/vfio-pci-Add-Ascend310b-scend910b-support.patch b/vfio-pci-Add-Ascend310b-scend910b-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..197bd0cac748efe7487d153a2d8bf8f9ed2c407f --- /dev/null +++ b/vfio-pci-Add-Ascend310b-scend910b-support.patch @@ -0,0 +1,134 @@ +From 0cc777f65565e77100e0a767f6165217246b0226 Mon Sep 17 00:00:00 2001 +From: yuxiating +Date: Tue, 14 May 2024 11:19:02 +0800 +Subject: [PATCH] vfio/pci: Add Ascend310b scend910b support + +Reference:https://support.huawei.com/enterprise/zh/doc/EDOC1100349016/63b881f2 + +Signed-off-by: yuxiating +--- + hw/vfio/pci-quirks.c | 72 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 72 insertions(+) + +diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c +index a911e04a79..d83ed21387 100644 +--- a/hw/vfio/pci-quirks.c ++++ b/hw/vfio/pci-quirks.c +@@ -1211,7 +1211,9 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + + #define PCI_VENDOR_ID_HUAWEI 0x19e5 + #define PCI_DEVICE_ID_ASCEND910 0xd801 ++#define PCI_DEVICE_ID_ASCEND910B 0xd802 + #define PCI_DEVICE_ID_ASCEND710 0xd500 ++#define PCI_DEVICE_ID_ASCEND310B 0xd105 + #define PCI_DEVICE_ID_ASCEND310 0xd100 + #define PCI_SUB_DEVICE_ID_ASCEND710_1P_MIN 0x100 + #define PCI_SUB_DEVICE_ID_ASCEND710_1P_MAX 0x10f +@@ -1219,11 +1221,15 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + #define PCI_SUB_DEVICE_ID_ASCEND710_2P_MAX 0x11f + #define ASCEND910_XLOADER_SIZE 4 + #define ASCEND910_XLOADER_OFFSET 0x80400 ++#define ASCEND910B_XLOADER_SIZE 4 ++#define ASCEND910B_XLOADER_OFFSET 0x18208430 + #define ASCEND710_2P_BASE (128 * 1024 * 1024) + #define ASCEND710_1P_DEVNUM 1 + #define ASCEND710_2P_DEVNUM 2 + #define ASCEND710_XLOADER_SIZE 4 + #define ASCEND710_XLOADER_OFFSET 0x100430 ++#define ASCEND310B_XLOADER_SIZE 4 ++#define ASCEND310B_XLOADER_OFFSET 0x4430 + #define ASCEND310_XLOADER_SIZE 4 + #define ASCEND310_XLOADER_OFFSET 0x400 + +@@ -1263,6 +1269,38 @@ static const MemoryRegionOps vfio_ascend_intercept_regs_quirk = { + .endianness = DEVICE_LITTLE_ENDIAN, + }; + ++static void vfio_probe_ascend910b_bar2_quirk(VFIOPCIDevice *vdev, int nr) ++{ ++ VFIOQuirk *quirk; ++ VFIOAscendBarQuirk *bar2_quirk; ++ ++ if (vdev->vendor_id != PCI_VENDOR_ID_HUAWEI || nr != 2 ++ || vdev->device_id != PCI_DEVICE_ID_ASCEND910B) { ++ return; ++ } ++ ++ quirk = g_malloc0(sizeof(*quirk)); ++ quirk->nr_mem = 1; ++ quirk->mem = g_new0(MemoryRegion, quirk->nr_mem); ++ bar2_quirk = quirk->data = g_new0(typeof(*bar2_quirk), quirk->nr_mem); ++ bar2_quirk[0].vdev = vdev; ++ bar2_quirk[0].offset = ASCEND910B_XLOADER_OFFSET; ++ bar2_quirk[0].bar = nr; ++ ++ /* intercept w/r to the xloader-updating register, ++ * so the vm can't enable xloader-updating ++ */ ++ memory_region_init_io(&quirk->mem[0], OBJECT(vdev), ++ &vfio_ascend_intercept_regs_quirk, ++ &bar2_quirk[0], ++ "vfio-ascend910b-bar2-intercept-regs-quirk", ++ ASCEND910B_XLOADER_SIZE); ++ memory_region_add_subregion_overlap(vdev->bars[nr].region.mem, ++ bar2_quirk[0].offset, ++ &quirk->mem[0], 1); ++ QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); ++} ++ + static void vfio_probe_ascend910_bar0_quirk(VFIOPCIDevice *vdev, int nr) + { + VFIOQuirk *quirk; +@@ -1360,6 +1398,38 @@ static void vfio_probe_ascend710_bar2_quirk(VFIOPCIDevice *vdev, int nr) + QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); + } + ++static void vfio_probe_ascend310b_bar2_quirk(VFIOPCIDevice *vdev, int nr) ++{ ++ VFIOQuirk *quirk; ++ VFIOAscendBarQuirk *bar2_quirk; ++ ++ if (vdev->vendor_id != PCI_VENDOR_ID_HUAWEI || nr != 2 ++ || vdev->device_id != PCI_DEVICE_ID_ASCEND310B) { ++ return; ++ } ++ ++ quirk = g_malloc0(sizeof(*quirk)); ++ quirk->nr_mem = 1; ++ quirk->mem = g_new0(MemoryRegion, quirk->nr_mem); ++ bar2_quirk = quirk->data = g_new0(typeof(*bar2_quirk), quirk->nr_mem); ++ bar2_quirk[0].vdev = vdev; ++ bar2_quirk[0].offset = ASCEND310B_XLOADER_OFFSET; ++ bar2_quirk[0].bar = nr; ++ ++ /* intercept w/r to the xloader-updating register, ++ * so the vm can't enable xloader-updating ++ */ ++ memory_region_init_io(&quirk->mem[0], OBJECT(vdev), ++ &vfio_ascend_intercept_regs_quirk, ++ &bar2_quirk[0], ++ "vfio-ascend310b-bar2-intercept-regs-quirk", ++ ASCEND310B_XLOADER_SIZE); ++ memory_region_add_subregion_overlap(vdev->bars[nr].region.mem, ++ bar2_quirk[0].offset, ++ &quirk->mem[0], 1); ++ QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); ++} ++ + static void vfio_probe_ascend310_bar4_quirk(VFIOPCIDevice *vdev, int nr) + { + VFIOQuirk *quirk; +@@ -1445,8 +1515,10 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr) + #ifdef CONFIG_VFIO_IGD + vfio_probe_igd_bar4_quirk(vdev, nr); + #endif ++ vfio_probe_ascend910b_bar2_quirk(vdev, nr); + vfio_probe_ascend910_bar0_quirk(vdev, nr); + vfio_probe_ascend710_bar2_quirk(vdev, nr); ++ vfio_probe_ascend310b_bar2_quirk(vdev, nr); + vfio_probe_ascend310_bar4_quirk(vdev, nr); + } + +-- +2.27.0 +