Skip to content

Microsoft Hypervisor root partition ioctl interface

Nuno Das Neves linux-hyperv lkml virtualization 3 versions – In review

Get series with b4
b4 am 1632853875-20261-1-git-send-email-nunodasneves@linux.microsoft.com

Versions newest first · linked by author and title

  1. v3 Latest19 patches 4 repliesIn review
  2. v219 patches 0 repliesSuperseded
  3. v119 patches 15 repliesSuperseded

Changes in v3 from the cover letter

1. Fix kernel test robot issues
2. Bugfix in GVA to GPA patch provided by Anatol Belski

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19x86/hyperv: convert hyperv statuses to linux error codesarch/x86/hyperv/hv_proc.c arch/x86/include/asm/mshyperv.h include/asm-generic/hyperv-tlfs.h+50 -130 replies
2/19x86/hyperv: convert hyperv statuses to stringsarch/x86/hyperv/hv_init.c arch/x86/hyperv/hv_proc.c include/asm-generic/hyperv-tlfs.h +1 more+46 -280 replies
3/19drivers/hv: minimal mshv module (/dev/mshv/)arch/x86/hyperv/Makefile drivers/hv/Kconfig drivers/hv/Makefile +1 more+99 -00 replies
4/19drivers/hv: check extension ioctlDocumentation/userspace-api/ioctl/ioctl-number.rst Documentation/virt/mshv/api.rst drivers/hv/mshv_main.c +2 more+116 -00 replies
5/19drivers/hv: create partition ioctlDocumentation/virt/mshv/api.rst arch/x86/include/asm/hyperv-tlfs.h arch/x86/include/uapi/asm/hyperv-tlfs.h +5 more+318 -00 replies
6/19drivers/hv: create, initialize, finalize, delete partition hypercallsarch/x86/hyperv/hv_proc.c drivers/hv/Makefile drivers/hv/hv_call.c +3 more+243 -20 replies
7/19drivers/hv: withdraw memory hypercalldrivers/hv/hv_call.c drivers/hv/mshv.h drivers/hv/mshv_main.c +1 more+73 -20 replies
8/19drivers/hv: map and unmap guest memoryDocumentation/virt/mshv/api.rst drivers/hv/hv_call.c drivers/hv/mshv.h +5 more+394 -53 replies
9/19drivers/hv: create vcpu ioctlDocumentation/virt/mshv/api.rst drivers/hv/mshv_main.c include/linux/mshv.h +1 more+142 -10 replies
10/19drivers/hv: get and set vcpu registers ioctlsDocumentation/virt/mshv/api.rst arch/x86/include/uapi/asm/hyperv-tlfs.h drivers/hv/hv_call.c +6 more+859 -310 replies
11/19drivers/hv: set up synic pages for intercept messagesarch/x86/include/uapi/asm/hyperv-tlfs.h drivers/hv/Makefile drivers/hv/hv_synic.c +5 more+422 -821 reply
12/19drivers/hv: run vp ioctl and isrDocumentation/virt/mshv/api.rst arch/x86/kernel/cpu/mshyperv.c drivers/hv/hv_synic.c +5 more+310 -10 replies
13/19drivers/hv: install intercept ioctlDocumentation/virt/mshv/api.rst arch/x86/include/uapi/asm/hyperv-tlfs.h drivers/hv/hv_call.c +4 more+128 -00 replies
14/19drivers/hv: assert interrupt ioctlDocumentation/virt/mshv/api.rst arch/x86/include/asm/hyperv-tlfs.h arch/x86/include/uapi/asm/hyperv-tlfs.h +5 more+105 -140 replies
15/19drivers/hv: get and set vp state ioctlsDocumentation/virt/mshv/api.rst arch/x86/include/uapi/asm/hyperv-tlfs.h drivers/hv/hv_call.c +5 more+432 -10 replies
16/19drivers/hv: mmap vp register pageDocumentation/virt/mshv/api.rst arch/x86/include/uapi/asm/hyperv-tlfs.h drivers/hv/hv_call.c +6 more+202 -00 replies
17/19drivers/hv: get and set partition property ioctlsDocumentation/virt/mshv/api.rst drivers/hv/hv_call.c drivers/hv/mshv.h +4 more+208 -00 replies
18/19drivers/hv: Add enlightenment bits to create partition ioctlDocumentation/virt/mshv/api.rst arch/x86/include/uapi/asm/hyperv-tlfs.h drivers/hv/mshv_main.c +2 more+137 -00 replies
19/19drivers/hv: Translate GVA to GPAdrivers/hv/hv_call.c drivers/hv/mshv.h drivers/hv/mshv_main.c +3 more+150 -00 replies

Reviews trailers per patch

2 of 19 patches have a Reviewed-by or Acked-by.

PatchSunil MuthuswamyWei Liu
1/19R-b
2/19
3/19
4/19
5/19
6/19
7/19
8/19
9/19
10/19
11/19
12/19
13/19
14/19
15/19
16/19
17/19
18/19
19/19R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/19] Microsoft Hypervisor root partition ioctl interface

This patch series provides a userspace interface for creating and running guest virtual machines while running on the Microsoft Hypervisor [0].

Since managing guest machines can only be done when Linux is the root partition, this series depends on Wei Liu's patch series merged in 5.12:
https://lore.kernel.org/linux-hyperv/[email protected]/

