* [RFC PATCH 0/3] mshv: Fix soft reboot by using scrub partition ioctl on init
@ 2026-10-30 14:20 Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 1/3] accel/mshv: mark mshv cpus as resetable Doru Blânzeanu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Doru Blânzeanu @ 2026-10-30 14:20 UTC (permalink / raw)
To: qemu-devel
Cc: Wei Liu, Michael S. Tsirkin, Magnus Kulke, Paolo Bonzini,
Doru Blânzeanu, Cornelia Huck, Doru Blânzeanu,
Magnus Kulke
This series is an RFC because, the kernel mshv driver changes that introduce
this ioctl, are not upstream yet.
Below is a link to the posted kernel patch.
https://lore.kernel.org/linux-hyperv/20261029062801.28598-2-wei.liu@kernel.org/
This patch series uses the SCRUB_PARTITION ioctl during reset to ensure a sane
state for the mshv driver.
The series consists of:
1. accel/mshv: mask mshv cpus as resetable
2. include/hw/hyperv: Add SCRUB_PARTITION ioctl
3. accel/mshv: use scrub_partition ioctl on init
The second commit that adds the SCRUB_PARTITION ioctl definition can be dropped
once the kernel patch is merged and the Qemu linux-headers are updated.
In short, the changes mark the vCPUs as resettable and run the SCRUB_PARTITION
ioctl on the `synchronize_post_reset` hook for the first vCPU.
Doru Blânzeanu (2):
include/hw/hyperv: Add SCRUB_PARTITION ioctl
accel/mshv: use scrub_partition ioctl on init
Magnus Kulke (1):
accel/mshv: mark mshv cpus as resetable
accel/mshv/mshv-all.c | 27 +++++++++++++++++++++++++--
include/hw/hyperv/hvgdk_mini.h | 2 ++
2 files changed, 27 insertions(+), 2 deletions(-)
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC PATCH 1/3] accel/mshv: mark mshv cpus as resetable
2026-10-30 14:20 [RFC PATCH 0/3] mshv: Fix soft reboot by using scrub partition ioctl on init Doru Blânzeanu
@ 2026-10-30 14:20 ` Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 2/3] include/hw/hyperv: Add SCRUB_PARTITION ioctl Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 3/3] accel/mshv: use scrub_partition ioctl on init Doru Blânzeanu
2 siblings, 0 replies; 4+ messages in thread
From: Doru Blânzeanu @ 2026-10-30 14:20 UTC (permalink / raw)
To: qemu-devel
Cc: Wei Liu, Michael S. Tsirkin, Magnus Kulke, Paolo Bonzini,
Doru Blânzeanu, Cornelia Huck, Doru Blânzeanu,
Magnus Kulke
From: Magnus Kulke <magnuskulke@linux.microsoft.com>
Guest using the MSHV accelerator aren't resetable otherwise.
Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Signed-off-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
---
accel/mshv/mshv-all.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c
index d820a67b95..a7b7017fb1 100644
--- a/accel/mshv/mshv-all.c
+++ b/accel/mshv/mshv-all.c
@@ -952,7 +952,7 @@ static void mshv_cpu_synchronize(CPUState *cpu)
static bool mshv_cpus_are_resettable(void)
{
- return false;
+ return true;
}
static void mshv_accel_class_init(ObjectClass *oc, const void *data)
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFC PATCH 2/3] include/hw/hyperv: Add SCRUB_PARTITION ioctl
2026-10-30 14:20 [RFC PATCH 0/3] mshv: Fix soft reboot by using scrub partition ioctl on init Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 1/3] accel/mshv: mark mshv cpus as resetable Doru Blânzeanu
@ 2026-10-30 14:20 ` Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 3/3] accel/mshv: use scrub_partition ioctl on init Doru Blânzeanu
2 siblings, 0 replies; 4+ messages in thread
From: Doru Blânzeanu @ 2026-10-30 14:20 UTC (permalink / raw)
To: qemu-devel
Cc: Wei Liu, Michael S. Tsirkin, Magnus Kulke, Paolo Bonzini,
Doru Blânzeanu, Cornelia Huck, Doru Blânzeanu,
Magnus Kulke
Signed-off-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
---
include/hw/hyperv/hvgdk_mini.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h
index 0983e3a58d..5178ed07a1 100644
--- a/include/hw/hyperv/hvgdk_mini.h
+++ b/include/hw/hyperv/hvgdk_mini.h
@@ -545,6 +545,8 @@ struct hv_input_assert_virtual_interrupt {
#define MSHV_IOEVENTFD _IOW(MSHV_IOCTL, 0x04, struct mshv_user_ioeventfd)
#define MSHV_SET_MSI_ROUTING _IOW(MSHV_IOCTL, 0x05, struct mshv_user_irq_table)
+#define MSHV_SCRUB_PARTITION _IO(MSHV_IOCTL, 0x0B)
+
/*
********************************
* VP APIs for child partitions *
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFC PATCH 3/3] accel/mshv: use scrub_partition ioctl on init
2026-10-30 14:20 [RFC PATCH 0/3] mshv: Fix soft reboot by using scrub partition ioctl on init Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 1/3] accel/mshv: mark mshv cpus as resetable Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 2/3] include/hw/hyperv: Add SCRUB_PARTITION ioctl Doru Blânzeanu
@ 2026-10-30 14:20 ` Doru Blânzeanu
2 siblings, 0 replies; 4+ messages in thread
From: Doru Blânzeanu @ 2026-10-30 14:20 UTC (permalink / raw)
To: qemu-devel
Cc: Wei Liu, Michael S. Tsirkin, Magnus Kulke, Paolo Bonzini,
Doru Blânzeanu, Cornelia Huck, Doru Blânzeanu,
Magnus Kulke
This is relevant on soft resets, when the MSHV partition will have a
preinitialized state for guest enlightenments and LAPIC state.
Without invoking the ioctl, a rebooted guest will fail during boot
when attempting to init Hyper-V enlightenments or the APIC.
Signed-off-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
---
accel/mshv/mshv-all.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c
index a7b7017fb1..5e51d0f1fa 100644
--- a/accel/mshv/mshv-all.c
+++ b/accel/mshv/mshv-all.c
@@ -84,6 +84,17 @@ static int mshv_load_cleanup(void *opaque)
return 0;
}
+static int scrub_partition(int vm_fd)
+{
+ int ret = ioctl(vm_fd, MSHV_SCRUB_PARTITION);
+
+ if (ret < 0) {
+ error_report("Failed to scrub partition");
+ return -errno;
+ }
+
+ return 0;
+}
static int get_host_partition_property(int mshv_fd, uint32_t property_code,
uint64_t *value)
@@ -906,7 +917,19 @@ static void mshv_cpu_synchronize_post_init(CPUState *cpu)
static void mshv_cpu_synchronize_post_reset(CPUState *cpu)
{
- int ret = mshv_arch_store_vcpu_state(cpu);
+ int ret;
+ bool is_bsp = (cpu == first_cpu);
+
+ if (is_bsp) {
+ ret = scrub_partition(mshv_state->vm);
+ if (ret < 0) {
+ error_report("Failed to scrub partition during reset: %s",
+ strerror(-ret));
+ vm_stop(RUN_STATE_INTERNAL_ERROR);
+ }
+ }
+
+ ret = mshv_arch_store_vcpu_state(cpu);
if (ret) {
error_report("Failed to put registers after reset: %s",
strerror(-ret));
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-30 14:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 14:20 [RFC PATCH 0/3] mshv: Fix soft reboot by using scrub partition ioctl on init Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 1/3] accel/mshv: mark mshv cpus as resetable Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 2/3] include/hw/hyperv: Add SCRUB_PARTITION ioctl Doru Blânzeanu
2026-10-30 14:20 ` [RFC PATCH 3/3] accel/mshv: use scrub_partition ioctl on init Doru Blânzeanu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.