From: "Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>
To: qemu-devel@nongnu.org
Cc: "Wei Liu" <wei.liu@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Magnus Kulke" <magnuskulke@microsoft.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Doru Blânzeanu" <dblanzeanu@microsoft.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>,
"Magnus Kulke" <magnuskulke@linux.microsoft.com>
Subject: [RFC PATCH 3/3] accel/mshv: use scrub_partition ioctl on init
Date: Fri, 30 Oct 2026 16:20:37 +0200 [thread overview]
Message-ID: <20261030142037.267641-4-dblanzeanu@linux.microsoft.com> (raw)
In-Reply-To: <20261030142037.267641-1-dblanzeanu@linux.microsoft.com>
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
prev parent reply other threads:[~2026-10-30 14:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030142037.267641-4-dblanzeanu@linux.microsoft.com \
--to=dblanzeanu@linux.microsoft.com \
--cc=cohuck@redhat.com \
--cc=dblanzeanu@microsoft.com \
--cc=magnuskulke@linux.microsoft.com \
--cc=magnuskulke@microsoft.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.