Re: [PATCH v6 00/10] Introduce /dev/mshv root partition driver
From: Wei Liu
Date: Mon Mar 17 2025 - 17:27:35 EST
On Fri, Mar 14, 2025 at 12:28:46PM -0700, Nuno Das Neves wrote:
> This series introduces support for creating and running guest virtual
> machines while running on the Microsoft Hypervisor[0] as root partition.
> This is done via an IOCTL interface accessed through /dev/mshv, similar to
> /dev/kvm. Another series introducing this support was previously posted in
> 2021[1], and versions 1-4 of this series were posted in 2023[2].
>
> Patches 1-4 are small refactors and additions to Hyper-V code.
> Patches 5-6 just export some definitions needed by /dev/mshv.
> Patches 7-9 introduce some functionality and definitions in common code, that
> are specific to the driver.
> Patch 10 contains the driver code.
>
> -----------------
> [0] "Hyper-V" is more well-known, but it really refers to the whole stack
> including the hypervisor and other components that run in Windows
> kernel and userspace.
> [1] Previous /dev/mshv patch series (2021) and discussion:
> https://lore.kernel.org/linux-hyperv/1632853875-20261-1-git-send-email-nunodasneves@xxxxxxxxxxxxxxxxxxx/
> [2] v4 (2023):
> https://lore.kernel.org/linux-hyperv/1696010501-24584-1-git-send-email-nunodasneves@xxxxxxxxxxxxxxxxxxx/
>
> -----------------
> Changes since v5:
> * Rework patch 1:
> 1. Introduce hv_status_printk() logging macros which print the raw HV_STATUS_
> code along with string [Roman Kisel]
> 2. Iterate over an array of data items to get the string and errno for the
> hv_result_to_*() functions. [Michael Kelley]
> 3. Use hv_status_printk() to log errors in hyperv/irqdomain.c and
> hyperv-iommu.c [Easwar Hariharan]
> * Minor cleanup, improvements, and commit wording changes in patches 2, 3, 4, 6
> [Roman Kisel, Easwar Hariharan, Michael Kelley]
> * Fix issues with declaration and lifecycle of hv_synic_eventring_tail in patch
> 7 [Michael Kelley]
> * Improve detail and clarity of commit message in patch 8 [Michael Kelley]
> * Minor cleanups in patch 9 - uapi types -> kernel types, #ifdef CONFIG_X86_64
> -> CONFIG_X86 for consistency, fix HVCALL_* ordering, remove redundant
> __packed, use explicit enum value [Stanislav Kinsburskii, Easwar Hariharan,
> Michael Kelley, Tianyu Lan]
> * Minor fixes and cleanup in patch 10 [Michael Kelley]
> * Add MODULE_DESCRIPTION() to patch 10 [Jeff Johnson]
>
> Changes since v4:
> * Slim down the IOCTL interface significantly, via several means:
> 1. Use generic "passthrough" call MSHV_ROOT_HVCALL to replace many ioctls.
> 2. Use MSHV_* versions of some of the HV_* definitions.
> 3. Move hv headers out of uapi altogether, into include/hyperv/, see:
> https://lore.kernel.org/linux-hyperv/1732577084-2122-1-git-send-email-nunodasneves@xxxxxxxxxxxxxxxxxxx/
> * Remove mshv_vtl module altogther, it will be posted in followup series
> * Also remove the parent "mshv" module which didn't serve much purpose
> * Update and refactor parts of the driver code for clarity, extensibility
>
> Changes since v3 (summarized):
> * Clean up the error and debug logging:
> 1. Add a set of macros vp_*() and partition_*() which call the equivalent
> dev_*(), passing the device from the partition struct
> * The new macros also print the partition and vp ids to aid debugging
> and reduce repeated code
> 2. Use dev_*() (mostly via the new macros) instead of pr_*() *almost*
> everywhere - in interrupt context we can't always get the device struct
> 3. Remove pr_*() logging from hv_call.c and mshv_root_hv_call.c
>
> Changes since v2 (summarized):
> * Fix many checkpatch.pl --strict style issues
> * Initialize status in get/set registers hypercall helpers
> * Add missing return on error in get_vp_signaled_count
>
> Changes since v1 (summarized):
> * Clean up formatting, commit messages
>
> Nuno Das Neves (9):
> hyperv: Log hypercall status codes as strings
> arm64/hyperv: Add some missing functions to arm64
> hyperv: Introduce hv_recommend_using_aeoi()
> acpi: numa: Export node_to_pxm()
> Drivers: hv: Export some functions for use by root partition module
> Drivers: hv: Introduce per-cpu event ring tail
> x86: hyperv: Add mshv_handler() irq handler and setup function
> hyperv: Add definitions for root partition driver to hv headers
> Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs
>
> Stanislav Kinsburskii (1):
> x86/mshyperv: Add support for extended Hyper-V features
Series applied to hyperv-next. Thanks.
I had to fix one minor compilation issue in patch 10, but nothing major.
I also folded the following patch to a previous patch that introduced
MSHV_ROOT (not in this series).
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 794e88e9dc6b..3118d5472fab 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -57,7 +57,7 @@ config HYPERV_BALLOON
config MSHV_ROOT
tristate "Microsoft Hyper-V root partition support"
- depends on HYPERV
+ depends on HYPERV && (X86_64 || ARM64)
depends on !HYPERV_VTL_MODE
# The hypervisor interface operates on 4k pages. Enforcing it here
# simplifies many assumptions in the root partition code.
Wei.