Re: [PATCH] mshv: Add an ioctl to scrub partition state
From: Mukesh R
Date: Thu Nov 05 2026 - 19:47:38 EST
On 10/28/26 23:27, wei.liu@xxxxxxxxxx wrote:
From: John Starks <jostarks@xxxxxxxxxxxxx>
Userspace VMMs need to reset a child partition's hypervisor-managed state
without destroying its VPs or rebuilding its memory and eventfd
registrations. Exposing HvCallScrubPartition through generic hypercall
passthrough would bypass the synchronization and cached-state updates
needed by the driver.
Add MSHV_SCRUB_PARTITION as a no-argument partition-fd ioctl. Hold the
partition mutex and try-lock each populated VP mutex in index order,
using the partition mutex as the lockdep nesting lock. Return -EBUSY
without issuing the hypercall if a VP is busy. This excludes VP ioctls
without waiting indefinitely for a running VP; userspace must stop its
run threads before requesting scrub.
After a successful scrub, clear cached intercept suspend so the next run
clears explicit suspend rather than trying to consume a stale intercept.
Preserve deferred blocked waits and notification accounting: a VP becoming
dispatchable does not imply its host notification has already arrived.
Keep the locks through this update and unwind them on every exit.
Scrub is nonallocating, so issue one fast hypercall, trace its status and
return the existing errno translation. Let the hypervisor determine which
partition configurations support scrub. Device quiescing and restoring
guest execution state remain userspace responsibilities.
Signed-off-by: John Starks <jostarks@xxxxxxxxxxxxx>
Signed-off-by: Wei Liu <wei.liu@xxxxxxxxxx>
---
Tested repeated scrub/run, sparse and 64-VP locking, busy unwinding,
interrupted blocked runs, concurrent memory invalidation and irqfd
activity on x86-64, and delayed notifications with separate diagnostic
instrumentation. The affected ARM64 objects compile. ARM64 runtime and
hypervisor scheduling remain untested. Doorbell delivery across scrub
works, but exposes an existing eventfd hardirq wait-context warning under
lockdep, separate from this change.
GitHub Copilot generated the implementation and test probes, investigated
locking and notification handling, ran builds and Incubator tests, and
drafted this description. Human review selected the dedicated ioctl and
try-lock policy and corrected the nonallocating hypercall contract.
---
drivers/hv/mshv_root.h | 1 +
drivers/hv/mshv_root_hv_call.c | 11 ++++++++
drivers/hv/mshv_root_main.c | 50 ++++++++++++++++++++++++++++++++++
drivers/hv/mshv_trace.h | 17 ++++++++++++
include/hyperv/hvgdk_mini.h | 1 +
include/hyperv/hvhdk.h | 4 +++
include/uapi/linux/mshv.h | 11 ++++++++
7 files changed, 95 insertions(+)
<snip>
Reviewed-by: Mukesh R <mrathor@xxxxxxxxxxxxxxxxxxx>