The first two patches provide some helpers for converting hypervisor status codes to linux error codes, and printing hypervisor status codes to dmesg for debugging.

Hyper-V related headers asm-generic/hyperv-tlfs.h and x86/asm/hyperv-tlfs.h are split into uapi and non-uapi. The uapi versions contain structures used in both the ioctl interface and the kernel.

The mshv API is introduced in drivers/hv/mshv_main.c. As each interface is introduced, documentation is added in Documentation/virt/mshv/api.rst. The API is file-desciptor based, like KVM. The entry point is /dev/mshv.

/dev/mshv ioctls:
MSHV_CHECK_EXTENSION
MSHV_CREATE_PARTITION

Partition (vm) ioctls:
MSHV_MAP_GUEST_MEMORY, MSHV_UNMAP_GUEST_MEMORY MSHV_INSTALL_INTERCEPT
MSHV_ASSERT_INTERRUPT MSHV_GET_PARTITION_PROPERTY, MSHV_SET_PARTITION_PROPERTY MSHV_CREATE_VP

Vp (vcpu) ioctls:
MSHV_GET_VP_REGISTERS, MSHV_SET_VP_REGISTERS
MSHV_RUN_VP
MSHV_GET_VP_STATE, MSHV_SET_VP_STATE
MSHV_VP_TRANSLATE_GVA
mmap() (register page)

[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.

Changes since v2:
1. Fix kernel test robot issues
2. Bugfix in GVA to GPA patch provided by Anatol Belski

Changes since v1:
1. Correct mshv_dev mode to octal 0600
2. Fix bug in mshv_vp_iotcl_run - correctly set suspend registers on early exit
3. Address comments from Wei Liu, Sunil Muthuswamy, and Vitaly Kuznetsov
4. Run checkpatch.pl - fix whitespace and other style issues

Changes since RFC:
1. Moved code from virt/mshv to drivers/hv
2. Split hypercall helper functions and synic code to hv_call.c and hv_synic.c
3. MSHV_REQUEST_VERSION ioctl replaced with MSHV_CHECK_EXTENSION
3. Numerous suggestions, fixes, style changes, etc from Michael Kelley, Vitaly Kuznetsov, Wei Liu, and Vineeth Pillai
4. Added patch to enable hypervisor enlightenments on partition creation
5. Added Wei Liu's patch for GVA to GPA translation

Nuno Das Neves (18):
x86/hyperv: convert hyperv statuses to linux error codes x86/hyperv: convert hyperv statuses to strings
drivers/hv: minimal mshv module (/dev/mshv/)
drivers/hv: check extension ioctl
drivers/hv: create partition ioctl
drivers/hv: create, initialize, finalize, delete partition hypercalls drivers/hv: withdraw memory hypercall
drivers/hv: map and unmap guest memory
drivers/hv: create vcpu ioctl
drivers/hv: get and set vcpu registers ioctls
drivers/hv: set up synic pages for intercept messages drivers/hv: run vp ioctl and isr
drivers/hv: install intercept ioctl
drivers/hv: assert interrupt ioctl
drivers/hv: get and set vp state ioctls
drivers/hv: mmap vp register page
drivers/hv: get and set partition property ioctls drivers/hv: Add enlightenment bits to create partition ioctl

Wei Liu (1):
drivers/hv: Translate GVA to GPA

 .../userspace-api/ioctl/ioctl-number.rst      |    2 +
 Documentation/virt/mshv/api.rst               |  173 +++
 arch/x86/hyperv/Makefile                      |    1 +
 arch/x86/hyperv/hv_init.c                     |    2 +-
 arch/x86/hyperv/hv_proc.c                     |   51 +-
 arch/x86/include/asm/hyperv-tlfs.h            |   15 +-
 arch/x86/include/asm/mshyperv.h               |    1 +
 arch/x86/include/uapi/asm/hyperv-tlfs.h       | 1274 +++++++++++++++++
 arch/x86/kernel/cpu/mshyperv.c                |   16 +
 drivers/hv/Kconfig                            |   18 +
 drivers/hv/Makefile                           |    4 +
 drivers/hv/hv_call.c                          |  742 ++++++++++
 drivers/hv/hv_synic.c                         |  181 +++
 drivers/hv/mshv.h                             |  120 ++
 drivers/hv/mshv_main.c                        | 1166 +++++++++++++++
 include/asm-generic/hyperv-tlfs.h             |  354 +++--
 include/asm-generic/mshyperv.h                |    4 +
 include/linux/mshv.h                          |   61 +
 include/uapi/asm-generic/hyperv-tlfs.h        |  242 ++++
 include/uapi/linux/mshv.h                     |  117 ++
 20 files changed, 4399 insertions(+), 145 deletions(-)
 create mode 100644 Documentation/virt/mshv/api.rst
 create mode 100644 arch/x86/include/uapi/asm/hyperv-tlfs.h
 create mode 100644 drivers/hv/hv_call.c
 create mode 100644 drivers/hv/hv_synic.c
 create mode 100644 drivers/hv/mshv.h
 create mode 100644 drivers/hv/mshv_main.c
 create mode 100644 include/linux/mshv.h
 create mode 100644 include/uapi/asm-generic/hyperv-tlfs.h
 create mode 100644 include/uapi/linux/mshv.h
Signature · 1 line
2.23.4